diff --git a/.gitignore b/.gitignore
index 18777cc6..ee446735 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,4 +45,4 @@ VisualGDB/VisualGDB/Release/gencomp
*.tlog
VSLinux/obj/ARM/Debug/amiberry-sdl2-dev
VisualGDB/VisualGDB/Debug/Amiberry-sdl2-dev
-VSLinux/obj/ARM/Debug/
+VSLinux/obj/
diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json
new file mode 100644
index 00000000..f8b48885
--- /dev/null
+++ b/.vs/ProjectSettings.json
@@ -0,0 +1,3 @@
+{
+ "CurrentProjectSetting": null
+}
\ No newline at end of file
diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json
new file mode 100644
index 00000000..39bc0a78
--- /dev/null
+++ b/.vs/VSWorkspaceState.json
@@ -0,0 +1,7 @@
+{
+ "ExpandedNodes": [
+ ""
+ ],
+ "SelectedNode": "\\Makefile",
+ "PreviewInSolutionExplorer": false
+}
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 736d0b65..bf05b6eb 100644
--- a/Makefile
+++ b/Makefile
@@ -3,109 +3,58 @@ ifeq ($(PLATFORM),)
endif
ifeq ($(PLATFORM),rpi3)
- CPU_FLAGS += -march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=hard
- MORE_CFLAGS += -DARMV6T2 -DUSE_ARMNEON -DCAPSLOCK_DEBIAN_WORKAROUND
- MORE_CFLAGS += -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads
- LDFLAGS += -lbcm_host -lvchiq_arm -lvcos -llzma -lfreetype -logg -lm -L/opt/vc/lib
- PROFILER_PATH = /home/pi/projects/amiberry/amiberry-sdl2-prof
+ CPU_FLAGS += -std=gnu++14 -march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=hard
+ MORE_CFLAGS += -DARMV6T2 -DUSE_ARMNEON
else ifeq ($(PLATFORM),rpi2)
- CPU_FLAGS += -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard
- MORE_CFLAGS += -DARMV6T2 -DUSE_ARMNEON -DCAPSLOCK_DEBIAN_WORKAROUND
- MORE_CFLAGS += -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads
- LDFLAGS += -lbcm_host -lvchiq_arm -lvcos -llzma -lfreetype -logg -lm -L/opt/vc/lib
- PROFILER_PATH = /home/pi/projects/amiberry/amiberry-sdl2-prof
+ CPU_FLAGS += -std=gnu++14 -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard
+ MORE_CFLAGS += -DARMV6T2 -DUSE_ARMNEON
else ifeq ($(PLATFORM),rpi1)
- CPU_FLAGS += -march=armv6zk -mfpu=vfp -mfloat-abi=hard
- MORE_CFLAGS += -DCAPSLOCK_DEBIAN_WORKAROUND
- MORE_CFLAGS += -I/opt/vc/include -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads
- LDFLAGS += -lbcm_host -lvchiq_arm -lvcos -llzma -lfreetype -logg -lm -L/opt/vc/lib
- PROFILER_PATH = /home/pi/projects/amiberry/amiberry-sdl2-prof
-else ifeq ($(PLATFORM),pine64)
- CPU_FLAGS += -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard
- MORE_CFLAGS += -DARMV6T2 -D__arm__
- LDFLAGS += -lvchiq_arm -lvcos -llzma -lfreetype -logg -lm
- CC = arm-linux-gnueabihf-gcc
- CXX = arm-linux-gnueabihf-g++
-else ifeq ($(PLATFORM),Pandora)
- CPU_FLAGS += -march=armv7-a -mfpu=neon -mfloat-abi=softfp
- MORE_CFLAGS += -DARMV6T2 -DUSE_ARMNEON -DPANDORA -msoft-float
- PROFILER_PATH = /media/MAINSD/pandora/test
-else ifeq ($(PLATFORM),xu4)
- CPU_FLAGS += -march=armv7ve -mcpu=cortex-a15.cortex-a7 -mtune=cortex-a15.cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard
- MORE_CFLAGS += -DARMV6T2 -DUSE_ARMNEON
- LDFLAGS += -llzma -lfreetype -logg
- ifdef DEBUG
- # Otherwise we'll get compilation errors, check https://tls.mbed.org/kb/development/arm-thumb-error-r7-cannot-be-used-in-asm-here
- # quote: The assembly code in bn_mul.h is optimized for the ARM platform and uses some registers, including r7 to efficiently do an operation. GCC also uses r7 as the frame pointer under ARM Thumb assembly.
- MORE_CFLAGS += -fomit-frame-pointer
- endif
-
-else ifeq ($(PLATFORM),android)
- CPU_FLAGS += -mfpu=neon -mfloat-abi=soft
- DEFS += -DANDROIDSDL
- ANDROID = 1
- HAVE_NEON = 1
- HAVE_SDL_DISPLAY = 1
+ CPU_FLAGS += -std=gnu++14 -march=armv6zk -mfpu=vfp -mfloat-abi=hard
endif
NAME = amiberry-sdl2-dev
RM = rm -f
-CC ?= gcc
-CXX ?= g++
-STRIP ?= strip
+CC = gcc
+CXX = g++
+STRIP = strip
PROG = $(NAME)
all: guisan $(PROG)
guisan:
- $(MAKE) -C src/guisan
+ cd src/guisan && make all && cd ../..
-#DEBUG=1
-#GEN_PROFILE=1
-#USE_PROFILE=1
+DEBUG=1
SDL_CFLAGS = `sdl2-config --cflags --libs`
DEFS += `xml2-config --cflags`
-DEFS += -DAMIBERRY -DCPU_arm -DARMV6_ASSEMBLY
+DEFS += -DARMV6_ASSEMBLY -DAMIBERRY
+DEFS += -DCAPSLOCK_DEBIAN_WORKAROUND
+DEFS += -DROM_PATH_PREFIX=\"./\" -DDATA_PREFIX=\"./data/\" -DSAVE_PREFIX=\"./saves/\"
DEFS += -DUSE_SDL
-MORE_CFLAGS += -Isrc -Isrc/osdep -Isrc/threaddep -Isrc/include -Isrc/guisan/include -Isrc/archivers
-MORE_CFLAGS += -fdiagnostics-color=auto
-#MORE_CFLAGS += -mstructure-size-boundary=32
-MORE_CFLAGS += -falign-functions=32
-MORE_CFLAGS += -std=gnu++14
+MORE_CFLAGS += -Isrc -Isrc/osdep -Isrc/threaddep -Isrc/include -Isrc/guisan/include
+MORE_CFLAGS += -Wno-unused -Wno-format -DGCCCONSTFUNC="__attribute__((const))"
+MORE_CFLAGS += -fexceptions -fpermissive
+MORE_CFLAGS += -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
-LDFLAGS += -lpthread -lz -lpng -lrt -lxml2 -lFLAC -lmpg123 -ldl -lmpeg2convert -lmpeg2
-LDFLAGS += -lSDL2 -lSDL2_image -lSDL2_ttf -lguisan -Lsrc/guisan/lib
+LDFLAGS += -lpthread -lm -lz -lpng -lrt -lxml2 -lFLAC -lmpg123 -ldl -lprofiler -ltcmalloc
+LDFLAGS += -lSDL2 -lSDL2_image -lSDL2_ttf -lguisan -L/opt/vc/lib -Lsrc/guisan/lib
ifndef DEBUG
- MORE_CFLAGS += -Ofast -pipe
- MORE_CFLAGS += -fweb -frename-registers
- MORE_CFLAGS += -funroll-loops -ftracer -funswitch-loops
+MORE_CFLAGS += -Ofast -pipe -Wno-write-strings
else
- MORE_CFLAGS += -g -rdynamic -funwind-tables -mapcs-frame -DDEBUG -Wl,--export-dynamic
+MORE_CFLAGS += -g -DDEBUG -Wl,--export-dynamic
endif
-ifdef WITH_LOGGING
- MORE_CFLAGS += -DWITH_LOGGING
-endif
-
-ASFLAGS += $(CPU_FLAGS) -falign-functions=32
+ASFLAGS += $(CPU_FLAGS)
CXXFLAGS += $(SDL_CFLAGS) $(CPU_FLAGS) $(DEFS) $(MORE_CFLAGS)
-ifdef GEN_PROFILE
- MORE_CFLAGS += -fprofile-generate=$(PROFILER_PATH) -fprofile-arcs -fvpt
-endif
-ifdef USE_PROFILE
- MORE_CFLAGS += -fprofile-use -fprofile-correction -fbranch-probabilities -fvpt
-endif
-
OBJS = \
src/akiko.o \
- src/ar.o \
src/aros.rom.o \
src/audio.o \
src/autoconf.o \
@@ -116,47 +65,31 @@ OBJS = \
src/blkdev_cdimage.o \
src/bsdsocket.o \
src/calc.o \
- src/cd32_fmv.o \
- src/cd32_fmv_genlock.o \
src/cdrom.o \
src/cfgfile.o \
src/cia.o \
src/crc32.o \
src/custom.o \
- src/def_icons.o \
- src/devices.o \
src/disk.o \
src/diskutil.o \
src/drawing.o \
src/events.o \
src/expansion.o \
- src/fdi2raw.o \
src/filesys.o \
- src/flashrom.o \
src/fpp.o \
- src/fpp_native.o \
- src/fpp_softfloat.o \
- src/softfloat/softfloat.o \
- src/softfloat/softfloat_decimal.o \
- src/softfloat/softfloat_fpsp.o \
src/fsdb.o \
src/fsdb_unix.o \
src/fsusage.o \
- src/gayle.o \
src/gfxboard.o \
src/gfxutil.o \
src/hardfile.o \
- src/hrtmon.rom.o \
- src/ide.o \
src/inputdevice.o \
src/keybuf.o \
src/main.o \
src/memory.o \
src/native2amiga.o \
src/rommgr.o \
- src/rtc.o \
src/savestate.o \
- src/scsi.o \
src/statusline.o \
src/traps.o \
src/uaelib.o \
@@ -164,23 +97,18 @@ OBJS = \
src/zfile.o \
src/zfile_archive.o \
src/archivers/7z/7zAlloc.o \
+ src/archivers/7z/7zDecode.o \
+ src/archivers/7z/7zExtract.o \
+ src/archivers/7z/7zHeader.o \
+ src/archivers/7z/7zIn.o \
+ src/archivers/7z/7zItem.o \
src/archivers/7z/7zBuf.o \
src/archivers/7z/7zCrc.o \
- src/archivers/7z/7zCrcOpt.o \
- src/archivers/7z/7zDec.o \
- src/archivers/7z/7zIn.o \
src/archivers/7z/7zStream.o \
src/archivers/7z/Bcj2.o \
src/archivers/7z/Bra.o \
src/archivers/7z/Bra86.o \
src/archivers/7z/LzmaDec.o \
- src/archivers/7z/Lzma2Dec.o \
- src/archivers/7z/BraIA64.o \
- src/archivers/7z/Delta.o \
- src/archivers/7z/Sha256.o \
- src/archivers/7z/Xz.o \
- src/archivers/7z/XzCrc64.o \
- src/archivers/7z/XzDec.o \
src/archivers/dms/crc_csum.o \
src/archivers/dms/getbits.o \
src/archivers/dms/maketbl.o \
@@ -204,7 +132,6 @@ OBJS = \
src/archivers/lha/uae_lha.o \
src/archivers/lha/util.o \
src/archivers/lzx/unlzx.o \
- src/archivers/mp2/kjmp2.o \
src/archivers/wrp/warp.o \
src/archivers/zip/unzip.o \
src/machdep/support.o \
@@ -212,10 +139,9 @@ OBJS = \
src/osdep/cda_play.o \
src/osdep/charset.o \
src/osdep/fsdb_host.o \
- src/osdep/amiberry_hardfile.o \
- src/osdep/keyboard.o \
+ src/osdep/hardfile_amiberry.o \
+ src/osdep/keyboard_amiberry.o \
src/osdep/mp3decoder.o \
- src/osdep/picasso96.o \
src/osdep/writelog.o \
src/osdep/amiberry.o \
src/osdep/amiberry_filesys.o \
@@ -225,14 +151,14 @@ OBJS = \
src/osdep/amiberry_rp9.o \
src/osdep/amiberry_mem.o \
src/osdep/sigsegv_handler.o \
- src/sounddep/sound.o \
+ src/osdep/menu/menu_config.o \
+ src/sounddep/sound_sdl_new.o \
src/osdep/gui/UaeRadioButton.o \
src/osdep/gui/UaeDropDown.o \
src/osdep/gui/UaeCheckBox.o \
src/osdep/gui/UaeListBox.o \
src/osdep/gui/InGameMessage.o \
src/osdep/gui/SelectorEntry.o \
- src/osdep/gui/ShowHelp.o \
src/osdep/gui/ShowMessage.o \
src/osdep/gui/SelectFolder.o \
src/osdep/gui/SelectFile.o \
@@ -240,29 +166,22 @@ OBJS = \
src/osdep/gui/EditFilesysVirtual.o \
src/osdep/gui/EditFilesysHardfile.o \
src/osdep/gui/PanelPaths.o \
- src/osdep/gui/PanelQuickstart.o \
src/osdep/gui/PanelConfig.o \
src/osdep/gui/PanelCPU.o \
src/osdep/gui/PanelChipset.o \
- src/osdep/gui/PanelCustom.o \
src/osdep/gui/PanelROM.o \
src/osdep/gui/PanelRAM.o \
src/osdep/gui/PanelFloppy.o \
src/osdep/gui/PanelHD.o \
- src/osdep/gui/PanelInput.o \
src/osdep/gui/PanelDisplay.o \
src/osdep/gui/PanelSound.o \
+ src/osdep/gui/PanelInput.o \
src/osdep/gui/PanelMisc.o \
src/osdep/gui/PanelSavestate.o \
src/osdep/gui/main_window.o \
src/osdep/gui/Navigation.o
-ifeq ($(ANDROID), 1)
-OBJS += src/osdep/gui/androidsdl_event.o
-OBJS += src/osdep/gui/PanelOnScreen.o
-OBJS += src/osdep/pandora_gfx.o
-endif
-
+OBJS += src/osdep/picasso96.o
OBJS += src/osdep/neon_helper.o
OBJS += src/newcpu.o
@@ -273,8 +192,6 @@ OBJS += src/cpustbl.o
OBJS += src/cpuemu_0.o
OBJS += src/cpuemu_4.o
OBJS += src/cpuemu_11.o
-OBJS += src/cpuemu_40.o
-OBJS += src/cpuemu_44.o
OBJS += src/jit/compemu.o
OBJS += src/jit/compstbl.o
OBJS += src/jit/compemu_fpp.o
@@ -291,7 +208,3 @@ endif
clean:
$(RM) $(PROG) $(OBJS)
-
-bootrom:
- od -v -t xC -w8 src/filesys |tail -n +5 | sed -e "s,^.......,," -e "s,[0123456789abcdefABCDEF][0123456789abcdefABCDEF],db(0x&);,g" > src/filesys_bootrom.cpp
- touch src/filesys.cpp
diff --git a/README.md b/README.md
index df27bbbd..fb3627a7 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
Amiga emulator for the Raspberry Pi
=================================
-Warning: this branch is still Work In Progress - it requires a few extra steps to build and some things may not be finished yet! :)
-If you're looking for the latest "stable" version, please use the master branch for now.
-Once this branch is complete, it will be merged back to the master and replace it.
+WARNING: Experimental, unstable, development branch.
+Stuff here will most probably break at some places. Don't bother reporting bugs!
# History (newest first)
+- Updated drawing, custom, events and a few other parts from WinUAE 3.4.1
- Added GPerfTools for profiling and optimized malloc functions (note: this adds 2 extra dependencies, check below)
- Added an option for choosing Scaling Method (for non-Picasso modes): Auto, Nearest Neighbor (pixelated) or Linear (smooth). Auto will automatically choose between the other two modes on the fly, depending on the Amiga resolution requested and if the native monitor resolution can display it as an exact multiple or not. This vastly improves the sharpness of the resulting image.
- Improved image centering (for non-Picasso modes)
diff --git a/VSLinux/Amiberry.vcxproj b/VSLinux/Amiberry.vcxproj
index 98ea7b34..d698318a 100644
--- a/VSLinux/Amiberry.vcxproj
+++ b/VSLinux/Amiberry.vcxproj
@@ -51,22 +51,20 @@
- cd ~/projects/Amiberry-sdl2; make -j3
- cd ~/projects/Amiberry-sdl2; make clean; make -j3
- cd ~/projects/Amiberry-sdl2; make clean
- C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\6\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\6;..\src;..\src\include;..\src\osdep;..\src\archivers;..\src\threaddep;..\src\guisan\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vmcs_host\linux;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vcos\pthreads;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\SDL2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\libxml2;$(NMakeIncludeSearchPath)
- DEBUG;ARMV6T2;USE_ARMNEON;ARMV6_ASSEMBLY;AMIBERRY;CPU_arm;CAPSLOCK_DEBIAN_WORKAROUND;USE_SDL;_REENTRANT;$(NMakePreprocessorDefinitions)
-
-
- $(RemoteRootDir)/$(ProjectName)-sdl2
+ cd ~/projects/Amiberry-dev; make
+ cd ~/projects/Amiberry-dev; make clean; make
+ cd ~/projects/Amiberry-dev; make clean
+ C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\libxml2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vcos\pthreads;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vmcs_host\linux;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\SDL2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\4.9;C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\4.9\include;D:\midwa\Projects\GitHub\amiberry\src\guisan\include;D:\midwa\Projects\GitHub\amiberry\src\threaddep;D:\midwa\Projects\GitHub\amiberry\src\osdep;D:\midwa\Projects\GitHub\amiberry\src;D:\midwa\Projects\GitHub\amiberry\src\include;$(NMakeIncludeSearchPath)
+ DEBUG;ARMV6T2;USE_ARMNEON;ARMV6_ASSEMBLY;AMIBERRY;CAPSLOCK_DEBIAN_WORKAROUND;ROM_PATH_PREFIX=\"./\";DATA_PREFIX=\"./data/\";SAVE_PREFIX=\"./saves/\";USE_SDL;_REENTRANT;$(NMakePreprocessorDefinitions)
+ $(RemoteRootDir)/$(ProjectName)-dev
- C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\6\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\6;..\src;..\src\include;..\src\osdep;..\src\archivers;..\src\threaddep;..\src\guisan\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vmcs_host\linux;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vcos\pthreads;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\SDL2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\libxml2;$(NMakeIncludeSearchPath)
- cd ~/projects/Amiberry-sdl2; make -j3
- cd ~/projects/Amiberry-sdl2; make clean; make -j3
- cd ~/projects/Amiberry-sdl2; make clean
- ARMV6T2;USE_ARMNEON;ARMV6_ASSEMBLY;AMIBERRY;CPU_arm;CAPSLOCK_DEBIAN_WORKAROUND;USE_SDL;_REENTRANT;$(NMakePreprocessorDefinitions)
- $(RemoteRootDir)/$(ProjectName)-sdl2
+ cd ~/projects/Amiberry-dev; make
+ cd ~/projects/Amiberry-dev; make clean; make
+ cd ~/projects/Amiberry-dev; make clean
+ C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\libxml2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vcos\pthreads;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vmcs_host\linux;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\SDL2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\4.9;C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\4.9\include;D:\midwa\Projects\GitHub\amiberry\src\guisan\include;D:\midwa\Projects\GitHub\amiberry\src\threaddep;D:\midwa\Projects\GitHub\amiberry\src\osdep;D:\midwa\Projects\GitHub\amiberry\src;D:\midwa\Projects\GitHub\amiberry\src\include;$(NMakeIncludeSearchPath)
+ ARMV6T2;USE_ARMNEON;ARMV6_ASSEMBLY;AMIBERRY;CAPSLOCK_DEBIAN_WORKAROUND;ROM_PATH_PREFIX=\"./\";DATA_PREFIX=\"./data/\";SAVE_PREFIX=\"./saves/\";USE_SDL;_REENTRANT;$(NMakePreprocessorDefinitions)
+ $(RemoteRootDir)/$(ProjectName)-dev
@@ -108,16 +106,22 @@
true
+
+ true
+
true
true
+
+ true
+
true
-
+
true
@@ -131,6 +135,9 @@
+
+ true
+
true
@@ -154,43 +161,19 @@
false
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -214,7 +197,6 @@
-
@@ -253,8 +235,6 @@
false
-
-
false
@@ -276,8 +256,6 @@
false
-
-
false
@@ -287,8 +265,6 @@
false
-
-
false
@@ -304,19 +280,15 @@
false
-
false
false
-
false
-
-
false
@@ -326,13 +298,15 @@
false
-
false
false
+
+ false
+
false
@@ -342,8 +316,6 @@
false
-
-
false
@@ -352,7 +324,6 @@
-
@@ -404,7 +375,6 @@
-
@@ -412,14 +382,14 @@
-
-
-
+
+
+
@@ -433,18 +403,13 @@
false
-
false
-
false
-
-
-
-
+
false
@@ -465,36 +430,20 @@
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -509,11 +458,9 @@
-
-
@@ -522,63 +469,53 @@
-
+
-
-
+
+
-
-
-
+
+
-
-
-
+
+
-
+
-
-
-
-
-
-
-
-
@@ -589,6 +526,7 @@
+
@@ -601,33 +539,19 @@
-
-
-
-
-
-
-
-
- cp ~/projects/Amiberry-sdl2/amiberry-sdl2 ~/projects/amiberry/amiberry-sdl2-dev
-
-
-
-
- Copy binary to launch location
+ cp ~/projects/Amiberry-dev/amiberry-sdl2-dev ~/projects/amiberry
- cp ~/projects/Amiberry-sdl2/amiberry-sdl2 ~/projects/amiberry/amiberry-sdl2-dev
- Copy binary to launch location
+ cp ~/projects/Amiberry-dev/amiberry-sdl2-dev ~/projects/amiberry
diff --git a/VSLinux/Amiberry.vcxproj.filters b/VSLinux/Amiberry.vcxproj.filters
index e85b836f..d72d3cf3 100644
--- a/VSLinux/Amiberry.vcxproj.filters
+++ b/VSLinux/Amiberry.vcxproj.filters
@@ -264,6 +264,9 @@
src
+
+ src
+
src
diff --git a/VSLinux/Amiberry.vcxproj.user b/VSLinux/Amiberry.vcxproj.user
index 9c9299c9..14f5d4cc 100644
--- a/VSLinux/Amiberry.vcxproj.user
+++ b/VSLinux/Amiberry.vcxproj.user
@@ -1,15 +1,15 @@

-
- projects/amiberry/amiberry-sdl2-dev
- projects/amiberry
- LinuxDebugger
- export DEBUG=1
-
- projects/amiberry/amiberry-sdl2-dev
- projects/amiberry
+ ~/projects/amiberry
LinuxDebugger
- export DEBUG=0
+ ~/projects/amiberry/amiberry-sdl2-dev
+ DISPLAY=:0.0
+
+
+ ~/projects/amiberry
+ LinuxDebugger
+ ~/projects/amiberry/amiberry-sdl2-dev
+ DISPLAY=:0.0
\ No newline at end of file
diff --git a/VSLinux/guisan/guisan.vcxproj b/VSLinux/guisan/guisan.vcxproj
index 3a21fa6f..4d9ec4ed 100644
--- a/VSLinux/guisan/guisan.vcxproj
+++ b/VSLinux/guisan/guisan.vcxproj
@@ -40,12 +40,12 @@
true
Makefile
- ~/projects/Amiberry-sdl2/src
+ ~/projects/Amiberry-dev/src
false
Makefile
- ~/projects/Amiberry-sdl2/src
+ ~/projects/Amiberry-dev/src
true
@@ -69,14 +69,14 @@
- cd ~/projects/Amiberry-sdl2/src/guisan/; make all
- cd ~/projects/Amiberry-sdl2/src/guisan/; make clean
- cd ~/projects/Amiberry-sdl2/src/guisan/; make clean; make all
+ cd ~/projects/Amiberry-dev/src/guisan/; make all
+ cd ~/projects/Amiberry-dev/src/guisan/; make clean
+ cd ~/projects/Amiberry-dev/src/guisan/; make clean; make all
- cd ~/projects/Amiberry-sdl2/src/guisan/; make all
- cd ~/projects/Amiberry-sdl2/src/guisan/; make clean; make all
- cd ~/projects/Amiberry-sdl2/src/guisan/; make clean
+ cd ~/projects/Amiberry-dev/src/guisan/; make all
+ cd ~/projects/Amiberry-dev/src/guisan/; make clean; make all
+ cd ~/projects/Amiberry-dev/src/guisan/; make clean
diff --git a/VisualGDB/Amiberry.sln b/VisualGDB/Amiberry.sln
new file mode 100644
index 00000000..c293a35c
--- /dev/null
+++ b/VisualGDB/Amiberry.sln
@@ -0,0 +1,112 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26228.9
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Amiberry", "Amiberry\Amiberry.vcxproj", "{D76BB09D-FF2A-4028-A065-421C430CD238}"
+ ProjectSection(ProjectDependencies) = postProject
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2} = {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "guisan", "guisan\guisan.vcxproj", "{A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genlinetoscr", "genlinetoscr\genlinetoscr.vcxproj", "{883F2A00-8030-429B-AC7F-E930DDF9568F}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "genblitter", "genblitter\genblitter.vcxproj", "{619EFB8C-E41A-4058-B085-1B8CD22692DD}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|VisualGDB = Debug|VisualGDB
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|VisualGDB = Release|VisualGDB
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ Release-rpi1|VisualGDB = Release-rpi1|VisualGDB
+ Release-rpi1|x64 = Release-rpi1|x64
+ Release-rpi1|x86 = Release-rpi1|x86
+ Release-rpi2|VisualGDB = Release-rpi2|VisualGDB
+ Release-rpi2|x64 = Release-rpi2|x64
+ Release-rpi2|x86 = Release-rpi2|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Debug|VisualGDB.ActiveCfg = Debug|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Debug|VisualGDB.Build.0 = Debug|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Debug|x64.ActiveCfg = Debug|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Debug|x86.ActiveCfg = Debug|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Release|VisualGDB.ActiveCfg = Release|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Release|VisualGDB.Build.0 = Release|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Release|x64.ActiveCfg = Release|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Release|x86.ActiveCfg = Release|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Release-rpi1|VisualGDB.ActiveCfg = Release-rpi1|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Release-rpi1|VisualGDB.Build.0 = Release-rpi1|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Release-rpi1|x64.ActiveCfg = Release-rpi1|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Release-rpi1|x86.ActiveCfg = Release-rpi1|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Release-rpi2|VisualGDB.ActiveCfg = Release-rpi2|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Release-rpi2|VisualGDB.Build.0 = Release-rpi2|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Release-rpi2|x64.ActiveCfg = Release-rpi2|VisualGDB
+ {D76BB09D-FF2A-4028-A065-421C430CD238}.Release-rpi2|x86.ActiveCfg = Release-rpi2|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Debug|VisualGDB.ActiveCfg = Debug|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Debug|VisualGDB.Build.0 = Debug|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Debug|x64.ActiveCfg = Debug|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Debug|x86.ActiveCfg = Debug|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release|VisualGDB.ActiveCfg = Release|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release|VisualGDB.Build.0 = Release|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release|x64.ActiveCfg = Release|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release|x86.ActiveCfg = Release|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release-rpi1|VisualGDB.ActiveCfg = Release|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release-rpi1|VisualGDB.Build.0 = Release|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release-rpi1|x64.ActiveCfg = Debug|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release-rpi1|x64.Build.0 = Debug|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release-rpi1|x86.ActiveCfg = Debug|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release-rpi1|x86.Build.0 = Debug|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release-rpi2|VisualGDB.ActiveCfg = Release|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release-rpi2|VisualGDB.Build.0 = Release|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release-rpi2|x64.ActiveCfg = Debug|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release-rpi2|x64.Build.0 = Debug|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release-rpi2|x86.ActiveCfg = Debug|VisualGDB
+ {A431BAB9-641E-48D7-8ACE-BC1D5100FBA2}.Release-rpi2|x86.Build.0 = Debug|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Debug|VisualGDB.ActiveCfg = Debug|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Debug|VisualGDB.Build.0 = Debug|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Debug|x64.ActiveCfg = Debug|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Debug|x86.ActiveCfg = Debug|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release|VisualGDB.ActiveCfg = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release|VisualGDB.Build.0 = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release|x64.ActiveCfg = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release|x86.ActiveCfg = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release-rpi1|VisualGDB.ActiveCfg = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release-rpi1|VisualGDB.Build.0 = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release-rpi1|x64.ActiveCfg = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release-rpi1|x64.Build.0 = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release-rpi1|x86.ActiveCfg = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release-rpi1|x86.Build.0 = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release-rpi2|VisualGDB.ActiveCfg = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release-rpi2|VisualGDB.Build.0 = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release-rpi2|x64.ActiveCfg = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release-rpi2|x64.Build.0 = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release-rpi2|x86.ActiveCfg = Release|VisualGDB
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}.Release-rpi2|x86.Build.0 = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Debug|VisualGDB.ActiveCfg = Debug|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Debug|VisualGDB.Build.0 = Debug|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Debug|x64.ActiveCfg = Debug|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Debug|x86.ActiveCfg = Debug|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release|VisualGDB.ActiveCfg = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release|VisualGDB.Build.0 = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release|x64.ActiveCfg = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release|x86.ActiveCfg = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release-rpi1|VisualGDB.ActiveCfg = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release-rpi1|VisualGDB.Build.0 = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release-rpi1|x64.ActiveCfg = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release-rpi1|x64.Build.0 = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release-rpi1|x86.ActiveCfg = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release-rpi1|x86.Build.0 = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release-rpi2|VisualGDB.ActiveCfg = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release-rpi2|VisualGDB.Build.0 = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release-rpi2|x64.ActiveCfg = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release-rpi2|x64.Build.0 = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release-rpi2|x86.ActiveCfg = Release|VisualGDB
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}.Release-rpi2|x86.Build.0 = Release|VisualGDB
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/VisualGDB/Amiberry/Amiberry-Debug.vgdbsettings b/VisualGDB/Amiberry/Amiberry-Debug.vgdbsettings
index e97229df..04dd1c28 100644
--- a/VisualGDB/Amiberry/Amiberry-Debug.vgdbsettings
+++ b/VisualGDB/Amiberry/Amiberry-Debug.vgdbsettings
@@ -90,7 +90,7 @@
main
true
false
- false
+ true
false
0
diff --git a/VisualGDB/Amiberry/Amiberry.vcxproj b/VisualGDB/Amiberry/Amiberry.vcxproj
index f2585dec..49635a19 100644
--- a/VisualGDB/Amiberry/Amiberry.vcxproj
+++ b/VisualGDB/Amiberry/Amiberry.vcxproj
@@ -5,20 +5,23 @@
Debug
VisualGDB
+
+ Release-rpi1
+ VisualGDB
+
+
+ Release-rpi2
+ VisualGDB
+
Release
VisualGDB
- 15.0
- {FDC6BF55-C4BC-44FB-85A9-3369784716E8}
+ {D76BB09D-FF2A-4028-A065-421C430CD238}
-
-
-
-
@@ -27,72 +30,110 @@
Debug
- com.visualgdb.raspberry_pi
- 6.3.0/7.12/r1
- $(ProjectName)-sdl2
+ C:\SysGCC\raspberry
+ $(ProjectName)-sdl2-dev
- com.visualgdb.raspberry_pi
- 6.3.0/7.12/r1
- $(ProjectName)-sdl2
+ C:\SysGCC\raspberry
+ $(ProjectName)-sdl2-dev
+
+
+ C:\SysGCC\raspberry
+ $(ProjectName)-sdl2-dev-rpi2
+
+
+ C:\SysGCC\raspberry
+ $(ProjectName)-sdl2-dev-rpi1
GNUPP14
- =/usr/local/include/SDL2;=/opt/vc/include;=/opt/vc/include/interface/vmcs_host/linux;=/opt/vc/include/interface/vcos/pthreads;=/usr/include/libxml2;../../src;../../src/osdep;../../src/threaddep;../../src/include;../../src/guisan/include;../../src/archivers;%(ClCompile.AdditionalIncludeDirectories)
- DEBUG=1;ARMV6T2;USE_ARMNEON;_REENTRANT;AMIBERRY;CPU_arm;ARMV6_ASSEMBLY;USE_SDL;%(ClCompile.PreprocessorDefinitions)
- -march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=hard %(AdditionalOptions)
+ C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\4.9\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\4.9;C:\SysGCC\raspberry\arm-linux-gnueabihf\include;../../src;../../src/include;../../src/osdep;../../src/threaddep;../../src/guisan/include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include;=/opt/vc/include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vmcs_host\linux;=/opt/vc/include/interface/vmcs_host/linux;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vcos\pthreads;=/opt/vc/include/interface/vcos/pthreads;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;=/usr/include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\SDL2;=/usr/include/SDL2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\libxml2;=/usr/include/libxml2;%(ClCompile.AdditionalIncludeDirectories)
+ DEBUG=1;_REENTRANT;CAPSLOCK_DEBIAN_WORKAROUND;ARMV6T2;USE_ARMNEON;ARMV6_ASSEMBLY;AMIBERRY;USE_SDL;CPU_arm;ROM_PATH_PREFIX=\"./\";DATA_PREFIX=\"./data/\";SAVE_PREFIX=\"./saves/\";GCCCONSTFUNC="__attribute__((const))";%(ClCompile.PreprocessorDefinitions)
+ -march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=hard -pipe -Wno-write-strings %(AdditionalOptions)
- ;%(Link.AdditionalLinkerInputs)
- =/opt/vc/lib;=/usr/local/lib;../../src/guisan/lib;%(Link.LibrarySearchDirectories)
- bcm_host;vchiq_arm;vcos;lzma;freetype;ogg;m;SDL2;pthread;z;png;rt;xml2;FLAC;mpg123;dl;mpeg2convert;mpeg2;SDL2_image;SDL2_ttf;guisan;%(Link.AdditionalLibraryNames)
+ ../../src/guisan/lib;=/opt/vc/lib;=/usr/lib/arm-linux-gnueabihf;%(Link.LibrarySearchDirectories)
+ SDL2;SDL2_image;SDL2_ttf;pthread;m;z;png;rt;xml2;FLAC;mpg123;dl;guisan;profiler;tcmalloc;%(Link.AdditionalLibraryNames)
+ -Wl,-gc-sections;%(Link.AdditionalLinkerInputs)
GNUPP14
- =/usr/local/include/SDL2;=/opt/vc/include;=/opt/vc/include/interface/vmcs_host/linux;=/opt/vc/include/interface/vcos/pthreads;=/usr/include/libxml2;../../src;../../src/osdep;../../src/threaddep;../../src/include;../../src/guisan/include;../../src/archivers;%(ClCompile.AdditionalIncludeDirectories)
- NDEBUG=1;RELEASE=1;ARMV6T2;USE_ARMNEON;_REENTRANT;AMIBERRY;CPU_arm;ARMV6_ASSEMBLY;USE_SDL;%(ClCompile.PreprocessorDefinitions)
- -march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=hard %(AdditionalOptions)
+ C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\4.9\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\4.9;C:\SysGCC\raspberry\arm-linux-gnueabihf\include;../../src;../../src/include;../../src/osdep;../../src/threaddep;../../src/guisan/include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include;=/opt/vc/include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vmcs_host\linux;=/opt/vc/include/interface/vmcs_host/linux;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vcos\pthreads;=/opt/vc/include/interface/vcos/pthreads;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;=/usr/include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\SDL2;=/usr/include/SDL2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\libxml2;=/usr/include/libxml2;%(ClCompile.AdditionalIncludeDirectories)
+ NDEBUG=1;RELEASE=1;_REENTRANT;CAPSLOCK_DEBIAN_WORKAROUND;ARMV6T2;USE_ARMNEON;ARMV6_ASSEMBLY;AMIBERRY;USE_SDL;CPU_arm;ROM_PATH_PREFIX=\"./\";DATA_PREFIX=\"./data/\";SAVE_PREFIX=\"./saves/\";GCCCONSTFUNC="__attribute__((const))";%(ClCompile.PreprocessorDefinitions)
+ -march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=hard -pipe -Wno-write-strings %(AdditionalOptions)
+ true
+ true
- ;%(Link.AdditionalLinkerInputs)
- =/opt/vc/lib;=/usr/local/lib;../../src/guisan/lib;%(Link.LibrarySearchDirectories)
- bcm_host;vchiq_arm;vcos;lzma;freetype;ogg;m;SDL2;pthread;z;png;rt;xml2;FLAC;mpg123;dl;mpeg2convert;mpeg2;SDL2_image;SDL2_ttf;guisan;%(Link.AdditionalLibraryNames)
+ -Wl,-gc-sections;%(Link.AdditionalLinkerInputs)
+ ../../src/guisan/lib;=/opt/vc/lib;=/usr/lib/arm-linux-gnueabihf;%(Link.LibrarySearchDirectories)
+ SDL2;SDL2_image;SDL2_ttf;pthread;m;z;png;rt;xml2;FLAC;mpg123;dl;guisan;profiler;tcmalloc;%(Link.AdditionalLibraryNames)
+
+
+
+
+
+
+ GNUPP14
+ C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\4.9\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\4.9;C:\SysGCC\raspberry\arm-linux-gnueabihf\include;../../src;../../src/include;../../src/osdep;../../src/threaddep;../../src/guisan/include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include;=/opt/vc/include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vmcs_host\linux;=/opt/vc/include/interface/vmcs_host/linux;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vcos\pthreads;=/opt/vc/include/interface/vcos/pthreads;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;=/usr/include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\SDL2;=/usr/include/SDL2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\libxml2;=/usr/include/libxml2;%(ClCompile.AdditionalIncludeDirectories)
+ NDEBUG=1;RELEASE=1;_REENTRANT;CAPSLOCK_DEBIAN_WORKAROUND;ARMV6T2;USE_ARMNEON;ARMV6_ASSEMBLY;AMIBERRY;USE_SDL;CPU_arm;ROM_PATH_PREFIX=\"./\";DATA_PREFIX=\"./data/\";SAVE_PREFIX=\"./saves/\";GCCCONSTFUNC="__attribute__((const))";%(ClCompile.PreprocessorDefinitions)
+ -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -pipe -Wno-write-strings %(AdditionalOptions)
+ true
+ true
+
+
+ -Wl,-gc-sections;%(Link.AdditionalLinkerInputs)
+ ../../src/guisan/lib;=/opt/vc/lib;=/usr/lib/arm-linux-gnueabihf;%(Link.LibrarySearchDirectories)
+ SDL2;SDL2_image;SDL2_ttf;pthread;m;z;png;rt;xml2;FLAC;mpg123;dl;guisan;profiler;tcmalloc;%(Link.AdditionalLibraryNames)
+
+
+
+
+
+
+
+
+ GNUPP14
+ C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\4.9\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\4.9;C:\SysGCC\raspberry\arm-linux-gnueabihf\include;../../src;../../src/include;../../src/osdep;../../src/threaddep;../../src/guisan/include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include;=/opt/vc/include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vmcs_host\linux;=/opt/vc/include/interface/vmcs_host/linux;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vcos\pthreads;=/opt/vc/include/interface/vcos/pthreads;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;=/usr/include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\SDL2;=/usr/include/SDL2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\libxml2;=/usr/include/libxml2;%(ClCompile.AdditionalIncludeDirectories)
+ NDEBUG=1;RELEASE=1;_REENTRANT;CAPSLOCK_DEBIAN_WORKAROUND;ARMV6_ASSEMBLY;AMIBERRY;USE_SDL;CPU_arm;ROM_PATH_PREFIX=\"./\";DATA_PREFIX=\"./data/\";SAVE_PREFIX=\"./saves/\";GCCCONSTFUNC="__attribute__((const))";%(ClCompile.PreprocessorDefinitions)
+ -march=armv6zk -mfpu=vfp -mfloat-abi=hard -pipe -Wno-write-strings %(AdditionalOptions)
+ true
+ true
+
+
+ -Wl,-gc-sections;%(Link.AdditionalLinkerInputs)
+ ../../src/guisan/lib;=/opt/vc/lib;=/usr/lib/arm-linux-gnueabihf;%(Link.LibrarySearchDirectories)
+ SDL2;SDL2_image;SDL2_ttf;pthread;m;z;png;rt;xml2;FLAC;mpg123;dl;guisan;profiler;tcmalloc;%(Link.AdditionalLibraryNames)
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -116,7 +157,6 @@
-
@@ -130,8 +170,6 @@
-
-
@@ -139,33 +177,22 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -178,14 +205,6 @@
-
-
-
-
-
-
-
-
@@ -199,14 +218,12 @@
-
-
@@ -214,27 +231,30 @@
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
@@ -242,37 +262,83 @@
-
-
-
-
-
-
-
+
+ true
+
+
+ true
+
+
+ true
+
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+ true
+
+
+
+
+ true
+
+
+ true
+
-
-
+
+
+
+
+
-
-
-
-
-
-
+
-
-
-
-
-
@@ -287,86 +353,140 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
+
-
+
+
-
-
-
+
+
-
-
-
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
-
-
@@ -376,14 +496,14 @@
-
+
+
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/VisualGDB/VisualGDB/Debug/genlinetoscr b/VisualGDB/VisualGDB/Debug/genlinetoscr
new file mode 100644
index 00000000..6d22c98b
Binary files /dev/null and b/VisualGDB/VisualGDB/Debug/genlinetoscr differ
diff --git a/VisualGDB/genblitter/Readme.txt b/VisualGDB/genblitter/Readme.txt
new file mode 100644
index 00000000..85dd819a
--- /dev/null
+++ b/VisualGDB/genblitter/Readme.txt
@@ -0,0 +1,17 @@
+This tool generates the following files:
+- blit.h
+- blitfunc.cpp
+- blitfunc.h
+- blittable.cpp
+
+To use it, compile it for the target platform, then execute it there as follows:
+
+genblitter.exe i > blit.h
+
+genblitter.exe f > blitfunc.cpp
+
+genblitter.exe h > blitfunc.h
+
+genblitter.exe t > blittable.cpp
+
+Copy the resulting files back in the "src" directory of Amiberry
\ No newline at end of file
diff --git a/VisualGDB/genblitter/genblitter-Debug.vgdbsettings b/VisualGDB/genblitter/genblitter-Debug.vgdbsettings
new file mode 100644
index 00000000..be31e6ea
--- /dev/null
+++ b/VisualGDB/genblitter/genblitter-Debug.vgdbsettings
@@ -0,0 +1,154 @@
+
+
+ Debug
+
+
+
+ MinGWUnixSlash
+
+
+ 192.168.1.152
+ SSH
+ pi
+
+ false
+ false
+ false
+ false
+ false
+ $(ProjectDir)
+
+
+
+ Raspberry PI
+ com.visualgdb.raspberry_pi
+ C:\SysGCC\raspberry
+ false
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gcc.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-g++.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gdb.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-ar.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-objcopy.exe
+ C:\SysGCC\raspberry\bin\make.exe
+
+ C:\SysGCC\raspberry\bin
+
+ true
+ false
+
+
+ MinGWUnixSlash
+
+
+ genblitter.vcxproj
+
+
+
+ LANG
+ en_US.UTF-8
+
+
+ PATH
+ C:\SysGCC\raspberry\bin;%PATH%
+
+
+
+
+ 1
+
+
+
+
+
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+
+ false
+ false
+ false
+ false
+ false
+ false
+ true
+ false
+ None
+ false
+ false
+ main
+ true
+ false
+ false
+ false
+
+
+
+
+
+ LANG
+ en_US.UTF-8
+
+
+ PATH
+ C:\SysGCC\raspberry\bin;%PATH%
+
+
+
+
+ $(TargetPath)
+ 2000
+
+
+ false
+ /home/pi/projects//$(TargetFileName)
+ Local
+ false
+ false
+ Auto
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+ Default
+
+
+
+ true
+
+
+
+
+ False
+
+
+
+
+ true
+
+ Enabled
+ true
+ true
+ true
+
+
+
+
+
+ VisualGDB\VisualGDBCache
+
\ No newline at end of file
diff --git a/VisualGDB/genblitter/genblitter-Release.vgdbsettings b/VisualGDB/genblitter/genblitter-Release.vgdbsettings
new file mode 100644
index 00000000..d05d7a56
--- /dev/null
+++ b/VisualGDB/genblitter/genblitter-Release.vgdbsettings
@@ -0,0 +1,142 @@
+
+
+ Release
+
+
+
+ MinGWUnixSlash
+
+
+ 192.168.1.152
+ SSH
+ pi
+
+ false
+ false
+ false
+ false
+ false
+ $(ProjectDir)
+
+
+
+ Raspberry PI
+ com.visualgdb.raspberry_pi
+ C:\SysGCC\raspberry
+ false
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gcc.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-g++.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gdb.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-ar.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-objcopy.exe
+ C:\SysGCC\raspberry\bin\make.exe
+
+ C:\SysGCC\raspberry\bin
+
+ true
+ false
+
+
+ MinGWUnixSlash
+
+
+ genblitter.vcxproj
+
+
+
+ LANG
+ en_US.UTF-8
+
+
+ PATH
+ C:\SysGCC\raspberry\bin;%PATH%
+
+
+
+ 1
+
+
+
+
+
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+
+ false
+ false
+ false
+ false
+ false
+ false
+ true
+ false
+ None
+ false
+ false
+ main
+ true
+ false
+ false
+ false
+
+
+
+
+
+ LANG
+ en_US.UTF-8
+
+
+ PATH
+ C:\SysGCC\raspberry\bin;%PATH%
+
+
+
+
+ $(TargetPath)
+ 2000
+
+
+ false
+ /home/pi/projects//$(TargetFileName)
+ Local
+ false
+ false
+ Auto
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+ Default
+
+
+
+ true
+
+
+
+
+ Unknown
+
+ true
+
+
+ VisualGDB\VisualGDBCache
+
\ No newline at end of file
diff --git a/VisualGDB/genblitter/genblitter.vcxproj b/VisualGDB/genblitter/genblitter.vcxproj
new file mode 100644
index 00000000..a7368611
--- /dev/null
+++ b/VisualGDB/genblitter/genblitter.vcxproj
@@ -0,0 +1,71 @@
+
+
+
+
+ Debug
+ VisualGDB
+
+
+ Release
+ VisualGDB
+
+
+
+ 15.0
+ {619EFB8C-E41A-4058-B085-1B8CD22692DD}
+
+
+
+
+
+
+
+
+
+ Debug
+ C:\SysGCC\raspberry
+
+
+ C:\SysGCC\raspberry
+
+
+
+ GNUPP14
+ C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\4.9\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\4.9;C:\SysGCC\raspberry\arm-linux-gnueabihf\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;../../src/include;../../src;../../src/osdep;%(ClCompile.AdditionalIncludeDirectories)
+ DEBUG=1;%(ClCompile.PreprocessorDefinitions)
+
+
+ ;%(Link.AdditionalLinkerInputs)
+ ;%(Link.LibrarySearchDirectories)
+ ;%(Link.AdditionalLibraryNames)
+
+
+
+
+
+ GNUPP14
+ C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\4.9\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\4.9;C:\SysGCC\raspberry\arm-linux-gnueabihf\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;../../src/include;../../src;../../src/osdep;%(ClCompile.AdditionalIncludeDirectories)
+ NDEBUG=1;RELEASE=1;%(ClCompile.PreprocessorDefinitions)
+
+
+ ;%(Link.AdditionalLinkerInputs)
+ ;%(Link.LibrarySearchDirectories)
+ ;%(Link.AdditionalLibraryNames)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VisualGDB/genblitter/genblitter.vcxproj.filters b/VisualGDB/genblitter/genblitter.vcxproj.filters
new file mode 100644
index 00000000..fcb90c62
--- /dev/null
+++ b/VisualGDB/genblitter/genblitter.vcxproj.filters
@@ -0,0 +1,40 @@
+
+
+
+
+ {afe8a49f-0586-4eea-b2ea-cc1c4567db36}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {4718ef87-4582-42a4-8469-11a35b5a4418}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+ {e9ba1ae1-6dab-41af-8b75-7c41100a7fc9}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
+
+
+ {c7346196-4f74-4afd-aa85-9da2661c7ab7}
+ *.vgdbsettings
+
+
+
+
+ VisualGDB settings
+
+
+ VisualGDB settings
+
+
+
+
+ Source files
+
+
+ Source files
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VisualGDB/genblitter/genblitter.vcxproj.user b/VisualGDB/genblitter/genblitter.vcxproj.user
new file mode 100644
index 00000000..be250787
--- /dev/null
+++ b/VisualGDB/genblitter/genblitter.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/VisualGDB/genlinetoscr/Readme.txt b/VisualGDB/genlinetoscr/Readme.txt
new file mode 100644
index 00000000..ff2f6f3c
--- /dev/null
+++ b/VisualGDB/genlinetoscr/Readme.txt
@@ -0,0 +1,7 @@
+This tool generates the "linetoscr.cpp" file.
+
+Compile it for the target system (e.g. Raspberry) then run it there as:
+
+genlinetoscr > linetoscr.cpp
+
+Copy the generated file back into the "src" directory.
\ No newline at end of file
diff --git a/VisualGDB/genlinetoscr/genlinetoscr-Debug.vgdbsettings b/VisualGDB/genlinetoscr/genlinetoscr-Debug.vgdbsettings
new file mode 100644
index 00000000..9513a9ac
--- /dev/null
+++ b/VisualGDB/genlinetoscr/genlinetoscr-Debug.vgdbsettings
@@ -0,0 +1,154 @@
+
+
+ Debug
+
+
+
+ MinGWUnixSlash
+
+
+ 192.168.1.152
+ SSH
+ pi
+
+ false
+ false
+ false
+ false
+ false
+ $(ProjectDir)
+
+
+
+ Raspberry PI
+ com.visualgdb.raspberry_pi
+ C:\SysGCC\raspberry
+ false
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gcc.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-g++.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gdb.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-ar.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-objcopy.exe
+ C:\SysGCC\raspberry\bin\make.exe
+
+ C:\SysGCC\raspberry\bin
+
+ true
+ false
+
+
+ MinGWUnixSlash
+
+
+ genlinetoscr.vcxproj
+
+
+
+ LANG
+ en_US.UTF-8
+
+
+ PATH
+ C:\SysGCC\raspberry\bin;%PATH%
+
+
+
+
+ 1
+
+
+
+
+
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+
+ false
+ false
+ false
+ false
+ false
+ false
+ true
+ false
+ None
+ false
+ false
+ main
+ true
+ false
+ false
+ false
+
+
+
+
+
+ LANG
+ en_US.UTF-8
+
+
+ PATH
+ C:\SysGCC\raspberry\bin;%PATH%
+
+
+
+
+ $(TargetPath)
+ 2000
+
+
+ false
+ /home/pi/projects//$(TargetFileName)
+ Local
+ false
+ false
+ Auto
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+ Default
+
+
+
+ true
+
+
+
+
+ False
+
+
+
+
+ true
+
+ Enabled
+ true
+ true
+ true
+
+
+
+
+
+ VisualGDB\VisualGDBCache
+
\ No newline at end of file
diff --git a/VisualGDB/genlinetoscr/genlinetoscr-Release.vgdbsettings b/VisualGDB/genlinetoscr/genlinetoscr-Release.vgdbsettings
new file mode 100644
index 00000000..4427ede4
--- /dev/null
+++ b/VisualGDB/genlinetoscr/genlinetoscr-Release.vgdbsettings
@@ -0,0 +1,142 @@
+
+
+ Release
+
+
+
+ MinGWUnixSlash
+
+
+ 192.168.1.152
+ SSH
+ pi
+
+ false
+ false
+ false
+ false
+ false
+ $(ProjectDir)
+
+
+
+ Raspberry PI
+ com.visualgdb.raspberry_pi
+ C:\SysGCC\raspberry
+ false
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gcc.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-g++.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gdb.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-ar.exe
+ C:\SysGCC\raspberry\bin\arm-linux-gnueabihf-objcopy.exe
+ C:\SysGCC\raspberry\bin\make.exe
+
+ C:\SysGCC\raspberry\bin
+
+ true
+ false
+
+
+ MinGWUnixSlash
+
+
+ genlinetoscr.vcxproj
+
+
+
+ LANG
+ en_US.UTF-8
+
+
+ PATH
+ C:\SysGCC\raspberry\bin;%PATH%
+
+
+
+ 1
+
+
+
+
+
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+ false
+
+ false
+ false
+ false
+ false
+ false
+ false
+ true
+ false
+ None
+ false
+ false
+ main
+ true
+ false
+ false
+ false
+
+
+
+
+
+ LANG
+ en_US.UTF-8
+
+
+ PATH
+ C:\SysGCC\raspberry\bin;%PATH%
+
+
+
+
+ $(TargetPath)
+ 2000
+
+
+ false
+ /home/pi/projects//$(TargetFileName)
+ Local
+ false
+ false
+ Auto
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+ Default
+
+
+
+ true
+
+
+
+
+ Unknown
+
+ true
+
+
+ VisualGDB\VisualGDBCache
+
\ No newline at end of file
diff --git a/VisualGDB/genlinetoscr/genlinetoscr.vcxproj b/VisualGDB/genlinetoscr/genlinetoscr.vcxproj
new file mode 100644
index 00000000..a7deedd9
--- /dev/null
+++ b/VisualGDB/genlinetoscr/genlinetoscr.vcxproj
@@ -0,0 +1,70 @@
+
+
+
+
+ Debug
+ VisualGDB
+
+
+ Release
+ VisualGDB
+
+
+
+ 15.0
+ {883F2A00-8030-429B-AC7F-E930DDF9568F}
+
+
+
+
+
+
+
+
+
+ Debug
+ C:\SysGCC\raspberry
+
+
+ C:\SysGCC\raspberry
+
+
+
+ GNUPP14
+ C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\4.9\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\4.9;C:\SysGCC\raspberry\arm-linux-gnueabihf\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;../../src/include;../../src;../../src/osdep;%(ClCompile.AdditionalIncludeDirectories)
+ DEBUG=1;%(ClCompile.PreprocessorDefinitions)
+
+
+ ;%(Link.AdditionalLinkerInputs)
+ ;%(Link.LibrarySearchDirectories)
+ ;%(Link.AdditionalLibraryNames)
+
+
+
+
+
+ GNUPP14
+ C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\4.9\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\4.9;C:\SysGCC\raspberry\arm-linux-gnueabihf\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;../../src/include;../../src;../../src/osdep;%(ClCompile.AdditionalIncludeDirectories)
+ NDEBUG=1;RELEASE=1;%(ClCompile.PreprocessorDefinitions)
+
+
+ ;%(Link.AdditionalLinkerInputs)
+ ;%(Link.LibrarySearchDirectories)
+ ;%(Link.AdditionalLibraryNames)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VisualGDB/genlinetoscr/genlinetoscr.vcxproj.filters b/VisualGDB/genlinetoscr/genlinetoscr.vcxproj.filters
new file mode 100644
index 00000000..dc1e79f8
--- /dev/null
+++ b/VisualGDB/genlinetoscr/genlinetoscr.vcxproj.filters
@@ -0,0 +1,37 @@
+
+
+
+
+ {19e139ec-d402-45d4-89fc-39f22443a95b}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {0a02e0a2-214b-4e9e-a7c5-0668ebf38e34}
+ h;hpp;hxx;hm;inl;inc;xsd
+
+
+ {30f92ef0-a24c-49e2-9e92-906dcef4d050}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
+
+
+ {20bde34c-9e8e-42ee-83c1-c8c8143c7516}
+ *.vgdbsettings
+
+
+
+
+ VisualGDB settings
+
+
+ VisualGDB settings
+
+
+
+
+ Source files
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VisualGDB/genlinetoscr/genlinetoscr.vcxproj.user b/VisualGDB/genlinetoscr/genlinetoscr.vcxproj.user
new file mode 100644
index 00000000..be250787
--- /dev/null
+++ b/VisualGDB/genlinetoscr/genlinetoscr.vcxproj.user
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/akiko.cpp b/src/akiko.cpp
index 40d67724..7337abc6 100644
--- a/src/akiko.cpp
+++ b/src/akiko.cpp
@@ -7,7 +7,7 @@
* - NVRAM
* - CDROM
*
-* Copyright 2001-2016 Toni Wilen
+* Copyright 2001-2010 Toni Wilen
*
*/
@@ -15,8 +15,9 @@
#include "sysdeps.h"
#include "options.h"
-#include "memory.h"
+#include "include/memory.h"
#include "newcpu.h"
+#include "events.h"
#include "savestate.h"
#include "blkdev.h"
#include "zfile.h"
@@ -26,15 +27,21 @@
#include "crc32.h"
#include "uae.h"
#include "custom.h"
-#include "flashrom.h"
+
+#define AKIKO_DEBUG_NVRAM 0
+#define AKIKO_DEBUG_IO 0
+#define AKIKO_DEBUG_IO_CMD 0
// 43 48 49 4E 4F 4E 20 20 4F 2D 36 35 38 2D 32 20 32 34
#define FIRMWAREVERSION "CHINON O-658-2 24"
-static void irq (void)
+static void irq(void)
{
+#if AKIKO_DEBUG_IO > 1
+ write_log(_T("Akiko Interrupt\n"));
+#endif
if (!(intreq & 8)) {
- INTREQ_0 (0x8000 | 0x0008);
+ INTREQ_0(0x8000 | 0x0008);
}
}
@@ -47,71 +54,234 @@ static void irq (void)
* 0xb80030: bit 7 = SCL (clock), 6 = SDA (data)
* 0xb80032: 0xb80030 data direction register (0 = input, 1 = output)
*
+* Because I don't have any experience on I2C, following code may be
+* unnecessarily complex and not 100% correct..
*/
-static uae_u8 *cd32_nvram;
-static void *cd32_eeprom;
-static uae_u8 cd32_i2c_direction;
-static bool cd32_i2c_data_scl, cd32_i2c_data_sda;
-static struct zfile *flashfile;
+enum i2c { I2C_WAIT, I2C_START, I2C_DEVICEADDR, I2C_WORDADDR, I2C_DATA };
-static void nvram_read (void)
+/* size of EEPROM, don't try to change,
+* (hardcoded in Kickstart)
+*/
+#define NVRAM_SIZE 1024
+/* max size of one write request */
+#define NVRAM_PAGE_SIZE 16
+
+static uae_u8 cd32_nvram[NVRAM_SIZE], nvram_writetmp[NVRAM_PAGE_SIZE];
+static int nvram_address, nvram_writeaddr;
+static int nvram_rw;
+static int bitcounter = -1, direction = -1;
+static uae_u8 nvram_byte;
+static int scl_out, scl_in, scl_dir, oscl, sda_out, sda_in, sda_dir, osda;
+static int sda_dir_nvram;
+static int state = I2C_WAIT;
+
+static void nvram_write(int offset, int len)
{
- zfile_fclose(flashfile);
- flashfile = NULL;
- eeprom_free(cd32_eeprom);
- cd32_eeprom = NULL;
- cd32_i2c_data_scl = cd32_i2c_data_sda = true;
- cd32_i2c_direction = 0;
+ struct zfile *f;
+
if (!currprefs.cs_cd32nvram)
return;
- if (!cd32_nvram)
- cd32_nvram = xmalloc(uae_u8, currprefs.cs_cd32nvram_size);
- memset(cd32_nvram, 0, currprefs.cs_cd32nvram_size);
- flashfile = zfile_fopen (currprefs.flashfile, _T("rb+"), ZFD_NORMAL);
- if (!flashfile)
- flashfile = zfile_fopen (currprefs.flashfile, _T("wb"), 0);
- if (flashfile) {
- int size = zfile_fread(cd32_nvram, 1, currprefs.cs_cd32nvram_size, flashfile);
- if (size < currprefs.cs_cd32nvram_size)
- zfile_fwrite(cd32_nvram + size, 1, currprefs.cs_cd32nvram_size - size, flashfile);
+ f = zfile_fopen(currprefs.flashfile, _T("rb+"), ZFD_NORMAL);
+ if (!f) {
+ f = zfile_fopen(currprefs.flashfile, _T("wb"), 0);
+ if (!f) return;
+ zfile_fwrite(cd32_nvram, NVRAM_SIZE, 1, f);
}
- cd32_eeprom = eeprom_new(cd32_nvram, currprefs.cs_cd32nvram_size, flashfile);
+ zfile_fseek(f, offset, SEEK_SET);
+ zfile_fwrite(cd32_nvram + offset, len, 1, f);
+ zfile_fclose(f);
}
-static void akiko_nvram_write (int offset, uae_u32 v)
+static void nvram_read(void)
{
+ struct zfile *f;
+
+ if (!currprefs.cs_cd32nvram)
+ return;
+ f = zfile_fopen(currprefs.flashfile, _T("rb"), ZFD_NORMAL);
+ memset(cd32_nvram, 0, NVRAM_SIZE);
+ if (!f) return;
+ zfile_fread(cd32_nvram, NVRAM_SIZE, 1, f);
+ zfile_fclose(f);
+}
+
+static void i2c_do(void)
+{
+#if AKIKO_DEBUG_NVRAM
+ int i;
+#endif
+ sda_in = 1;
+ if (!sda_dir_nvram && scl_out && oscl) {
+ if (!sda_out && osda) { /* START-condition? */
+ state = I2C_DEVICEADDR;
+ bitcounter = 0;
+ direction = -1;
+#if AKIKO_DEBUG_NVRAM
+ write_log(_T("START\n"));
+#endif
+ return;
+ }
+ else if (sda_out && !osda) { /* STOP-condition? */
+ state = I2C_WAIT;
+ bitcounter = -1;
+#if AKIKO_DEBUG_NVRAM
+ write_log(_T("STOP\n"));
+#endif
+ if (direction > 0) {
+ memcpy(cd32_nvram + (nvram_address & ~(NVRAM_PAGE_SIZE - 1)), nvram_writetmp, NVRAM_PAGE_SIZE);
+ nvram_write(nvram_address & ~(NVRAM_PAGE_SIZE - 1), NVRAM_PAGE_SIZE);
+ direction = -1;
+ gui_flicker_led(LED_MD, 0, 2);
+#if AKIKO_DEBUG_NVRAM
+ write_log(_T("NVRAM write address %04X:"), nvram_address & ~(NVRAM_PAGE_SIZE - 1));
+ for (i = 0; i < NVRAM_PAGE_SIZE; i++)
+ write_log(_T("%02X"), nvram_writetmp[i]);
+ write_log(_T("\n"));
+
+#endif
+ }
+ return;
+ }
+ }
+ if (bitcounter >= 0) {
+ if (direction) {
+ /* Amiga -> NVRAM */
+ if (scl_out && !oscl) {
+ if (bitcounter == 8) {
+#if AKIKO_DEBUG_NVRAM
+ write_log(_T("RB %02X "), nvram_byte, M68K_GETPC);
+#endif
+ sda_in = 0; /* ACK */
+ if (direction > 0) {
+ nvram_writetmp[nvram_writeaddr++] = nvram_byte;
+ nvram_writeaddr &= 15;
+ bitcounter = 0;
+ }
+ else {
+ bitcounter = -1;
+ }
+ }
+ else {
+ //write_log (_T("NVRAM received bit %d, offset %d\n"), sda_out, bitcounter);
+ nvram_byte <<= 1;
+ nvram_byte |= sda_out;
+ bitcounter++;
+ }
+ }
+ }
+ else {
+ /* NVRAM -> Amiga */
+ if (scl_out && !oscl && bitcounter < 8) {
+ if (bitcounter == 0)
+ nvram_byte = cd32_nvram[nvram_address];
+ sda_dir_nvram = 1;
+ sda_in = (nvram_byte & 0x80) ? 1 : 0;
+ //write_log (_T("NVRAM sent bit %d, offset %d\n"), sda_in, bitcounter);
+ nvram_byte <<= 1;
+ bitcounter++;
+ if (bitcounter == 8) {
+#if AKIKO_DEBUG_NVRAM
+ write_log(_T("NVRAM sent byte %02X address %04X PC=%08X\n"), cd32_nvram[nvram_address], nvram_address, M68K_GETPC);
+#endif
+ nvram_address++;
+ nvram_address &= NVRAM_SIZE - 1;
+ sda_dir_nvram = 0;
+ }
+ }
+ if (!sda_out && sda_dir && !scl_out) /* ACK from Amiga */
+ bitcounter = 0;
+ }
+ if (bitcounter >= 0) return;
+ }
+ switch (state)
+ {
+ case I2C_DEVICEADDR:
+ if ((nvram_byte & 0xf0) != 0xa0) {
+ write_log(_T("WARNING: I2C_DEVICEADDR: device address != 0xA0\n"));
+ state = I2C_WAIT;
+ return;
+ }
+ nvram_rw = (nvram_byte & 1) ? 0 : 1;
+ if (nvram_rw) {
+ /* 2 high address bits, only fetched if WRITE = 1 */
+ nvram_address &= 0xff;
+ nvram_address |= ((nvram_byte >> 1) & 3) << 8;
+ state = I2C_WORDADDR;
+ direction = -1;
+ }
+ else {
+ state = I2C_DATA;
+ direction = 0;
+ sda_dir_nvram = 1;
+ }
+ bitcounter = 0;
+#if AKIKO_DEBUG_NVRAM
+ write_log(_T("I2C_DEVICEADDR: rw %d, address %02Xxx PC=%08X\n"), nvram_rw, nvram_address >> 8, M68K_GETPC);
+#endif
+ break;
+ case I2C_WORDADDR:
+ nvram_address &= 0x300;
+ nvram_address |= nvram_byte;
+#if AKIKO_DEBUG_NVRAM
+ write_log(_T("I2C_WORDADDR: address %04X PC=%08X\n"), nvram_address, M68K_GETPC);
+#endif
+ if (direction < 0) {
+ memcpy(nvram_writetmp, cd32_nvram + (nvram_address & ~(NVRAM_PAGE_SIZE - 1)), NVRAM_PAGE_SIZE);
+ nvram_writeaddr = nvram_address & (NVRAM_PAGE_SIZE - 1);
+ gui_flicker_led(LED_MD, 0, 1);
+ }
+ state = I2C_DATA;
+ bitcounter = 0;
+ direction = 1;
+ break;
+ }
+}
+
+static void akiko_nvram_write(int offset, uae_u32 v)
+{
+ int sda;
switch (offset)
{
case 0:
- if (cd32_i2c_direction & 0x80)
- cd32_i2c_data_scl = (v & 0x80) != 0;
- else
- cd32_i2c_data_scl = true;
- eeprom_i2c_set(cd32_eeprom, BITBANG_I2C_SCL, cd32_i2c_data_scl);
- if (cd32_i2c_direction & 0x40)
- cd32_i2c_data_sda = (v & 0x40) != 0;
- else
- cd32_i2c_data_sda = true;
- eeprom_i2c_set(cd32_eeprom, BITBANG_I2C_SDA, cd32_i2c_data_sda);
+ oscl = scl_out;
+ scl_out = (v & 0x80) ? 1 : 0;
+ osda = sda_out;
+ sda_out = (v & 0x40) ? 1 : 0;
break;
case 2:
- cd32_i2c_direction = v;
+ scl_dir = (v & 0x80) ? 1 : 0;
+ sda_dir = (v & 0x40) ? 1 : 0;
break;
+ default:
+ return;
+ }
+ sda = sda_out;
+ if (oscl != scl_out || osda != sda) {
+ i2c_do();
+ oscl = scl_out;
+ osda = sda;
}
}
-static uae_u32 akiko_nvram_read (int offset)
+static uae_u32 akiko_nvram_read(int offset)
{
uae_u32 v = 0;
switch (offset)
{
case 0:
- v |= eeprom_i2c_set(cd32_eeprom, BITBANG_I2C_SCL, cd32_i2c_data_scl) ? 0x80 : 0x00;
- v |= eeprom_i2c_set(cd32_eeprom, BITBANG_I2C_SDA, cd32_i2c_data_sda) ? 0x40 : 0x00;
+ if (!scl_dir)
+ v |= scl_in ? 0x80 : 0x00;
+ else
+ v |= scl_out ? 0x80 : 0x00;
+ if (!sda_dir)
+ v |= sda_in ? 0x40 : 0x00;
+ else
+ v |= sda_out ? 0x40 : 0x00;
break;
case 2:
- v = cd32_i2c_direction;
+ v |= scl_dir ? 0x80 : 0x00;
+ v |= sda_dir ? 0x40 : 0x00;
break;
}
return v;
@@ -126,82 +296,99 @@ static uae_u32 akiko_buffer[8];
static int akiko_read_offset, akiko_write_offset;
static uae_u32 akiko_result[8];
+#if 0
+static void akiko_c2p_do(void)
+{
+ int i;
+
+ for (i = 0; i < 8; i++)
+ akiko_result[i] = 0;
+ /* FIXME: better c2p algoritm than this piece of crap.... */
+ for (i = 0; i < 8 * 32; i++) {
+ if (akiko_buffer[7 - (i >> 5)] & (1 << (i & 31)))
+ akiko_result[i & 7] |= 1 << (i >> 3);
+ }
+}
+#else
/* Optimised Chunky-to-Planar algorithm by Mequa */
static uae_u32 akiko_precalc_shift[32];
static uae_u32 akiko_precalc_bytenum[32][8];
-static void akiko_precalculate (void)
+static void akiko_precalculate(void)
{
uae_u32 i, j;
for (i = 0; i < 32; i++) {
- akiko_precalc_shift [(int)i] = 1 << i;
+ akiko_precalc_shift[(int)i] = 1 << i;
for (j = 0; j < 8; j++) {
akiko_precalc_bytenum[(int)i][(int)j] = (i >> 3) + ((7 - j) << 2);
}
}
}
-static void akiko_c2p_do (void)
+static void akiko_c2p_do(void)
{
int i;
for (i = 0; i < 8; i++) {
- akiko_result[i] = (((akiko_buffer[0] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][0]) )
- | (((akiko_buffer[1] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][1]) )
- | (((akiko_buffer[2] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][2]) )
- | (((akiko_buffer[3] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][3]) )
- | (((akiko_buffer[4] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][4]) )
- | (((akiko_buffer[5] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][5]) )
- | (((akiko_buffer[6] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][6]) )
- | (((akiko_buffer[7] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][7]) )
- | (((akiko_buffer[0] & akiko_precalc_shift[i+8]) != 0) << (akiko_precalc_bytenum[i+8][0]) )
- | (((akiko_buffer[1] & akiko_precalc_shift[i+8]) != 0) << (akiko_precalc_bytenum[i+8][1]) )
- | (((akiko_buffer[2] & akiko_precalc_shift[i+8]) != 0) << (akiko_precalc_bytenum[i+8][2]) )
- | (((akiko_buffer[3] & akiko_precalc_shift[i+8]) != 0) << (akiko_precalc_bytenum[i+8][3]) )
- | (((akiko_buffer[4] & akiko_precalc_shift[i+8]) != 0) << (akiko_precalc_bytenum[i+8][4]) )
- | (((akiko_buffer[5] & akiko_precalc_shift[i+8]) != 0) << (akiko_precalc_bytenum[i+8][5]) )
- | (((akiko_buffer[6] & akiko_precalc_shift[i+8]) != 0) << (akiko_precalc_bytenum[i+8][6]) )
- | (((akiko_buffer[7] & akiko_precalc_shift[i+8]) != 0) << (akiko_precalc_bytenum[i+8][7]) )
- | (((akiko_buffer[0] & akiko_precalc_shift[i+16]) != 0) << (akiko_precalc_bytenum[i+16][0]))
- | (((akiko_buffer[1] & akiko_precalc_shift[i+16]) != 0) << (akiko_precalc_bytenum[i+16][1]))
- | (((akiko_buffer[2] & akiko_precalc_shift[i+16]) != 0) << (akiko_precalc_bytenum[i+16][2]))
- | (((akiko_buffer[3] & akiko_precalc_shift[i+16]) != 0) << (akiko_precalc_bytenum[i+16][3]))
- | (((akiko_buffer[4] & akiko_precalc_shift[i+16]) != 0) << (akiko_precalc_bytenum[i+16][4]))
- | (((akiko_buffer[5] & akiko_precalc_shift[i+16]) != 0) << (akiko_precalc_bytenum[i+16][5]))
- | (((akiko_buffer[6] & akiko_precalc_shift[i+16]) != 0) << (akiko_precalc_bytenum[i+16][6]))
- | (((akiko_buffer[7] & akiko_precalc_shift[i+16]) != 0) << (akiko_precalc_bytenum[i+16][7]))
- | (((akiko_buffer[0] & akiko_precalc_shift[i+24]) != 0) << (akiko_precalc_bytenum[i+24][0]))
- | (((akiko_buffer[1] & akiko_precalc_shift[i+24]) != 0) << (akiko_precalc_bytenum[i+24][1]))
- | (((akiko_buffer[2] & akiko_precalc_shift[i+24]) != 0) << (akiko_precalc_bytenum[i+24][2]))
- | (((akiko_buffer[3] & akiko_precalc_shift[i+24]) != 0) << (akiko_precalc_bytenum[i+24][3]))
- | (((akiko_buffer[4] & akiko_precalc_shift[i+24]) != 0) << (akiko_precalc_bytenum[i+24][4]))
- | (((akiko_buffer[5] & akiko_precalc_shift[i+24]) != 0) << (akiko_precalc_bytenum[i+24][5]))
- | (((akiko_buffer[6] & akiko_precalc_shift[i+24]) != 0) << (akiko_precalc_bytenum[i+24][6]))
- | (((akiko_buffer[7] & akiko_precalc_shift[i+24]) != 0) << (akiko_precalc_bytenum[i+24][7]));
+ akiko_result[i] = (((akiko_buffer[0] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][0]))
+ | (((akiko_buffer[1] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][1]))
+ | (((akiko_buffer[2] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][2]))
+ | (((akiko_buffer[3] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][3]))
+ | (((akiko_buffer[4] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][4]))
+ | (((akiko_buffer[5] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][5]))
+ | (((akiko_buffer[6] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][6]))
+ | (((akiko_buffer[7] & akiko_precalc_shift[i]) != 0) << (akiko_precalc_bytenum[i][7]))
+ | (((akiko_buffer[0] & akiko_precalc_shift[i + 8]) != 0) << (akiko_precalc_bytenum[i + 8][0]))
+ | (((akiko_buffer[1] & akiko_precalc_shift[i + 8]) != 0) << (akiko_precalc_bytenum[i + 8][1]))
+ | (((akiko_buffer[2] & akiko_precalc_shift[i + 8]) != 0) << (akiko_precalc_bytenum[i + 8][2]))
+ | (((akiko_buffer[3] & akiko_precalc_shift[i + 8]) != 0) << (akiko_precalc_bytenum[i + 8][3]))
+ | (((akiko_buffer[4] & akiko_precalc_shift[i + 8]) != 0) << (akiko_precalc_bytenum[i + 8][4]))
+ | (((akiko_buffer[5] & akiko_precalc_shift[i + 8]) != 0) << (akiko_precalc_bytenum[i + 8][5]))
+ | (((akiko_buffer[6] & akiko_precalc_shift[i + 8]) != 0) << (akiko_precalc_bytenum[i + 8][6]))
+ | (((akiko_buffer[7] & akiko_precalc_shift[i + 8]) != 0) << (akiko_precalc_bytenum[i + 8][7]))
+ | (((akiko_buffer[0] & akiko_precalc_shift[i + 16]) != 0) << (akiko_precalc_bytenum[i + 16][0]))
+ | (((akiko_buffer[1] & akiko_precalc_shift[i + 16]) != 0) << (akiko_precalc_bytenum[i + 16][1]))
+ | (((akiko_buffer[2] & akiko_precalc_shift[i + 16]) != 0) << (akiko_precalc_bytenum[i + 16][2]))
+ | (((akiko_buffer[3] & akiko_precalc_shift[i + 16]) != 0) << (akiko_precalc_bytenum[i + 16][3]))
+ | (((akiko_buffer[4] & akiko_precalc_shift[i + 16]) != 0) << (akiko_precalc_bytenum[i + 16][4]))
+ | (((akiko_buffer[5] & akiko_precalc_shift[i + 16]) != 0) << (akiko_precalc_bytenum[i + 16][5]))
+ | (((akiko_buffer[6] & akiko_precalc_shift[i + 16]) != 0) << (akiko_precalc_bytenum[i + 16][6]))
+ | (((akiko_buffer[7] & akiko_precalc_shift[i + 16]) != 0) << (akiko_precalc_bytenum[i + 16][7]))
+ | (((akiko_buffer[0] & akiko_precalc_shift[i + 24]) != 0) << (akiko_precalc_bytenum[i + 24][0]))
+ | (((akiko_buffer[1] & akiko_precalc_shift[i + 24]) != 0) << (akiko_precalc_bytenum[i + 24][1]))
+ | (((akiko_buffer[2] & akiko_precalc_shift[i + 24]) != 0) << (akiko_precalc_bytenum[i + 24][2]))
+ | (((akiko_buffer[3] & akiko_precalc_shift[i + 24]) != 0) << (akiko_precalc_bytenum[i + 24][3]))
+ | (((akiko_buffer[4] & akiko_precalc_shift[i + 24]) != 0) << (akiko_precalc_bytenum[i + 24][4]))
+ | (((akiko_buffer[5] & akiko_precalc_shift[i + 24]) != 0) << (akiko_precalc_bytenum[i + 24][5]))
+ | (((akiko_buffer[6] & akiko_precalc_shift[i + 24]) != 0) << (akiko_precalc_bytenum[i + 24][6]))
+ | (((akiko_buffer[7] & akiko_precalc_shift[i + 24]) != 0) << (akiko_precalc_bytenum[i + 24][7]));
}
}
+#endif
-static void akiko_c2p_write (int offset, uae_u32 v)
+static void akiko_c2p_write(int offset, uae_u32 v)
{
if (offset == 3)
akiko_buffer[akiko_write_offset] = 0;
- akiko_buffer[akiko_write_offset] |= v << ( 8 * (3 - offset));
+ akiko_buffer[akiko_write_offset] |= v << (8 * (3 - offset));
if (offset == 0) {
akiko_write_offset++;
akiko_write_offset &= 7;
}
- akiko_read_offset = -1;
+ akiko_read_offset = 0;
}
-static uae_u32 akiko_c2p_read (int offset)
+static uae_u32 akiko_c2p_read(int offset)
{
uae_u32 v;
- if (akiko_read_offset < 0) {
- akiko_c2p_do ();
- akiko_read_offset = 0;
- }
+ if (akiko_read_offset == 0 && offset == 3)
+ akiko_c2p_do();
akiko_write_offset = 0;
v = akiko_result[akiko_read_offset];
+ if (offset == 0) {
+ akiko_read_offset++;
+ akiko_read_offset &= 7;
+ }
return v >> (8 * (3 - offset));
}
@@ -267,7 +454,6 @@ static uae_u8 cdcomrxcmp; /* 0x1f */
static uae_u8 cdrom_result_buffer[32];
static uae_u8 cdrom_command_buffer[32];
static uae_u8 cdrom_command;
-static uae_u8 cdrom_last_rx;
static int cdrom_toc_counter;
static uae_u32 cdrom_toc_crc;
@@ -282,12 +468,13 @@ static int cdrom_command_length;
static int cdrom_checksum_error, cdrom_unknown_command;
static int cdrom_data_offset, cdrom_speed, cdrom_sector_counter;
static int cdrom_current_sector, cdrom_seek_delay;
+static int cdrom_data_end;
static int cdrom_audiotimeout;
static int cdrom_led;
static int cdrom_receive_length, cdrom_receive_offset;
static int cdrom_muted;
static int cd_initialized;
-static int cdrom_tx_dma_delay, cdrom_rx_dma_delay;
+static int cdrom_tx_dma_delay;
static uae_u8 *sector_buffer_1, *sector_buffer_2;
static int sector_buffer_sector_1, sector_buffer_sector_2;
@@ -295,72 +482,82 @@ static int sector_buffer_sector_1, sector_buffer_sector_2;
static uae_u8 *sector_buffer_info_1, *sector_buffer_info_2;
static int unitnum = -1;
-static uae_u8 cdrom_door = 1;
static bool akiko_inited;
static volatile int mediachanged, mediacheckcounter;
static volatile int frame2counter;
static smp_comm_pipe requests;
static volatile int akiko_thread_running;
-static uae_sem_t akiko_sem = 0, sub_sem = 0;
+static uae_sem_t akiko_sem, sub_sem;
-static void checkint (void)
+static void checkint(void)
{
- if (cdrom_intreq & cdrom_intena) {
- irq ();
- }
+ if (cdrom_intreq & cdrom_intena)
+ irq();
}
-static void set_status (uae_u32 status)
+static void set_status(uae_u32 status)
{
+#if AKIKO_DEBUG_IO
+ if (!(cdrom_intreq & status))
+ write_log(_T("Akiko INTREQ %08x (%08x)\n"), status, cdrom_intreq | status);
+#endif
cdrom_intreq |= status;
- checkint ();
+ checkint();
cdrom_led ^= LED_CD_ACTIVE2;
}
-void rethink_akiko (void)
+void rethink_akiko(void)
{
- checkint ();
+ checkint();
}
-static void cdaudiostop_do (void)
+static void cdaudiostop_do(void)
{
qcode_valid = 0;
if (unitnum < 0)
return;
- sys_command_cd_pause (unitnum, 0);
- sys_command_cd_stop (unitnum);
+ sys_command_cd_pause(unitnum, 0);
+ sys_command_cd_stop(unitnum);
}
-static void cdaudiostop (void)
+static void cdaudiostop(void)
{
cdrom_audiostatus = 0;
cdrom_audiotimeout = 0;
cdrom_paused = 0;
cdrom_playing = 0;
- write_comm_pipe_u32 (&requests, 0x0104, 1);
+ write_comm_pipe_u32(&requests, 0x0104, 1);
}
-static void subfunc (uae_u8 *data, int cnt)
+static void subfunc(uae_u8 *data, int cnt)
{
if (!(cdrom_flags & CDFLAG_SUBCODE))
return;
- uae_sem_wait (&sub_sem);
+ uae_sem_wait(&sub_sem);
+#if 0
+ int total = 0;
+ for (int i = 0; i < MAX_SUBCODEBUFFER; i++) {
+ if (subcodebufferinuse[i])
+ total++;
+ }
+ write_log(_T("%d "), total);
+#endif
if (subcodebufferinuse[subcodebufferoffsetw]) {
- memset (subcodebufferinuse, 0,sizeof (subcodebufferinuse));
+ memset(subcodebufferinuse, 0, sizeof(subcodebufferinuse));
subcodebufferoffsetw = subcodebufferoffset = 0;
- uae_sem_post (&sub_sem);
+ uae_sem_post(&sub_sem);
//write_log (_T("CD32: subcode buffer overflow 1\n"));
return;
}
int offset = subcodebufferoffsetw;
while (cnt > 0) {
if (subcodebufferinuse[offset]) {
- write_log (_T("CD32: subcode buffer overflow 2\n"));
+ write_log(_T("CD32: subcode buffer overflow 2\n"));
break;
}
subcodebufferinuse[offset] = 1;
- memcpy (&subcodebuffer[offset * SUB_CHANNEL_SIZE], data, SUB_CHANNEL_SIZE);
+ memcpy(&subcodebuffer[offset * SUB_CHANNEL_SIZE], data, SUB_CHANNEL_SIZE);
data += SUB_CHANNEL_SIZE;
offset++;
if (offset >= MAX_SUBCODEBUFFER)
@@ -368,15 +565,16 @@ static void subfunc (uae_u8 *data, int cnt)
cnt--;
}
subcodebufferoffsetw = offset;
- uae_sem_post (&sub_sem);
+ uae_sem_post(&sub_sem);
}
-static int statusfunc (int status, int playpos)
+static int statusfunc(int status)
{
if (status == -1)
return 0;
if (status == -2)
return 10;
+#if 1
if (cdrom_audiostatus != status) {
if (status == AUDIO_STATUS_IN_PROGRESS) {
cdrom_playing = 1;
@@ -387,22 +585,23 @@ static int statusfunc (int status, int playpos)
}
}
cdrom_audiostatus = status;
+#endif
return 0;
}
-static void cdaudioplay_do (void)
+static void cdaudioplay_do(void)
{
- uae_u32 startlsn = read_comm_pipe_u32_blocking (&requests);
- uae_u32 endlsn = read_comm_pipe_u32_blocking (&requests);
- uae_u32 scan = read_comm_pipe_u32_blocking (&requests);
+ uae_u32 startlsn = read_comm_pipe_u32_blocking(&requests);
+ uae_u32 endlsn = read_comm_pipe_u32_blocking(&requests);
+ uae_u32 scan = read_comm_pipe_u32_blocking(&requests);
qcode_valid = 0;
if (unitnum < 0)
return;
- sys_command_cd_pause (unitnum, 0);
- sys_command_cd_play (unitnum, startlsn, endlsn, scan, statusfunc, subfunc);
+ sys_command_cd_pause(unitnum, 0);
+ sys_command_cd_play(unitnum, startlsn, endlsn, scan, statusfunc, subfunc);
}
-static bool isaudiotrack (int startlsn)
+static bool isaudiotrack(int startlsn)
{
struct cd_toc *s = NULL;
uae_u32 addr;
@@ -418,15 +617,15 @@ static bool isaudiotrack (int startlsn)
s++;
}
if (s && (s->control & 0x0c) == 0x04) {
- write_log (_T("CD32: tried to play data track %d!\n"), s->track);
+ write_log(_T("tried to play data track %d!\n"), s->track);
return false;
}
return true;
}
-static struct cd_toc *get_track (int startlsn)
+static struct cd_toc *get_track(int startlsn)
{
- for (int i = cdrom_toc_cd_buffer.first_track_offset + 1; i <= cdrom_toc_cd_buffer.last_track_offset + 1; i++) {
+ for (int i = cdrom_toc_cd_buffer.first_track_offset + 1; i <= cdrom_toc_cd_buffer.last_track_offset; i++) {
struct cd_toc *s = &cdrom_toc_cd_buffer.toc[i];
uae_u32 addr = s->paddress;
if (startlsn < addr)
@@ -436,17 +635,17 @@ static struct cd_toc *get_track (int startlsn)
}
static int last_play_end;
-static int cd_play_audio (int startlsn, int endlsn, int scan)
+static int cd_play_audio(int startlsn, int endlsn, int scan)
{
struct cd_toc *s = NULL;
if (!cdrom_toc_cd_buffer.points)
return 0;
- s = get_track (startlsn);
+ s = get_track(startlsn);
if (s && (s->control & 0x0c) == 0x04) {
- s = get_track (startlsn + 150);
+ s = get_track(startlsn + 150);
if (s && (s->control & 0x0c) == 0x04) {
- write_log (_T("CD32: tried to play data track %d!\n"), s->track);
+ write_log(_T("tried to play data track %d!\n"), s->track);
s++;
startlsn = s->paddress;
s++;
@@ -458,22 +657,22 @@ static int cd_play_audio (int startlsn, int endlsn, int scan)
last_play_end = endlsn;
cdrom_audiotimeout = 10;
cdrom_paused = 0;
- write_comm_pipe_u32 (&requests, 0x0110, 0);
- write_comm_pipe_u32 (&requests, startlsn, 0);
- write_comm_pipe_u32 (&requests, endlsn, 0);
- write_comm_pipe_u32 (&requests, scan, 1);
+ write_comm_pipe_u32(&requests, 0x0110, 0);
+ write_comm_pipe_u32(&requests, startlsn, 0);
+ write_comm_pipe_u32(&requests, endlsn, 0);
+ write_comm_pipe_u32(&requests, scan, 1);
return 1;
}
/* read qcode */
static int last_play_pos;
-static int cd_qcode (uae_u8 *d)
+static int cd_qcode(uae_u8 *d)
{
uae_u8 *buf, *s, as;
if (d)
- memset (d, 0, 11);
+ memset(d, 0, 11);
last_play_pos = 0;
buf = qcode_buf;
as = buf[1];
@@ -483,7 +682,7 @@ static int cd_qcode (uae_u8 *d)
if (cdrom_audiostatus != AUDIO_STATUS_IN_PROGRESS && cdrom_audiostatus != AUDIO_STATUS_PAUSED)
return 0;
s = buf + 4;
- last_play_pos = msf2lsn (fromlongbcd (s + 7));
+ last_play_pos = msf2lsn(fromlongbcd(s + 7));
if (!d)
return 0;
buf[2] = 0;
@@ -508,103 +707,88 @@ static int cd_qcode (uae_u8 *d)
/* Make sure end of disc position is not missed.
*/
if (last_play_pos >= cdrom_toc_cd_buffer.lastaddress || cdrom_toc_cd_buffer.lastaddress - last_play_pos < 10) {
- int msf = lsn2msf (cdrom_toc_cd_buffer.lastaddress);
- d[8] = tobcd ((uae_u8)(msf >> 16));
- d[9] = tobcd ((uae_u8)(msf >> 8));
- d[10] = tobcd ((uae_u8)(msf >> 0));
+ int msf = lsn2msf(cdrom_toc_cd_buffer.lastaddress);
+ d[8] = tobcd((uae_u8)(msf >> 16));
+ d[9] = tobcd((uae_u8)(msf >> 8));
+ d[10] = tobcd((uae_u8)(msf >> 0));
}
}
+// write_log (_T("%02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X\n"),
+// d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10], d[11]);
return 0;
}
/* read toc */
-static int get_cdrom_toc (void)
+static int get_cdrom_toc(void)
{
int j;
int datatrack = 0, secondtrack = 0;
cdrom_toc_counter = -1;
- if (!sys_command_cd_toc (unitnum, &cdrom_toc_cd_buffer))
+ if (!sys_command_cd_toc(unitnum, &cdrom_toc_cd_buffer))
return 1;
- memset (cdrom_toc_buffer, 0, MAX_TOC_ENTRIES * 13);
+ memset(cdrom_toc_buffer, 0, MAX_TOC_ENTRIES * 13);
+ cdrom_data_end = -1;
for (j = 0; j < cdrom_toc_cd_buffer.points; j++) {
struct cd_toc *s = &cdrom_toc_cd_buffer.toc[j];
uae_u8 *d = &cdrom_toc_buffer[j * 13];
int addr = s->paddress;
- int msf = lsn2msf (addr);
+ int msf = lsn2msf(addr);
if (s->point == 0xa0 || s->point == 0xa1)
msf = s->track << 16;
d[1] = (s->adr << 0) | (s->control << 4);
- d[3] = s->point < 100 ? tobcd (s->point) : s->point;
- d[8] = tobcd ((msf >> 16) & 0xff);
- d[9] = tobcd ((msf >> 8) & 0xff);
- d[10] = tobcd ((msf >> 0) & 0xff);
+ d[3] = s->point < 100 ? tobcd(s->point) : s->point;
+ d[8] = tobcd((msf >> 16) & 0xff);
+ d[9] = tobcd((msf >> 8) & 0xff);
+ d[10] = tobcd((msf >> 0) & 0xff);
if (s->point == 1 && (s->control & 0x0c) == 0x04)
datatrack = 1;
- if (s->point >= 2 && s->point < 100 && (s->control & 0x0c) != 0x04 && !secondtrack)
+ if (s->point == 2)
secondtrack = addr;
}
- cdrom_toc_crc = get_crc32 (cdrom_toc_buffer, cdrom_toc_cd_buffer.points * 13);
- return 0;
-}
-static bool is_valid_data_sector(int sector)
-{
- for (int i = 0; i < cdrom_toc_cd_buffer.points; i++) {
- struct cd_toc *s = &cdrom_toc_cd_buffer.toc[i];
- if (s->point < 1 || s->point > 99)
- continue;
- if ((s->control & 0x0c) != 4)
- continue;
- if (sector >= s->paddress && (sector < s[1].paddress || s[1].point >= 0xa1))
- return true;
+ cdrom_toc_crc = get_crc32(cdrom_toc_buffer, cdrom_toc_cd_buffer.points * 13);
+ if (datatrack) {
+ if (secondtrack)
+ cdrom_data_end = secondtrack;
+ else
+ cdrom_data_end = cdrom_toc_cd_buffer.lastaddress;
}
- return false;
+ return 0;
}
/* open device */
-static int sys_cddev_open (void)
+static int sys_cddev_open(void)
{
- struct device_info di = { 0 };
- unitnum = get_standard_cd_unit (CD_STANDARD_UNIT_CD32);
- sys_command_info (unitnum, &di, 0);
- write_log (_T("CD32: using drive %s (unit %d, media %d)\n"), di.label, unitnum, di.media_inserted);
+ struct device_info di;
+ unitnum = get_standard_cd_unit(CD_STANDARD_UNIT_CD32);
+ sys_command_info(unitnum, &di, 0);
+ write_log(_T("using drive %s (unit %d, media %d)\n"), di.label, unitnum, di.media_inserted);
/* make sure CD audio is not playing */
- cdaudiostop_do ();
+ cdaudiostop_do();
return 0;
}
/* close device */
-static void sys_cddev_close (void)
+static void sys_cddev_close(void)
{
if (unitnum >= 0) {
- cdaudiostop_do ();
- sys_command_close (unitnum);
+ cdaudiostop_do();
+ sys_command_close(unitnum);
}
unitnum = -1;
}
-static bool cdrom_can_return_data(void)
+static int command_lengths[] = { 1, 2, 1, 1, 12, 2, 1, 1, 4, 1, 2, -1, -1, -1, -1, -1 };
+
+static int cdrom_start_return_data(int len)
{
if (cdrom_receive_length > 0)
- return false;
- return true;
-}
-
-static int cdrom_start_return_data (int len)
-{
- if (!cdrom_can_return_data())
return 0;
if (len <= 0)
return -1;
cdrom_receive_length = len;
- uae_u8 checksum = 0xff;
- for (int i = 0; i < cdrom_receive_length; i++) {
- checksum -= cdrom_result_buffer[i];
- }
- cdrom_result_buffer[cdrom_receive_length++] = checksum;
- cdrom_receive_offset = 0;
- set_status(CDINTERRUPT_DRIVERECV);
+ cdrom_receive_offset = -1;
return 1;
}
@@ -616,9 +800,11 @@ static int cdrom_start_return_data (int len)
more data available) when cdcomrxinx matches cdcomrxcmp
*/
-static void cdrom_return_data (void)
+static void cdrom_return_data(void)
{
uae_u32 cmd_buf = cdrx_address;
+ int i;
+ uae_u8 checksum;
if (!cdrom_receive_length)
return;
@@ -626,35 +812,54 @@ static void cdrom_return_data (void)
return;
if (cdcomrxinx == cdcomrxcmp)
return;
- if (cdrom_rx_dma_delay > 0)
- return;
- while (cdrom_receive_offset < cdrom_receive_length) {
- cdrom_last_rx = cdrom_result_buffer[cdrom_receive_offset];
- put_byte (cmd_buf + cdcomrxinx, cdrom_last_rx);
+#if AKIKO_DEBUG_IO
+ write_log(_T("OUT IDX=0x%02X-0x%02X LEN=%d,%08x:"), cdcomrxinx, cdcomrxcmp, cdrom_receive_length, cmd_buf);
+#endif
+
+ if (cdrom_receive_offset < 0) {
+ checksum = 0xff;
+ for (i = 0; i < cdrom_receive_length; i++) {
+ checksum -= cdrom_result_buffer[i];
+#if AKIKO_DEBUG_IO
+ write_log(_T("%02X "), cdrom_result_buffer[i]);
+#endif
+ }
+#if AKIKO_DEBUG_IO
+ write_log(_T("(%02X)\n"), checksum);
+#endif
+ cdrom_result_buffer[cdrom_receive_length++] = checksum;
+ cdrom_receive_offset = 0;
+ }
+ else {
+#if AKIKO_DEBUG_IO
+ write_log(_T("\n"));
+#endif
+ }
+ while (cdrom_receive_offset < cdrom_receive_length && cdcomrxinx != cdcomrxcmp) {
+ put_byte(cmd_buf + cdcomrxinx, cdrom_result_buffer[cdrom_receive_offset]);
cdcomrxinx++;
cdrom_receive_offset++;
- if (cdcomrxinx == cdcomrxcmp) {
- set_status(CDINTERRUPT_RXDMADONE);
- break;
- }
}
- if (cdrom_receive_offset == cdrom_receive_length) {
+ if (cdcomrxinx == cdcomrxcmp) {
+ set_status(CDINTERRUPT_RXDMADONE);
+#if AKIKO_DEBUG_IO
+ write_log(_T("RXDMADONE %d/%d\n"), cdrom_receive_offset, cdrom_receive_length);
+#endif
+ }
+
+ if (cdrom_receive_offset == cdrom_receive_length)
cdrom_receive_length = 0;
- cdrom_receive_offset = 0;
- cdrom_intreq &= ~CDINTERRUPT_DRIVERECV;
- set_status(CDINTERRUPT_DRIVEXMIT);
- }
}
-static int cdrom_command_led (void)
+static int cdrom_command_led(void)
{
int v = cdrom_command_buffer[1];
int old = cdrom_led;
cdrom_led &= ~LED_CD_ACTIVE;
cdrom_led |= (v & 1) ? LED_CD_ACTIVE : 0;
if (cdrom_led != old)
- gui_flicker_led (LED_CD, 0, cdrom_led);
+ gui_flicker_led(LED_CD, 0, cdrom_led);
if (v & 0x80) { // result wanted?
cdrom_result_buffer[0] = cdrom_command;
cdrom_result_buffer[1] = (cdrom_led & LED_CD_ACTIVE) ? 1 : 0;
@@ -663,116 +868,122 @@ static int cdrom_command_led (void)
return 0;
}
-static int cdrom_command_idle_status (void)
+static int cdrom_command_idle_status(void)
{
cdrom_result_buffer[0] = 0x0a;
cdrom_result_buffer[1] = 0x70;
return 2;
}
-static int cdrom_command_media_status (void)
+static int cdrom_command_media_status(void)
{
cdrom_result_buffer[0] = 0x0a;
- cdrom_result_buffer[1] = sys_command_ismedia (unitnum, 0) > 0 ? 0x01: 0x00;
+ cdrom_result_buffer[1] = sys_command_ismedia(unitnum, 0) > 0 ? 0x83 : 0x80;
return 2;
}
/* check if cd drive door is open or closed, return firmware info */
-static int cdrom_command_status (void)
+static int cdrom_command_status(void)
{
- cdrom_result_buffer[1] = cdrom_door;
+ cdrom_result_buffer[1] = 0x01;
+ //cdrom_result_buffer[1] = 0x80; door open
if (unitnum >= 0)
- get_cdrom_toc ();
+ get_cdrom_toc();
/* firmware info */
- memcpy (cdrom_result_buffer + 2, FIRMWAREVERSION, sizeof FIRMWAREVERSION);
+ memcpy(cdrom_result_buffer + 2, FIRMWAREVERSION, sizeof FIRMWAREVERSION);
cdrom_result_buffer[0] = cdrom_command;
- cd_initialized = 2;
+ cd_initialized = 1;
return 20;
}
/* return one TOC entry, each TOC entry repeats 3 times */
#define TOC_REPEAT 3
-static int cdrom_return_toc_entry (void)
+static int cdrom_return_toc_entry(void)
{
cdrom_result_buffer[0] = 6;
+#if AKIKO_DEBUG_IO_CMD
+ write_log(_T("CD32: TOC entry %d/%d\n"), cdrom_toc_counter / TOC_REPEAT, cdrom_toc_cd_buffer.points);
+#endif
if (cdrom_toc_cd_buffer.points == 0) {
- cdrom_result_buffer[1] = CDS_ERROR | cdrom_door;
+ cdrom_result_buffer[1] = CDS_ERROR;
return 15;
}
- cdrom_result_buffer[1] = 0x0a; // unknown but real CD32 sets it
- memcpy (cdrom_result_buffer + 2, cdrom_toc_buffer + (cdrom_toc_counter / TOC_REPEAT) * 13, 13);
- cdrom_result_buffer[6] = tobcd(99);
- cdrom_result_buffer[7] = tobcd(24 + cdrom_toc_counter / 75);
- cdrom_result_buffer[8] = tobcd(cdrom_toc_counter % 75);
+ cdrom_result_buffer[1] = 0;
+ memcpy(cdrom_result_buffer + 2, cdrom_toc_buffer + (cdrom_toc_counter / TOC_REPEAT) * 13, 13);
cdrom_toc_counter++;
if (cdrom_toc_counter / TOC_REPEAT >= cdrom_toc_cd_buffer.points)
cdrom_toc_counter = -1;
return 15;
}
-static int checkerr (void)
+static int checkerr(void)
{
if (!cdrom_disk) {
- cdrom_result_buffer[1] = CH_ERR_NODISK | cdrom_door;
+ cdrom_result_buffer[1] = CH_ERR_NODISK;
return 1;
}
return 0;
}
-static int cdrom_command_stop (void)
+static int cdrom_command_stop(void)
{
cdrom_audiotimeout = 0;
cdrom_result_buffer[0] = cdrom_command;
- if (checkerr ())
+ if (checkerr())
return 2;
cdrom_result_buffer[1] = 0;
- cdaudiostop ();
+ cdaudiostop();
return 2;
}
/* pause CD audio */
-static int cdrom_command_pause (void)
+static int cdrom_command_pause(void)
{
+#if AKIKO_DEBUG_IO_CMD
+ write_log(_T("CD32: pause: %d, %d\n"), cdrom_paused, cdrom_playing);
+#endif
cdrom_audiotimeout = 0;
cdrom_toc_counter = -1;
cdrom_result_buffer[0] = cdrom_command;
- if (checkerr ())
+ if (checkerr())
return 2;
- cdrom_result_buffer[1] = (cdrom_playing ? CDS_PLAYING : 0) | cdrom_door;
+ cdrom_result_buffer[1] = cdrom_playing ? CDS_PLAYING : 0;
if (cdrom_paused)
return 2;
cdrom_paused = 1;
if (!cdrom_playing)
return 2;
- write_comm_pipe_u32 (&requests, 0x0102, 1);
+ write_comm_pipe_u32(&requests, 0x0102, 1);
return 2;
}
/* unpause CD audio */
-static int cdrom_command_unpause (void)
+static int cdrom_command_unpause(void)
{
+#if AKIKO_DEBUG_IO_CMD
+ write_log(_T("CD32: unpause: %d, %d\n"), cdrom_paused, cdrom_playing);
+#endif
cdrom_result_buffer[0] = cdrom_command;
- if (checkerr ())
+ if (checkerr())
return 2;
- cdrom_result_buffer[1] = (cdrom_playing ? CDS_PLAYING : 0) | cdrom_door;
+ cdrom_result_buffer[1] = cdrom_playing ? CDS_PLAYING : 0;
if (!cdrom_paused)
return 2;
cdrom_paused = 0;
if (!cdrom_playing)
return 2;
- write_comm_pipe_u32 (&requests, 0x0103, 1);
+ write_comm_pipe_u32(&requests, 0x0103, 1);
return 2;
}
/* seek head/play CD audio/read data sectors */
-static int cdrom_command_multi (void)
+static int cdrom_command_multi(void)
{
- int seekpos = msf2lsn (fromlongbcd (cdrom_command_buffer + 1));
- int endpos = msf2lsn (fromlongbcd (cdrom_command_buffer + 4));
+ int seekpos = msf2lsn(fromlongbcd(cdrom_command_buffer + 1));
+ int endpos = msf2lsn(fromlongbcd(cdrom_command_buffer + 4));
if (cdrom_playing)
- cdaudiostop ();
- cdrom_paused = 0;
+ cdaudiostop();
cdrom_speed = (cdrom_command_buffer[8] & 0x40) ? 2 : 1;
cdrom_result_buffer[0] = cdrom_command;
cdrom_result_buffer[1] = 0;
@@ -781,90 +992,86 @@ static int cdrom_command_multi (void)
return 2;
}
- if (cdrom_command_buffer[7] & 0x80) { /* data read */
+ if (cdrom_command_buffer[7] == 0x80) { /* data read */
+#if AKIKO_DEBUG_IO_CMD
+ int cdrom_data_offset_end = endpos;
+#endif
cdrom_data_offset = seekpos;
- cdrom_seek_delay = abs (cdrom_current_sector - cdrom_data_offset);
- if (cdrom_seek_delay < 100 || currprefs.cd_speed == 0) {
+ cdrom_seek_delay = abs(cdrom_current_sector - cdrom_data_offset);
+ if (cdrom_seek_delay < 100) {
cdrom_seek_delay = 1;
- } else {
+ }
+ else {
cdrom_seek_delay /= 1000;
cdrom_seek_delay += 10;
if (cdrom_seek_delay > 100)
cdrom_seek_delay = 100;
}
+#if AKIKO_DEBUG_IO_CMD
+ write_log(_T("READ DATA %06X (%d) - %06X (%d) SPD=%dx PC=%08X\n"),
+ seekpos,
+ cdrom_data_offset,
+ endpos,
+ cdrom_data_offset_end,
+ cdrom_speed,
+ M68K_GETPC);
+#endif
cdrom_result_buffer[1] |= 0x02;
- } else { /* play audio */
- // offset 10, bit 2 set: don't send subchannel data
- if (seekpos < 0) {
- cdrom_toc_counter = 0;
- } else {
- cdrom_toc_counter = -1;
- cdrom_result_buffer[1] = 0x42; // play command starting?
- cdrom_playing = 1;
- if (!cd_play_audio (seekpos, endpos, 0)) {
- // play didn't start, report it in next status packet
- cdrom_audiotimeout = -3;
- }
+ }
+ else if (cdrom_command_buffer[10] & 4) { /* play audio */
+#if AKIKO_DEBUG_IO_CMD
+ int scan = 0;
+ if (cdrom_command_buffer[7] & 0x04)
+ scan = 1;
+ else if (cdrom_command_buffer[7] & 0x08)
+ scan = -1;
+ write_log(_T("PLAY FROM %06X (%d) to %06X (%d) SCAN=%d\n"),
+ seekpos,
+ msf2lsn(seekpos),
+ endpos,
+ msf2lsn(endpos),
+ scan);
+#endif
+ //cdrom_result_buffer[1] |= CDS_PLAYING;
+ cdrom_playing = 1;
+ if (!cd_play_audio(seekpos, endpos, 0)) {
+ // play didn't start, report it in next status packet
+ cdrom_audiotimeout = -3;
}
}
+ else {
+#if AKIKO_DEBUG_IO_CMD
+ write_log(_T("SEEKTO %06X\n"), seekpos);
+#endif
+ if (seekpos < 150)
+ cdrom_toc_counter = 0;
+ else
+ cdrom_toc_counter = -1;
+ }
return 2;
}
-static int cdrom_playend_notify (int status)
+static int cdrom_playend_notify(int status)
{
cdrom_result_buffer[0] = 4;
if (status < 0)
- cdrom_result_buffer[1] = CDS_ERROR; // error
+ cdrom_result_buffer[1] = 0x80; // error
else if (status == 0)
- cdrom_result_buffer[1] = CDS_PLAYING | 2; // play started
+ cdrom_result_buffer[1] = 0x08; // play started
else
- cdrom_result_buffer[1] = CDS_PLAYEND; // play ended
- cdrom_result_buffer[1] |= cdrom_door;
+ cdrom_result_buffer[1] = 0x00; // play ended
return 2;
}
/* return subq entry */
-static int cdrom_command_subq (void)
+static int cdrom_command_subq(void)
{
cdrom_result_buffer[0] = cdrom_command;
cdrom_result_buffer[1] = 0;
- cd_qcode (cdrom_result_buffer + 2);
+ cd_qcode(cdrom_result_buffer + 2);
return 15;
}
-static const int command_lengths[] = { 1, 2, 1, 1, 12, 2, 1, 1, 4, 1, 2, -1, -1, -1, -1, -1 };
-
-static bool cdrom_add_command_byte(uae_u8 b)
-{
- cdrom_command_buffer[cdrom_command_length++] = b;
- cdrom_command = cdrom_command_buffer[0];
- int cmd_len = command_lengths[cdrom_command & 0x0f];
-
- cdrom_checksum_error = 0;
- cdrom_unknown_command = 0;
-
- if (cmd_len < 0) {
- cdrom_unknown_command = 1;
- cdrom_command_active = 1;
- return true;
- }
-
- if (cmd_len + 1 > cdrom_command_length)
- return false;
-
- uae_u8 checksum = 0;
-
- for (int i = 0; i < cmd_len + 1; i++) {
- checksum += cdrom_command_buffer[i];
- }
- if (checksum != 0xff) {
- cdrom_checksum_error = 1;
- }
- cdrom_command_active = 1;
- cdrom_command_length = cmd_len;
- return true;
-}
-
/*
TX DMA reads bytes from memory and sends them to
CDROM hardware if TX DMA enabled, CDROM data transfer
@@ -873,56 +1080,93 @@ static bool cdrom_add_command_byte(uae_u8 b)
CDINTERRUPT_TXDMADONE triggered when cdromtxinx matches cdcomtx.
*/
-static bool can_send_command(void)
+static void cdrom_run_command(void)
{
- if (!cd_initialized)
- return false;
- if (cdrom_command_active)
- return false;
- if (cdrom_receive_length)
- return false;
- return true;
-}
+ int i, cmd_len;
+ uae_u8 checksum;
+#if 0
+ uae_u8 *pp = get_real_address(cdtx_address);
+#endif
-static void cdrom_run_command (void)
-{
if (!(cdrom_flags & CDFLAG_TXD))
return;
- if (cdrom_flags & CDFLAG_ENABLE)
+ if ((cdrom_flags & CDFLAG_ENABLE))
+ return;
+ if (cdrom_command_active)
+ return;
+ if (cdrom_receive_length)
return;
if (cdcomtxinx == cdcomtxcmp)
return;
if (cdrom_tx_dma_delay > 0)
return;
- if (!can_send_command())
+
+ cdrom_command = get_byte(cdtx_address + cdcomtxinx);
+
+ if (cdrom_command == 0) {
+ cdcomtxinx++;
return;
-
- uae_u8 b = get_byte(cdtx_address + cdcomtxinx);
- cdrom_add_command_byte(b);
- cdcomtxinx++;
-
- if (cdcomtxinx == cdcomtxcmp) {
- set_status(CDINTERRUPT_TXDMADONE);
}
+
+ cdrom_checksum_error = 0;
+ cdrom_unknown_command = 0;
+
+ cmd_len = command_lengths[cdrom_command & 0x0f];
+ if (cmd_len < 0) {
+#if AKIKO_DEBUG_IO_CMD
+ write_log(_T("unknown command %x\n"), cdrom_command & 0x0f);
+#endif
+ cdrom_unknown_command = 1;
+ cdrom_command_active = 1;
+ cdrom_command_length = 1;
+ set_status(CDINTERRUPT_TXDMADONE);
+ return;
+ }
+
+#if AKIKO_DEBUG_IO_CMD
+ write_log(_T("IN CMD=%02X IDX=0x%02X-0x%02X LEN=%d:"), cdrom_command & 0x0f, cdcomtxinx, cdcomtxcmp, cmd_len);
+#endif
+ checksum = 0;
+ for (i = 0; i < cmd_len + 1; i++) {
+ cdrom_command_buffer[i] = get_byte(cdtx_address + ((cdcomtxinx + i) & 0xff));
+ checksum += cdrom_command_buffer[i];
+#if AKIKO_DEBUG_IO_CMD
+ if (i == cmd_len)
+ write_log(_T("(%02X) "), cdrom_command_buffer[i]); // checksum
+ else
+ write_log(_T("%02X "), cdrom_command_buffer[i]);
+#endif
+ }
+ if (checksum != 0xff) {
+#if AKIKO_DEBUG_IO_CMD
+ write_log(_T(" checksum error"));
+#endif
+ cdrom_checksum_error = 1;
+ //activate_debugger ();
+ }
+#if AKIKO_DEBUG_IO_CMD
+ write_log(_T("\n"));
+#endif
+ cdrom_command_active = 1;
+ cdrom_command_length = cmd_len;
+ set_status(CDINTERRUPT_TXDMADONE);
}
-static void cdrom_run_command_run (void)
+static void cdrom_run_command_run(void)
{
int len;
- cdrom_command_length = 0;
- cdrom_command_active = 0;
-
- memset (cdrom_result_buffer, 0, sizeof (cdrom_result_buffer));
+ cdcomtxinx = cdcomtxinx + cdrom_command_length + 1;
+ memset(cdrom_result_buffer, 0, sizeof(cdrom_result_buffer));
if (cdrom_checksum_error || cdrom_unknown_command) {
cdrom_result_buffer[0] = (cdrom_command & 0xf0) | 5;
if (cdrom_checksum_error)
- cdrom_result_buffer[1] |= CH_ERR_CHECKSUM | cdrom_door;
+ cdrom_result_buffer[1] |= CH_ERR_CHECKSUM;
else if (cdrom_unknown_command)
- cdrom_result_buffer[1] |= CH_ERR_BADCOMMAND | cdrom_door;
+ cdrom_result_buffer[1] |= CH_ERR_BADCOMMAND;
len = 2;
- cdrom_start_return_data (len);
+ cdrom_start_return_data(len);
return;
}
@@ -933,39 +1177,37 @@ static void cdrom_run_command_run (void)
cdrom_result_buffer[0] = cdrom_command;
break;
case 1:
- len = cdrom_command_stop ();
+ len = cdrom_command_stop();
break;
case 2:
- len = cdrom_command_pause ();
+ len = cdrom_command_pause();
break;
case 3:
- len = cdrom_command_unpause ();
+ len = cdrom_command_unpause();
break;
case 4:
- len = cdrom_command_multi ();
+ len = cdrom_command_multi();
break;
case 5:
- len = cdrom_command_led ();
+ len = cdrom_command_led();
break;
case 6:
- len = cdrom_command_subq ();
+ len = cdrom_command_subq();
break;
case 7:
- len = cdrom_command_status ();
+ len = cdrom_command_status();
break;
default:
len = 0;
break;
}
- if (len == 0) {
- set_status(CDINTERRUPT_DRIVEXMIT);
+ if (len == 0)
return;
- }
- cdrom_start_return_data (len);
+ cdrom_start_return_data(len);
}
/* DMA transfer one CD sector */
-static void cdrom_run_read (void)
+static void cdrom_run_read(void)
{
int i, sector, inc;
int sec;
@@ -973,8 +1215,10 @@ static void cdrom_run_read (void)
if (!(cdrom_flags & CDFLAG_ENABLE))
return;
- if (!cdrom_pbx)
+ if (!cdrom_pbx) {
+ set_status(CDINTERRUPT_OVERFLOW);
return;
+ }
if (!(cdrom_flags & CDFLAG_PBX))
return;
if (cdrom_data_offset < 0)
@@ -994,44 +1238,35 @@ static void cdrom_run_read (void)
if (sector_buffer_info_1[sec] != 0xff && sector_buffer_info_1[sec] != 0) {
uae_u8 buf[2352];
- memcpy (buf, sector_buffer_1 + sec * 2352, 2352);
+ memcpy(buf, sector_buffer_1 + sec * 2352, 2352);
buf[0] = 0;
buf[1] = 0;
buf[2] = 0;
buf[3] = cdrom_sector_counter & 31;
for (i = 0; i < 2352; i++)
- put_byte (cdrom_addressdata + seccnt * 4096 + i, buf[i]);
+ put_byte(cdrom_addressdata + seccnt * 4096 + i, buf[i]);
for (i = 0; i < 73 * 2; i++)
- put_byte (cdrom_addressdata + seccnt * 4096 + 0xc00 + i, 0);
+ put_byte(cdrom_addressdata + seccnt * 4096 + 0xc00 + i, 0);
cdrom_pbx &= ~(1 << seccnt);
- set_status (CDINTERRUPT_PBX);
-
- if ((cdrom_flags & CDFLAG_RAW) || !(cdrom_flags & CDFLAG_CAS))
- write_log(_T("CD32: Akiko warning: Flags = %08x!\n"), cdrom_flags);
-
- if (cdrom_flags & CDFLAG_SUBCODE) {
- uae_u8 subbuf[SUB_CHANNEL_SIZE] = { 0 };
- uae_u8 subbuf2[SUB_CHANNEL_SIZE];
- if (sys_command_cd_qcode(unitnum, subbuf2, sector, true))
- sub_to_interleaved(subbuf2, subbuf);
- if (cdrom_subcodeoffset >= 128)
- cdrom_subcodeoffset = 0;
- else
- cdrom_subcodeoffset = 128;
- // 96 byte subchannel data
- for (int i = 0; i < SUB_CHANNEL_SIZE; i++)
- put_byte(subcode_address + cdrom_subcodeoffset + i, subbuf[i]);
- put_long(subcode_address + cdrom_subcodeoffset + SUB_CHANNEL_SIZE, 0xffff0000);
- cdrom_subcodeoffset += 100;
- set_status(CDINTERRUPT_SUBCODE);
- }
-
- } else {
+ set_status(CDINTERRUPT_PBX);
+ }
+ else {
inc = 0;
}
if (sector_buffer_info_1[sec] != 0xff)
sector_buffer_info_1[sec]--;
- } else {
+#if AKIKO_DEBUG_IO_CMD
+ write_log(_T("pbx=%04x sec=%d, scnt=%d -> %d. %d (%04x) %08X\n"),
+ cdrom_pbx,
+ cdrom_data_offset,
+ cdrom_sector_counter,
+ sector,
+ seccnt,
+ 1 << seccnt,
+ cdrom_addressdata + seccnt * 4096);
+#endif
+ }
+ else {
inc = 0;
}
if (inc)
@@ -1040,86 +1275,73 @@ static void cdrom_run_read (void)
static int lastmediastate = 0;
-static void akiko_handler (bool framesync)
+static void akiko_handler(bool framesync)
{
if (unitnum < 0)
return;
-
- if (cdrom_receive_length)
- return;
-
- if (!cd_initialized) {
- // first status is always 0x0a if booted with CD inserted
- if (sys_command_ismedia(unitnum, 0) > 0)
- cdrom_start_return_data(cdrom_command_media_status());
- cd_initialized = 1;
- return;
- }
-
- if (cd_initialized < 2)
+ if (!cd_initialized || cdrom_receive_length)
return;
if (mediachanged) {
- if (cdrom_can_return_data()) {
- cdrom_start_return_data (cdrom_command_media_status ());
+ if (cdrom_start_return_data(0) < 0) {
+ cdrom_start_return_data(cdrom_command_media_status());
mediachanged = 0;
- get_cdrom_toc ();
+ get_cdrom_toc();
/* do not remove! first try may fail */
- get_cdrom_toc ();
+ get_cdrom_toc();
}
return;
}
if (cdrom_audiotimeout > 1)
cdrom_audiotimeout--;
- if (cdrom_audiotimeout == 1 && cdrom_can_return_data()) { // play start
- if (!cdrom_playing)
- cdrom_playing = 1;
- if (cdrom_playing == 1)
- cdrom_start_return_data (cdrom_playend_notify (0));
- cdrom_playing = 2;
+ if (cdrom_audiotimeout == 1) { // play start
+ cdrom_playing = 1;
+ //cdrom_start_return_data (cdrom_playend_notify (0));
cdrom_audiotimeout = 0;
}
if (cdrom_audiotimeout == -1) { // play finished (or disk end)
if (cdrom_playing) {
- cdaudiostop ();
+ cdaudiostop();
cdrom_audiotimeout = -2;
- } else {
+ }
+ else {
cdrom_audiotimeout = 0;
}
}
- if (cdrom_audiotimeout == -2 && cdrom_can_return_data()) { // play end notification
- cdrom_start_return_data (cdrom_playend_notify (1));
+ if (cdrom_audiotimeout == -2) { // play end notification
+ cdrom_start_return_data(cdrom_playend_notify(1));
cdrom_audiotimeout = 0;
}
// play didn't start notification (illegal address)
- if (cdrom_audiotimeout == -3 && cdrom_can_return_data()) { // return error status
- cdrom_start_return_data (cdrom_playend_notify (-1));
+ if (cdrom_audiotimeout == -3) { // return error status
+ cdrom_start_return_data(cdrom_playend_notify(-1));
cdrom_audiotimeout = 0;
}
/* one toc entry / frame */
- if (cdrom_toc_counter >= 0 && !cdrom_command_active && framesync && cdrom_can_return_data()) {
- cdrom_start_return_data (cdrom_return_toc_entry ());
+ if (cdrom_toc_counter >= 0 && !cdrom_command_active && framesync) {
+ if (cdrom_start_return_data(-1)) {
+ cdrom_start_return_data(cdrom_return_toc_entry());
+ }
}
}
-static void akiko_internal (void)
+static void akiko_internal(void)
{
if (!currprefs.cs_cd32cd)
return;
- cdrom_return_data ();
- cdrom_run_command ();
+ cdrom_return_data();
+ cdrom_run_command();
if (cdrom_command_active > 0) {
cdrom_command_active--;
if (!cdrom_command_active)
- cdrom_run_command_run ();
+ cdrom_run_command_run();
}
}
-void AKIKO_hsync_handler (void)
+void AKIKO_hsync_handler(void)
{
bool framesync = false;
-
if (!currprefs.cs_cd32cd || !akiko_inited)
return;
@@ -1127,25 +1349,22 @@ void AKIKO_hsync_handler (void)
framecounter--;
if (framecounter <= 0) {
if (cdrom_seek_delay <= 0) {
- cdrom_run_read ();
- } else {
+ cdrom_run_read();
+ }
+ else {
cdrom_seek_delay--;
}
framecounter += (float)maxvpos * vblank_hz / (75.0 * cdrom_speed);
- if (currprefs.cd_speed == 0)
- framecounter = 1;
framesync = true;
}
if (cdrom_tx_dma_delay > 0)
cdrom_tx_dma_delay--;
- if (cdrom_rx_dma_delay > 0)
- cdrom_rx_dma_delay--;
subcodecounter--;
if (subcodecounter <= 0) {
if ((cdrom_flags & CDFLAG_SUBCODE) && cdrom_playing && subcodebufferoffset != subcodebufferoffsetw) {
- uae_sem_wait (&sub_sem);
+ uae_sem_wait(&sub_sem);
if (subcodebufferinuse[subcodebufferoffset]) {
if (cdrom_subcodeoffset >= 128)
cdrom_subcodeoffset = 0;
@@ -1153,17 +1372,17 @@ void AKIKO_hsync_handler (void)
cdrom_subcodeoffset = 128;
// 96 byte subchannel data
for (int i = 0; i < SUB_CHANNEL_SIZE; i++)
- put_byte (subcode_address + cdrom_subcodeoffset + i, subcodebuffer[subcodebufferoffset * SUB_CHANNEL_SIZE + i]);
- put_long (subcode_address + cdrom_subcodeoffset + SUB_CHANNEL_SIZE, 0xffff0000);
+ put_byte(subcode_address + cdrom_subcodeoffset + i, subcodebuffer[subcodebufferoffset * SUB_CHANNEL_SIZE + i]);
+ put_long(subcode_address + cdrom_subcodeoffset + SUB_CHANNEL_SIZE, 0xffffffff);
subcodebufferinuse[subcodebufferoffset] = 0;
cdrom_subcodeoffset += 100;
subcodebufferoffset++;
if (subcodebufferoffset >= MAX_SUBCODEBUFFER)
subcodebufferoffset -= MAX_SUBCODEBUFFER;
- set_status (CDINTERRUPT_SUBCODE);
+ set_status(CDINTERRUPT_SUBCODE);
//write_log (_T("*"));
}
- uae_sem_post (&sub_sem);
+ uae_sem_post(&sub_sem);
}
subcodecounter = maxvpos * vblank_hz / (75 * cdrom_speed) - 5;
}
@@ -1173,12 +1392,12 @@ void AKIKO_hsync_handler (void)
if (mediacheckcounter > 0)
mediacheckcounter--;
- akiko_internal ();
- akiko_handler (framesync);
+ akiko_internal();
+ akiko_handler(framesync);
}
/* cdrom data buffering thread */
-static void *akiko_thread (void *null)
+static void *akiko_thread(void *null)
{
int i;
uae_u8 *tmp1;
@@ -1186,149 +1405,144 @@ static void *akiko_thread (void *null)
int tmp3;
int sector;
- while (akiko_thread_running || comm_pipe_has_data (&requests)) {
+ while (akiko_thread_running || comm_pipe_has_data(&requests)) {
- if (comm_pipe_has_data (&requests)) {
- uae_u32 b = read_comm_pipe_u32_blocking (&requests);
+ if (comm_pipe_has_data(&requests)) {
+ uae_u32 b = read_comm_pipe_u32_blocking(&requests);
switch (b)
{
case 0x0102: // pause
- sys_command_cd_pause (unitnum, 1);
+ sys_command_cd_pause(unitnum, 1);
break;
case 0x0103: // unpause
- sys_command_cd_pause (unitnum, 0);
+ sys_command_cd_pause(unitnum, 0);
break;
case 0x0104: // stop
- cdaudiostop_do ();
+ cdaudiostop_do();
break;
case 0x0105: // mute change
- sys_command_cd_volume (unitnum, cdrom_muted ? 0 : 0x7fff, cdrom_muted ? 0 : 0x7fff);
+ sys_command_cd_volume(unitnum, cdrom_muted ? 0 : 0x7fff, cdrom_muted ? 0 : 0x7fff);
break;
case 0x0110: // do_play!
- sys_command_cd_volume (unitnum, cdrom_muted ? 0 : 0x7fff, cdrom_muted ? 0 : 0x7fff);
- cdaudioplay_do ();
+ sys_command_cd_volume(unitnum, cdrom_muted ? 0 : 0x7fff, cdrom_muted ? 0 : 0x7fff);
+ cdaudioplay_do();
break;
}
}
if (frame2counter <= 0) {
frame2counter = 312 * 50 / 2;
- if (unitnum >= 0 && sys_command_cd_qcode (unitnum, qcode_buf, -1, false)) {
+ if (unitnum >= 0 && sys_command_cd_qcode(unitnum, qcode_buf)) {
qcode_valid = 1;
}
}
if (mediacheckcounter <= 0) {
mediacheckcounter = 312 * 50 * 2;
- int media = sys_command_ismedia (unitnum, 1);
+ int media = sys_command_ismedia(unitnum, 1);
if (media < 0) {
- write_log (_T("CD32: device unit %d lost\n"), unitnum);
+ write_log(_T("CD32: device unit %d lost\n"), unitnum);
media = lastmediastate = cdrom_disk = 0;
mediachanged = 1;
- cdaudiostop_do ();
- } else if (media != lastmediastate) {
+ cdaudiostop_do();
+ }
+ else if (media != lastmediastate) {
if (!media && lastmediastate > 1) {
// ignore missing media if statefile restored with cd present
if (lastmediastate == 2)
- write_log (_T("CD32: CD missing but statefile was stored with CD inserted: faking media present\n"));
+ write_log(_T("CD32: CD missing but statefile was stored with CD inserted: faking media present\n"));
lastmediastate = 3;
- } else {
- write_log (_T("CD32: media changed = %d\n"), media);
+ }
+ else {
+ write_log(_T("CD32: media changed = %d\n"), media);
lastmediastate = cdrom_disk = media;
mediachanged = 1;
- cdaudiostop_do ();
+ cdaudiostop_do();
}
}
}
- uae_sem_wait (&akiko_sem);
+ uae_sem_wait(&akiko_sem);
sector = cdrom_current_sector;
for (i = 0; i < SECTOR_BUFFER_SIZE; i++) {
if (sector_buffer_info_1[i] == 0xff)
break;
}
- if (sector >= 0 && is_valid_data_sector(sector) &&
+ if (cdrom_data_end > 0 && sector >= 0 &&
(sector_buffer_sector_1 < 0 || sector < sector_buffer_sector_1 || sector >= sector_buffer_sector_1 + SECTOR_BUFFER_SIZE * 2 / 3 || i != SECTOR_BUFFER_SIZE)) {
int blocks;
- memset (sector_buffer_info_2, 0, SECTOR_BUFFER_SIZE);
+ memset(sector_buffer_info_2, 0, SECTOR_BUFFER_SIZE);
+#if AKIKO_DEBUG_IO_CMD
+ write_log(_T("filling buffer sector=%d (max=%d)\n"), sector, cdrom_data_end);
+#endif
sector_buffer_sector_2 = sector;
- if (!is_valid_data_sector(sector + SECTOR_BUFFER_SIZE)) {
- for (blocks = SECTOR_BUFFER_SIZE; blocks > 0; blocks--) {
- if (is_valid_data_sector(sector + blocks))
- break;
- }
- } else {
+ if (sector + SECTOR_BUFFER_SIZE >= cdrom_data_end)
+ blocks = cdrom_data_end - sector;
+ else
blocks = SECTOR_BUFFER_SIZE;
- }
- if (blocks) {
- int ok = sys_command_cd_rawread (unitnum, sector_buffer_2, sector, blocks, 2352);
- if (!ok) {
- int offset = 0;
- while (offset < SECTOR_BUFFER_SIZE) {
- int ok = 0;
- if (is_valid_data_sector(sector))
- ok = sys_command_cd_rawread (unitnum, sector_buffer_2 + offset * 2352, sector, 1, 2352);
- sector_buffer_info_2[offset] = ok ? 3 : 0;
- offset++;
- sector++;
- }
- } else {
- for (int i = 0; i < SECTOR_BUFFER_SIZE; i++)
- sector_buffer_info_2[i] = i < blocks ? 3 : 0;
+ int ok = sys_command_cd_rawread(unitnum, sector_buffer_2, sector, blocks, 2352);
+ if (!ok) {
+ int offset = 0;
+ while (offset < SECTOR_BUFFER_SIZE) {
+ int ok = 0;
+ if (sector < cdrom_data_end)
+ ok = sys_command_cd_rawread(unitnum, sector_buffer_2 + offset * 2352, sector, 1, 2352);
+ sector_buffer_info_2[offset] = ok ? 3 : 0;
+ offset++;
+ sector++;
}
- tmp1 = sector_buffer_info_1;
- sector_buffer_info_1 = sector_buffer_info_2;
- sector_buffer_info_2 = tmp1;
- tmp2 = sector_buffer_1;
- sector_buffer_1 = sector_buffer_2;
- sector_buffer_2 = tmp2;
- tmp3 = sector_buffer_sector_1;
- sector_buffer_sector_1 = sector_buffer_sector_2;
- sector_buffer_sector_2 = tmp3;
}
+ else {
+ for (int i = 0; i < SECTOR_BUFFER_SIZE; i++)
+ sector_buffer_info_2[i] = i < blocks ? 3 : 0;
+ }
+ tmp1 = sector_buffer_info_1;
+ sector_buffer_info_1 = sector_buffer_info_2;
+ sector_buffer_info_2 = tmp1;
+ tmp2 = sector_buffer_1;
+ sector_buffer_1 = sector_buffer_2;
+ sector_buffer_2 = tmp2;
+ tmp3 = sector_buffer_sector_1;
+ sector_buffer_sector_1 = sector_buffer_sector_2;
+ sector_buffer_sector_2 = tmp3;
}
- uae_sem_post (&akiko_sem);
- sleep_millis (10);
+ uae_sem_post(&akiko_sem);
+ sleep_millis(10);
}
akiko_thread_running = -1;
return 0;
}
-STATIC_INLINE uae_u8 akiko_get_long (uae_u32 v, int offset)
+STATIC_INLINE uae_u8 akiko_get_long(uae_u32 v, int offset)
{
return v >> ((3 - offset) * 8);
}
-STATIC_INLINE void akiko_put_long (uae_u32 *p, int offset, int v)
+STATIC_INLINE void akiko_put_long(uae_u32 *p, int offset, int v)
{
*p &= ~(0xff << ((3 - offset) * 8));
*p |= v << ((3 - offset) * 8);
}
-static uae_u32 REGPARAM3 akiko_lget (uaecptr) REGPARAM;
-static uae_u32 REGPARAM3 akiko_wget (uaecptr) REGPARAM;
-static uae_u32 REGPARAM3 akiko_bget (uaecptr) REGPARAM;
-static uae_u32 REGPARAM3 akiko_lgeti (uaecptr) REGPARAM;
-static uae_u32 REGPARAM3 akiko_wgeti (uaecptr) REGPARAM;
-static void REGPARAM3 akiko_lput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 akiko_wput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 akiko_bput (uaecptr, uae_u32) REGPARAM;
+static uae_u32 REGPARAM3 akiko_lget(uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 akiko_wget(uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 akiko_bget(uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 akiko_lgeti(uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 akiko_wgeti(uaecptr) REGPARAM;
+static void REGPARAM3 akiko_lput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 akiko_wput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 akiko_bput(uaecptr, uae_u32) REGPARAM;
-static uae_u32 akiko_bget2 (uaecptr addr, int msg)
+static uae_u32 akiko_bget2(uaecptr addr, int msg)
{
uae_u8 v = 0;
- addr &= 0x3f;
+ addr &= 0xffff;
switch (addr)
{
- /* "C0CACAFE" = Akiko identification.
- * Kickstart Akiko C2P support requires $CAFE at $B80002.W
- * $B80000 $C0CA is not checked.
- */
- case 0x00:
- return 0xC0;
- case 0x01:
+ /* "CAFE" = Akiko identification.
+ * Kickstart ignores Akiko C2P if this ID isn't correct */
case 0x02:
return 0xCA;
case 0x03:
@@ -1339,30 +1553,30 @@ static uae_u32 akiko_bget2 (uaecptr addr, int msg)
case 0x32:
case 0x33:
if (currprefs.cs_cd32nvram)
- v = akiko_nvram_read (addr - 0x30);
+ v = akiko_nvram_read(addr - 0x30);
return v;
+
/* C2P */
case 0x38:
case 0x39:
case 0x3a:
case 0x3b:
if (currprefs.cs_cd32c2p)
- v = akiko_c2p_read (addr - 0x38);
+ v = akiko_c2p_read(addr - 0x38);
return v;
}
- if (!currprefs.cs_cd32cd)
- return v;
- uae_sem_wait (&akiko_sem);
+ uae_sem_wait(&akiko_sem);
switch (addr)
{
- /* CDROM control */
+ if (currprefs.cs_cd32cd) {
+ /* CDROM control */
case 0x04:
case 0x05:
case 0x06:
case 0x07:
- v = akiko_get_long (cdrom_intreq, addr - 0x04);
+ v = akiko_get_long(cdrom_intreq, addr - 0x04);
break;
case 0x08:
case 0x09:
@@ -1370,129 +1584,111 @@ static uae_u32 akiko_bget2 (uaecptr addr, int msg)
case 0x0b:
v = akiko_get_long(cdrom_intena, addr - 0x08);
break;
- case 0x0c:
- case 0x0d:
- case 0x0e:
- case 0x0f:
- // read only duplicate of intena
- v = akiko_get_long(cdrom_intena, addr - 0x0c);
- break;
-
- // 0x18-0x1b are mirrored to 0x10, 0x14 and 0x1c
- case 0x18:
case 0x10:
+ case 0x11:
+ case 0x12:
+ case 0x13:
+ v = akiko_get_long(cdrom_addressdata, addr - 0x10);
+ break;
case 0x14:
- case 0x1c:
+ case 0x15:
+ case 0x16:
+ case 0x17:
+ v = akiko_get_long(cdrom_addressmisc, addr - 0x14);
+ break;
+ case 0x18:
v = cdrom_subcodeoffset;
break;
case 0x19:
- case 0x11:
- case 0x15:
- case 0x1d:
v = cdcomtxinx;
break;
case 0x1a:
- case 0x12:
- case 0x16:
- case 0x1e:
v = cdcomrxinx;
break;
- case 0x1b:
-
- case 0x13:
- case 0x17:
case 0x1f:
- v = 0;
+ v = cdcomrxcmp;
break;
-
case 0x20:
case 0x21:
- v = akiko_get_long (cdrom_pbx, addr - 0x20 + 2);
+ v = akiko_get_long(cdrom_pbx, addr - 0x20 + 2);
break;
case 0x24:
case 0x25:
case 0x26:
case 0x27:
- v = akiko_get_long (cdrom_flags, addr - 0x24);
+ v = akiko_get_long(cdrom_flags, addr - 0x24);
break;
+ }
+ else if (addr < 0x30) {
+ break;
+ }
- case 0x28:
- if (!(cdrom_flags & CDFLAG_RXD) && cdrom_receive_offset < cdrom_receive_length) {
- cdrom_last_rx = cdrom_result_buffer[cdrom_receive_offset++];
- if (cdrom_receive_offset == cdrom_receive_length) {
- cdrom_intreq &= ~CDINTERRUPT_DRIVERECV;
- cdrom_receive_length = 0;
- set_status(CDINTERRUPT_DRIVEXMIT);
- }
- } else {
- cdrom_intreq &= ~CDINTERRUPT_DRIVERECV;
- }
- v = cdrom_last_rx;
- break;
-
- default:
- write_log (_T("akiko_bget: unknown address %08X PC=%08X\n"), addr, M68K_GETPC);
- v = 0;
- break;
+ default:
+ write_log(_T("akiko_bget: unknown address %08X PC=%08X\n"), addr, M68K_GETPC);
+ v = 0;
+ break;
}
- akiko_internal ();
- uae_sem_post (&akiko_sem);
+ akiko_internal();
+ uae_sem_post(&akiko_sem);
+ if (msg && addr < 0x30 && AKIKO_DEBUG_IO)
+ write_log(_T("akiko_bget %08X: %08X %02X\n"), M68K_GETPC, addr, v & 0xff);
return v;
}
-static void check_read_c2p(uaecptr addr)
+static uae_u32 REGPARAM2 akiko_bget(uaecptr addr)
{
- if (addr < 0x38 || addr >= 0x3c)
- return;
- akiko_read_offset++;
- akiko_read_offset &= 7;
+#ifdef JIT
+ special_mem |= S_READ;
+#endif
+ return akiko_bget2(addr, 1);
}
-static uae_u32 REGPARAM2 akiko_bget (uaecptr addr)
-{
- uae_u8 v;
- addr &= 0xffff;
- if (addr >= 0x8000)
- return 0;
- v = akiko_bget2 (addr, 1);
- check_read_c2p(addr);
- return v;
-}
-
-static uae_u32 REGPARAM2 akiko_wget (uaecptr addr)
+static uae_u32 REGPARAM2 akiko_wget(uaecptr addr)
{
uae_u16 v;
+#ifdef JIT
+ special_mem |= S_READ;
+#endif
addr &= 0xffff;
- if (addr >= 0x8000)
- return 0;
- v = akiko_bget2 (addr + 1, 0);
- v |= akiko_bget2 (addr + 0, 0) << 8;
- check_read_c2p(addr);
+ v = akiko_bget2(addr + 1, 0);
+ v |= akiko_bget2(addr + 0, 0) << 8;
+ if (addr < 0x30 && AKIKO_DEBUG_IO)
+ write_log(_T("akiko_wget %08X: %08X %04X\n"), M68K_GETPC, addr, v & 0xffff);
return v;
}
-static uae_u32 REGPARAM2 akiko_lget (uaecptr addr)
+static uae_u32 REGPARAM2 akiko_lget(uaecptr addr)
{
uae_u32 v;
+#ifdef JIT
+ special_mem |= S_READ;
+#endif
addr &= 0xffff;
- if (addr >= 0x8000)
- return 0;
- v = akiko_bget2 (addr + 3, 0);
- v |= akiko_bget2 (addr + 2, 0) << 8;
- v |= akiko_bget2 (addr + 1, 0) << 16;
- v |= akiko_bget2 (addr + 0, 0) << 24;
- check_read_c2p(addr);
+ v = akiko_bget2(addr + 3, 0);
+ v |= akiko_bget2(addr + 2, 0) << 8;
+ v |= akiko_bget2(addr + 1, 0) << 16;
+ v |= akiko_bget2(addr + 0, 0) << 24;
+ if (addr < 0x30 && (addr != 4 && addr != 8) && AKIKO_DEBUG_IO)
+ write_log(_T("akiko_lget %08X: %08X %08X\n"), M68K_GETPC, addr, v);
return v;
}
-static void akiko_bput2 (uaecptr addr, uae_u32 v, int msg)
+bool akiko_ntscmode(void)
+{
+ return (cdrom_flags & CDFLAG_NTSC) != 0;
+}
+
+static void akiko_bput2(uaecptr addr, uae_u32 v, int msg)
{
uae_u32 tmp;
- addr &= 0x3f;
+ addr &= 0xffff;
v &= 0xff;
+ if (msg && addr < 0x30 && AKIKO_DEBUG_IO)
+ write_log(_T("akiko_bput %08X: %08X=%02X\n"), M68K_GETPC, addr, v & 0xff);
+
switch (addr)
{
case 0x30:
@@ -1500,7 +1696,7 @@ static void akiko_bput2 (uaecptr addr, uae_u32 v, int msg)
case 0x32:
case 0x33:
if (currprefs.cs_cd32nvram)
- akiko_nvram_write (addr - 0x30, v);
+ akiko_nvram_write(addr - 0x30, v);
return;
case 0x38:
@@ -1508,136 +1704,129 @@ static void akiko_bput2 (uaecptr addr, uae_u32 v, int msg)
case 0x3a:
case 0x3b:
if (currprefs.cs_cd32c2p)
- akiko_c2p_write (addr - 0x38, v);
+ akiko_c2p_write(addr - 0x38, v);
return;
}
- if (!currprefs.cs_cd32cd)
- return;
-
- uae_sem_wait (&akiko_sem);
+ uae_sem_wait(&akiko_sem);
switch (addr)
{
- case 0x08:
- case 0x09:
- case 0x0a:
- case 0x0b:
- akiko_put_long (&cdrom_intena, addr - 0x08, v);
- cdrom_intena &= 0xff000000;
- break;
- case 0x10:
- case 0x11:
- case 0x12:
- case 0x13:
- akiko_put_long (&cdrom_addressdata, addr - 0x10, v);
- cdrom_addressdata &= 0x00fff000;
- break;
- case 0x14:
- case 0x15:
- case 0x16:
- case 0x17:
- akiko_put_long (&cdrom_addressmisc, addr - 0x14, v);
- cdrom_addressmisc &= 0x00fffc00;
- subcode_address = cdrom_addressmisc | 0x100;
- cdrx_address = cdrom_addressmisc;
- cdtx_address = cdrom_addressmisc | 0x200;
- break;
- case 0x18:
- cdrom_intreq &= ~CDINTERRUPT_SUBCODE;
- break;
- case 0x1d:
- cdrom_intreq &= ~CDINTERRUPT_TXDMADONE;
- cdcomtxcmp = v;
- cdrom_tx_dma_delay = 3;
- break;
- case 0x1f:
- cdrom_intreq &= ~CDINTERRUPT_RXDMADONE;
- cdcomrxcmp = v;
- cdrom_rx_dma_delay = 3;
- break;
- case 0x20:
- case 0x21:
- tmp = cdrom_pbx;
- akiko_put_long (&cdrom_pbx, addr - 0x20 + 2, v);
- cdrom_pbx |= tmp;
- cdrom_pbx &= 0xffff;
- // cdrom_pbx stays zeroed if disabled.
- if (!(cdrom_flags & CDFLAG_PBX))
- cdrom_pbx = 0x0000;
- cdrom_intreq &= ~CDINTERRUPT_PBX;
- break;
- case 0x24:
- case 0x25:
- case 0x26:
- case 0x27:
- tmp = cdrom_flags;
- akiko_put_long (&cdrom_flags, addr - 0x24, v);
- if ((cdrom_flags & CDFLAG_ENABLE) && !(tmp & CDFLAG_ENABLE)) {
- cdrom_sector_counter = 0;
- cdrom_intreq &= ~CDINTERRUPT_OVERFLOW;
- }
- if (!(cdrom_flags & CDFLAG_PBX)) {
- cdrom_pbx = 0x0000;
- }
- if ((cdrom_flags & CDFLAG_SUBCODE) && !(tmp & CDFLAG_SUBCODE)) {
- uae_sem_wait (&sub_sem);
- memset (subcodebufferinuse, 0, sizeof subcodebufferinuse);
- subcodebufferoffset = subcodebufferoffsetw = 0;
- uae_sem_post (&sub_sem);
- }
- cdrom_flags &= 0xff800000;
- break;
- case 0x28:
- if (!(cdrom_flags & CDFLAG_TXD)) {
- cdrom_intreq &= ~CDINTERRUPT_DRIVEXMIT;
- if (can_send_command()) {
- cdrom_add_command_byte(v);
- if (can_send_command()) {
- set_status(CDINTERRUPT_DRIVEXMIT);
- }
+ if (currprefs.cs_cd32cd) {
+ case 0x04:
+ case 0x05:
+ case 0x06:
+ case 0x07:
+ akiko_put_long(&cdrom_intreq, addr - 0x04, v);
+ break;
+ case 0x08:
+ case 0x09:
+ case 0x0a:
+ case 0x0b:
+ akiko_put_long(&cdrom_intena, addr - 0x08, v);
+ if (addr == 8)
+ cdrom_intreq &= cdrom_intena;
+ break;
+ case 0x10:
+ case 0x11:
+ case 0x12:
+ case 0x13:
+ akiko_put_long(&cdrom_addressdata, addr - 0x10, v);
+ cdrom_addressdata &= 0x00fff000;
+ break;
+ case 0x14:
+ case 0x15:
+ case 0x16:
+ case 0x17:
+ akiko_put_long(&cdrom_addressmisc, addr - 0x14, v);
+ cdrom_addressmisc &= 0x00fffc00;
+ subcode_address = cdrom_addressmisc | 0x100;
+ cdrx_address = cdrom_addressmisc;
+ cdtx_address = cdrom_addressmisc | 0x200;
+ break;
+ case 0x18:
+ cdrom_intreq &= ~CDINTERRUPT_SUBCODE;
+ break;
+ case 0x1d:
+ cdrom_intreq &= ~CDINTERRUPT_TXDMADONE;
+ cdcomtxcmp = v;
+ cdrom_tx_dma_delay = 5;
+ break;
+ case 0x1f:
+ cdrom_intreq &= ~CDINTERRUPT_RXDMADONE;
+ cdcomrxcmp = v;
+ break;
+ case 0x20:
+ case 0x21:
+ tmp = cdrom_pbx;
+ akiko_put_long(&cdrom_pbx, addr - 0x20 + 2, v);
+ cdrom_pbx |= tmp;
+ cdrom_pbx &= 0xffff;
+ cdrom_intreq &= ~CDINTERRUPT_PBX;
+ break;
+ case 0x24:
+ case 0x25:
+ case 0x26:
+ case 0x27:
+ tmp = cdrom_flags;
+ akiko_put_long(&cdrom_flags, addr - 0x24, v);
+ if ((cdrom_flags & CDFLAG_ENABLE) && !(tmp & CDFLAG_ENABLE))
+ cdrom_sector_counter = 0;
+ if (!(cdrom_flags & CDFLAG_PBX) && (tmp & CDFLAG_PBX))
+ cdrom_pbx = 0;
+ if ((cdrom_flags & CDFLAG_SUBCODE) && !(tmp & CDFLAG_SUBCODE)) {
+ uae_sem_wait(&sub_sem);
+ memset(subcodebufferinuse, 0, sizeof subcodebufferinuse);
+ subcodebufferoffset = subcodebufferoffsetw = 0;
+ uae_sem_post(&sub_sem);
}
+ break;
+ }
+ else if (addr < 0x30) {
+ break;
}
- break;
default:
- write_log (_T("akiko_bput: unknown address %08X=%02X PC=%08X\n"), addr, v & 0xff, M68K_GETPC);
+ write_log(_T("akiko_bput: unknown address %08X=%02X PC=%08X\n"), addr, v & 0xff, M68K_GETPC);
break;
}
- akiko_internal ();
- uae_sem_post (&akiko_sem);
+ akiko_internal();
+ uae_sem_post(&akiko_sem);
}
-bool akiko_ntscmode(void)
-{
- return (cdrom_flags & CDFLAG_NTSC) != 0;
-}
-
-static void REGPARAM2 akiko_bput (uaecptr addr, uae_u32 v)
+static void REGPARAM2 akiko_bput(uaecptr addr, uae_u32 v)
{
addr &= 0xffff;
if (addr >= 0x8000)
return;
- akiko_bput2 (addr, v, 1);
+ akiko_bput2(addr, v, 1);
}
-static void REGPARAM2 akiko_wput (uaecptr addr, uae_u32 v)
+static void REGPARAM2 akiko_wput(uaecptr addr, uae_u32 v)
{
addr &= 0xfff;
if (addr >= 0x8000)
return;
- akiko_bput2 (addr + 1, v & 0xff, 0);
- akiko_bput2 (addr + 0, v >> 8, 0);
+ if ((addr < 0x30 && AKIKO_DEBUG_IO)) {
+ //if (log_cd32 > 1)
+ // write_log(_T("akiko_wput %08X: %08X=%04X\n"), M68K_GETPC, addr, v & 0xffff);
+ }
+ akiko_bput2(addr + 1, v & 0xff, 0);
+ akiko_bput2(addr + 0, v >> 8, 0);
}
-static void REGPARAM2 akiko_lput (uaecptr addr, uae_u32 v)
+static void REGPARAM2 akiko_lput(uaecptr addr, uae_u32 v)
{
addr &= 0xffff;
if (addr >= 0x8000)
return;
- akiko_bput2 (addr + 3, (v >> 0) & 0xff, 0);
- akiko_bput2 (addr + 2, (v >> 8) & 0xff, 0);
- akiko_bput2 (addr + 1, (v >> 16) & 0xff, 0);
- akiko_bput2 (addr + 0, (v >> 24) & 0xff, 0);
+ if (addr < 0x30 && AKIKO_DEBUG_IO) {
+ //if (log_cd32 > 1)
+ // write_log(_T("akiko_lput %08X: %08X=%08X\n"), M68K_GETPC, addr, v);
+ }
+ akiko_bput2(addr + 3, (v >> 0) & 0xff, 0);
+ akiko_bput2(addr + 2, (v >> 8) & 0xff, 0);
+ akiko_bput2(addr + 1, (v >> 16) & 0xff, 0);
+ akiko_bput2(addr + 0, (v >> 24) & 0xff, 0);
}
addrbank akiko_bank = {
@@ -1648,48 +1837,48 @@ addrbank akiko_bank = {
ABFLAG_IO | ABFLAG_SAFE, S_READ, S_WRITE
};
-static const uae_u8 patchdata[]={0x0c,0x82,0x00,0x00,0x03,0xe8,0x64,0x00,0x00,0x46};
-static void patchrom (void)
+static const uae_u8 patchdata[] = { 0x0c, 0x82, 0x00, 0x00, 0x03, 0xe8, 0x64, 0x00, 0x00, 0x46 };
+static void patchrom(void)
{
- int i;
+ int i;
if (currprefs.cpu_model > 68020 || currprefs.cachesize || currprefs.m68k_speed != 0) {
uae_u8 *p = extendedkickmem_bank.baseaddr;
- if (p) {
- for (i = 0; i < 524288 - sizeof (patchdata); i++) {
- if (!memcmp (p + i, patchdata, sizeof(patchdata))) {
- protect_roms (false);
- p[i + 6] = 0x4e;
- p[i + 7] = 0x71;
- p[i + 8] = 0x4e;
- p[i + 9] = 0x71;
- protect_roms (true);
- write_log (_T("CD32: extended rom delay loop patched at 0x%08x\n"), i + 6 + 0xe00000);
- return;
- }
+ for (i = 0; i < 524288 - sizeof(patchdata); i++) {
+ if (!memcmp(p + i, patchdata, sizeof(patchdata))) {
+ protect_roms(false);
+ p[i + 6] = 0x4e;
+ p[i + 7] = 0x71;
+ p[i + 8] = 0x4e;
+ p[i + 9] = 0x71;
+ protect_roms(true);
+ write_log(_T("extended rom delay loop patched at 0x%p\n"), i + 6 + 0xe00000);
+ return;
}
- write_log (_T("CD32: couldn't patch extended rom\n"));
}
+ write_log(_T("couldn't patch extended rom\n"));
}
}
-static void akiko_cdrom_free (void)
+static void akiko_cdrom_free(void)
{
- sys_cddev_close ();
- xfree (sector_buffer_1);
- xfree (sector_buffer_2);
- xfree (sector_buffer_info_1);
- xfree (sector_buffer_info_2);
+ sys_cddev_close();
+ xfree(sector_buffer_1);
+ xfree(sector_buffer_2);
+ xfree(sector_buffer_info_1);
+ xfree(sector_buffer_info_2);
sector_buffer_1 = 0;
sector_buffer_2 = 0;
sector_buffer_info_1 = 0;
sector_buffer_info_2 = 0;
}
-void akiko_reset (void)
+void akiko_reset(void)
{
- cdaudiostop_do ();
- nvram_read ();
- eeprom_reset(cd32_eeprom);
+ cdaudiostop_do();
+ nvram_read();
+ state = I2C_WAIT;
+ bitcounter = -1;
+ direction = -1;
cdrom_speed = 1;
cdrom_current_sector = -1;
@@ -1698,10 +1887,6 @@ void akiko_reset (void)
cdcomrxinx = 0;
cdcomtxcmp = 0;
lastmediastate = -1;
- cdrom_last_rx = 0;
- cdrom_intreq = CDINTERRUPT_SUBCODE;
- cdrom_subcodeoffset = 0xc2;
- cdrom_intena = 0;
}
cdrom_led = 0;
cdrom_receive_length = 0;
@@ -1709,70 +1894,58 @@ void akiko_reset (void)
cd_initialized = 0;
if (akiko_thread_running > 0) {
- cdaudiostop ();
+ cdaudiostop();
akiko_thread_running = 0;
- while(akiko_thread_running == 0)
- sleep_millis (10);
- destroy_comm_pipe(&requests);
+ while (akiko_thread_running == 0)
+ sleep_millis(10);
akiko_thread_running = 0;
}
- akiko_cdrom_free ();
+ akiko_cdrom_free();
mediacheckcounter = 0;
akiko_inited = false;
}
-void akiko_free (void)
+
+void akiko_free(void)
{
- akiko_reset ();
- akiko_cdrom_free ();
- if(akiko_sem != 0)
- uae_sem_destroy(&akiko_sem);
- akiko_sem = 0;
- if(sub_sem != 0)
- uae_sem_destroy(&sub_sem);
- sub_sem = 0;
+ akiko_reset();
+ akiko_cdrom_free();
}
-int akiko_init (void)
+int akiko_init(void)
{
if (!currprefs.cs_cd32cd)
return 0;
- akiko_free ();
- akiko_precalculate ();
+ akiko_free();
+ akiko_precalculate();
unitnum = -1;
- sys_cddev_open ();
- sector_buffer_1 = xmalloc (uae_u8, SECTOR_BUFFER_SIZE * 2352);
- sector_buffer_2 = xmalloc (uae_u8, SECTOR_BUFFER_SIZE * 2352);
- sector_buffer_info_1 = xmalloc (uae_u8, SECTOR_BUFFER_SIZE);
- sector_buffer_info_2 = xmalloc (uae_u8, SECTOR_BUFFER_SIZE);
+ sys_cddev_open();
+ sector_buffer_1 = xmalloc(uae_u8, SECTOR_BUFFER_SIZE * 2352);
+ sector_buffer_2 = xmalloc(uae_u8, SECTOR_BUFFER_SIZE * 2352);
+ sector_buffer_info_1 = xmalloc(uae_u8, SECTOR_BUFFER_SIZE);
+ sector_buffer_info_2 = xmalloc(uae_u8, SECTOR_BUFFER_SIZE);
sector_buffer_sector_1 = -1;
sector_buffer_sector_2 = -1;
- if(akiko_sem != 0)
- uae_sem_destroy(&akiko_sem);
- akiko_sem = 0;
- uae_sem_init (&akiko_sem, 0, 1);
- if(sub_sem != 0)
- uae_sem_destroy(&sub_sem);
- sub_sem = 0;
- uae_sem_init (&sub_sem, 0, 1);
+ uae_sem_init(&akiko_sem, 0, 1);
+ uae_sem_init(&sub_sem, 0, 1);
if (!savestate_state) {
cdrom_playing = cdrom_paused = 0;
cdrom_data_offset = -1;
}
- patchrom ();
+ patchrom();
if (!akiko_thread_running) {
akiko_thread_running = 1;
- init_comm_pipe (&requests, 100, 1);
- uae_start_thread (_T("akiko"), akiko_thread, 0, NULL);
+ init_comm_pipe(&requests, 100, 1);
+ uae_start_thread(_T("akiko"), akiko_thread, 0, NULL);
}
- gui_flicker_led (LED_HD, 0, -1);
+ gui_flicker_led(LED_HD, 0, -1);
akiko_inited = true;
return 1;
}
#ifdef SAVESTATE
-uae_u8 *save_akiko (int *len, uae_u8 *dstptr)
+uae_u8 *save_akiko(int *len, uae_u8 *dstptr)
{
uae_u8 *dstbak, *dst;
int i;
@@ -1783,101 +1956,102 @@ uae_u8 *save_akiko (int *len, uae_u8 *dstptr)
if (dstptr)
dstbak = dst = dstptr;
else
- dstbak = dst = xmalloc (uae_u8, 1000);
- save_u16 (0);
- save_u16 (0xCAFE);
- save_u32 (cdrom_intreq);
- save_u32 (cdrom_intena);
- save_u32 (0);
- save_u32 (cdrom_addressdata);
- save_u32 (cdrom_addressmisc);
- save_u8 (cdrom_subcodeoffset);
- save_u8 (cdcomtxinx);
- save_u8 (cdcomrxinx);
- save_u8 (0);
- save_u8 (0);
- save_u8 (cdcomtxcmp);
- save_u8 (0);
- save_u8 (cdcomrxcmp);
- save_u16 ((uae_u16)cdrom_pbx);
- save_u16 (0);
- save_u32 (cdrom_flags);
- save_u32 (0);
- save_u32 (0);
- save_u32 (cd32_i2c_direction << 8);
- save_u32 (0);
- save_u32 (0);
+ dstbak = dst = xmalloc(uae_u8, 1000);
+ save_u16(0);
+ save_u16(0xCAFE);
+ save_u32(cdrom_intreq);
+ save_u32(cdrom_intena);
+ save_u32(0);
+ save_u32(cdrom_addressdata);
+ save_u32(cdrom_addressmisc);
+ save_u8(cdrom_subcodeoffset);
+ save_u8(cdcomtxinx);
+ save_u8(cdcomrxinx);
+ save_u8(0);
+ save_u8(0);
+ save_u8(cdcomtxcmp);
+ save_u8(0);
+ save_u8(cdcomrxcmp);
+ save_u16((uae_u16)cdrom_pbx);
+ save_u16(0);
+ save_u32(cdrom_flags);
+ save_u32(0);
+ save_u32(0);
+ save_u32((scl_dir ? 0x8000 : 0) | (sda_dir ? 0x4000 : 0));
+ save_u32(0);
+ save_u32(0);
for (i = 0; i < 8; i++)
- save_u32 (akiko_buffer[i]);
- save_u8 ((uae_u8)akiko_read_offset);
- save_u8 ((uae_u8)akiko_write_offset);
+ save_u32(akiko_buffer[i]);
+ save_u8((uae_u8)akiko_read_offset);
+ save_u8((uae_u8)akiko_write_offset);
- save_u32 ((cdrom_playing ? 1 : 0) | (cdrom_paused ? 2 : 0) | (cdrom_disk ? 4 : 0));
+ save_u32((cdrom_playing ? 1 : 0) | (cdrom_paused ? 2 : 0) | (cdrom_disk ? 4 : 0));
if (cdrom_playing)
- cd_qcode (0);
- save_u32 (lsn2msf (last_play_pos));
- save_u32 (lsn2msf (last_play_end));
- save_u8 ((uae_u8)cdrom_toc_counter);
+ cd_qcode(0);
+ save_u32(lsn2msf(last_play_pos));
+ save_u32(lsn2msf(last_play_end));
+ save_u8((uae_u8)cdrom_toc_counter);
- save_u8 (cdrom_speed);
- save_u8 (cdrom_current_sector);
+ save_u8(cdrom_speed);
+ save_u8(cdrom_current_sector);
- save_u32 (cdrom_toc_crc);
- save_u8 (cdrom_toc_cd_buffer.points);
- save_u32 (cdrom_toc_cd_buffer.lastaddress);
+ save_u32(cdrom_toc_crc);
+ save_u8(cdrom_toc_cd_buffer.points);
+ save_u32(cdrom_toc_cd_buffer.lastaddress);
*len = dst - dstbak;
return dstbak;
}
-uae_u8 *restore_akiko (uae_u8 *src)
+uae_u8 *restore_akiko(uae_u8 *src)
{
uae_u32 v;
int i;
- akiko_free ();
+ akiko_free();
if (!currprefs.cs_cd32cd) {
changed_prefs.cs_cd32c2p = changed_prefs.cs_cd32cd = changed_prefs.cs_cd32nvram = true;
currprefs.cs_cd32c2p = currprefs.cs_cd32cd = currprefs.cs_cd32nvram = true;
- akiko_init ();
+ akiko_init();
}
- restore_u16 ();
- restore_u16 ();
- cdrom_intreq = restore_u32 ();
- cdrom_intena = restore_u32 ();
- restore_u32 ();
- cdrom_addressdata = restore_u32 ();
- cdrom_addressmisc = restore_u32 ();
+ restore_u16();
+ restore_u16();
+ cdrom_intreq = restore_u32();
+ cdrom_intena = restore_u32();
+ restore_u32();
+ cdrom_addressdata = restore_u32();
+ cdrom_addressmisc = restore_u32();
subcode_address = cdrom_addressmisc | 0x100;
cdrx_address = cdrom_addressmisc;
cdtx_address = cdrom_addressmisc | 0x200;
- cdrom_subcodeoffset = restore_u8 ();
- cdcomtxinx = restore_u8 ();
- cdcomrxinx = restore_u8 ();
- restore_u8 ();
- restore_u8 ();
- cdcomtxcmp = restore_u8 ();
- restore_u8 ();
- cdcomrxcmp = restore_u8 ();
- cdrom_pbx = restore_u16 ();
- restore_u16 ();
- cdrom_flags = restore_u32 ();
- restore_u32 ();
- restore_u32 ();
- v = restore_u32 ();
- cd32_i2c_direction = v >> 8;
- restore_u32 ();
- restore_u32 ();
+ cdrom_subcodeoffset = restore_u8();
+ cdcomtxinx = restore_u8();
+ cdcomrxinx = restore_u8();
+ restore_u8();
+ restore_u8();
+ cdcomtxcmp = restore_u8();
+ restore_u8();
+ cdcomrxcmp = restore_u8();
+ cdrom_pbx = restore_u16();
+ restore_u16();
+ cdrom_flags = restore_u32();
+ restore_u32();
+ restore_u32();
+ v = restore_u32();
+ scl_dir = (v & 0x8000) ? 1 : 0;
+ sda_dir = (v & 0x4000) ? 1 : 0;
+ restore_u32();
+ restore_u32();
for (i = 0; i < 8; i++)
- akiko_buffer[i] = restore_u32 ();
- akiko_read_offset = restore_u8 ();
- akiko_write_offset = restore_u8 ();
+ akiko_buffer[i] = restore_u32();
+ akiko_read_offset = restore_u8();
+ akiko_write_offset = restore_u8();
cdrom_playing = cdrom_paused = cdrom_disk = 0;
- v = restore_u32 ();
+ v = restore_u32();
if (v & 1)
cdrom_playing = 1;
if (v & 2)
@@ -1886,46 +2060,45 @@ uae_u8 *restore_akiko (uae_u8 *src)
cdrom_disk = 1;
lastmediastate = cdrom_disk ? 2 : 0;
- last_play_pos = msf2lsn (restore_u32 ());
- last_play_end = msf2lsn (restore_u32 ());
- cdrom_toc_counter = (uae_s8)restore_u8 ();
- cdrom_speed = restore_u8 ();
- cdrom_current_sector = (uae_s8)restore_u8 ();
+ last_play_pos = msf2lsn(restore_u32());
+ last_play_end = msf2lsn(restore_u32());
+ cdrom_toc_counter = (uae_s8)restore_u8();
+ cdrom_speed = restore_u8();
+ cdrom_current_sector = (uae_s8)restore_u8();
- restore_u32 ();
- restore_u8 ();
- restore_u32 ();
+ restore_u32();
+ restore_u8();
+ restore_u32();
return src;
}
-void restore_akiko_finish (void)
+void restore_akiko_finish(void)
{
if (!currprefs.cs_cd32cd)
return;
- sys_cddev_close ();
- akiko_init ();
- akiko_c2p_do ();
- get_cdrom_toc ();
- write_comm_pipe_u32 (&requests, 0x0102, 1); // pause
- write_comm_pipe_u32 (&requests, 0x0104, 1); // stop
- write_comm_pipe_u32 (&requests, 0x0103, 1); // unpause
- if (cdrom_playing && isaudiotrack (last_play_pos)) {
- write_comm_pipe_u32 (&requests, 0x0103, 1); // unpause
- write_comm_pipe_u32 (&requests, 0x0110, 0); // play
- write_comm_pipe_u32 (&requests, last_play_pos, 0);
- write_comm_pipe_u32 (&requests, last_play_end, 0);
- write_comm_pipe_u32 (&requests, 0, 1);
+ sys_cddev_close();
+ akiko_init();
+ akiko_c2p_do();
+ get_cdrom_toc();
+ write_comm_pipe_u32(&requests, 0x0102, 1); // pause
+ write_comm_pipe_u32(&requests, 0x0104, 1); // stop
+ write_comm_pipe_u32(&requests, 0x0103, 1); // unpause
+ if (cdrom_playing && isaudiotrack(last_play_pos)) {
+ write_comm_pipe_u32(&requests, 0x0103, 1); // unpause
+ write_comm_pipe_u32(&requests, 0x0110, 0); // play
+ write_comm_pipe_u32(&requests, last_play_pos, 0);
+ write_comm_pipe_u32(&requests, last_play_end, 0);
+ write_comm_pipe_u32(&requests, 0, 1);
}
- cd_initialized = 2;
+ cd_initialized = 1;
}
#endif
-void akiko_mute (int muted)
+void akiko_mute(int muted)
{
cdrom_muted = muted;
if (unitnum >= 0)
- write_comm_pipe_u32 (&requests, 0x0105, 1);
+ write_comm_pipe_u32(&requests, 0x0105, 1);
}
-
diff --git a/src/audio.cpp b/src/audio.cpp
index 0467a4af..8271223f 100644
--- a/src/audio.cpp
+++ b/src/audio.cpp
@@ -16,27 +16,30 @@
#include "sysdeps.h"
#include "options.h"
-#include "memory.h"
+#include "include/memory.h"
#include "custom.h"
#include "newcpu.h"
#include "autoconf.h"
#include "gensound.h"
#include "audio.h"
#include "sounddep/sound.h"
+#include "events.h"
#include "savestate.h"
#include "gui.h"
#include
+#define MAX_EV ~0u
+
#define PERIOD_MIN 4
#define PERIOD_MIN_NONCE 60
STATIC_INLINE bool isaudio(void)
{
- return currprefs.produce_sound != 0;
+ return currprefs.produce_sound != 0;
}
-STATIC_INLINE bool usehacks (void)
+STATIC_INLINE bool usehacks(void)
{
return currprefs.cpu_model >= 68020 || currprefs.m68k_speed != 0;
}
@@ -52,63 +55,56 @@ typedef struct {
int time, output;
} sinc_queue_t;
-struct audio_channel_data2
-{
- int current_sample, last_sample;
- int sample_accum, sample_accum_time;
- int sinc_output_state;
- sinc_queue_t sinc_queue[SINC_QUEUE_LENGTH];
- int sinc_queue_time;
- int sinc_queue_head;
- int vol;
- unsigned int adk_mask;
-};
-
-struct audio_channel_data
-{
- unsigned int evtime;
+struct audio_channel_data {
+ unsigned int adk_mask;
+ unsigned int evtime;
bool dmaenstore;
bool intreq2;
bool dr;
bool dsr;
bool pbufldl;
bool dat_written;
- uaecptr lc, pt;
- int state;
- int per;
- int len, wlen;
- uae_u16 dat, dat2;
- struct audio_channel_data2 data;
- /* too fast cpu fixes */
+ uaecptr lc, pt;
+ int current_sample, last_sample;
+ int state;
+ int per;
+ int vol;
+ int len, wlen;
+ uae_u16 dat, dat2;
+ int sample_accum, sample_accum_time;
+ int sinc_output_state;
+ sinc_queue_t sinc_queue[SINC_QUEUE_LENGTH];
+ int sinc_queue_time;
+ int sinc_queue_head;
+ /* too fast cpu fixes */
uaecptr ptx;
bool ptx_written;
bool ptx_tofetch;
int dmaofftime_active;
};
-static struct audio_channel_data audio_channel[AUDIO_CHANNELS_PAULA];
-static struct audio_channel_data2 *audio_data[AUDIO_CHANNELS_PAULA];
+static struct audio_channel_data audio_channel[4];
int sound_available = 0;
-void (*sample_handler) (void);
-static void (*sample_prehandler) (unsigned long best_evtime);
+void(*sample_handler)(void);
+static void(*sample_prehandler)(unsigned long best_evtime);
-unsigned long scaled_sample_evtime;
-
-int sound_cd_volume[2];
+float scaled_sample_evtime;
static unsigned long last_cycles;
-static unsigned long next_sample_evtime;
+static float next_sample_evtime;
typedef uae_s8 sample8_t;
-#define DO_CHANNEL_1(v, c) do { (v) *= audio_channel[c].data.vol; } while (0)
+#define DO_CHANNEL_1(v, c) do { (v) *= audio_channel[c].vol; } while (0)
-STATIC_INLINE int FINISH_DATA (int data, int bits)
+STATIC_INLINE int FINISH_DATA(int data, int bits)
{
if (bits == 16) {
return data;
- } else if (bits - 16 > 0) {
+ }
+ else if (bits - 16 > 0) {
data >>= bits - 16;
- } else {
+ }
+ else {
int shift = 16 - bits;
data <<= shift;
}
@@ -128,7 +124,7 @@ static int led_filter_forced, sound_use_filter, sound_use_filter_sinc, led_filte
#define DENORMAL_OFFSET (1E-10)
static struct filter_state {
- float rc1, rc2, rc3, rc4, rc5;
+ float rc1, rc2, rc3, rc4, rc5;
} sound_filter_state[2];
static float a500e_filter1_a0;
@@ -136,9 +132,9 @@ static float a500e_filter2_a0;
static float filter_a0; /* a500 and a1200 use the same */
enum {
- FILTER_NONE = 0,
- FILTER_MODEL_A500,
- FILTER_MODEL_A1200
+ FILTER_NONE = 0,
+ FILTER_MODEL_A500,
+ FILTER_MODEL_A1200
};
/* Amiga has two separate filtering circuits per channel, a static RC filter
@@ -159,190 +155,191 @@ enum {
static int filter(int input, struct filter_state *fs)
{
- int o;
- float normal_output, led_output;
+ int o;
+ float normal_output, led_output;
- input = (uae_s16)input;
- switch (sound_use_filter) {
+ input = (uae_s16)input;
+ switch (sound_use_filter) {
- case FILTER_MODEL_A500:
- fs->rc1 = a500e_filter1_a0 * input + (1 - a500e_filter1_a0) * fs->rc1 + DENORMAL_OFFSET;
- fs->rc2 = a500e_filter2_a0 * fs->rc1 + (1-a500e_filter2_a0) * fs->rc2;
- normal_output = fs->rc2;
+ case FILTER_MODEL_A500:
+ fs->rc1 = a500e_filter1_a0 * input + (1 - a500e_filter1_a0) * fs->rc1 + DENORMAL_OFFSET;
+ fs->rc2 = a500e_filter2_a0 * fs->rc1 + (1 - a500e_filter2_a0) * fs->rc2;
+ normal_output = fs->rc2;
- fs->rc3 = filter_a0 * normal_output + (1 - filter_a0) * fs->rc3;
- fs->rc4 = filter_a0 * fs->rc3 + (1 - filter_a0) * fs->rc4;
- fs->rc5 = filter_a0 * fs->rc4 + (1 - filter_a0) * fs->rc5;
+ fs->rc3 = filter_a0 * normal_output + (1 - filter_a0) * fs->rc3;
+ fs->rc4 = filter_a0 * fs->rc3 + (1 - filter_a0) * fs->rc4;
+ fs->rc5 = filter_a0 * fs->rc4 + (1 - filter_a0) * fs->rc5;
- led_output = fs->rc5;
- break;
+ led_output = fs->rc5;
+ break;
- case FILTER_MODEL_A1200:
- normal_output = input;
+ case FILTER_MODEL_A1200:
+ normal_output = input;
- fs->rc2 = filter_a0 * normal_output + (1 - filter_a0) * fs->rc2 + DENORMAL_OFFSET;
- fs->rc3 = filter_a0 * fs->rc2 + (1 - filter_a0) * fs->rc3;
- fs->rc4 = filter_a0 * fs->rc3 + (1 - filter_a0) * fs->rc4;
+ fs->rc2 = filter_a0 * normal_output + (1 - filter_a0) * fs->rc2 + DENORMAL_OFFSET;
+ fs->rc3 = filter_a0 * fs->rc2 + (1 - filter_a0) * fs->rc3;
+ fs->rc4 = filter_a0 * fs->rc3 + (1 - filter_a0) * fs->rc4;
- led_output = fs->rc4;
- break;
+ led_output = fs->rc4;
+ break;
+ case FILTER_NONE:
+ default:
+ return input;
- case FILTER_NONE:
- default:
- return input;
+ }
- }
+ if (led_filter_on)
+ o = led_output;
+ else
+ o = normal_output;
- if (led_filter_on)
- o = led_output;
- else
- o = normal_output;
+ if (o > 32767)
+ o = 32767;
+ else if (o < -32768)
+ o = -32768;
- if (o > 32767)
- o = 32767;
- else if (o < -32768)
- o = -32768;
-
- return o;
+ return o;
}
/* Always put the right word before the left word. */
-static void (*put_sound_word_mono_func)(uae_u32 w);
-static void (*put_sound_word_stereo_func)(uae_u32 left, uae_u32 right);
+static void(*put_sound_word_mono_func)(uae_u32 w);
+static void(*put_sound_word_stereo_func)(uae_u32 left, uae_u32 right);
-static void put_sound_word_stereo_func_filter_mixed(uae_u32 lnew, uae_u32 rnew)
+static void put_sound_word_stereo_func_filter_mixed(uae_u32 left, uae_u32 right)
{
uae_u32 rold, lold, tmp;
- lnew = filter (lnew, &sound_filter_state[0]);
- rnew = filter (rnew, &sound_filter_state[1]);
+ left = filter(left, &sound_filter_state[0]);
+ right = filter(right, &sound_filter_state[1]);
- left_word_saved[saved_ptr] = lnew;
- right_word_saved[saved_ptr] = rnew;
+ left_word_saved[saved_ptr] = left;
+ right_word_saved[saved_ptr] = right;
- saved_ptr = (saved_ptr + 1) & mixed_stereo_size;
+ saved_ptr = (saved_ptr + 1) & mixed_stereo_size;
- lold = left_word_saved[saved_ptr];
- tmp = (rnew * mixed_mul2 + lold * mixed_mul1) / MIXED_STEREO_SCALE;
+ lold = left_word_saved[saved_ptr];
+ tmp = (right * mixed_mul2 + lold * mixed_mul1) / MIXED_STEREO_SCALE;
- rold = right_word_saved[saved_ptr];
- lnew = (lnew * mixed_mul2 + rold * mixed_mul1) / MIXED_STEREO_SCALE;
+ rold = right_word_saved[saved_ptr];
+ left = (left * mixed_mul2 + rold * mixed_mul1) / MIXED_STEREO_SCALE;
- PUT_SOUND_WORD_STEREO(lnew, tmp);
+ PUT_SOUND_WORD_STEREO(left, tmp);
}
static void put_sound_word_stereo_func_filter_notmixed(uae_u32 left, uae_u32 right)
{
- left = filter (left, &sound_filter_state[0]);
- right = filter (right, &sound_filter_state[1]);
- PUT_SOUND_WORD_STEREO(left, right);
+ left = filter(left, &sound_filter_state[0]);
+ right = filter(right, &sound_filter_state[1]);
+ PUT_SOUND_WORD_STEREO(left, right);
}
-static void put_sound_word_stereo_func_nofilter_mixed(uae_u32 lnew, uae_u32 rnew)
+static void put_sound_word_stereo_func_nofilter_mixed(uae_u32 left, uae_u32 right)
{
uae_u32 rold, lold, tmp;
- left_word_saved[saved_ptr] = lnew;
- right_word_saved[saved_ptr] = rnew;
+ left_word_saved[saved_ptr] = left;
+ right_word_saved[saved_ptr] = right;
- saved_ptr = (saved_ptr + 1) & mixed_stereo_size;
+ saved_ptr = (saved_ptr + 1) & mixed_stereo_size;
- lold = left_word_saved[saved_ptr];
- tmp = (rnew * mixed_mul2 + lold * mixed_mul1) / MIXED_STEREO_SCALE;
+ lold = left_word_saved[saved_ptr];
+ tmp = (right * mixed_mul2 + lold * mixed_mul1) / MIXED_STEREO_SCALE;
- rold = right_word_saved[saved_ptr];
- lnew = (lnew * mixed_mul2 + rold * mixed_mul1) / MIXED_STEREO_SCALE;
+ rold = right_word_saved[saved_ptr];
+ left = (left * mixed_mul2 + rold * mixed_mul1) / MIXED_STEREO_SCALE;
- PUT_SOUND_WORD_STEREO(lnew, tmp);
+ PUT_SOUND_WORD_STEREO(left, tmp);
}
static void put_sound_word_stereo_func_nofilter_notmixed(uae_u32 left, uae_u32 right)
{
- PUT_SOUND_WORD_STEREO(left, right);
+ PUT_SOUND_WORD_STEREO(left, right);
}
static void put_sound_word_mono_func_filter(uae_u32 data)
{
- data = filter (data, &sound_filter_state[0]);
- PUT_SOUND_WORD(data);
+ data = filter(data, &sound_filter_state[0]);
+ PUT_SOUND_WORD(data);
}
static void put_sound_word_mono_func_nofilter(uae_u32 data)
{
- PUT_SOUND_WORD(data);
+ PUT_SOUND_WORD(data);
}
+
static void anti_prehandler(unsigned long best_evtime)
{
- int i, output;
- struct audio_channel_data2 *acd;
+ int i, output;
+ struct audio_channel_data *acd;
- /* Handle accumulator antialiasiation */
- for (i = 0; i < AUDIO_CHANNELS_PAULA; i++) {
- acd = audio_data[i];
- output = (acd->current_sample * acd->vol) & acd->adk_mask;
- acd->sample_accum += output * best_evtime;
- acd->sample_accum_time += best_evtime;
- }
+ /* Handle accumulator antialiasiation */
+ for (i = 0; i < 4; i++) {
+ acd = &audio_channel[i];
+ output = (acd->current_sample * acd->vol) & acd->adk_mask;
+ acd->sample_accum += output * best_evtime;
+ acd->sample_accum_time += best_evtime;
+ }
}
-STATIC_INLINE void samplexx_anti_handler (int *datasp)
+STATIC_INLINE void samplexx_anti_handler(int *datasp)
{
- int i;
- for (i = 0; i < AUDIO_CHANNELS_PAULA; i++) {
- struct audio_channel_data2 *acd = audio_data[i];
- datasp[i] = acd->sample_accum_time ? (acd->sample_accum / acd->sample_accum_time) : 0;
- acd->sample_accum = 0;
- acd->sample_accum_time = 0;
- }
+ int i;
+ for (i = 0; i < 4; i++) {
+ datasp[i] = audio_channel[i].sample_accum_time ? (audio_channel[i].sample_accum / audio_channel[i].sample_accum_time) : 0;
+ audio_channel[i].sample_accum = 0;
+ audio_channel[i].sample_accum_time = 0;
+ }
}
-static void sinc_prehandler_paula (unsigned long best_evtime)
+static void sinc_prehandler(unsigned long best_evtime)
{
int i, output;
- struct audio_channel_data2 *acd;
+ struct audio_channel_data *acd;
- for (i = 0; i < AUDIO_CHANNELS_PAULA; i++) {
- acd = audio_data[i];
+ for (i = 0; i < 4; i++) {
+ acd = &audio_channel[i];
int vol = acd->vol;
output = (acd->current_sample * vol) & acd->adk_mask;
/* if output state changes, record the state change and also
* write data into sinc queue for mixing in the BLEP */
- if (acd->sinc_output_state != output) {
+ if (acd->sinc_output_state != output) {
acd->sinc_queue_head = (acd->sinc_queue_head - 1) & (SINC_QUEUE_LENGTH - 1);
acd->sinc_queue[acd->sinc_queue_head].time = acd->sinc_queue_time;
acd->sinc_queue[acd->sinc_queue_head].output = output - acd->sinc_output_state;
- acd->sinc_output_state = output;
- }
+ acd->sinc_output_state = output;
+ }
acd->sinc_queue_time += best_evtime;
- }
+ }
}
+
/* this interpolator performs BLEP mixing (bleps are shaped like integrated sinc
* functions) with a type of BLEP that matches the filtering configuration. */
-STATIC_INLINE void samplexx_sinc_handler (int *datasp)
+STATIC_INLINE void samplexx_sinc_handler(int *datasp)
{
- int n, i;
- int const *winsinc;
+ int i, n;
+ int const *winsinc;
- if (sound_use_filter_sinc) {
- n = (sound_use_filter_sinc == FILTER_MODEL_A500) ? 0 : 2;
- if (led_filter_on)
- n += 1;
- } else {
- n = 4;
- }
- winsinc = winsinc_integral[n];
+ if (sound_use_filter_sinc) {
+ n = (sound_use_filter_sinc == FILTER_MODEL_A500) ? 0 : 2;
+ if (led_filter_on)
+ n += 1;
+ }
+ else {
+ n = 4;
+ }
+ winsinc = winsinc_integral[n];
- for (i = 0; i < AUDIO_CHANNELS_PAULA; i++) {
- int j, v;
- struct audio_channel_data2 *acd = audio_data[i];
- /* The sum rings with harmonic components up to infinity... */
- int sum = acd->sinc_output_state << 17;
- /* ...but we cancel them through mixing in BLEPs instead */
+ for (i = 0; i < 4; i += 1) {
+ int j, v;
+ struct audio_channel_data *acd = &audio_channel[i];
+ /* The sum rings with harmonic components up to infinity... */
+ int sum = acd->sinc_output_state << 17;
+ /* ...but we cancel them through mixing in BLEPs instead */
int offsetpos = acd->sinc_queue_head & (SINC_QUEUE_LENGTH - 1);
for (j = 0; j < SINC_QUEUE_LENGTH; j += 1) {
int age = acd->sinc_queue_time - acd->sinc_queue[offsetpos].time;
@@ -352,187 +349,182 @@ STATIC_INLINE void samplexx_sinc_handler (int *datasp)
offsetpos = (offsetpos + 1) & (SINC_QUEUE_LENGTH - 1);
}
v = sum >> 15;
- if (v > 32767)
- v = 32767;
- else if (v < -32768)
- v = -32768;
- datasp[i] = v;
- }
+ if (v > 32767)
+ v = 32767;
+ else if (v < -32768)
+ v = -32768;
+ datasp[i] = v;
+ }
}
-static void sample16i_sinc_handler (void)
+static void sample16i_sinc_handler(void)
{
- int datas[AUDIO_CHANNELS_PAULA], data1;
+ int datas[4], data1;
- samplexx_sinc_handler (datas);
- data1 = datas[0] + datas[3] + datas[1] + datas[2];
- data1 = FINISH_DATA (data1, 18);
-
- set_sound_buffers ();
- put_sound_word_mono_func (data1);
- check_sound_buffers ();
+ samplexx_sinc_handler(datas);
+ data1 = datas[0] + datas[3] + datas[1] + datas[2];
+ data1 = FINISH_DATA(data1, 18);
+ set_sound_buffers();
+ PUT_SOUND_WORD_MONO(data1);
+ check_sound_buffers();
}
-void sample16_handler (void)
+void sample16_handler(void)
{
- int data;
- if(audio_channel[0].data.adk_mask)
- data = audio_channel[0].data.current_sample * audio_channel[0].data.vol;
- else
- data = 0;
- if(audio_channel[1].data.adk_mask)
- data += audio_channel[1].data.current_sample * audio_channel[1].data.vol;
- if(audio_channel[2].data.adk_mask)
- data += audio_channel[2].data.current_sample * audio_channel[2].data.vol;
- if(audio_channel[3].data.adk_mask)
- data += audio_channel[3].data.current_sample * audio_channel[3].data.vol;
+ uae_u32 data;
+ if (audio_channel[0].adk_mask)
+ data = audio_channel[0].current_sample * audio_channel[0].vol;
+ else
+ data = 0;
+ if (audio_channel[1].adk_mask)
+ data += audio_channel[1].current_sample * audio_channel[1].vol;
+ if (audio_channel[2].adk_mask)
+ data += audio_channel[2].current_sample * audio_channel[2].vol;
+ if (audio_channel[3].adk_mask)
+ data += audio_channel[3].current_sample * audio_channel[3].vol;
- data = FINISH_DATA (data, 16);
-
- set_sound_buffers ();
- put_sound_word_mono_func (data);
- check_sound_buffers ();
+ data = FINISH_DATA(data, 16);
+ set_sound_buffers();
+ PUT_SOUND_WORD_MONO(data);
+ check_sound_buffers();
}
/* This interpolator examines sample points when Paula switches the output
* voltage and computes the average of Paula's output */
-static void sample16i_anti_handler (void)
+static void sample16i_anti_handler(void)
{
- int datas[AUDIO_CHANNELS_PAULA], data1;
+ int datas[4], data1;
- samplexx_anti_handler (datas);
- data1 = datas[0] + datas[3] + datas[1] + datas[2];
- data1 = FINISH_DATA (data1, 16);
-
- set_sound_buffers ();
- put_sound_word_mono_func (data1);
- check_sound_buffers ();
+ samplexx_anti_handler(datas);
+ data1 = datas[0] + datas[3] + datas[1] + datas[2];
+ data1 = FINISH_DATA(data1, 16);
+ set_sound_buffers();
+ PUT_SOUND_WORD_MONO(data1);
+ check_sound_buffers();
}
-static void sample16i_rh_handler (void)
+static void sample16i_rh_handler(void)
{
- unsigned long delta, ratio;
+ unsigned long delta, ratio;
- int data0 = audio_channel[0].data.current_sample;
- int data1 = audio_channel[1].data.current_sample;
- int data2 = audio_channel[2].data.current_sample;
- int data3 = audio_channel[3].data.current_sample;
- int data0p = audio_channel[0].data.last_sample;
- int data1p = audio_channel[1].data.last_sample;
- int data2p = audio_channel[2].data.last_sample;
- int data3p = audio_channel[3].data.last_sample;
- int data;
+ uae_u32 data0 = audio_channel[0].current_sample;
+ uae_u32 data1 = audio_channel[1].current_sample;
+ uae_u32 data2 = audio_channel[2].current_sample;
+ uae_u32 data3 = audio_channel[3].current_sample;
+ uae_u32 data0p = audio_channel[0].last_sample;
+ uae_u32 data1p = audio_channel[1].last_sample;
+ uae_u32 data2p = audio_channel[2].last_sample;
+ uae_u32 data3p = audio_channel[3].last_sample;
+ uae_u32 data;
- DO_CHANNEL_1 (data0, 0);
- DO_CHANNEL_1 (data1, 1);
- DO_CHANNEL_1 (data2, 2);
- DO_CHANNEL_1 (data3, 3);
- DO_CHANNEL_1 (data0p, 0);
- DO_CHANNEL_1 (data1p, 1);
- DO_CHANNEL_1 (data2p, 2);
- DO_CHANNEL_1 (data3p, 3);
+ DO_CHANNEL_1(data0, 0);
+ DO_CHANNEL_1(data1, 1);
+ DO_CHANNEL_1(data2, 2);
+ DO_CHANNEL_1(data3, 3);
+ DO_CHANNEL_1(data0p, 0);
+ DO_CHANNEL_1(data1p, 1);
+ DO_CHANNEL_1(data2p, 2);
+ DO_CHANNEL_1(data3p, 3);
- data0 &= audio_channel[0].data.adk_mask;
- data0p &= audio_channel[0].data.adk_mask;
- data1 &= audio_channel[1].data.adk_mask;
- data1p &= audio_channel[1].data.adk_mask;
- data2 &= audio_channel[2].data.adk_mask;
- data2p &= audio_channel[2].data.adk_mask;
- data3 &= audio_channel[3].data.adk_mask;
- data3p &= audio_channel[3].data.adk_mask;
+ data0 &= audio_channel[0].adk_mask;
+ data0p &= audio_channel[0].adk_mask;
+ data1 &= audio_channel[1].adk_mask;
+ data1p &= audio_channel[1].adk_mask;
+ data2 &= audio_channel[2].adk_mask;
+ data2p &= audio_channel[2].adk_mask;
+ data3 &= audio_channel[3].adk_mask;
+ data3p &= audio_channel[3].adk_mask;
- /* linear interpolation and summing up... */
- delta = audio_channel[0].per;
- ratio = ((audio_channel[0].evtime % delta) << 8) / delta;
- data0 = (data0 * (256 - ratio) + data0p * ratio) >> 8;
- delta = audio_channel[1].per;
- ratio = ((audio_channel[1].evtime % delta) << 8) / delta;
- data0 += (data1 * (256 - ratio) + data1p * ratio) >> 8;
- delta = audio_channel[2].per;
- ratio = ((audio_channel[2].evtime % delta) << 8) / delta;
- data0 += (data2 * (256 - ratio) + data2p * ratio) >> 8;
- delta = audio_channel[3].per;
- ratio = ((audio_channel[3].evtime % delta) << 8) / delta;
- data0 += (data3 * (256 - ratio) + data3p * ratio) >> 8;
+ /* linear interpolation and summing up... */
+ delta = audio_channel[0].per;
+ ratio = ((audio_channel[0].evtime % delta) << 8) / delta;
+ data0 = (data0 * (256 - ratio) + data0p * ratio) >> 8;
+ delta = audio_channel[1].per;
+ ratio = ((audio_channel[1].evtime % delta) << 8) / delta;
+ data0 += (data1 * (256 - ratio) + data1p * ratio) >> 8;
+ delta = audio_channel[2].per;
+ ratio = ((audio_channel[2].evtime % delta) << 8) / delta;
+ data0 += (data2 * (256 - ratio) + data2p * ratio) >> 8;
+ delta = audio_channel[3].per;
+ ratio = ((audio_channel[3].evtime % delta) << 8) / delta;
+ data0 += (data3 * (256 - ratio) + data3p * ratio) >> 8;
data = data0;
- data = FINISH_DATA (data, 16);
-
- set_sound_buffers ();
- put_sound_word_mono_func (data);
- check_sound_buffers();
+ data = FINISH_DATA(data, 16);
+ set_sound_buffers();
+ PUT_SOUND_WORD_MONO(data);
+ check_sound_buffers();
}
-static void sample16i_crux_handler (void)
+static void sample16i_crux_handler(void)
{
- int data0 = audio_channel[0].data.current_sample;
- int data1 = audio_channel[1].data.current_sample;
- int data2 = audio_channel[2].data.current_sample;
- int data3 = audio_channel[3].data.current_sample;
- int data0p = audio_channel[0].data.last_sample;
- int data1p = audio_channel[1].data.last_sample;
- int data2p = audio_channel[2].data.last_sample;
- int data3p = audio_channel[3].data.last_sample;
- int data;
+ uae_u32 data0 = audio_channel[0].current_sample;
+ uae_u32 data1 = audio_channel[1].current_sample;
+ uae_u32 data2 = audio_channel[2].current_sample;
+ uae_u32 data3 = audio_channel[3].current_sample;
+ uae_u32 data0p = audio_channel[0].last_sample;
+ uae_u32 data1p = audio_channel[1].last_sample;
+ uae_u32 data2p = audio_channel[2].last_sample;
+ uae_u32 data3p = audio_channel[3].last_sample;
+ uae_u32 data;
- DO_CHANNEL_1 (data0, 0);
- DO_CHANNEL_1 (data1, 1);
- DO_CHANNEL_1 (data2, 2);
- DO_CHANNEL_1 (data3, 3);
- DO_CHANNEL_1 (data0p, 0);
- DO_CHANNEL_1 (data1p, 1);
- DO_CHANNEL_1 (data2p, 2);
- DO_CHANNEL_1 (data3p, 3);
+ DO_CHANNEL_1(data0, 0);
+ DO_CHANNEL_1(data1, 1);
+ DO_CHANNEL_1(data2, 2);
+ DO_CHANNEL_1(data3, 3);
+ DO_CHANNEL_1(data0p, 0);
+ DO_CHANNEL_1(data1p, 1);
+ DO_CHANNEL_1(data2p, 2);
+ DO_CHANNEL_1(data3p, 3);
- data0 &= audio_channel[0].data.adk_mask;
- data0p &= audio_channel[0].data.adk_mask;
- data1 &= audio_channel[1].data.adk_mask;
- data1p &= audio_channel[1].data.adk_mask;
- data2 &= audio_channel[2].data.adk_mask;
- data2p &= audio_channel[2].data.adk_mask;
- data3 &= audio_channel[3].data.adk_mask;
- data3p &= audio_channel[3].data.adk_mask;
+ data0 &= audio_channel[0].adk_mask;
+ data0p &= audio_channel[0].adk_mask;
+ data1 &= audio_channel[1].adk_mask;
+ data1p &= audio_channel[1].adk_mask;
+ data2 &= audio_channel[2].adk_mask;
+ data2p &= audio_channel[2].adk_mask;
+ data3 &= audio_channel[3].adk_mask;
+ data3p &= audio_channel[3].adk_mask;
- {
- struct audio_channel_data *cdp;
- unsigned long ratio, ratio1;
+ {
+ struct audio_channel_data *cdp;
+ unsigned long ratio, ratio1;
#define INTERVAL (scaled_sample_evtime * 3)
- cdp = audio_channel + 0;
- ratio1 = cdp->per - cdp->evtime;
- ratio = (ratio1 << 12) / INTERVAL;
- if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
- ratio = 4096;
- data0 = (data0 * ratio + data0p * (4096 - ratio)) >> 12;
+ cdp = audio_channel + 0;
+ ratio1 = cdp->per - cdp->evtime;
+ ratio = (ratio1 << 12) / INTERVAL;
+ if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
+ ratio = 4096;
+ data0 = (data0 * ratio + data0p * (4096 - ratio)) >> 12;
- cdp = audio_channel + 1;
- ratio1 = cdp->per - cdp->evtime;
- ratio = (ratio1 << 12) / INTERVAL;
- if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
- ratio = 4096;
- data1 = (data1 * ratio + data1p * (4096 - ratio)) >> 12;
+ cdp = audio_channel + 1;
+ ratio1 = cdp->per - cdp->evtime;
+ ratio = (ratio1 << 12) / INTERVAL;
+ if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
+ ratio = 4096;
+ data1 = (data1 * ratio + data1p * (4096 - ratio)) >> 12;
- cdp = audio_channel + 2;
- ratio1 = cdp->per - cdp->evtime;
- ratio = (ratio1 << 12) / INTERVAL;
- if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
- ratio = 4096;
- data2 = (data2 * ratio + data2p * (4096 - ratio)) >> 12;
+ cdp = audio_channel + 2;
+ ratio1 = cdp->per - cdp->evtime;
+ ratio = (ratio1 << 12) / INTERVAL;
+ if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
+ ratio = 4096;
+ data2 = (data2 * ratio + data2p * (4096 - ratio)) >> 12;
- cdp = audio_channel + 3;
- ratio1 = cdp->per - cdp->evtime;
- ratio = (ratio1 << 12) / INTERVAL;
- if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
- ratio = 4096;
- data3 = (data3 * ratio + data3p * (4096 - ratio)) >> 12;
- }
- data1 += data2;
- data0 += data3;
- data0 += data1;
+ cdp = audio_channel + 3;
+ ratio1 = cdp->per - cdp->evtime;
+ ratio = (ratio1 << 12) / INTERVAL;
+ if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
+ ratio = 4096;
+ data3 = (data3 * ratio + data3p * (4096 - ratio)) >> 12;
+ }
+ data1 += data2;
+ data0 += data3;
+ data0 += data1;
data = data0;
- data = FINISH_DATA (data, 16);
-
- set_sound_buffers ();
- put_sound_word_mono_func (data);
- check_sound_buffers ();
+ data = FINISH_DATA(data, 16);
+ set_sound_buffers();
+ PUT_SOUND_WORD_MONO(data);
+ check_sound_buffers();
}
#ifdef HAVE_STEREO_SUPPORT
@@ -540,276 +532,261 @@ static void sample16i_crux_handler (void)
/* This interpolator examines sample points when Paula switches the output
* voltage and computes the average of Paula's output */
-static void sample16si_anti_handler (void)
+static void sample16si_anti_handler(void)
{
- int datas[AUDIO_CHANNELS_PAULA], data1, data2;
+ int datas[4], data1, data2;
- samplexx_anti_handler (datas);
- data1 = datas[0] + datas[3];
- data2 = datas[1] + datas[2];
- data1 = FINISH_DATA (data1, 15);
- data2 = FINISH_DATA (data2, 15);
-
- set_sound_buffers ();
- put_sound_word_stereo_func(data1, data2);
- check_sound_buffers ();
+ samplexx_anti_handler(datas);
+ data1 = datas[0] + datas[3];
+ data2 = datas[1] + datas[2];
+ data1 = FINISH_DATA(data1, 15);
+ data2 = FINISH_DATA(data2, 15);
+ set_sound_buffers();
+ put_sound_word_stereo_func(data1, data2);
+ check_sound_buffers();
}
-static void sample16si_sinc_handler (void)
+static void sample16si_sinc_handler(void)
{
- int datas[AUDIO_CHANNELS_PAULA], data1, data2;
+ int datas[4], data1, data2;
- samplexx_sinc_handler (datas);
- data1 = datas[0] + datas[3];
- data2 = datas[1] + datas[2];
- data1 = FINISH_DATA (data1, 17);
- data2 = FINISH_DATA (data2, 17);
-
- set_sound_buffers ();
- put_sound_word_stereo_func(data1, data2);
- check_sound_buffers ();
+ samplexx_sinc_handler(datas);
+ data1 = datas[0] + datas[3];
+ data2 = datas[1] + datas[2];
+ data1 = FINISH_DATA(data1, 17);
+ data2 = FINISH_DATA(data2, 17);
+ set_sound_buffers();
+ put_sound_word_stereo_func(data1, data2);
+ check_sound_buffers();
}
-void sample16s_handler (void)
+void sample16s_handler(void)
{
- int data_l = audio_channel[0].data.adk_mask ? audio_channel[0].data.current_sample * audio_channel[0].data.vol : 0;
- int data_r = audio_channel[1].data.adk_mask ? audio_channel[1].data.current_sample * audio_channel[1].data.vol : 0;
- if(audio_channel[2].data.adk_mask)
- data_r += audio_channel[2].data.current_sample * audio_channel[2].data.vol;
- if(audio_channel[3].data.adk_mask)
- data_l += audio_channel[3].data.current_sample * audio_channel[3].data.vol;
- data_l = FINISH_DATA(data_l, 15);
- data_r = FINISH_DATA(data_r, 15);
+ uae_u32 data_l = audio_channel[0].adk_mask ? audio_channel[0].current_sample * audio_channel[0].vol : 0;
+ uae_u32 data_r = audio_channel[1].adk_mask ? audio_channel[1].current_sample * audio_channel[1].vol : 0;
+ if (audio_channel[2].adk_mask)
+ data_r += audio_channel[2].current_sample * audio_channel[2].vol;
+ if (audio_channel[3].adk_mask)
+ data_l += audio_channel[3].current_sample * audio_channel[3].vol;
+ data_l = FINISH_DATA(data_l, 15);
+ data_r = FINISH_DATA(data_r, 15);
- set_sound_buffers ();
- put_sound_word_stereo_func(data_l, data_r);
- check_sound_buffers();
+ set_sound_buffers();
+ put_sound_word_stereo_func(data_l, data_r);
+ check_sound_buffers();
}
-static void sample16si_crux_handler (void)
+static void sample16si_crux_handler(void)
{
- int data0 = audio_channel[0].data.current_sample;
- int data1 = audio_channel[1].data.current_sample;
- int data2 = audio_channel[2].data.current_sample;
- int data3 = audio_channel[3].data.current_sample;
- int data0p = audio_channel[0].data.last_sample;
- int data1p = audio_channel[1].data.last_sample;
- int data2p = audio_channel[2].data.last_sample;
- int data3p = audio_channel[3].data.last_sample;
+ uae_u32 data0 = audio_channel[0].current_sample;
+ uae_u32 data1 = audio_channel[1].current_sample;
+ uae_u32 data2 = audio_channel[2].current_sample;
+ uae_u32 data3 = audio_channel[3].current_sample;
+ uae_u32 data0p = audio_channel[0].last_sample;
+ uae_u32 data1p = audio_channel[1].last_sample;
+ uae_u32 data2p = audio_channel[2].last_sample;
+ uae_u32 data3p = audio_channel[3].last_sample;
- DO_CHANNEL_1 (data0, 0);
- DO_CHANNEL_1 (data1, 1);
- DO_CHANNEL_1 (data2, 2);
- DO_CHANNEL_1 (data3, 3);
- DO_CHANNEL_1 (data0p, 0);
- DO_CHANNEL_1 (data1p, 1);
- DO_CHANNEL_1 (data2p, 2);
- DO_CHANNEL_1 (data3p, 3);
+ DO_CHANNEL_1(data0, 0);
+ DO_CHANNEL_1(data1, 1);
+ DO_CHANNEL_1(data2, 2);
+ DO_CHANNEL_1(data3, 3);
+ DO_CHANNEL_1(data0p, 0);
+ DO_CHANNEL_1(data1p, 1);
+ DO_CHANNEL_1(data2p, 2);
+ DO_CHANNEL_1(data3p, 3);
- data0 &= audio_channel[0].data.adk_mask;
- data0p &= audio_channel[0].data.adk_mask;
- data1 &= audio_channel[1].data.adk_mask;
- data1p &= audio_channel[1].data.adk_mask;
- data2 &= audio_channel[2].data.adk_mask;
- data2p &= audio_channel[2].data.adk_mask;
- data3 &= audio_channel[3].data.adk_mask;
- data3p &= audio_channel[3].data.adk_mask;
+ data0 &= audio_channel[0].adk_mask;
+ data0p &= audio_channel[0].adk_mask;
+ data1 &= audio_channel[1].adk_mask;
+ data1p &= audio_channel[1].adk_mask;
+ data2 &= audio_channel[2].adk_mask;
+ data2p &= audio_channel[2].adk_mask;
+ data3 &= audio_channel[3].adk_mask;
+ data3p &= audio_channel[3].adk_mask;
- {
- struct audio_channel_data *cdp;
- unsigned long ratio, ratio1;
+ {
+ struct audio_channel_data *cdp;
+ unsigned long ratio, ratio1;
#define INTERVAL (scaled_sample_evtime * 3)
- cdp = audio_channel + 0;
- ratio1 = cdp->per - cdp->evtime;
- ratio = (ratio1 << 12) / INTERVAL;
- if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
- ratio = 4096;
- data0 = (data0 * ratio + data0p * (4096 - ratio)) >> 12;
+ cdp = audio_channel + 0;
+ ratio1 = cdp->per - cdp->evtime;
+ ratio = (ratio1 << 12) / INTERVAL;
+ if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
+ ratio = 4096;
+ data0 = (data0 * ratio + data0p * (4096 - ratio)) >> 12;
- cdp = audio_channel + 1;
- ratio1 = cdp->per - cdp->evtime;
- ratio = (ratio1 << 12) / INTERVAL;
- if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
- ratio = 4096;
- data1 = (data1 * ratio + data1p * (4096 - ratio)) >> 12;
+ cdp = audio_channel + 1;
+ ratio1 = cdp->per - cdp->evtime;
+ ratio = (ratio1 << 12) / INTERVAL;
+ if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
+ ratio = 4096;
+ data1 = (data1 * ratio + data1p * (4096 - ratio)) >> 12;
- cdp = audio_channel + 2;
- ratio1 = cdp->per - cdp->evtime;
- ratio = (ratio1 << 12) / INTERVAL;
- if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
- ratio = 4096;
- data2 = (data2 * ratio + data2p * (4096 - ratio)) >> 12;
+ cdp = audio_channel + 2;
+ ratio1 = cdp->per - cdp->evtime;
+ ratio = (ratio1 << 12) / INTERVAL;
+ if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
+ ratio = 4096;
+ data2 = (data2 * ratio + data2p * (4096 - ratio)) >> 12;
- cdp = audio_channel + 3;
- ratio1 = cdp->per - cdp->evtime;
- ratio = (ratio1 << 12) / INTERVAL;
- if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
- ratio = 4096;
- data3 = (data3 * ratio + data3p * (4096 - ratio)) >> 12;
- }
- data1 += data2;
- data0 += data3;
- data0 = FINISH_DATA (data0, 15);
- data1 = FINISH_DATA (data1, 15);
-
- set_sound_buffers ();
- put_sound_word_stereo_func(data0, data1);
- check_sound_buffers ();
+ cdp = audio_channel + 3;
+ ratio1 = cdp->per - cdp->evtime;
+ ratio = (ratio1 << 12) / INTERVAL;
+ if (cdp->evtime < scaled_sample_evtime || ratio1 >= INTERVAL)
+ ratio = 4096;
+ data3 = (data3 * ratio + data3p * (4096 - ratio)) >> 12;
+ }
+ data1 += data2;
+ data0 += data3;
+ data0 = FINISH_DATA(data0, 15);
+ data1 = FINISH_DATA(data1, 15);
+ set_sound_buffers();
+ put_sound_word_stereo_func(data0, data1);
+ check_sound_buffers();
}
-static void sample16si_rh_handler (void)
+static void sample16si_rh_handler(void)
{
- unsigned long delta, ratio;
+ unsigned long delta, ratio;
- int data0 = audio_channel[0].data.current_sample;
- int data1 = audio_channel[1].data.current_sample;
- int data2 = audio_channel[2].data.current_sample;
- int data3 = audio_channel[3].data.current_sample;
- int data0p = audio_channel[0].data.last_sample;
- int data1p = audio_channel[1].data.last_sample;
- int data2p = audio_channel[2].data.last_sample;
- int data3p = audio_channel[3].data.last_sample;
+ uae_u32 data0 = audio_channel[0].current_sample;
+ uae_u32 data1 = audio_channel[1].current_sample;
+ uae_u32 data2 = audio_channel[2].current_sample;
+ uae_u32 data3 = audio_channel[3].current_sample;
+ uae_u32 data0p = audio_channel[0].last_sample;
+ uae_u32 data1p = audio_channel[1].last_sample;
+ uae_u32 data2p = audio_channel[2].last_sample;
+ uae_u32 data3p = audio_channel[3].last_sample;
- DO_CHANNEL_1 (data0, 0);
- DO_CHANNEL_1 (data1, 1);
- DO_CHANNEL_1 (data2, 2);
- DO_CHANNEL_1 (data3, 3);
- DO_CHANNEL_1 (data0p, 0);
- DO_CHANNEL_1 (data1p, 1);
- DO_CHANNEL_1 (data2p, 2);
- DO_CHANNEL_1 (data3p, 3);
+ DO_CHANNEL_1(data0, 0);
+ DO_CHANNEL_1(data1, 1);
+ DO_CHANNEL_1(data2, 2);
+ DO_CHANNEL_1(data3, 3);
+ DO_CHANNEL_1(data0p, 0);
+ DO_CHANNEL_1(data1p, 1);
+ DO_CHANNEL_1(data2p, 2);
+ DO_CHANNEL_1(data3p, 3);
- data0 &= audio_channel[0].data.adk_mask;
- data0p &= audio_channel[0].data.adk_mask;
- data1 &= audio_channel[1].data.adk_mask;
- data1p &= audio_channel[1].data.adk_mask;
- data2 &= audio_channel[2].data.adk_mask;
- data2p &= audio_channel[2].data.adk_mask;
- data3 &= audio_channel[3].data.adk_mask;
- data3p &= audio_channel[3].data.adk_mask;
+ data0 &= audio_channel[0].adk_mask;
+ data0p &= audio_channel[0].adk_mask;
+ data1 &= audio_channel[1].adk_mask;
+ data1p &= audio_channel[1].adk_mask;
+ data2 &= audio_channel[2].adk_mask;
+ data2p &= audio_channel[2].adk_mask;
+ data3 &= audio_channel[3].adk_mask;
+ data3p &= audio_channel[3].adk_mask;
- /* linear interpolation and summing up... */
- delta = audio_channel[0].per;
- ratio = ((audio_channel[0].evtime % delta) << 8) / delta;
- data0 = (data0 * (256 - ratio) + data0p * ratio) >> 8;
- delta = audio_channel[1].per;
- ratio = ((audio_channel[1].evtime % delta) << 8) / delta;
- data1 = (data1 * (256 - ratio) + data1p * ratio) >> 8;
- delta = audio_channel[2].per;
- ratio = ((audio_channel[2].evtime % delta) << 8) / delta;
- data1 += (data2 * (256 - ratio) + data2p * ratio) >> 8;
- delta = audio_channel[3].per;
- ratio = ((audio_channel[3].evtime % delta) << 8) / delta;
- data0 += (data3 * (256 - ratio) + data3p * ratio) >> 8;
- data0 = FINISH_DATA (data0, 15);
- data1 = FINISH_DATA (data1, 15);
-
- set_sound_buffers ();
- put_sound_word_stereo_func(data0, data1);
- check_sound_buffers ();
+ /* linear interpolation and summing up... */
+ delta = audio_channel[0].per;
+ ratio = ((audio_channel[0].evtime % delta) << 8) / delta;
+ data0 = (data0 * (256 - ratio) + data0p * ratio) >> 8;
+ delta = audio_channel[1].per;
+ ratio = ((audio_channel[1].evtime % delta) << 8) / delta;
+ data1 = (data1 * (256 - ratio) + data1p * ratio) >> 8;
+ delta = audio_channel[2].per;
+ ratio = ((audio_channel[2].evtime % delta) << 8) / delta;
+ data1 += (data2 * (256 - ratio) + data2p * ratio) >> 8;
+ delta = audio_channel[3].per;
+ ratio = ((audio_channel[3].evtime % delta) << 8) / delta;
+ data0 += (data3 * (256 - ratio) + data3p * ratio) >> 8;
+ data0 = FINISH_DATA(data0, 15);
+ data1 = FINISH_DATA(data1, 15);
+ set_sound_buffers();
+ put_sound_word_stereo_func(data0, data1);
+ check_sound_buffers();
}
#else
-void sample16s_handler (void)
+void sample16s_handler(void)
{
- sample16_handler ();
+ sample16_handler();
}
-static void sample16si_crux_handler (void)
+static void sample16si_crux_handler(void)
{
- sample16i_crux_handler ();
+ sample16i_crux_handler();
}
-static void sample16si_rh_handler (void)
+static void sample16si_rh_handler(void)
{
- sample16i_rh_handler ();
+ sample16i_rh_handler();
}
#endif
static int audio_work_to_do;
-static void zerostate (int nr)
+static void zerostate(int nr)
{
struct audio_channel_data *cdp = audio_channel + nr;
- cdp->state = 0;
- cdp->evtime = MAX_EV;
+ cdp->state = 0;
+ cdp->evtime = MAX_EV;
cdp->intreq2 = 0;
cdp->dmaenstore = false;
cdp->dmaofftime_active = 0;
}
-static void schedule_audio (void)
+static void schedule_audio(void)
{
unsigned long best = MAX_EV;
- int i;
+ int i;
eventtab[ev_audio].active = 0;
- for (i = 0; i < AUDIO_CHANNELS_PAULA; i++) {
- struct audio_channel_data *cdp = audio_channel + i;
+ for (i = 0; i < 4; i++) {
+ struct audio_channel_data *cdp = audio_channel + i;
if (cdp->evtime != MAX_EV) {
if (best > cdp->evtime) {
best = cdp->evtime;
- eventtab[ev_audio].active = 1;
- }
- }
- }
- eventtab[ev_audio].evtime = get_cycles () + best;
+ eventtab[ev_audio].active = 1;
+ }
+ }
+ }
+
+ eventtab[ev_audio].evtime = get_cycles() + best;
}
-static void audio_event_reset (void)
+static void audio_event_reset(void)
{
int i;
- last_cycles = get_cycles ();
+ last_cycles = get_cycles();
next_sample_evtime = scaled_sample_evtime;
- if (!isrestore ()) {
- for (i = 0; i < AUDIO_CHANNELS_PAULA; i++)
- zerostate (i);
+ if (!isrestore()) {
+ for (i = 0; i < 4; i++)
+ zerostate(i);
}
- schedule_audio ();
- events_schedule ();
+ schedule_audio();
+ events_schedule();
}
void audio_deactivate(void)
{
- gui_data.sndbuf_status = 3;
- gui_data.sndbuf = 0;
+ gui_data.sndbuf_status = 3;
+ gui_data.sndbuf = 0;
audio_work_to_do = 0;
- pause_sound_buffer ();
- clear_sound_buffers();
- audio_event_reset();
+ pause_sound_buffer();
+ clear_sound_buffers();
+ audio_event_reset();
}
int audio_activate(void)
{
- int ret = 0;
-
- if (!audio_work_to_do) {
- restart_sound_buffer();
- ret = 1;
- audio_event_reset();
- }
- audio_work_to_do = 4 * maxvpos_nom * 50;
- return ret;
+ int ret = 0;
+ if (!audio_work_to_do) {
+ restart_sound_buffer();
+ ret = 1;
+ audio_event_reset();
+ }
+ audio_work_to_do = 4 * maxvpos_nom * 50;
+ return ret;
}
-
STATIC_INLINE int is_audio_active(void)
{
- return audio_work_to_do;
+ return audio_work_to_do;
}
-STATIC_INLINE void update_volume(int nr, uae_u16 v)
-{
- struct audio_channel_data *cdp = audio_channel + nr;
- // 7 bit register in Paula.
- v &= 127;
- if (v > 64)
- v = 64;
- cdp->data.vol = v;
-}
-
-uae_u16 audio_dmal (void)
+uae_u16 audio_dmal(void)
{
uae_u16 dmal = 0;
- for (int nr = 0; nr < AUDIO_CHANNELS_PAULA; nr++) {
+ for (int nr = 0; nr < 4; nr++) {
struct audio_channel_data *cdp = audio_channel + nr;
if (cdp->dr)
dmal |= 1 << (nr * 2);
@@ -820,24 +797,24 @@ uae_u16 audio_dmal (void)
return dmal;
}
-static int isirq (int nr)
+static int isirq(int nr)
{
- return INTREQR() & (0x80 << nr);
+ return INTREQR() & (0x80 << nr);
}
-static void setirq (int nr, int which)
+static void setirq(int nr, int which)
{
- INTREQ_0 (0x8000 | (0x80 << nr));
+ INTREQ_0(0x8000 | (0x80 << nr));
}
-static void newsample (int nr, sample8_t sample)
+static void newsample(int nr, sample8_t sample)
{
struct audio_channel_data *cdp = audio_channel + nr;
- cdp->data.last_sample = cdp->data.current_sample;
- cdp->data.current_sample = sample;
+ cdp->last_sample = cdp->current_sample;
+ cdp->current_sample = sample;
}
-STATIC_INLINE void setdr (int nr)
+STATIC_INLINE void setdr(int nr)
{
struct audio_channel_data *cdp = audio_channel + nr;
cdp->dr = true;
@@ -846,7 +823,7 @@ STATIC_INLINE void setdr (int nr)
}
}
-static void loaddat (int nr, bool modper)
+static void loaddat(int nr, bool modper)
{
struct audio_channel_data *cdp = audio_channel + nr;
int audav = adkcon & (0x01 << nr);
@@ -856,34 +833,39 @@ static void loaddat (int nr, bool modper)
return;
if (modper && audap) {
if (cdp->dat == 0)
- cdp[1].per = 65536 * CYCLE_UNIT;
+ cdp[1].per = PERIOD_MAX;
else if (cdp->dat > PERIOD_MIN)
cdp[1].per = cdp->dat * CYCLE_UNIT;
else
cdp[1].per = PERIOD_MIN * CYCLE_UNIT;
- } else if (audav) {
- update_volume(nr + 1, cdp->dat);
}
- } else {
+ else if (audav) {
+ cdp[1].vol = cdp->dat;
+ cdp[1].vol &= 127;
+ if (cdp[1].vol > 64)
+ cdp[1].vol = 64;
+ }
+ }
+ else {
cdp->dat2 = cdp->dat;
}
}
-static void loaddat (int nr)
+static void loaddat(int nr)
{
- loaddat (nr, false);
+ loaddat(nr, false);
}
-STATIC_INLINE void loadper (int nr)
+STATIC_INLINE void loadper(int nr)
{
struct audio_channel_data *cdp = audio_channel + nr;
cdp->evtime = cdp->per;
if (cdp->evtime < CYCLE_UNIT)
- write_log (_T("LOADPER%d bug %d\n"), nr, cdp->evtime);
+ write_log(_T("LOADPER%d bug %d\n"), nr, cdp->evtime);
}
-static void audio_state_channel2 (int nr, bool perfin)
+static void audio_state_channel2(int nr, bool perfin)
{
struct audio_channel_data *cdp = audio_channel + nr;
bool chan_ena = (dmacon & DMA_MASTER) && (dmacon & (1 << nr));
@@ -891,27 +873,29 @@ static void audio_state_channel2 (int nr, bool perfin)
int audav = adkcon & (0x01 << nr);
int audap = adkcon & (0x10 << nr);
int napnav = (!audav && !audap) || audav;
- int hpos = current_hpos ();
+ int hpos = current_hpos();
cdp->dmaenstore = chan_ena;
if (currprefs.produce_sound == 0) {
- zerostate (nr);
+ zerostate(nr);
return;
}
- audio_activate ();
+ audio_activate();
if ((cdp->state == 2 || cdp->state == 3) && usehacks()) {
- if (!chan_ena && old_dma) {
- // DMA switched off, state=2/3 and "too fast CPU": set flag
+ if (!chan_ena && old_dma) {
+ // DMA switched off, state=2/3 and "too fast CPU": set flag
cdp->dmaofftime_active = true;
}
if (cdp->dmaofftime_active && !old_dma && chan_ena) {
// We are still in state=2/3 and program is going to re-enable
// DMA. Force state to zero to prevent CPU timed DMA wait
// routines in common tracker players to lose notes.
- newsample (nr, (cdp->dat2 >> 0) & 0xff);
- zerostate (nr);
+ newsample(nr, (cdp->dat2 >> 0) & 0xff);
+ // if (napnav)
+ // setirq (nr, 91);
+ zerostate(nr);
}
}
@@ -930,32 +914,35 @@ static void audio_state_channel2 (int nr, bool perfin)
if (cdp->wlen > 2)
cdp->ptx_tofetch = true;
cdp->dsr = true;
- } else if (cdp->dat_written && !isirq (nr)) {
+ }
+ else if (cdp->dat_written && !isirq(nr)) {
cdp->state = 2;
- setirq (nr, 0);
- loaddat (nr);
+ setirq(nr, 0);
+ loaddat(nr);
if (usehacks() && cdp->per < 10 * CYCLE_UNIT) {
// make sure audio.device AUDxDAT startup returns to idle state before DMA is enabled
- newsample (nr, (cdp->dat2 >> 0) & 0xff);
- zerostate (nr);
- } else {
- cdp->pbufldl = true;
- audio_state_channel2 (nr, false);
+ newsample(nr, (cdp->dat2 >> 0) & 0xff);
+ zerostate(nr);
}
- } else {
- zerostate (nr);
+ else {
+ cdp->pbufldl = true;
+ audio_state_channel2(nr, false);
+ }
+ }
+ else {
+ zerostate(nr);
}
break;
case 1:
cdp->evtime = MAX_EV;
if (!chan_ena) {
- zerostate (nr);
+ zerostate(nr);
return;
}
if (!cdp->dat_written)
return;
- setirq (nr, 10);
- setdr (nr);
+ setirq(nr, 10);
+ setdr(nr);
if (cdp->wlen != 1)
cdp->wlen = (cdp->wlen - 1) & 0xffff;
cdp->state = 5;
@@ -963,7 +950,7 @@ static void audio_state_channel2 (int nr, bool perfin)
case 5:
cdp->evtime = MAX_EV;
if (!chan_ena) {
- zerostate (nr);
+ zerostate(nr);
return;
}
if (!cdp->dat_written)
@@ -972,132 +959,130 @@ static void audio_state_channel2 (int nr, bool perfin)
cdp->ptx_written = 0;
cdp->lc = cdp->ptx;
}
- loaddat (nr);
+ loaddat(nr);
if (napnav)
- setdr (nr);
+ setdr(nr);
cdp->state = 2;
- loadper (nr);
+ loadper(nr);
cdp->pbufldl = true;
cdp->intreq2 = 0;
- audio_state_channel2 (nr, false);
+ audio_state_channel2(nr, false);
break;
case 2:
if (cdp->pbufldl) {
- newsample (nr, (cdp->dat2 >> 8) & 0xff);
- loadper (nr);
+ newsample(nr, (cdp->dat2 >> 8) & 0xff);
+ loadper(nr);
cdp->pbufldl = false;
}
if (!perfin)
return;
if (audap)
- loaddat (nr, true);
+ loaddat(nr, true);
if (chan_ena) {
if (audap)
- setdr (nr);
+ setdr(nr);
if (cdp->intreq2 && audap)
- setirq (nr, 21);
- } else {
+ setirq(nr, 21);
+ }
+ else {
if (audap)
- setirq (nr, 22);
+ setirq(nr, 22);
}
cdp->pbufldl = true;
cdp->state = 3;
- audio_state_channel2 (nr, false);
+ audio_state_channel2(nr, false);
break;
case 3:
if (cdp->pbufldl) {
- newsample (nr, (cdp->dat2 >> 0) & 0xff);
- loadper (nr);
+ newsample(nr, (cdp->dat2 >> 0) & 0xff);
+ loadper(nr);
cdp->pbufldl = false;
}
if (!perfin)
return;
if (chan_ena) {
- loaddat (nr);
+ loaddat(nr);
if (cdp->intreq2 && napnav)
- setirq (nr, 31);
+ setirq(nr, 31);
if (napnav)
- setdr (nr);
- } else {
- if (isirq (nr)) {
- zerostate (nr);
+ setdr(nr);
+ }
+ else {
+ if (isirq(nr)) {
+ zerostate(nr);
return;
}
- loaddat (nr);
+ loaddat(nr);
if (napnav)
- setirq (nr, 32);
+ setirq(nr, 32);
}
cdp->intreq2 = 0;
cdp->pbufldl = true;
cdp->state = 2;
- audio_state_channel2 (nr, false);
+ audio_state_channel2(nr, false);
break;
}
}
-static void audio_state_channel (int nr, bool perfin)
+static void audio_state_channel(int nr, bool perfin)
{
struct audio_channel_data *cdp = audio_channel + nr;
- audio_state_channel2 (nr, perfin);
- cdp->dat_written = false;
+ audio_state_channel2(nr, perfin);
+ cdp->dat_written = false;
}
-void audio_state_machine (void)
+void audio_state_machine(void)
{
- update_audio ();
- for (int nr = 0; nr < AUDIO_CHANNELS_PAULA; nr++) {
+ update_audio();
+ for (int nr = 0; nr < 4; nr++) {
struct audio_channel_data *cdp = audio_channel + nr;
- audio_state_channel2 (nr, false);
+ audio_state_channel2(nr, false);
cdp->dat_written = false;
}
- schedule_audio ();
- events_schedule ();
+ schedule_audio();
+ events_schedule();
}
-void audio_reset (void)
+void audio_reset(void)
{
- int i;
- struct audio_channel_data *cdp;
+ int i;
+ struct audio_channel_data *cdp;
- reset_sound ();
- memset(sound_filter_state, 0, sizeof sound_filter_state);
- if (!isrestore ()) {
- for (i = 0; i < AUDIO_CHANNELS_PAULA; i++) {
- cdp = &audio_channel[i];
- memset (cdp, 0, sizeof *audio_channel);
- cdp->per = PERIOD_MAX - 1;
- cdp->data.vol = 0;
- cdp->evtime = MAX_EV;
- }
- }
+ reset_sound();
+ memset(sound_filter_state, 0, sizeof sound_filter_state);
+ if (!isrestore()) {
+ for (i = 0; i < 4; i++) {
+ cdp = &audio_channel[i];
+ memset(cdp, 0, sizeof *audio_channel);
+ cdp->per = PERIOD_MAX - 1;
+ cdp->vol = 0;
+ cdp->evtime = MAX_EV;
+ }
+ }
- last_cycles = get_cycles ();
- next_sample_evtime = scaled_sample_evtime;
- schedule_audio ();
- events_schedule ();
+ last_cycles = get_cycles();
+ next_sample_evtime = scaled_sample_evtime;
+
+ schedule_audio();
+ events_schedule();
}
-static int sound_prefs_changed (void)
+static int sound_prefs_changed(void)
{
- if (!config_changed)
- return 0;
- if (changed_prefs.produce_sound != currprefs.produce_sound
- || changed_prefs.sound_stereo != currprefs.sound_stereo
- || changed_prefs.sound_freq != currprefs.sound_freq)
- return 1;
+ if (changed_prefs.produce_sound != currprefs.produce_sound
+ || changed_prefs.sound_stereo != currprefs.sound_stereo
+ || changed_prefs.sound_freq != currprefs.sound_freq)
+ return 1;
- if (changed_prefs.sound_stereo_separation != currprefs.sound_stereo_separation
- || changed_prefs.sound_mixed_stereo_delay != currprefs.sound_mixed_stereo_delay
- || changed_prefs.sound_interpol != currprefs.sound_interpol
- || changed_prefs.sound_volume_cd != currprefs.sound_volume_cd
- || changed_prefs.sound_filter != currprefs.sound_filter
- || changed_prefs.sound_filter_type != currprefs.sound_filter_type)
- return -1;
- return 0;
+ if (changed_prefs.sound_stereo_separation != currprefs.sound_stereo_separation
+ || changed_prefs.sound_mixed_stereo_delay != currprefs.sound_mixed_stereo_delay
+ || changed_prefs.sound_interpol != currprefs.sound_interpol
+ || changed_prefs.sound_filter != currprefs.sound_filter
+ || changed_prefs.sound_filter_type != currprefs.sound_filter_type)
+ return -1;
+ return 0;
}
-double softfloat_tan(double v);
-
/* This computes the 1st order low-pass filter term b0.
* The a1 term is 1.0 - b0. The center frequency marks the -3 dB point. */
#ifndef M_PI
@@ -1105,332 +1090,358 @@ double softfloat_tan(double v);
#endif
static float rc_calculate_a0(int sample_rate, int cutoff_freq)
{
- float omega;
- /* The BLT correction formula below blows up if the cutoff is above nyquist. */
- if (cutoff_freq >= sample_rate / 2)
- return 1.0;
+ float omega;
+ /* The BLT correction formula below blows up if the cutoff is above nyquist. */
+ if (cutoff_freq >= sample_rate / 2)
+ return 1.0;
- omega = 2 * M_PI * cutoff_freq / sample_rate;
- /* Compensate for the bilinear transformation. This allows us to specify the
- * stop frequency more exactly, but the filter becomes less steep further
- * from stopband. */
- omega = softfloat_tan (omega / 2.0) * 2.0;
- float out = 1.0 / (1.0 + 1.0 / omega);
- return out;
+ omega = 2 * M_PI * cutoff_freq / sample_rate;
+ /* Compensate for the bilinear transformation. This allows us to specify the
+ * stop frequency more exactly, but the filter becomes less steep further
+ * from stopband. */
+ omega = tan(omega / 2) * 2;
+ return 1 / (1 + 1 / omega);
}
-void check_prefs_changed_audio (void)
+void check_prefs_changed_audio(void)
{
- int ch;
+ int ch;
- if (sound_available) {
- ch = sound_prefs_changed ();
+ if (sound_available) {
+ ch = sound_prefs_changed();
if (ch > 0) {
- clear_sound_buffers ();
+ clear_sound_buffers();
}
if (ch) {
- set_audio ();
- audio_activate ();
+ set_audio();
+ audio_activate();
}
}
}
void set_audio(void)
{
- int old_mixed_size = mixed_stereo_size;
- int sep, delay;
- int ch;
+ int old_mixed_size = mixed_stereo_size;
+ int sep, delay;
+ int ch;
- ch = sound_prefs_changed ();
- if (ch >= 0)
- close_sound ();
+ ch = sound_prefs_changed();
+ if (ch >= 0)
+ close_sound();
currprefs.produce_sound = changed_prefs.produce_sound;
currprefs.sound_stereo = changed_prefs.sound_stereo;
currprefs.sound_freq = changed_prefs.sound_freq;
- currprefs.sound_stereo_separation = changed_prefs.sound_stereo_separation;
- currprefs.sound_mixed_stereo_delay = changed_prefs.sound_mixed_stereo_delay;
+ currprefs.sound_stereo_separation = changed_prefs.sound_stereo_separation;
+ currprefs.sound_mixed_stereo_delay = changed_prefs.sound_mixed_stereo_delay;
currprefs.sound_interpol = changed_prefs.sound_interpol;
- currprefs.sound_filter = changed_prefs.sound_filter;
- currprefs.sound_filter_type = changed_prefs.sound_filter_type;
- currprefs.sound_volume_cd = changed_prefs.sound_volume_cd;
+ currprefs.sound_filter = changed_prefs.sound_filter;
+ currprefs.sound_filter_type = changed_prefs.sound_filter_type;
- sound_cd_volume[0] = sound_cd_volume[1] = (100 - (currprefs.sound_volume_cd < 0 ? 0 : currprefs.sound_volume_cd)) * 32768 / 100;
+ if (ch >= 0) {
+ if (currprefs.produce_sound >= 2) {
+ if (!init_audio()) {
+ if (!sound_available) {
+ write_log(_T("Sound is not supported.\n"));
+ }
+ else {
+ write_log(_T("Sorry, can't initialize sound.\n"));
+ currprefs.produce_sound = 1;
+ /* So we don't do this every frame */
+ changed_prefs.produce_sound = 1;
+ }
+ }
+ }
+ next_sample_evtime = scaled_sample_evtime;
+ last_cycles = get_cycles();
+ compute_vsynctime();
+ }
+ else {
+ sound_volume(0);
+ }
- if (ch >= 0) {
- if (currprefs.produce_sound >= 2) {
- if (!init_audio ()) {
- if (! sound_available) {
- write_log (_T("Sound is not supported.\n"));
- } else {
- write_log (_T("Sorry, can't initialize sound.\n"));
- currprefs.produce_sound = 1;
- /* So we don't do this every frame */
- changed_prefs.produce_sound = 1;
- }
- }
- }
- next_sample_evtime = scaled_sample_evtime;
- last_cycles = get_cycles ();
- compute_vsynctime ();
- } else {
- sound_volume (0);
- }
-
- sep = (currprefs.sound_stereo_separation = changed_prefs.sound_stereo_separation) * 3 / 2;
- if (sep >= 15)
- sep = 16;
- delay = currprefs.sound_mixed_stereo_delay = changed_prefs.sound_mixed_stereo_delay;
- mixed_mul1 = MIXED_STEREO_SCALE / 2 - sep;
- mixed_mul2 = MIXED_STEREO_SCALE / 2 + sep;
+ sep = (currprefs.sound_stereo_separation = changed_prefs.sound_stereo_separation) * 3 / 2;
+ if (sep >= 15)
+ sep = 16;
+ delay = currprefs.sound_mixed_stereo_delay = changed_prefs.sound_mixed_stereo_delay;
+ mixed_mul1 = MIXED_STEREO_SCALE / 2 - sep;
+ mixed_mul2 = MIXED_STEREO_SCALE / 2 + sep;
mixed_stereo_size = delay > 0 ? (1 << delay) - 1 : 0;
mixed_on = sep < MIXED_STEREO_MAX || mixed_stereo_size > 0;
- if (mixed_on && old_mixed_size != mixed_stereo_size) {
- saved_ptr = 0;
- memset (right_word_saved, 0, sizeof right_word_saved);
- }
-
- led_filter_forced = -1; // always off
- sound_use_filter = sound_use_filter_sinc = 0;
- if (currprefs.sound_filter) {
- if (currprefs.sound_filter == FILTER_SOUND_ON)
- led_filter_forced = 1;
- if (currprefs.sound_filter == FILTER_SOUND_EMUL)
- led_filter_forced = 0;
- if (currprefs.sound_filter_type == FILTER_SOUND_TYPE_A500)
- sound_use_filter = FILTER_MODEL_A500;
- else if (currprefs.sound_filter_type == FILTER_SOUND_TYPE_A1200)
- sound_use_filter = FILTER_MODEL_A1200;
- }
- a500e_filter1_a0 = rc_calculate_a0(currprefs.sound_freq, 6200);
- a500e_filter2_a0 = rc_calculate_a0(currprefs.sound_freq, 20000);
- filter_a0 = rc_calculate_a0(currprefs.sound_freq, 7000);
- memset (sound_filter_state, 0, sizeof sound_filter_state);
- led_filter_audio();
-
- /* Select the right interpolation method. */
- if (sample_handler == sample16_handler
- || sample_handler == sample16i_crux_handler
- || sample_handler == sample16i_rh_handler
- || sample_handler == sample16i_sinc_handler
- || sample_handler == sample16i_anti_handler)
- {
- sample_handler = (currprefs.sound_interpol == 0 ? sample16_handler
- : currprefs.sound_interpol == 3 ? sample16i_rh_handler
- : currprefs.sound_interpol == 4 ? sample16i_crux_handler
- : currprefs.sound_interpol == 2 ? sample16i_sinc_handler
- : sample16i_anti_handler);
- } else if (sample_handler == sample16s_handler
- || sample_handler == sample16si_crux_handler
- || sample_handler == sample16si_rh_handler
- || sample_handler == sample16si_sinc_handler
- || sample_handler == sample16si_anti_handler)
- {
- sample_handler = (currprefs.sound_interpol == 0 ? sample16s_handler
- : currprefs.sound_interpol == 3 ? sample16si_rh_handler
- : currprefs.sound_interpol == 4 ? sample16si_crux_handler
- : currprefs.sound_interpol == 2 ? sample16si_sinc_handler
- : sample16si_anti_handler);
- }
- sample_prehandler = NULL;
- if (sample_handler == sample16si_sinc_handler || sample_handler == sample16i_sinc_handler) {
- sample_prehandler = sinc_prehandler_paula;
- sound_use_filter_sinc = sound_use_filter;
- sound_use_filter = 0;
- } else if (sample_handler == sample16si_anti_handler || sample_handler == sample16i_anti_handler) {
- sample_prehandler = anti_prehandler;
- }
- for (int i = 0; i < AUDIO_CHANNELS_PAULA; i++) {
- audio_data[i] = &audio_channel[i].data;
+ if (mixed_on && old_mixed_size != mixed_stereo_size) {
+ saved_ptr = 0;
+ memset(right_word_saved, 0, sizeof right_word_saved);
}
- if(currprefs.sound_stereo) {
- if(currprefs.sound_filter) {
- if(mixed_on)
- put_sound_word_stereo_func = put_sound_word_stereo_func_filter_mixed;
- else
- put_sound_word_stereo_func = put_sound_word_stereo_func_filter_notmixed;
- }
- else {
- if(mixed_on)
- put_sound_word_stereo_func = put_sound_word_stereo_func_nofilter_mixed;
- else
- put_sound_word_stereo_func = put_sound_word_stereo_func_nofilter_notmixed;
- }
- }
- else {
- if(currprefs.sound_filter) {
- put_sound_word_mono_func = put_sound_word_mono_func_filter;
- }
- else {
- put_sound_word_mono_func = put_sound_word_mono_func_nofilter;
- }
- }
+ led_filter_forced = -1; // always off
+ sound_use_filter = sound_use_filter_sinc = 0;
+ if (currprefs.sound_filter) {
+ if (currprefs.sound_filter == FILTER_SOUND_ON)
+ led_filter_forced = 1;
+ if (currprefs.sound_filter == FILTER_SOUND_EMUL)
+ led_filter_forced = 0;
+ if (currprefs.sound_filter_type == FILTER_SOUND_TYPE_A500)
+ sound_use_filter = FILTER_MODEL_A500;
+ else if (currprefs.sound_filter_type == FILTER_SOUND_TYPE_A1200)
+ sound_use_filter = FILTER_MODEL_A1200;
+ }
+ a500e_filter1_a0 = rc_calculate_a0(currprefs.sound_freq, 6200);
+ a500e_filter2_a0 = rc_calculate_a0(currprefs.sound_freq, 20000);
+ filter_a0 = rc_calculate_a0(currprefs.sound_freq, 7000);
+ led_filter_audio();
- if (currprefs.produce_sound == 0) {
- eventtab[ev_audio].active = 0;
- events_schedule ();
- } else {
- audio_activate ();
- schedule_audio ();
- events_schedule ();
- }
- set_config_changed ();
+ /* Select the right interpolation method. */
+ if (sample_handler == sample16_handler
+ || sample_handler == sample16i_crux_handler
+ || sample_handler == sample16i_rh_handler
+ || sample_handler == sample16i_sinc_handler
+ || sample_handler == sample16i_anti_handler)
+ {
+ sample_handler = (currprefs.sound_interpol == 0 ? sample16_handler
+ : currprefs.sound_interpol == 3 ? sample16i_rh_handler
+ : currprefs.sound_interpol == 4 ? sample16i_crux_handler
+ : currprefs.sound_interpol == 2 ? sample16i_sinc_handler
+ : sample16i_anti_handler);
+ }
+ else if (sample_handler == sample16s_handler
+ || sample_handler == sample16si_crux_handler
+ || sample_handler == sample16si_rh_handler
+ || sample_handler == sample16si_sinc_handler
+ || sample_handler == sample16si_anti_handler)
+ {
+ sample_handler = (currprefs.sound_interpol == 0 ? sample16s_handler
+ : currprefs.sound_interpol == 3 ? sample16si_rh_handler
+ : currprefs.sound_interpol == 4 ? sample16si_crux_handler
+ : currprefs.sound_interpol == 2 ? sample16si_sinc_handler
+ : sample16si_anti_handler);
+ }
+ sample_prehandler = NULL;
+ if (sample_handler == sample16si_sinc_handler || sample_handler == sample16i_sinc_handler) {
+ sample_prehandler = sinc_prehandler;
+ sound_use_filter_sinc = sound_use_filter;
+ sound_use_filter = 0;
+ }
+ else if (sample_handler == sample16si_anti_handler || sample_handler == sample16i_anti_handler) {
+ sample_prehandler = anti_prehandler;
+ }
+
+ if (currprefs.sound_stereo) {
+ if (currprefs.sound_filter) {
+ if (mixed_on)
+ put_sound_word_stereo_func = put_sound_word_stereo_func_filter_mixed;
+ else
+ put_sound_word_stereo_func = put_sound_word_stereo_func_filter_notmixed;
+ }
+ else {
+ if (mixed_on)
+ put_sound_word_stereo_func = put_sound_word_stereo_func_nofilter_mixed;
+ else
+ put_sound_word_stereo_func = put_sound_word_stereo_func_nofilter_notmixed;
+ }
+ }
+ else {
+ if (currprefs.sound_filter) {
+ put_sound_word_mono_func = put_sound_word_mono_func_filter;
+ }
+ else {
+ put_sound_word_mono_func = put_sound_word_mono_func_nofilter;
+ }
+ }
+
+ if (currprefs.produce_sound == 0) {
+ eventtab[ev_audio].active = 0;
+ events_schedule();
+ }
+ else {
+ audio_activate();
+ schedule_audio();
+ events_schedule();
+ }
}
-void update_audio (void)
+void update_audio(void)
{
- unsigned long int n_cycles = 0;
+ unsigned long int n_cycles = 0;
- if (!isaudio())
- goto end;
- if (isrestore ())
- goto end;
- if (!is_audio_active())
- goto end;
+ if (!isaudio())
+ goto end;
+ if (isrestore())
+ goto end;
+ if (!is_audio_active())
+ goto end;
- n_cycles = get_cycles () - last_cycles;
- while (n_cycles > 0) {
+ n_cycles = get_cycles() - last_cycles;
+ while (n_cycles > 0) {
unsigned long int best_evtime = n_cycles;
- unsigned long rounded;
- int i;
+ unsigned long rounded;
+ int i;
- for (i = 0; i < AUDIO_CHANNELS_PAULA; i++) {
- if (audio_channel[i].evtime != MAX_EV && best_evtime > audio_channel[i].evtime)
- best_evtime = audio_channel[i].evtime;
- }
+ for (i = 0; i < 4; i++) {
+ if (audio_channel[i].evtime != MAX_EV && best_evtime > audio_channel[i].evtime)
+ best_evtime = audio_channel[i].evtime;
+ }
- rounded = next_sample_evtime;
+ rounded = next_sample_evtime;
- if (currprefs.produce_sound > 1 && best_evtime > rounded)
- best_evtime = rounded;
+ if (currprefs.produce_sound > 1 && best_evtime > rounded)
+ best_evtime = rounded;
- /* Decrease time-to-wait counters */
- next_sample_evtime -= best_evtime;
+ /* Decrease time-to-wait counters */
+ next_sample_evtime -= best_evtime;
- if (sample_prehandler && (currprefs.produce_sound > 1)) {
- sample_prehandler(best_evtime / CYCLE_UNIT);
- }
+ if (sample_prehandler && (currprefs.produce_sound > 1)) {
+ sample_prehandler(best_evtime / CYCLE_UNIT);
+ }
- for (i = 0; i < AUDIO_CHANNELS_PAULA; i++) {
- if (audio_channel[i].evtime != MAX_EV)
- audio_channel[i].evtime -= best_evtime;
- }
+ for (i = 0; i < 4; i++) {
+ if (audio_channel[i].evtime != MAX_EV)
+ audio_channel[i].evtime -= best_evtime;
+ }
- n_cycles -= best_evtime;
+ n_cycles -= best_evtime;
- /* Test if new sample needs to be outputted */
- if ((rounded == best_evtime) && (currprefs.produce_sound > 1)) {
- next_sample_evtime += scaled_sample_evtime;
- (*sample_handler) ();
- }
+ /* Test if new sample needs to be outputted */
+ if ((rounded == best_evtime) && (currprefs.produce_sound > 1)) {
+ next_sample_evtime += scaled_sample_evtime;
+ (*sample_handler)();
+ }
- for (i = 0; i < AUDIO_CHANNELS_PAULA; i++) {
+ for (i = 0; i < 4; i++) {
if (audio_channel[i].evtime == 0) {
- audio_state_channel (i, true);
+ audio_state_channel(i, true);
+ if (audio_channel[i].evtime == 0) {
+ write_log(_T("evtime==0 sound bug channel %d\n"), i);
+ audio_channel[i].evtime = MAX_EV;
+ }
}
- }
+ }
}
end:
- last_cycles = get_cycles () - n_cycles;
+ last_cycles = get_cycles() - n_cycles;
}
-void audio_evhandler (void)
+void audio_evhandler(void)
{
- update_audio ();
- schedule_audio ();
+ update_audio();
+ schedule_audio();
}
-void audio_hsync (void)
+void audio_hsync(void)
{
- if (!isaudio())
- return;
+ if (!isaudio())
+ return;
if (audio_work_to_do > 0) {
- audio_work_to_do--;
- if (audio_work_to_do == 0)
- audio_deactivate();
- }
- update_audio();
+ audio_work_to_do--;
+ if (audio_work_to_do == 0)
+ audio_deactivate();
+ }
+
+ update_audio();
}
-void AUDxDAT (int nr, uae_u16 v)
+void AUDxDAT(int nr, uae_u16 v, uaecptr addr)
{
struct audio_channel_data *cdp = audio_channel + nr;
int chan_ena = (dmacon & DMA_MASTER) && (dmacon & (1 << nr));
+#if DEBUG_AUDIO > 0
+ if (debugchannel(nr) && (DEBUG_AUDIO > 1 || (!chan_ena || addr == 0xffffffff || (cdp->state != 2 && cdp->state != 3)))) {
+ write_log(_T("AUD%dDAT: %04X ADDR=%08X LEN=%d/%d %d,%d,%d %06X\n"), nr,
+ v, addr, cdp->wlen, cdp->len, cdp->state, chan_ena, isirq(nr) ? 1 : 0, M68K_GETPC);
+ }
+#endif
cdp->dat = v;
cdp->dat_written = true;
+#if TEST_AUDIO > 0
+ if (debugchannel(nr) && cdp->have_dat)
+ write_log(_T("%d: audxdat 1=%04x 2=%04x but old dat not yet used\n"), nr, cdp->dat, cdp->dat2);
+ cdp->have_dat = true;
+#endif
if (cdp->state == 2 || cdp->state == 3) {
if (chan_ena) {
if (cdp->wlen == 1) {
cdp->wlen = cdp->len;
cdp->intreq2 = true;
- } else {
+ //if (sampleripper_enabled)
+ // do_samplerip(cdp);
+#if DEBUG_AUDIO > 0
+ if (debugchannel(nr) && cdp->wlen > 1)
+ write_log(_T("AUD%d looped, IRQ=%d, LC=%08X LEN=%d\n"), nr, isirq(nr) ? 1 : 0, cdp->pt, cdp->wlen);
+#endif
+ }
+ else {
cdp->wlen = (cdp->wlen - 1) & 0xffff;
}
}
- } else {
- audio_activate ();
- update_audio ();
- audio_state_channel (nr, false);
- schedule_audio ();
- events_schedule ();
+ }
+ else {
+ audio_activate();
+ update_audio();
+ audio_state_channel(nr, false);
+ schedule_audio();
+ events_schedule();
}
cdp->dat_written = false;
}
+void AUDxDAT(int nr, uae_u16 v)
+{
+ AUDxDAT(nr, v, 0xffffffff);
+}
-void audio_dmal_do (int nr, bool reset)
+uaecptr audio_getpt(int nr, bool reset)
{
struct audio_channel_data *cdp = audio_channel + nr;
- uae_u16 dat = chipmem_wget_indirect (cdp->pt);
- cdp->pt += 2;
+ uaecptr p = cdp->pt;
+ cdp->pt += 2;
if (reset)
cdp->pt = cdp->lc;
cdp->ptx_tofetch = false;
- AUDxDAT (nr, dat);
+ return p;
}
-void AUDxLCH (int nr, uae_u16 v)
+void AUDxLCH(int nr, uae_u16 v)
{
struct audio_channel_data *cdp = audio_channel + nr;
- audio_activate();
- update_audio ();
+ audio_activate();
+ update_audio();
- // someone wants to update PT but DSR has not yet been processed.
- // too fast CPU and some tracker players: enable DMA, CPU delay, update AUDxPT with loop position
+ // someone wants to update PT but DSR has not yet been processed.
+ // too fast CPU and some tracker players: enable DMA, CPU delay, update AUDxPT with loop position
if (usehacks() && ((cdp->ptx_tofetch && cdp->state == 1) || cdp->ptx_written)) {
cdp->ptx = cdp->lc;
cdp->ptx_written = true;
- } else {
- cdp->lc = (cdp->lc & 0xffff) | ((uae_u32)v << 16);
- }
+ }
+ else {
+ cdp->lc = (cdp->lc & 0xffff) | ((uae_u32)v << 16);
+ }
}
-void AUDxLCL (int nr, uae_u16 v)
+void AUDxLCL(int nr, uae_u16 v)
{
struct audio_channel_data *cdp = audio_channel + nr;
- audio_activate();
- update_audio ();
+ audio_activate();
+ update_audio();
if (usehacks() && ((cdp->ptx_tofetch && cdp->state == 1) || cdp->ptx_written)) {
cdp->ptx = cdp->lc;
cdp->ptx_written = true;
- } else {
- cdp->lc = (cdp->lc & ~0xffff) | (v & 0xFFFE);
- }
+ }
+ else {
+ cdp->lc = (cdp->lc & ~0xffff) | (v & 0xFFFE);
+ }
}
-void AUDxPER (int nr, uae_u16 v)
+void AUDxPER(int nr, uae_u16 v)
{
struct audio_channel_data *cdp = audio_channel + nr;
unsigned long per;
- audio_activate();
- update_audio ();
+ audio_activate();
+ update_audio();
per = v * CYCLE_UNIT;
- if (per == 0)
- per = PERIOD_MAX - 1;
+ if (per == 0)
+ per = PERIOD_MAX - 1;
if (per < PERIOD_MIN * CYCLE_UNIT) {
/* smaller values would cause extremely high cpu usage */
@@ -1443,113 +1454,116 @@ void AUDxPER (int nr, uae_u16 v)
per = PERIOD_MIN_NONCE * CYCLE_UNIT;
}
- if (cdp->per == PERIOD_MAX - 1 && per != PERIOD_MAX - 1) {
- cdp->evtime = CYCLE_UNIT;
- if (isaudio()) {
- schedule_audio ();
- events_schedule ();
- }
- }
- cdp->per = per;
+ if (cdp->per == PERIOD_MAX - 1 && per != PERIOD_MAX - 1) {
+ cdp->evtime = CYCLE_UNIT;
+ if (isaudio()) {
+ schedule_audio();
+ events_schedule();
+ }
+ }
+ cdp->per = per;
}
-void AUDxLEN (int nr, uae_u16 v)
+void AUDxLEN(int nr, uae_u16 v)
{
struct audio_channel_data *cdp = audio_channel + nr;
- audio_activate();
- update_audio ();
- cdp->len = v;
+ audio_activate();
+ update_audio();
+ cdp->len = v;
}
-void AUDxVOL (int nr, uae_u16 v)
+void AUDxVOL(int nr, uae_u16 v)
{
struct audio_channel_data *cdp = audio_channel + nr;
-
- audio_activate();
- update_audio ();
- update_volume(nr, v);
+ // 7 bit register in Paula.
+ v &= 127;
+ if (v > 64)
+ v = 64;
+ audio_activate();
+ update_audio();
+ cdp->vol = v;
}
-void audio_update_adkmasks (void)
+void audio_update_adkmasks(void)
{
- static int prevcon = -1;
- unsigned long t = adkcon | (adkcon >> 4);
+ static int prevcon = -1;
+ unsigned long t = adkcon | (adkcon >> 4);
- audio_channel[0].data.adk_mask = (((t >> 0) & 1) - 1);
- audio_channel[1].data.adk_mask = (((t >> 1) & 1) - 1);
- audio_channel[2].data.adk_mask = (((t >> 2) & 1) - 1);
- audio_channel[3].data.adk_mask = (((t >> 3) & 1) - 1);
- if ((prevcon & 0xff) != (adkcon & 0xff)) {
- audio_activate();
- prevcon = adkcon;
- }
+ audio_channel[0].adk_mask = (((t >> 0) & 1) - 1);
+ audio_channel[1].adk_mask = (((t >> 1) & 1) - 1);
+ audio_channel[2].adk_mask = (((t >> 2) & 1) - 1);
+ audio_channel[3].adk_mask = (((t >> 3) & 1) - 1);
+ if ((prevcon & 0xff) != (adkcon & 0xff)) {
+ audio_activate();
+ prevcon = adkcon;
+ }
}
-int init_audio (void)
+int init_audio(void)
{
- return init_sound ();
+ return init_sound();
}
-void led_filter_audio (void)
+void led_filter_audio(void)
{
- led_filter_on = 0;
- if (led_filter_forced > 0 || (gui_data.powerled && led_filter_forced >= 0))
- led_filter_on = 1;
+ led_filter_on = 0;
+ if (led_filter_forced > 0 || (gui_data.powerled && led_filter_forced >= 0))
+ led_filter_on = 1;
}
-void restore_audio_finish (void)
+void restore_audio_finish(void)
{
- last_cycles = get_cycles ();
- schedule_audio ();
- events_schedule ();
+ last_cycles = get_cycles();
+ schedule_audio();
+ events_schedule();
}
-uae_u8 *restore_audio (int nr, uae_u8 *src)
+uae_u8 *restore_audio(int nr, uae_u8 *src)
{
- struct audio_channel_data *acd = audio_channel + nr;
+ struct audio_channel_data *acd = audio_channel + nr;
- zerostate (nr);
- acd->state = restore_u8 ();
- acd->data.vol = restore_u8 ();
- acd->intreq2 = restore_u8 () ? true : false;
- uae_u8 flags = restore_u8 ();
+ zerostate(nr);
+ acd->state = restore_u8();
+ acd->vol = restore_u8();
+ acd->intreq2 = restore_u8() ? true : false;
+ uae_u8 flags = restore_u8();
acd->dr = acd->dsr = false;
if (flags & 1)
acd->dr = true;
if (flags & 2)
acd->dsr = true;
- acd->len = restore_u16 ();
- acd->wlen = restore_u16 ();
- uae_u16 p = restore_u16 ();
- acd->per = p ? p * CYCLE_UNIT : PERIOD_MAX;
- acd->dat = acd->dat2 = restore_u16 ();
- acd->lc = restore_u32 ();
- acd->pt = restore_u32 ();
- acd->evtime = restore_u32 ();
+ acd->len = restore_u16();
+ acd->wlen = restore_u16();
+ uae_u16 p = restore_u16();
+ acd->per = p ? p * CYCLE_UNIT : PERIOD_MAX;
+ acd->dat = acd->dat2 = restore_u16();
+ acd->lc = restore_u32();
+ acd->pt = restore_u32();
+ acd->evtime = restore_u32();
acd->dmaenstore = (dmacon & DMA_MASTER) && (dmacon & (1 << nr));
- return src;
+ return src;
}
-uae_u8 *save_audio (int nr, int *len, uae_u8 *dstptr)
+uae_u8 *save_audio(int nr, int *len, uae_u8 *dstptr)
{
struct audio_channel_data *acd = audio_channel + nr;
- uae_u8 *dst, *dstbak;
+ uae_u8 *dst, *dstbak;
- if (dstptr)
- dstbak = dst = dstptr;
- else
- dstbak = dst = xmalloc (uae_u8, 100);
- save_u8 (acd->state);
- save_u8 (acd->data.vol);
- save_u8 (acd->intreq2);
- save_u8 ((acd->dr ? 1 : 0) | (acd->dsr ? 2 : 0) | 0x80);
- save_u16 (acd->len);
- save_u16 (acd->wlen);
- save_u16 (acd->per == PERIOD_MAX ? 0 : acd->per / CYCLE_UNIT);
- save_u16 (acd->dat);
- save_u32 (acd->lc);
- save_u32 (acd->pt);
- save_u32 (acd->evtime);
- *len = dst - dstbak;
- return dstbak;
-}
+ if (dstptr)
+ dstbak = dst = dstptr;
+ else
+ dstbak = dst = xmalloc(uae_u8, 100);
+ save_u8(acd->state);
+ save_u8(acd->vol);
+ save_u8(acd->intreq2);
+ save_u8((acd->dr ? 1 : 0) | (acd->dsr ? 2 : 0) | 0x80);
+ save_u16(acd->len);
+ save_u16(acd->wlen);
+ save_u16(acd->per == PERIOD_MAX ? 0 : acd->per / CYCLE_UNIT);
+ save_u16(acd->dat);
+ save_u32(acd->lc);
+ save_u32(acd->pt);
+ save_u32(acd->evtime);
+ *len = dst - dstbak;
+ return dstbak;
+}
\ No newline at end of file
diff --git a/src/autoconf.cpp b/src/autoconf.cpp
index 576f4e16..b5219bb9 100644
--- a/src/autoconf.cpp
+++ b/src/autoconf.cpp
@@ -1,23 +1,30 @@
- /*
- * UAE - The Un*x Amiga Emulator
- *
- * AutoConfig devices
- *
- * Copyright 1995, 1996 Bernd Schmidt
- * Copyright 1996 Ed Hanway
- */
+/*
+* UAE - The Un*x Amiga Emulator
+*
+* AutoConfig devices
+*
+* Copyright 1995, 1996 Bernd Schmidt
+* Copyright 1996 Ed Hanway
+*/
#include "sysconfig.h"
#include "sysdeps.h"
+#define NEW_TRAP_DEBUG 0
+
#include "options.h"
#include "uae.h"
#include "memory.h"
#include "custom.h"
+#include "events.h"
#include "newcpu.h"
#include "autoconf.h"
#include "traps.h"
+#include "debug.h"
+#include "threaddep/thread.h"
+#include "native2amiga.h"
#include "inputdevice.h"
+//#include "uae/ppc.h"
/* Commonly used autoconfig strings */
@@ -28,33 +35,83 @@ uaecptr EXPANSION_bootcode, EXPANSION_nullfunc;
/* ROM tag area memory access */
uaecptr rtarea_base = RTAREA_DEFAULT;
+uae_sem_t hardware_trap_event[RTAREA_TRAP_DATA_SIZE / RTAREA_TRAP_DATA_SLOT_SIZE];
+uae_sem_t hardware_trap_event2[RTAREA_TRAP_DATA_SIZE / RTAREA_TRAP_DATA_SLOT_SIZE];
+
+static uaecptr rt_trampoline_ptr, trap_entry;
+static bool rtarea_write_enabled;
+extern volatile uae_atomic hwtrap_waiting;
+extern volatile int trap_mode;
DECLARE_MEMORY_FUNCTIONS(rtarea);
addrbank rtarea_bank = {
- rtarea_lget, rtarea_wget, rtarea_bget,
- rtarea_lput, rtarea_wput, rtarea_bput,
+ rtarea_lget, rtarea_wget, rtarea_bget,
+ rtarea_lput, rtarea_wput, rtarea_bput,
rtarea_xlate, rtarea_check, NULL, _T("rtarea"), _T("UAE Boot ROM"),
rtarea_lget, rtarea_wget,
- ABFLAG_ROMIN, S_READ, S_WRITE
+ ABFLAG_ROMIN | ABFLAG_PPCIOSPACE, S_READ, S_WRITE
};
+#define MAX_ABSOLUTE_ROM_ADDRESS 1024
+
+static int absolute_rom_address;
+static uaecptr absolute_rom_addresses[MAX_ABSOLUTE_ROM_ADDRESS];
+static uaecptr rombase_new;
+
+static bool istrapwait(void)
+{
+ for (int i = 0; i < RTAREA_TRAP_DATA_NUM + RTAREA_TRAP_DATA_SEND_NUM; i++) {
+ uae_u8 *data = rtarea_bank.baseaddr + RTAREA_TRAP_DATA + i * RTAREA_TRAP_DATA_SLOT_SIZE;
+ uae_u8 *status = rtarea_bank.baseaddr + RTAREA_TRAP_STATUS + i * RTAREA_TRAP_STATUS_SIZE;
+ if (get_long_host(data + RTAREA_TRAP_DATA_TASKWAIT) && status[3] && status[2] >= 0x80) {
+ return true;
+ }
+ }
+ return false;
+}
+
#define RTAREA_WRITEOFFSET 0xfff0
-static uae_u8 *REGPARAM2 rtarea_xlate (uaecptr addr)
+static bool rtarea_trap_data(uaecptr addr)
{
- addr &= 0xFFFF;
+ if (currprefs.uaeboard < 2)
+ return false;
+ if (addr >= RTAREA_TRAP_DATA && addr < RTAREA_TRAP_DATA + (RTAREA_TRAP_DATA_NUM + RTAREA_TRAP_DATA_SEND_NUM) * RTAREA_TRAP_DATA_SLOT_SIZE)
+ return true;
+ return false;
+}
+static bool rtarea_trap_status(uaecptr addr)
+{
+ if (currprefs.uaeboard < 2)
+ return false;
+ if (addr >= RTAREA_TRAP_STATUS && addr < RTAREA_TRAP_STATUS + (RTAREA_TRAP_DATA_NUM + RTAREA_TRAP_DATA_SEND_NUM) * RTAREA_TRAP_STATUS_SIZE)
+ return true;
+ return false;
+}
+static bool rtarea_trap_status_extra(uaecptr addr)
+{
+ if (currprefs.uaeboard < 2)
+ return false;
+ if (addr >= RTAREA_TRAP_STATUS + 0x100 && addr < RTAREA_TRAP_STATUS + 0x100 + (RTAREA_TRAP_DATA_NUM + RTAREA_TRAP_DATA_SEND_NUM) * RTAREA_TRAP_STATUS_SIZE)
+ return true;
+ return false;
+}
+
+static uae_u8 *REGPARAM2 rtarea_xlate(uaecptr addr)
+{
+ addr &= 0xFFFF;
return rtarea_bank.baseaddr + addr;
}
-static int REGPARAM2 rtarea_check (uaecptr addr, uae_u32 size)
+static int REGPARAM2 rtarea_check(uaecptr addr, uae_u32 size)
{
- addr &= 0xFFFF;
- return (addr + size) <= 0xFFFF;
+ addr &= 0xFFFF;
+ return (addr + size) <= 0xFFFF;
}
-static uae_u32 REGPARAM2 rtarea_lget (uaecptr addr)
+static uae_u32 REGPARAM2 rtarea_lget(uaecptr addr)
{
- addr &= 0xFFFF;
+ addr &= 0xFFFF;
if (addr & 1)
return 0;
if (addr >= 0xfffd)
@@ -62,114 +119,96 @@ static uae_u32 REGPARAM2 rtarea_lget (uaecptr addr)
return (rtarea_bank.baseaddr[addr + 0] << 24) | (rtarea_bank.baseaddr[addr + 1] << 16) |
(rtarea_bank.baseaddr[addr + 2] << 8) | (rtarea_bank.baseaddr[addr + 3] << 0);
}
-static uae_u32 REGPARAM2 rtarea_wget (uaecptr addr)
+static uae_u32 REGPARAM2 rtarea_wget(uaecptr addr)
{
- addr &= 0xFFFF;
+ addr &= 0xFFFF;
if (addr & 1)
return 0;
+ uaecptr addr2 = addr - RTAREA_TRAP_STATUS;
+
+ if (rtarea_trap_status(addr)) {
+ int trap_offset = addr2 & (RTAREA_TRAP_STATUS_SIZE - 1);
+ int trap_slot = addr2 / RTAREA_TRAP_STATUS_SIZE;
+ // lock attempt
+ if (trap_offset == 2) {
+ if (rtarea_bank.baseaddr[addr + 1] & 0x80) {
+ return rtarea_bank.baseaddr[addr + 1];
+ }
+ rtarea_bank.baseaddr[addr + 1] |= 0x80;
+ rtarea_bank.baseaddr[addr + 0] = 0;
+ return 0;
+ }
+ }
return (rtarea_bank.baseaddr[addr] << 8) + rtarea_bank.baseaddr[addr + 1];
}
-static uae_u32 REGPARAM2 rtarea_bget (uaecptr addr)
+static uae_u32 REGPARAM2 rtarea_bget(uaecptr addr)
{
- addr &= 0xFFFF;
-
- if (addr == RTAREA_INTREQ + 0) {
- rtarea_bank.baseaddr[addr] = atomic_bit_test_and_reset(&uae_int_requested, 0);
- //write_log(rtarea_bank.baseaddr[addr] ? _T("+") : _T("-"));
- } else if (addr == RTAREA_INTREQ + 1) {
- rtarea_bank.baseaddr[addr] = 0;
- } else if (addr == RTAREA_INTREQ + 2) {
- rtarea_bank.baseaddr[addr] = 0;
- }
- return rtarea_bank.baseaddr[addr];
+ addr &= 0xFFFF;
+ return rtarea_bank.baseaddr[addr];
}
static bool rtarea_write(uaecptr addr)
{
+ if (rtarea_write_enabled)
+ return true;
if (addr >= RTAREA_WRITEOFFSET)
return true;
if (addr >= RTAREA_SYSBASE && addr < RTAREA_SYSBASE + 4)
return true;
- return false;
+ return rtarea_trap_data(addr) || rtarea_trap_status(addr) || rtarea_trap_status_extra(addr);
}
-static void REGPARAM2 rtarea_bput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 rtarea_bput(uaecptr addr, uae_u32 value)
{
addr &= 0xffff;
if (!rtarea_write(addr))
return;
rtarea_bank.baseaddr[addr] = value;
- if (addr == RTAREA_INTREQ + 3) {
- mousehack_wakeup();
- }
}
-static void REGPARAM2 rtarea_wput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 rtarea_wput(uaecptr addr, uae_u32 value)
{
addr &= 0xffff;
- value &= 0xffff;
-
- if (addr & 1)
+ if (addr < RTAREA_WRITEOFFSET)
return;
-
- if (!rtarea_write(addr))
- return;
-
- rtarea_bank.baseaddr[addr + 0] = value >> 8;
- rtarea_bank.baseaddr[addr + 1] = (uae_u8)value;
+ rtarea_bput(addr, value >> 8);
+ rtarea_bput(addr + 1, value & 0xff);
}
-static void REGPARAM2 rtarea_lput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 rtarea_lput(uaecptr addr, uae_u32 value)
{
addr &= 0xffff;
- if (addr & 1)
+ if (addr < RTAREA_WRITEOFFSET)
return;
- if (addr >= 0xfffd)
- return;
- if (!rtarea_write(addr))
- return;
- rtarea_bank.baseaddr[addr + 0] = value >> 24;
- rtarea_bank.baseaddr[addr + 1] = value >> 16;
- rtarea_bank.baseaddr[addr + 2] = value >> 8;
- rtarea_bank.baseaddr[addr + 3] = value >> 0;
-}
-
-void rtarea_reset(void)
-{
- uae_u8 *p = rtarea_bank.baseaddr;
- if (p) {
- memset(p + RTAREA_TRAP_DATA, 0, RTAREA_TRAP_DATA_SLOT_SIZE * (RTAREA_TRAP_DATA_NUM + RTAREA_TRAP_DATA_SEND_NUM));
- memset(p + RTAREA_TRAP_STATUS, 0, RTAREA_TRAP_STATUS_SIZE * (RTAREA_TRAP_DATA_NUM + RTAREA_TRAP_DATA_SEND_NUM));
- memset(p + RTAREA_HEARTBEAT, 0, 0x10000 - RTAREA_HEARTBEAT);
- memset(p + RTAREA_VARIABLES, 0, RTAREA_VARIABLES_SIZE);
- }
+ rtarea_wput(addr, value >> 16);
+ rtarea_wput(addr + 2, value & 0xffff);
}
/* some quick & dirty code to fill in the rt area and save me a lot of
- * scratch paper
- */
+* scratch paper
+*/
static int rt_addr;
static int rt_straddr;
-uae_u32 addr (int ptr)
+uae_u32 addr(int ptr)
{
- return (uae_u32)ptr + rtarea_base;
+ return (uae_u32)ptr + rtarea_base;
}
-void db (uae_u8 data)
+void db(uae_u8 data)
{
rtarea_bank.baseaddr[rt_addr++] = data;
}
-void dw (uae_u16 data)
+void dw(uae_u16 data)
{
rtarea_bank.baseaddr[rt_addr++] = (uae_u8)(data >> 8);
rtarea_bank.baseaddr[rt_addr++] = (uae_u8)data;
}
-void dl (uae_u32 data)
+void dl(uae_u32 data)
{
rtarea_bank.baseaddr[rt_addr++] = data >> 24;
rtarea_bank.baseaddr[rt_addr++] = data >> 16;
@@ -177,102 +216,198 @@ void dl (uae_u32 data)
rtarea_bank.baseaddr[rt_addr++] = data;
}
-uae_u8 dbg (uaecptr addr)
+uae_u8 dbg(uaecptr addr)
{
- addr -= rtarea_base;
+ addr -= rtarea_base;
return rtarea_bank.baseaddr[addr];
}
/* store strings starting at the end of the rt area and working
- * backward. store pointer at current address
- */
+* backward. store pointer at current address
+*/
-uae_u32 ds_ansi (const uae_char *str)
+uae_u32 ds_ansi(const uae_char *str)
{
- int len;
+ int len;
- if (!str)
- return addr (rt_straddr);
- len = strlen (str) + 1;
- rt_straddr -= len;
- strcpy ((uae_char*)rtarea_bank.baseaddr + rt_straddr, str);
- return addr (rt_straddr);
+ if (!str)
+ return addr(rt_straddr);
+ len = strlen(str) + 1;
+ rt_straddr -= len;
+ strcpy((uae_char*)rtarea_bank.baseaddr + rt_straddr, str);
+ return addr(rt_straddr);
}
-uae_u32 ds (const TCHAR *str)
+uae_u32 ds(const TCHAR *str)
{
- char *s = ua (str);
- uae_u32 v = ds_ansi (s);
- xfree (s);
+ char *s = ua(str);
+ uae_u32 v = ds_ansi(s);
+ xfree(s);
return v;
}
-uae_u32 ds_bstr_ansi (const uae_char *str)
+uae_u32 ds_bstr_ansi(const uae_char *str)
{
int len;
-
- len = strlen (str) + 2;
+
+ len = strlen(str) + 2;
rt_straddr -= len;
while (rt_straddr & 3)
rt_straddr--;
rtarea_bank.baseaddr[rt_straddr] = len - 2;
- strcpy ((uae_char*)rtarea_bank.baseaddr + rt_straddr + 1, str);
- return addr (rt_straddr) >> 2;
+ strcpy((uae_char*)rtarea_bank.baseaddr + rt_straddr + 1, str);
+ return addr(rt_straddr) >> 2;
}
-void calltrap (uae_u32 n)
+void save_rom_absolute(uaecptr addr)
{
- dw (0xA000 + n);
+ if (rombase_new)
+ return;
+ if (absolute_rom_address >= MAX_ABSOLUTE_ROM_ADDRESS) {
+ write_log(_T("MAX_ABSOLUTE_ROM_ADDRESS is too low!"));
+ abort();
+ }
+ for (int i = 0; i < absolute_rom_address; i++) {
+ if (absolute_rom_addresses[i] == addr) {
+ write_log(_T("Address %08x already added\n"), addr);
+ return;
+ }
+ }
+ absolute_rom_addresses[absolute_rom_address++] = addr;
}
-void org (uae_u32 a)
+void add_rom_absolute(uaecptr addr)
{
- if ( ((a & 0xffff0000) != 0x00f00000) && ((a & 0xffff0000) != rtarea_base) )
- write_log (_T("ORG: corrupt address! %08X"), a);
- rt_addr = a & 0xffff;
+ uaecptr h = here();
+ dl(addr);
+ save_rom_absolute(h);
}
-uae_u32 here (void)
+uae_u32 boot_rom_copy(TrapContext *ctx, uaecptr rombase, int mode)
{
- return addr (rt_addr);
+ uaecptr reloc = 0;
+ if (currprefs.uaeboard < 3)
+ return 0;
+ if (!mode) {
+ rtarea_write_enabled = true;
+ protect_roms(false);
+ rombase_new = rombase;
+ int size = 4 + 2 + 4;
+ for (int i = 0; i < absolute_rom_address; i++) {
+ uae_u32 a = absolute_rom_addresses[i];
+ if (a >= rtarea_base && a < rtarea_base + 0x10000) {
+ size += 2;
+ }
+ else {
+ size += 4;
+ }
+ }
+ reloc = uaeboard_alloc_ram(size);
+ uae_u8 *p = uaeboard_map_ram(reloc);
+ put_long_host(p, rtarea_base);
+ p += 4;
+ for (int i = 0; i < absolute_rom_address; i++) {
+ uae_u32 a = absolute_rom_addresses[i];
+ if (a >= rtarea_base && a < rtarea_base + 0x10000) {
+ put_word_host(p, a & 0xffff);
+ p += 2;
+ }
+ }
+ put_word_host(p, 0);
+ p += 2;
+ for (int i = 0; i < absolute_rom_address; i++) {
+ uae_u32 a = absolute_rom_addresses[i];
+ if (a < rtarea_base || a >= rtarea_base + 0x10000) {
+ put_long_host(p, a);
+ p += 4;
+ }
+ }
+ put_long_host(p, 0);
+ write_log(_T("ROMBASE %08x RAMBASE %08x RELOC %08x (%d)\n"), rtarea_base, rombase, reloc, absolute_rom_address);
+ }
+ else {
+ rtarea_write_enabled = false;
+ protect_roms(true);
+ write_log(_T("ROMBASE changed.\n"), absolute_rom_address);
+ reloc = 1;
+ }
+ return reloc;
}
-void align (int b)
+void calltrap(uae_u32 n)
{
- rt_addr = (rt_addr + b - 1) & ~(b - 1);
+ if (currprefs.uaeboard > 2) {
+ dw(0x4eb9); // JSR rt_trampoline_ptr
+ add_rom_absolute(rt_trampoline_ptr);
+ uaecptr a = here();
+ org(rt_trampoline_ptr);
+ dw(0x3f3c); // MOVE.W #n,-(SP)
+ dw(n);
+ dw(0x4ef9); // JMP rt_trampoline_entry
+ add_rom_absolute(trap_entry);
+ org(a);
+ rt_trampoline_ptr += 3 * 2 + 1 * 4;
+ }
+ else {
+ dw(0xA000 + n);
+ }
+}
+
+void org(uae_u32 a)
+{
+ if (((a & 0xffff0000) != 0x00f00000) && ((a & 0xffff0000) != rtarea_base))
+ write_log(_T("ORG: corrupt address! %08X"), a);
+ rt_addr = a & 0xffff;
+}
+
+uae_u32 here(void)
+{
+ return addr(rt_addr);
+}
+
+void align(int b)
+{
+ rt_addr = (rt_addr + b - 1) & ~(b - 1);
}
static uae_u32 REGPARAM2 nullfunc(TrapContext *ctx)
{
- write_log (_T("Null function called\n"));
- return 0;
+ write_log(_T("Null function called\n"));
+ return 0;
}
-static uae_u32 REGPARAM2 getchipmemsize (TrapContext *ctx)
+static uae_u32 REGPARAM2 getchipmemsize(TrapContext *ctx)
{
- trap_set_dreg(ctx, 1, 0);
- trap_set_areg(ctx, 1, 0);
- return chipmem_bank.allocated_size;
+ m68k_dreg(regs, 1) = z3chipmem_bank.allocated_size;
+ m68k_dreg(regs, 1) = z3chipmem_bank.start;
+ return chipmem_bank.allocated_size;
}
-static uae_u32 REGPARAM2 uae_puts (TrapContext *ctx)
+static uae_u32 REGPARAM2 uae_puts(TrapContext *ctx)
{
uae_char buf[MAX_DPATH];
- trap_get_string(ctx, buf, trap_get_areg(ctx, 0), sizeof (uae_char));
- write_log(_T("%s"), buf);
- return 0;
+ //trap_get_string(ctx, buf, trap_get_areg(ctx, 0), sizeof uae_char);
+ TCHAR *s = au(buf);
+ write_log(_T("%s"), s);
+ xfree(s);
+ return 0;
}
-void rtarea_init_mem (void)
+void rtarea_init_mem(void)
{
+ if (need_uae_boot_rom(&currprefs)) {
+ rtarea_bank.flags &= ~ABFLAG_ALLOCINDIRECT;
+ }
+ else {
+ // not enabled and something else may use same address space
+ rtarea_bank.flags |= ABFLAG_ALLOCINDIRECT;
+ }
rtarea_bank.reserved_size = RTAREA_SIZE;
rtarea_bank.start = rtarea_base;
- if (!mapped_malloc (&rtarea_bank)) {
- write_log (_T("virtual memory exhausted (rtarea)!\n"));
- target_startup_msg(_T("Internal error"), _T("Virtual memory exhausted (rtarea)."));
- uae_restart(1, NULL);
- return;
- }
+ if (!mapped_malloc(&rtarea_bank)) {
+ write_log(_T("virtual memory exhausted (rtarea)!\n"));
+ abort();
+ }
}
void rtarea_free(void)
@@ -280,102 +415,106 @@ void rtarea_free(void)
mapped_free(&rtarea_bank);
}
-void rtarea_init (void)
+void rtarea_init(void)
{
- uae_u32 a;
- TCHAR uaever[100];
+ uae_u32 a;
+ TCHAR uaever[100];
- rt_straddr = 0xFF00 - 2;
- rt_addr = 0;
+ rt_straddr = 0xFF00 - 2;
+ rt_addr = 0;
- init_traps ();
+ rt_trampoline_ptr = rtarea_base + RTAREA_TRAMPOLINE;
+ trap_entry = 0;
+ absolute_rom_address = 0;
+ rombase_new = 0;
- rtarea_init_mem ();
- memset (rtarea_bank.baseaddr, 0, RTAREA_SIZE);
+ init_traps();
- _stprintf (uaever, _T("uae-%d.%d.%d"), UAEMAJOR, UAEMINOR, UAESUBREV);
+ rtarea_init_mem();
+ memset(rtarea_bank.baseaddr, 0, RTAREA_SIZE);
- EXPANSION_uaeversion = ds (uaever);
- EXPANSION_explibname = ds (_T("expansion.library"));
- EXPANSION_doslibname = ds (_T("dos.library"));
- EXPANSION_uaedevname = ds (_T("uae.device"));
+ _stprintf(uaever, _T("uae-%d.%d.%d"), UAEMAJOR, UAEMINOR, UAESUBREV);
- dw (0);
- dw (0);
+ EXPANSION_uaeversion = ds(uaever);
+ EXPANSION_explibname = ds(_T("expansion.library"));
+ EXPANSION_doslibname = ds(_T("dos.library"));
+ EXPANSION_uaedevname = ds(_T("uae.device"));
+
+ dw(0);
+ dw(0);
#ifdef FILESYS
- filesys_install_code ();
+ filesys_install_code();
#endif
- deftrap (NULL); /* Generic emulator trap */
+ deftrap(NULL); /* Generic emulator trap */
- a = here();
- /* Dummy trap - removing this breaks the filesys emulation. */
- org (rtarea_base + 0xFF00);
- calltrap (deftrap2 (nullfunc, TRAPFLAG_NO_RETVAL, _T("")));
+ a = here();
+ /* Dummy trap - removing this breaks the filesys emulation. */
+ org(rtarea_base + 0xFF00);
+ calltrap(deftrap2(nullfunc, TRAPFLAG_NO_RETVAL, _T("")));
- org (rtarea_base + 0xFF80);
- calltrap (deftrapres (getchipmemsize, TRAPFLAG_DORET, _T("getchipmemsize")));
+ org(rtarea_base + 0xFF80);
+ calltrap(deftrapres(getchipmemsize, TRAPFLAG_DORET, _T("getchipmemsize")));
dw(RTS);
- org (rtarea_base + 0xFF10);
- calltrap (deftrapres (uae_puts, TRAPFLAG_NO_RETVAL, _T("uae_puts")));
- dw (RTS);
+ org(rtarea_base + 0xFF10);
+ calltrap(deftrapres(uae_puts, TRAPFLAG_NO_RETVAL, _T("uae_puts")));
+ dw(RTS);
- org (a);
-
- uae_boot_rom_size = here () - rtarea_base;
+ org(a);
+
+ uae_boot_rom_size = here() - rtarea_base;
if (uae_boot_rom_size >= RTAREA_TRAPS) {
- write_log (_T("RTAREA_TRAPS needs to be increased!"));
- target_startup_msg(_T("Internal error"), _T("RTAREA_TRAPS needs to be increased."));
- uae_restart(1, NULL);
- return;
+ write_log(_T("RTAREA_TRAPS needs to be increased!"));
+ abort();
}
#ifdef PICASSO96
- uaegfx_install_code (rtarea_base + RTAREA_RTG);
+ uaegfx_install_code(rtarea_base + RTAREA_RTG);
#endif
- org (RTAREA_TRAPS | rtarea_base);
- init_extended_traps();
+ org(RTAREA_TRAPS | rtarea_base);
+ init_extended_traps();
}
-volatile uae_atomic uae_int_requested = 0;
+volatile int uae_int_requested = 0;
void rtarea_setup(void)
{
- uaecptr base = need_uae_boot_rom (&currprefs);
- if (base) {
- write_log (_T("RTAREA located at %08X\n"), base);
- rtarea_base = base;
- }
+ uaecptr base = need_uae_boot_rom(&currprefs);
+ if (base) {
+ write_log(_T("RTAREA located at %08X\n"), base);
+ rtarea_base = base;
+ }
}
-uaecptr makedatatable (uaecptr resid, uaecptr resname, uae_u8 type, uae_s8 priority, uae_u16 ver, uae_u16 rev)
+uaecptr makedatatable(uaecptr resid, uaecptr resname, uae_u8 type, uae_s8 priority, uae_u16 ver, uae_u16 rev)
{
- uaecptr datatable = here ();
+ uaecptr datatable = here();
- dw (0xE000); /* INITBYTE */
- dw (0x0008); /* LN_TYPE */
- dw (type << 8);
- dw (0xE000); /* INITBYTE */
- dw (0x0009); /* LN_PRI */
- dw (priority << 8);
- dw (0xC000); /* INITLONG */
- dw (0x000A); /* LN_NAME */
- dl (resname);
- dw (0xE000); /* INITBYTE */
- dw (0x000E); /* LIB_FLAGS */
- dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */
- dw (0xD000); /* INITWORD */
- dw (0x0014); /* LIB_VERSION */
- dw (ver);
- dw (0xD000); /* INITWORD */
- dw (0x0016); /* LIB_REVISION */
- dw (rev);
- dw (0xC000); /* INITLONG */
- dw (0x0018); /* LIB_IDSTRING */
- dl (resid);
- dw (0x0000); /* end of table */
- return datatable;
+ dw(0xE000); /* INITBYTE */
+ dw(0x0008); /* LN_TYPE */
+ dw(type << 8);
+ dw(0xE000); /* INITBYTE */
+ dw(0x0009); /* LN_PRI */
+ dw(priority << 8);
+ dw(0xC000); /* INITLONG */
+ dw(0x000A); /* LN_NAME */
+ dl(resname);
+ dw(0xE000); /* INITBYTE */
+ dw(0x000E); /* LIB_FLAGS */
+ dw(0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */
+ dw(0xD000); /* INITWORD */
+ dw(0x0014); /* LIB_VERSION */
+ dw(ver);
+ dw(0xD000); /* INITWORD */
+ dw(0x0016); /* LIB_REVISION */
+ dw(rev);
+ dw(0xC000); /* INITLONG */
+ dw(0x0018); /* LIB_IDSTRING */
+ dl(resid);
+ dw(0x0000); /* end of table */
+ return datatable;
}
+
diff --git a/src/blitfunc.cpp b/src/blitfunc.cpp
index 4c3330fc..468ffb61 100644
--- a/src/blitfunc.cpp
+++ b/src/blitfunc.cpp
@@ -1,10 +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 "include/memory.h"
#include "blitter.h"
#include "blitfunc.h"
@@ -18,17 +16,15 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = (0);
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = (0) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
if (ptd) ptd += b->bltdmod;
}
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_0 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
@@ -39,22 +35,21 @@ uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = (0);
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = (0) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
if (ptd) ptd -= b->bltdmod;
}
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
+uae_u32 preva = 0;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -62,14 +57,13 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((~srca & srcc));
+ srca = ((uae_u32(preva) << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((~srca & srcc)) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -78,28 +72,27 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd += b->bltdmod;
}
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
+uae_u32 preva = 0;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((~srca & srcc));
+ srca = ((uae_u32(bltadat) << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((~srca & srcc)) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -108,15 +101,15 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd -= b->bltdmod;
}
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_2a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -124,19 +117,18 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = ((uae_u32(prevb) << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc & ~(srca & srcb)));
+ srca = ((uae_u32(preva) << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc & ~(srca & srcb))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -147,34 +139,33 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_2a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc & ~(srca & srcb)));
+ srca = ((uae_u32(bltadat) << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc & ~(srca & srcb))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -185,15 +176,15 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_30 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 dstd=0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
@@ -201,17 +192,16 @@ for (j = 0; j < b->vblitsize; j++) {
uae_u32 bltadat, srca;
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = ((uae_u32(prevb) << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srca & ~srcb));
+ srca = ((uae_u32(preva) << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srca & ~srcb)) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -220,32 +210,31 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd += b->bltdmod;
}
b->bltbhold = srcb;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_30 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
-uae_u32 dstd=0;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srca & ~srcb));
+ srca = ((uae_u32(bltadat) << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srca & ~srcb)) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -254,15 +243,15 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd -= b->bltdmod;
}
b->bltbhold = srcb;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_3a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -270,19 +259,18 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = ((uae_u32(prevb) << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcb ^ (srca | (srcb ^ srcc))));
+ srca = ((uae_u32(preva) << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcb ^ (srca | (srcb ^ srcc)))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -293,34 +281,33 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_3a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcb ^ (srca | (srcb ^ srcc))));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcb ^ (srca | (srcb ^ srcc)))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -331,15 +318,15 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_3c (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 dstd=0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
@@ -347,17 +334,16 @@ for (j = 0; j < b->vblitsize; j++) {
uae_u32 bltadat, srca;
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srca ^ srcb));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srca ^ srcb)) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -366,32 +352,31 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd += b->bltdmod;
}
b->bltbhold = srcb;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_3c (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
-uae_u32 dstd=0;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srca ^ srcb));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srca ^ srcb)) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -400,15 +385,15 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd -= b->bltdmod;
}
b->bltbhold = srcb;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_4a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -416,19 +401,18 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc ^ (srca & (srcb | srcc))));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc ^ (srca & (srcb | srcc)))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -439,34 +423,33 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_4a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc ^ (srca & (srcb | srcc))));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc ^ (srca & (srcb | srcc)))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -477,15 +460,15 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_6a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -493,19 +476,18 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc ^ (srca & srcb)));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc ^ (srca & srcb))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -516,34 +498,33 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_6a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc ^ (srca & srcb)));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc ^ (srca & srcb))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -554,15 +535,15 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_8a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -570,19 +551,18 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc & (~srca | srcb)));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc & (~srca | srcb))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -593,34 +573,33 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_8a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc & (~srca | srcb)));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc & (~srca | srcb))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -631,15 +610,15 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_8c (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -647,19 +626,18 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcb & (~srca | srcc)));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcb & (~srca | srcc))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -670,34 +648,33 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_8c (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcb & (~srca | srcc)));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcb & (~srca | srcc))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -708,15 +685,15 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_9a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -724,19 +701,18 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc ^ (srca & ~srcb)));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc ^ (srca & ~srcb))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -747,34 +723,33 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_9a (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc ^ (srca & ~srcb)));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc ^ (srca & ~srcb))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -785,15 +760,15 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_a8 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -801,19 +776,18 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc & (srca | srcb)));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc & (srca | srcb))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -824,34 +798,33 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_a8 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc & (srca | srcb)));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc & (srca | srcb))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -862,9 +835,8 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_aa (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
@@ -877,10 +849,9 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = (srcc);
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = (srcc) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -888,24 +859,22 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd += b->bltdmod;
}
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_aa (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = (srcc);
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = (srcc) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -913,15 +882,15 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd -= b->bltdmod;
}
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_b1 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -929,19 +898,18 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = (~(srca ^ (srcc | (srca ^ srcb))));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = (~(srca ^ (srcc | (srca ^ srcb)))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -952,34 +920,33 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_b1 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = (~(srca ^ (srcc | (srca ^ srcb))));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = (~(srca ^ (srcc | (srca ^ srcb)))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -990,15 +957,15 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_ca (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -1006,19 +973,18 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc ^ (srca & (srcb ^ srcc))));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc ^ (srca & (srcb ^ srcc)))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -1029,34 +995,33 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_ca (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc ^ (srca & (srcb ^ srcc))));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc ^ (srca & (srcb ^ srcc)))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -1067,15 +1032,14 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_cc (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 dstd=0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
@@ -1083,13 +1047,12 @@ for (j = 0; j < b->vblitsize; j++) {
uae_u32 bltadat, srca;
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = (srcb);
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = (srcb) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -1097,28 +1060,26 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd += b->bltdmod;
}
b->bltbhold = srcb;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_cc (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
-uae_u32 dstd=0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = (srcb);
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = (srcb) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -1126,15 +1087,15 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd -= b->bltdmod;
}
b->bltbhold = srcb;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_d8 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -1142,19 +1103,18 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srca ^ (srcc & (srca ^ srcb))));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srca ^ (srcc & (srca ^ srcb)))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -1165,34 +1125,33 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_d8 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srca ^ (srcc & (srca ^ srcb))));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srca ^ (srcc & (srca ^ srcb)))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -1203,15 +1162,15 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_e2 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -1219,19 +1178,18 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc ^ (srcb & (srca ^ srcc))));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc ^ (srcb & (srca ^ srcc)))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -1242,34 +1200,33 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_e2 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc ^ (srcb & (srca ^ srcc))));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc ^ (srcb & (srca ^ srcc)))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -1280,15 +1237,15 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_ea (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -1296,19 +1253,18 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc | (srca & srcb)));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc | (srca & srcb))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -1319,34 +1275,33 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_ea (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srcc | (srca & srcb)));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srcc | (srca & srcb))) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -1357,67 +1312,65 @@ for (j = 0; j < b->vblitsize; j++) {
}
b->bltbhold = srcb;
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_f0 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
+uae_u32 preva = 0;
uae_u32 dstd=0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = (srca);
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = (srca) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
if (pta) pta += b->bltamod;
if (ptd) ptd += b->bltdmod;
}
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_f0 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 dstd=0;
+uae_u32 preva = 0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = (srca);
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = (srca) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
if (pta) pta -= b->bltamod;
if (ptd) ptd -= b->bltdmod;
}
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_fa (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
+uae_u32 preva = 0;
uae_u32 srcc = b->bltcdat;
uae_u32 dstd=0;
uaecptr dstp = 0;
@@ -1425,14 +1378,13 @@ for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; }
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc += 2; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srca | srcc));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srca | srcc)) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -1441,28 +1393,27 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd += b->bltdmod;
}
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_fa (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
+uae_u32 preva = 0;
uae_u32 srcc = b->bltcdat;
-uae_u32 dstd=0;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
- if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; }
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (ptc) { srcc = chipmem_wget_indirect (ptc); ptc -= 2; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srca | srcc));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srca | srcc)) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -1471,15 +1422,15 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd -= b->bltdmod;
}
b->bltcdat = srcc;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_fc (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
int i,j;
uae_u32 totald = 0;
-uae_u32 srcb = b->bltbhold;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
uae_u32 dstd=0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
@@ -1487,17 +1438,16 @@ for (j = 0; j < b->vblitsize; j++) {
uae_u32 bltadat, srca;
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2;
- srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;
+ srcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srca | srcb));
+ srca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srca | srcb)) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd += 2; }
}
@@ -1506,32 +1456,31 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd += b->bltdmod;
}
b->bltbhold = srcb;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
void blitdofast_desc_fc (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b)
{
uae_u32 totald = 0;
int i,j;
-uae_u32 srcb = b->bltbhold;
-uae_u32 dstd=0;
+uae_u32 preva = 0;
+uae_u32 prevb = 0, srcb = b->bltbhold;
+uae_u32 dstd = 0;
uaecptr dstp = 0;
for (j = 0; j < b->vblitsize; j++) {
for (i = 0; i < b->hblitsize; i++) {
uae_u32 bltadat, srca;
if (ptb) {
- uae_u32 bltbdat = b->bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2;
- srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift;
- b->bltbold = bltbdat;
+ uae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;
+ srcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;
+ prevb = bltbdat;
}
- if (pta) { bltadat = b->bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; }
+ if (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }
bltadat &= blit_masktable[i];
- srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift;
- b->bltaold = bltadat;
- if (dstp)
- chipmem_wput_indirect (dstp, dstd);
- dstd = ((srca | srcb));
+ srca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;
+ preva = bltadat;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+ dstd = ((srca | srcb)) & 0xFFFF;
totald |= dstd;
if (ptd) { dstp = ptd; ptd -= 2; }
}
@@ -1540,7 +1489,6 @@ for (j = 0; j < b->vblitsize; j++) {
if (ptd) ptd -= b->bltdmod;
}
b->bltbhold = srcb;
-if (dstp)
- chipmem_wput_indirect (dstp, dstd);
-if ((totald<<16) != 0) b->blitzero = 0;
+ if (dstp) chipmem_wput_indirect (dstp, dstd);
+if (totald != 0) b->blitzero = 0;
}
diff --git a/src/blittable.cpp b/src/blittable.cpp
index 1c47b0ba..32ad76bc 100644
--- a/src/blittable.cpp
+++ b/src/blittable.cpp
@@ -1,10 +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 "include/memory.h"
#include "blitter.h"
#include "blitfunc.h"
diff --git a/src/blitter.cpp b/src/blitter.cpp
index 31e8942e..8cdaadfa 100644
--- a/src/blitter.cpp
+++ b/src/blitter.cpp
@@ -7,51 +7,94 @@
* (c) 2002 - 2005 Toni Wilen
*/
+#define SPEEDUP 1
+
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
#include "uae.h"
-#include "memory.h"
-#include "custom.h"
+#include "include/memory.h"
#include "newcpu.h"
+#include "custom.h"
+#include "events.h"
#include "savestate.h"
#include "blitter.h"
#include "blit.h"
-static int immediate_blits;
+ // 1 = logging
+ // 2 = no wait detection
+ // 4 = no D
+ // 8 = instant
+ // 16 = activate debugger if weird things
+ // 32 = logging (no line)
+
+#if BLITTER_DEBUG
+int log_blitter = 1 | 16;
+#else
+int log_blitter = 0;
+#endif
+
+/* we must not change ce-mode while blitter is running.. */
+static int blitter_cycle_exact, immediate_blits;
+static int blt_statefile_type;
uae_u16 bltcon0, bltcon1;
uae_u32 bltapt, bltbpt, bltcpt, bltdpt;
+uae_u32 bltptx;
+int bltptxpos, bltptxc;
+int blitter_nasty;
+// blitter is active and D may write to visible bitplane addresses
+int blitter_dangerous_bpl;
-static int original_ch;
+static int original_ch, original_fill, original_line;
static int blinea_shift;
static uae_u16 blinea, blineb;
static int blitline, blitfc, blitfill, blitife, blitsing, blitdesc;
static int blitline_started;
-static int blitonedot, blitsign;
+static int blitonedot, blitsign, blitlinepixel;
+static int blit_add;
+static int blit_modadda, blit_modaddb, blit_modaddc, blit_modaddd;
static int blit_ch;
+static int blitter_dontdo;
+static int blitter_delayed_debug;
+#ifdef BLITTER_SLOWDOWNDEBUG
+static int blitter_slowdowndebug;
+#endif
+
struct bltinfo blt_info;
static uae_u8 blit_filltable[256][4][2];
uae_u32 blit_masktable[BLITTER_MAX_WORDS];
enum blitter_states bltstate;
-static int blit_cyclecounter;
-static int blit_slowdown;
+static int blit_cyclecounter, blit_waitcyclecounter;
+static int blit_maxcyclecounter, blit_slowdown, blit_totalcyclecounter;
+static int blit_startcycles, blit_misscyclecounter;
+
+#ifdef CPUEMU_13
+extern uae_u8 cycle_line[256];
+#endif
static long blit_firstline_cycles;
static long blit_first_cycle;
static int blit_last_cycle, blit_dmacount, blit_dmacount2;
-static int blit_nod;
+static int blit_linecycles, blit_extracycles, blit_nod;
static const int *blit_diag;
-static int blit_faulty;
-static int ddat1use;
+static int blit_frozen, blit_faulty;
+static int blit_final;
+static int blt_delayed_irq;
+static uae_u16 ddat1, ddat2;
+static int ddat1use, ddat2use;
int blit_interrupt;
+static int last_blitter_hpos;
+
+#define BLITTER_STARTUP_CYCLES 2
+
/*
Blitter Idle Cycle:
@@ -157,7 +200,7 @@ static const int blit_cycle_diagram_finalld[] =
2, 0,0, 0,0
};
-static int get_cycle_diagram_type (const int *diag)
+static int get_cycle_diagram_type(const int *diag)
{
for (int i = 0; i < 16; i++) {
if (diag == &blit_cycle_diagram[i][0])
@@ -173,7 +216,8 @@ static int get_cycle_diagram_type (const int *diag)
return 0x82;
return 0xff;
}
-static const int *set_cycle_diagram_type (uae_u8 diag)
+
+static const int *set_cycle_diagram_type(uae_u8 diag)
{
if (diag >= 0x00 && diag <= 0x0f)
return &blit_cycle_diagram[diag][0];
@@ -185,10 +229,10 @@ static const int *set_cycle_diagram_type (uae_u8 diag)
return blit_cycle_diagram_finald;
if (diag == 0x82)
return blit_cycle_diagram_finalld;
- return NULL;
+ return nullptr;
}
-void build_blitfilltable (void)
+void build_blitfilltable(void)
{
unsigned int d, fillmask;
int i;
@@ -216,13 +260,147 @@ void build_blitfilltable (void)
}
}
-STATIC_INLINE int channel_state (int cycles)
+STATIC_INLINE void record_dma_blit(uae_u16 reg, uae_u16 dat, uae_u32 addr, int hpos)
{
- if (cycles < blit_diag[0])
- return blit_diag[1 + cycles];
- cycles -= blit_diag[0];
- cycles %= blit_diag[0];
- return blit_diag[1 + blit_diag[0] + cycles];
+#ifdef DEBUGGER
+ int type;
+
+ if (blitline)
+ type = DMARECORD_BLITTER_LINE;
+ else if (blitfill)
+ type = DMARECORD_BLITTER_FILL;
+ else
+ type = DMARECORD_BLITTER;
+ if (debug_dma)
+ record_dma(reg, dat, addr, hpos, vpos, type);
+ if (memwatch_enabled) {
+ if (reg == 0) {
+ uae_u32 mask = MW_MASK_BLITTER_D_N;
+ if (blitfill)
+ mask = MW_MASK_BLITTER_D_F;
+ if (blitline)
+ mask = MW_MASK_BLITTER_D_L;
+ debug_wputpeekdma_chipram(addr, dat, mask, reg);
+ }
+ else if (reg == 0x70) {
+ debug_wgetpeekdma_chipram(addr, dat, MW_MASK_BLITTER_C, reg);
+ }
+ else if (reg == 0x72) {
+ debug_wgetpeekdma_chipram(addr, dat, MW_MASK_BLITTER_B, reg);
+ }
+ else if (reg == 0x74) {
+ debug_wgetpeekdma_chipram(addr, dat, MW_MASK_BLITTER_A, reg);
+ }
+ }
+#endif
+}
+
+//static void blitter_dump(void)
+//{
+// int chipsize = currprefs.chipmem_size;
+// write_log(_T("PT A=%08X B=%08X C=%08X D=%08X\n"), bltapt, bltbpt, bltcpt, bltdpt);
+// write_log(_T("CON0=%04X CON1=%04X DAT A=%04X B=%04X C=%04X\n"),
+// bltcon0, bltcon1, blt_info.bltadat, blt_info.bltbdat, blt_info.bltcdat);
+// write_log(_T("AFWM=%04X ALWM=%04X MOD A=%04X B=%04X C=%04X D=%04X\n"),
+// blt_info.bltafwm, blt_info.bltalwm,
+// blt_info.bltamod & 0xffff, blt_info.bltbmod & 0xffff, blt_info.bltcmod & 0xffff, blt_info.bltdmod & 0xffff);
+// write_log(_T("PC=%08X DMA=%d\n"), m68k_getpc(), dmaen(DMA_BLITTER));
+//
+// if (((bltcon0 & 0x800) && bltapt >= chipsize) || ((bltcon0 & 0x400) && bltbpt >= chipsize) ||
+// ((bltcon0 & 0x200) && bltcpt >= chipsize) || ((bltcon0 & 0x100) && bltdpt >= chipsize))
+// write_log(_T("PT outside of chipram\n"));
+//}
+
+STATIC_INLINE const int *get_ch(void)
+{
+ if (blit_faulty)
+ return &blit_diag[0];
+ if (blit_final)
+ return blitline || blit_nod ? blit_cycle_diagram_finalld : blit_cycle_diagram_finald;
+ return blit_diag;
+}
+
+STATIC_INLINE int channel_state(int cycles)
+{
+ const int *diag;
+ if (cycles < 0)
+ return 0;
+ diag = get_ch();
+ if (cycles < diag[0])
+ return diag[1 + cycles];
+ cycles -= diag[0];
+ cycles %= diag[0];
+ return diag[1 + diag[0] + cycles];
+}
+STATIC_INLINE int channel_pos(int cycles)
+{
+ const int *diag;
+ if (cycles < 0)
+ return 0;
+ diag = get_ch();
+ if (cycles < diag[0])
+ return cycles;
+ cycles -= diag[0];
+ cycles %= diag[0];
+ return cycles;
+}
+
+int blitter_channel_state(void)
+{
+ return channel_state(blit_cyclecounter);
+}
+
+STATIC_INLINE int canblit(int hpos)
+{
+ if (!dmaen(DMA_BLITTER))
+ return -1;
+ if (is_bitplane_dma(hpos))
+ return 0;
+#ifdef CPUEMU_13
+ if (cycle_line[hpos] & CYCLE_MASK) {
+ return 0;
+ }
+#endif
+ return 1;
+}
+
+static void markidlecycle(int hpos)
+{
+ //if (debug_dma)
+ // record_dma_event(DMA_EVENT_BLITSTARTFINISH, hpos, vpos);
+}
+
+static void reset_channel_mods(void)
+{
+ if (bltptxpos < 0)
+ return;
+ bltptxpos = -1;
+ switch (bltptxc)
+ {
+ case 1:
+ bltapt = bltptx;
+ break;
+ case 2:
+ bltbpt = bltptx;
+ break;
+ case 3:
+ bltcpt = bltptx;
+ break;
+ case 4:
+ bltdpt = bltptx;
+ break;
+ }
+}
+
+static void check_channel_mods(int hpos, int ch)
+{
+ if (bltptxpos != hpos)
+ return;
+ if (ch == bltptxc) {
+ bltptxpos = -1;
+ //write_log(_T("BLITTER: %08X write to %cPT ignored! %08x\n"), bltptx, ch + 'A' - 1, m68k_getpc());
+ //activate_debugger();
+ }
}
// blitter interrupt is set (and busy bit cleared) when
@@ -234,221 +412,255 @@ STATIC_INLINE int channel_state (int cycles)
// (or cycle where last D write would have been if
// ONEDOT was active)
-static void blitter_interrupt (void)
+static void blitter_interrupt(int hpos, int done)
{
if (blit_interrupt)
return;
+ if (!done && (!blitter_cycle_exact || immediate_blits || currprefs.cpu_model >= 68030 || currprefs.cachesize || currprefs.m68k_speed < 0))
+ return;
blit_interrupt = 1;
- send_interrupt (6);
+ send_interrupt(6, 4 * CYCLE_UNIT);
+ //if (debug_dma)
+ // record_dma_event(DMA_EVENT_BLITIRQ, hpos, vpos);
}
-static void blitter_done (void)
+static void blitter_done(int hpos)
{
- ddat1use = 0;
- bltstate = BLT_done;
- blitter_interrupt ();
- blitter_done_notify ();
- event_remevent(ev_blitter);
- unset_special (SPCFLAG_BLTNASTY);
+ ddat1use = ddat2use = 0;
+ bltstate = blit_startcycles == 0 || !blitter_cycle_exact || immediate_blits ? BLT_done : BLT_init;
+ blitter_interrupt(hpos, 1);
+ blitter_done_notify(hpos);
+ markidlecycle(hpos);
+ event2_remevent(ev2_blitter);
+ unset_special(SPCFLAG_BLTNASTY);
+ if (log_blitter & 1)
+ write_log(_T("cycles %d, missed %d, total %d\n"),
+ blit_totalcyclecounter, blit_misscyclecounter, blit_totalcyclecounter + blit_misscyclecounter);
+ blitter_dangerous_bpl = 0;
}
-STATIC_INLINE void chipmem_agnus_wput2 (uaecptr addr, uae_u32 w)
+STATIC_INLINE void chipmem_agnus_wput2(uaecptr addr, uae_u32 w)
{
- chipmem_wput_indirect (addr, w);
+ //last_custom_value1 = w; blitter writes are not stored
+ if (!(log_blitter & 4)) {
+ chipmem_wput_indirect(addr, w);
+ //debug_wputpeekdma_chipram(addr, w, MW_MASK_BLITTER_D_N, 0x000);
+ }
}
static void blitter_dofast(void)
{
- int i,j;
- uaecptr bltadatptr = 0, bltbdatptr = 0, bltcdatptr = 0, bltddatptr = 0;
- uae_u8 mt = bltcon0 & 0xFF;
+ int i, j;
+ uaecptr bltadatptr = 0, bltbdatptr = 0, bltcdatptr = 0, bltddatptr = 0;
+ uae_u8 mt = bltcon0 & 0xFF;
blit_masktable[0] = blt_info.bltafwm;
blit_masktable[blt_info.hblitsize - 1] &= blt_info.bltalwm;
- if (bltcon0 & 0x800) {
- bltadatptr = (uaecptr)&chipmem_bank.baseaddr[bltapt & chipmem_full_mask];
- bltapt += (blt_info.hblitsize * 2 + blt_info.bltamod) * blt_info.vblitsize;
- }
- if (bltcon0 & 0x400) {
- bltbdatptr = (uaecptr)&chipmem_bank.baseaddr[bltbpt & chipmem_full_mask];
- bltbpt += (blt_info.hblitsize * 2 + blt_info.bltbmod) * blt_info.vblitsize;
- }
- if (bltcon0 & 0x200) {
- bltcdatptr = (uaecptr)&chipmem_bank.baseaddr[bltcpt & chipmem_full_mask];
- bltcpt += (blt_info.hblitsize * 2 + blt_info.bltcmod) * blt_info.vblitsize;
- }
- if (bltcon0 & 0x100) {
- bltddatptr = bltdpt;
- bltdpt += (blt_info.hblitsize * 2 + blt_info.bltdmod) * blt_info.vblitsize;
- }
+ if (bltcon0 & 0x800) {
+ bltadatptr = bltapt;
+ bltapt += (blt_info.hblitsize * 2 + blt_info.bltamod) * blt_info.vblitsize;
+ }
+ if (bltcon0 & 0x400) {
+ bltbdatptr = bltbpt;
+ bltbpt += (blt_info.hblitsize * 2 + blt_info.bltbmod) * blt_info.vblitsize;
+ }
+ if (bltcon0 & 0x200) {
+ bltcdatptr = bltcpt;
+ bltcpt += (blt_info.hblitsize * 2 + blt_info.bltcmod) * blt_info.vblitsize;
+ }
+ if (bltcon0 & 0x100) {
+ bltddatptr = bltdpt;
+ bltdpt += (blt_info.hblitsize * 2 + blt_info.bltdmod) * blt_info.vblitsize;
+ }
- if (blitfunc_dofast[mt] && !blitfill) {
- (*blitfunc_dofast[mt])(bltadatptr, bltbdatptr, bltcdatptr, bltddatptr, &blt_info);
- } else {
- uae_u32 blitbhold = blt_info.bltbhold;
- uaecptr dstp = 0;
-
- for (j = 0; j < blt_info.vblitsize; j++) {
- blitfc = !!(bltcon1 & 0x4);
- for (i = 0; i < blt_info.hblitsize; i++) {
- uae_u32 bltadat, blitahold;
- if (bltadatptr) {
- blt_info.bltadat = bltadat = do_get_mem_word ((uae_u16 *)bltadatptr);
- bltadatptr += 2;
- } else
- bltadat = blt_info.bltadat;
- bltadat &= blit_masktable[i];
- blitahold = (((uae_u32)blt_info.bltaold << 16) | bltadat) >> blt_info.blitashift;
- blt_info.bltaold = bltadat;
-
- if (bltbdatptr) {
- uae_u16 bltbdat = do_get_mem_word ((uae_u16 *)bltbdatptr);;
- bltbdatptr += 2;
- blitbhold = (((uae_u32)blt_info.bltbold << 16) | bltbdat) >> blt_info.blitbshift;
- blt_info.bltbold = bltbdat;
- blt_info.bltbdat = bltbdat;
- }
-
- if (bltcdatptr) {
- blt_info.bltcdat = do_get_mem_word ((uae_u16 *)bltcdatptr);
- bltcdatptr += 2;
- }
- if (dstp)
- chipmem_agnus_wput2 (dstp, blt_info.bltddat);
- blt_info.bltddat = blit_func (blitahold, blitbhold, blt_info.bltcdat, mt);
- if (blitfill) {
- uae_u16 d = blt_info.bltddat;
- int ifemode = blitife ? 2 : 0;
- int fc1 = blit_filltable[d & 255][ifemode + blitfc][1];
- blt_info.bltddat = (blit_filltable[d & 255][ifemode + blitfc][0]
- + (blit_filltable[d >> 8][ifemode + fc1][0] << 8));
- blitfc = blit_filltable[d >> 8][ifemode + fc1][1];
- }
- if (blt_info.bltddat)
- blt_info.blitzero = 0;
- if (bltddatptr) {
- dstp = bltddatptr;
- bltddatptr += 2;
- }
- }
- if (bltadatptr)
- bltadatptr += blt_info.bltamod;
- if (bltbdatptr)
- bltbdatptr += blt_info.bltbmod;
- if (bltcdatptr)
- bltcdatptr += blt_info.bltcmod;
- if (bltddatptr)
- bltddatptr += blt_info.bltdmod;
- }
- if (dstp)
- chipmem_agnus_wput2 (dstp, blt_info.bltddat);
- blt_info.bltbhold = blitbhold;
- }
- blit_masktable[0] = 0xFFFF;
- blit_masktable[blt_info.hblitsize - 1] = 0xFFFF;
-
- bltstate = BLT_done;
-}
-
-static void blitter_dofast_desc(void)
-{
- int i,j;
- uaecptr bltadatptr = 0, bltbdatptr = 0, bltcdatptr = 0, bltddatptr = 0;
- uae_u8 mt = bltcon0 & 0xFF;
-
- blit_masktable[0] = blt_info.bltafwm;
- blit_masktable[blt_info.hblitsize - 1] &= blt_info.bltalwm;
-
- if (bltcon0 & 0x800) {
- bltadatptr = (uaecptr)&chipmem_bank.baseaddr[bltapt & chipmem_full_mask];
- bltapt -= (blt_info.hblitsize * 2 + blt_info.bltamod) * blt_info.vblitsize;
- }
- if (bltcon0 & 0x400) {
- bltbdatptr = (uaecptr)&chipmem_bank.baseaddr[bltbpt & chipmem_full_mask];
- bltbpt -= (blt_info.hblitsize * 2 + blt_info.bltbmod) * blt_info.vblitsize;
- }
- if (bltcon0 & 0x200) {
- bltcdatptr = (uaecptr)&chipmem_bank.baseaddr[bltcpt & chipmem_full_mask];
- bltcpt -= (blt_info.hblitsize * 2 + blt_info.bltcmod) * blt_info.vblitsize;
- }
- if (bltcon0 & 0x100) {
- bltddatptr = bltdpt;
- bltdpt -= (blt_info.hblitsize * 2 + blt_info.bltdmod) * blt_info.vblitsize;
- }
- if (blitfunc_dofast_desc[mt] && !blitfill) {
- (*blitfunc_dofast_desc[mt])(bltadatptr, bltbdatptr, bltcdatptr, bltddatptr, &blt_info);
- } else {
- uae_u32 blitbhold = blt_info.bltbhold;
- uaecptr dstp = 0;
+#if SPEEDUP
+ if (blitfunc_dofast[mt] && !blitfill) {
+ (*blitfunc_dofast[mt])(bltadatptr, bltbdatptr, bltcdatptr, bltddatptr, &blt_info);
+ }
+ else
+#endif
+ {
+ uae_u32 blitbhold = blt_info.bltbhold;
+ uae_u32 preva = 0, prevb = 0;
+ uaecptr dstp = 0;
+ int dodst = 0;
for (j = 0; j < blt_info.vblitsize; j++) {
blitfc = !!(bltcon1 & 0x4);
for (i = 0; i < blt_info.hblitsize; i++) {
uae_u32 bltadat, blitahold;
+ uae_u16 bltbdat;
if (bltadatptr) {
- bltadat = blt_info.bltadat = do_get_mem_word ((uae_u16 *)bltadatptr);
- bltadatptr -= 2;
- } else
+ blt_info.bltadat = bltadat = chipmem_wget_indirect(bltadatptr);
+ bltadatptr += 2;
+ }
+ else
bltadat = blt_info.bltadat;
bltadat &= blit_masktable[i];
- blitahold = (((uae_u32)bltadat << 16) | blt_info.bltaold) >> blt_info.blitdownashift;
- blt_info.bltaold = bltadat;
+ blitahold = ((uae_u32(preva) << 16) | bltadat) >> blt_info.blitashift;
+ preva = bltadat;
if (bltbdatptr) {
- uae_u16 bltbdat = do_get_mem_word ((uae_u16 *)bltbdatptr);
- bltbdatptr -= 2;
- blitbhold = (((uae_u32)bltbdat << 16) | blt_info.bltbold) >> blt_info.blitdownbshift;
- blt_info.bltbold = bltbdat;
- blt_info.bltbdat = bltbdat;
- }
+ blt_info.bltbdat = bltbdat = chipmem_wget_indirect(bltbdatptr);
+ bltbdatptr += 2;
+ blitbhold = ((uae_u32(prevb) << 16) | bltbdat) >> blt_info.blitbshift;
+ prevb = bltbdat;
+ }
- if (bltcdatptr) {
- blt_info.bltcdat = blt_info.bltbdat = do_get_mem_word ((uae_u16 *)bltcdatptr);
- bltcdatptr -= 2;
- }
- if (dstp)
- chipmem_agnus_wput2 (dstp, blt_info.bltddat);
- blt_info.bltddat = blit_func (blitahold, blitbhold, blt_info.bltcdat, mt);
- if (blitfill) {
- uae_u16 d = blt_info.bltddat;
- int ifemode = blitife ? 2 : 0;
- int fc1 = blit_filltable[d & 255][ifemode + blitfc][1];
- blt_info.bltddat = (blit_filltable[d & 255][ifemode + blitfc][0]
- + (blit_filltable[d >> 8][ifemode + fc1][0] << 8));
- blitfc = blit_filltable[d >> 8][ifemode + fc1][1];
- }
- if (blt_info.bltddat)
- blt_info.blitzero = 0;
- if (bltddatptr) {
- dstp = bltddatptr;
- bltddatptr -= 2;
- }
- }
- if (bltadatptr)
- bltadatptr -= blt_info.bltamod;
- if (bltbdatptr)
- bltbdatptr -= blt_info.bltbmod;
- if (bltcdatptr)
- bltcdatptr -= blt_info.bltcmod;
- if (bltddatptr)
- bltddatptr -= blt_info.bltdmod;
- }
- if (dstp)
- chipmem_agnus_wput2 (dstp, blt_info.bltddat);
+ if (bltcdatptr) {
+ blt_info.bltcdat = chipmem_wget_indirect(bltcdatptr);
+ bltcdatptr += 2;
+ }
+ if (dodst)
+ chipmem_agnus_wput2(dstp, blt_info.bltddat);
+ blt_info.bltddat = blit_func(blitahold, blitbhold, blt_info.bltcdat, mt) & 0xFFFF;
+ if (blitfill) {
+ uae_u16 d = blt_info.bltddat;
+ int ifemode = blitife ? 2 : 0;
+ int fc1 = blit_filltable[d & 255][ifemode + blitfc][1];
+ blt_info.bltddat = (blit_filltable[d & 255][ifemode + blitfc][0]
+ + (blit_filltable[d >> 8][ifemode + fc1][0] << 8));
+ blitfc = blit_filltable[d >> 8][ifemode + fc1][1];
+ }
+ if (blt_info.bltddat)
+ blt_info.blitzero = 0;
+ if (bltddatptr) {
+ dodst = 1;
+ dstp = bltddatptr;
+ bltddatptr += 2;
+ }
+ }
+ if (bltadatptr)
+ bltadatptr += blt_info.bltamod;
+ if (bltbdatptr)
+ bltbdatptr += blt_info.bltbmod;
+ if (bltcdatptr)
+ bltcdatptr += blt_info.bltcmod;
+ if (bltddatptr)
+ bltddatptr += blt_info.bltdmod;
+ }
+ if (dodst)
+ chipmem_agnus_wput2(dstp, blt_info.bltddat);
blt_info.bltbhold = blitbhold;
}
blit_masktable[0] = 0xFFFF;
blit_masktable[blt_info.hblitsize - 1] = 0xFFFF;
- bltstate = BLT_done;
+ bltstate = BLT_done;
+}
+
+static void blitter_dofast_desc(void)
+{
+ int i, j;
+ uaecptr bltadatptr = 0, bltbdatptr = 0, bltcdatptr = 0, bltddatptr = 0;
+ uae_u8 mt = bltcon0 & 0xFF;
+
+ blit_masktable[0] = blt_info.bltafwm;
+ blit_masktable[blt_info.hblitsize - 1] &= blt_info.bltalwm;
+
+ if (bltcon0 & 0x800) {
+ bltadatptr = bltapt;
+ bltapt -= (blt_info.hblitsize * 2 + blt_info.bltamod) * blt_info.vblitsize;
+ }
+ if (bltcon0 & 0x400) {
+ bltbdatptr = bltbpt;
+ bltbpt -= (blt_info.hblitsize * 2 + blt_info.bltbmod) * blt_info.vblitsize;
+ }
+ if (bltcon0 & 0x200) {
+ bltcdatptr = bltcpt;
+ bltcpt -= (blt_info.hblitsize * 2 + blt_info.bltcmod) * blt_info.vblitsize;
+ }
+ if (bltcon0 & 0x100) {
+ bltddatptr = bltdpt;
+ bltdpt -= (blt_info.hblitsize * 2 + blt_info.bltdmod) * blt_info.vblitsize;
+ }
+#if SPEEDUP
+ if (blitfunc_dofast_desc[mt] && !blitfill) {
+ (*blitfunc_dofast_desc[mt])(bltadatptr, bltbdatptr, bltcdatptr, bltddatptr, &blt_info);
+ }
+ else
+#endif
+ {
+ uae_u32 blitbhold = blt_info.bltbhold;
+ uae_u32 preva = 0, prevb = 0;
+ uaecptr dstp = 0;
+ int dodst = 0;
+
+ for (j = 0; j < blt_info.vblitsize; j++) {
+ blitfc = !!(bltcon1 & 0x4);
+ for (i = 0; i < blt_info.hblitsize; i++) {
+ uae_u32 bltadat, blitahold;
+ uae_u16 bltbdat;
+ if (bltadatptr) {
+ bltadat = blt_info.bltadat = chipmem_wget_indirect(bltadatptr);
+ bltadatptr -= 2;
+ }
+ else
+ bltadat = blt_info.bltadat;
+ bltadat &= blit_masktable[i];
+ blitahold = ((uae_u32(bltadat) << 16) | preva) >> blt_info.blitdownashift;
+ preva = bltadat;
+
+ if (bltbdatptr) {
+ blt_info.bltbdat = bltbdat = chipmem_wget_indirect(bltbdatptr);
+ bltbdatptr -= 2;
+ blitbhold = ((uae_u32(bltbdat) << 16) | prevb) >> blt_info.blitdownbshift;
+ prevb = bltbdat;
+ }
+
+ if (bltcdatptr) {
+ blt_info.bltcdat = blt_info.bltbdat = chipmem_wget_indirect(bltcdatptr);
+ bltcdatptr -= 2;
+ }
+ if (dodst)
+ chipmem_agnus_wput2(dstp, blt_info.bltddat);
+ blt_info.bltddat = blit_func(blitahold, blitbhold, blt_info.bltcdat, mt) & 0xFFFF;
+ if (blitfill) {
+ uae_u16 d = blt_info.bltddat;
+ int ifemode = blitife ? 2 : 0;
+ int fc1 = blit_filltable[d & 255][ifemode + blitfc][1];
+ blt_info.bltddat = (blit_filltable[d & 255][ifemode + blitfc][0]
+ + (blit_filltable[d >> 8][ifemode + fc1][0] << 8));
+ blitfc = blit_filltable[d >> 8][ifemode + fc1][1];
+ }
+ if (blt_info.bltddat)
+ blt_info.blitzero = 0;
+ if (bltddatptr) {
+ dstp = bltddatptr;
+ dodst = 1;
+ bltddatptr -= 2;
+ }
+ }
+ if (bltadatptr)
+ bltadatptr -= blt_info.bltamod;
+ if (bltbdatptr)
+ bltbdatptr -= blt_info.bltbmod;
+ if (bltcdatptr)
+ bltcdatptr -= blt_info.bltcmod;
+ if (bltddatptr)
+ bltddatptr -= blt_info.bltdmod;
+ }
+ if (dodst)
+ chipmem_agnus_wput2(dstp, blt_info.bltddat);
+ blt_info.bltbhold = blitbhold;
+ }
+ blit_masktable[0] = 0xFFFF;
+ blit_masktable[blt_info.hblitsize - 1] = 0xFFFF;
+
+ bltstate = BLT_done;
}
STATIC_INLINE void blitter_read(void)
{
if (bltcon0 & 0x200) {
- blt_info.bltcdat = chipmem_wget_indirect(bltcpt);
+ if (!dmaen(DMA_BLITTER))
+ return;
+ blt_info.bltcdat = chipmem_wget_indirect(bltcpt);
+ //debug_wgetpeekdma_chipram(bltcpt, blt_info.bltcdat, MW_MASK_BLITTER_C, 0x070);
+ last_custom_value1 = blt_info.bltcdat;
}
+ bltstate = BLT_work;
}
STATIC_INLINE void blitter_write(void)
@@ -457,185 +669,655 @@ STATIC_INLINE void blitter_write(void)
blt_info.blitzero = 0;
/* D-channel state has no effect on linedraw, but C must be enabled or nothing is drawn! */
if (bltcon0 & 0x200) {
- chipmem_wput_indirect (bltdpt, blt_info.bltddat);
+ if (!dmaen(DMA_BLITTER))
+ return;
+ //last_custom_value1 = blt_info.bltddat; blitter writes are not stored
+ chipmem_wput_indirect(bltdpt, blt_info.bltddat);
+ //debug_wputpeekdma_chipram(bltdpt, blt_info.bltddat, MW_MASK_BLITTER_D_N, 0x000);
}
+ bltstate = BLT_next;
}
STATIC_INLINE void blitter_line_incx(void)
{
- if (++blinea_shift == 16) {
- blinea_shift = 0;
- bltcpt += 2;
- }
+ if (++blinea_shift == 16) {
+ blinea_shift = 0;
+ bltcpt += 2;
+ }
}
STATIC_INLINE void blitter_line_decx(void)
{
- if (blinea_shift-- == 0) {
- blinea_shift = 15;
- bltcpt -= 2;
- }
+ if (blinea_shift-- == 0) {
+ blinea_shift = 15;
+ bltcpt -= 2;
+ }
}
STATIC_INLINE void blitter_line_decy(void)
{
- bltcpt -= blt_info.bltcmod;
- blitonedot = 0;
+ bltcpt -= blt_info.bltcmod;
+ blitonedot = 0;
}
STATIC_INLINE void blitter_line_incy(void)
{
- bltcpt += blt_info.bltcmod;
- blitonedot = 0;
+ bltcpt += blt_info.bltcmod;
+ blitonedot = 0;
}
-static int blitter_line(void)
+static void blitter_line(void)
{
uae_u16 blitahold = (blinea & blt_info.bltafwm) >> blinea_shift;
uae_u16 blitchold = blt_info.bltcdat;
blt_info.bltbhold = (blineb & 1) ? 0xFFFF : 0;
- int blitlinepixel = !blitsing || (blitsing && !blitonedot);
- blt_info.bltddat = blit_func (blitahold, blt_info.bltbhold, blitchold, bltcon0 & 0xFF);
+ blitlinepixel = !blitsing || (blitsing && !blitonedot);
+ blt_info.bltddat = blit_func(blitahold, blt_info.bltbhold, blitchold, bltcon0 & 0xFF);
blitonedot++;
+}
+static void blitter_line_proc(void)
+{
if (bltcon0 & 0x800) {
if (blitsign)
- bltapt += (uae_s16)blt_info.bltbmod;
+ bltapt += uae_s16(blt_info.bltbmod);
else
- bltapt += (uae_s16)blt_info.bltamod;
+ bltapt += uae_s16(blt_info.bltamod);
}
if (!blitsign) {
if (bltcon1 & 0x10) {
if (bltcon1 & 0x8)
- blitter_line_decy ();
+ blitter_line_decy();
else
- blitter_line_incy ();
- } else {
+ blitter_line_incy();
+ }
+ else {
if (bltcon1 & 0x8)
- blitter_line_decx ();
+ blitter_line_decx();
else
- blitter_line_incx ();
+ blitter_line_incx();
}
}
if (bltcon1 & 0x10) {
if (bltcon1 & 0x4)
- blitter_line_decx ();
+ blitter_line_decx();
else
- blitter_line_incx ();
- } else {
+ blitter_line_incx();
+ }
+ else {
if (bltcon1 & 0x4)
- blitter_line_decy ();
+ blitter_line_decy();
else
- blitter_line_incy ();
+ blitter_line_incy();
}
- blitsign = 0 > (uae_s16)bltapt;
- return blitlinepixel;
+ blitsign = 0 > uae_s16(bltapt);
+ bltstate = BLT_write;
}
+
+
STATIC_INLINE void blitter_nxline(void)
{
blineb = (blineb << 1) | (blineb >> 15);
blt_info.vblitsize--;
+ bltstate = BLT_read;
}
+#ifdef CPUEMU_13
+
+static int blitter_cyclecounter;
+static int blitter_hcounter1, blitter_hcounter2;
+static int blitter_vcounter1, blitter_vcounter2;
+
+static void decide_blitter_line(int hsync, int hpos)
+{
+ if (blit_final && blt_info.vblitsize)
+ blit_final = 0;
+ while (last_blitter_hpos < hpos) {
+ int c = channel_state(blit_cyclecounter);
+
+ for (;;) {
+ int v = canblit(last_blitter_hpos);
+
+ if (blit_waitcyclecounter) {
+ blit_waitcyclecounter = 0;
+ break;
+ }
+
+ // final 2 idle cycles? does not need free bus
+ if (blit_final) {
+ blit_cyclecounter++;
+ blit_totalcyclecounter++;
+ if (blit_cyclecounter >= 2) {
+ blitter_done(last_blitter_hpos);
+ return;
+ }
+ break;
+ }
+
+ if (v <= 0) {
+ blit_misscyclecounter++;
+ blitter_nasty++;
+ break;
+ }
+
+ blit_cyclecounter++;
+ blit_totalcyclecounter++;
+
+ check_channel_mods(last_blitter_hpos, c);
+
+ if (c == 3) {
+
+ blitter_read();
+ alloc_cycle_blitter(last_blitter_hpos, &bltcpt, 3);
+ record_dma_blit(0x70, blt_info.bltcdat, bltcpt, last_blitter_hpos);
+ blitter_nasty++;
+
+ }
+ else if (c == 5) {
+
+ if (ddat1use) {
+ bltdpt = bltcpt;
+ }
+ ddat1use = 1;
+ blitter_line();
+ blitter_line_proc();
+ blitter_nxline();
+
+ }
+ else if (c == 4) {
+
+ /* onedot mode and no pixel = bus write access is skipped */
+ if (blitlinepixel) {
+ blitter_write();
+ alloc_cycle_blitter(last_blitter_hpos, &bltdpt, 4);
+ record_dma_blit(0x00, blt_info.bltddat, bltdpt, last_blitter_hpos);
+ blitlinepixel = 0;
+ blitter_nasty++;
+ }
+ if (blt_info.vblitsize == 0) {
+ bltdpt = bltcpt;
+ blit_final = 1;
+ blit_cyclecounter = 0;
+ blit_waitcyclecounter = 0;
+ // blit finished bit is set and interrupt triggered
+ // immediately after last D write
+ blitter_interrupt(last_blitter_hpos, 0);
+ break;
+ }
+
+ }
+
+ break;
+ }
+ last_blitter_hpos++;
+ }
+ if (hsync)
+ last_blitter_hpos = 0;
+ reset_channel_mods();
+}
+
+#endif
+
static void actually_do_blit(void)
{
- if (blitline) {
- do {
- blitter_read ();
+ if (blitline) {
+ do {
+ blitter_read();
if (ddat1use)
bltdpt = bltcpt;
ddat1use = 1;
- if (blitter_line ()) {
- blitter_write ();
+ blitter_line();
+ blitter_line_proc();
+ blitter_nxline();
+ if (blitlinepixel) {
+ blitter_write();
+ blitlinepixel = 0;
}
- blitter_nxline ();
if (blt_info.vblitsize == 0)
bltstate = BLT_done;
} while (bltstate != BLT_done);
- bltdpt = bltcpt;
- last_custom_value1 = blt_info.bltcdat;
- } else {
+ bltdpt = bltcpt;
+ }
+ else {
if (blitdesc)
- blitter_dofast_desc ();
+ blitter_dofast_desc();
else
- blitter_dofast ();
+ blitter_dofast();
bltstate = BLT_done;
}
}
-static void blitter_doit (void)
+static void blitter_doit(void)
{
if (blt_info.vblitsize == 0 || (blitline && blt_info.hblitsize != 2)) {
- blitter_done ();
+ blitter_done(current_hpos());
return;
}
- actually_do_blit ();
- blitter_done ();
+ if (log_blitter) {
+ if (!blitter_dontdo)
+ actually_do_blit();
+ else
+ bltstate = BLT_done;
+ }
+ else {
+ actually_do_blit();
+ }
+ blitter_done(current_hpos());
}
-void blitter_handler(void)
+void blitter_handler(uae_u32 data)
{
static int blitter_stuck;
- if (!dmaen (DMA_BLITTER)) {
- event_newevent (ev_blitter, 10);
+ if (!dmaen(DMA_BLITTER)) {
+ event2_newevent(ev2_blitter, 10, 0);
blitter_stuck++;
if (blitter_stuck < 20000 || !immediate_blits)
return; /* gotta come back later. */
- /* "free" blitter in immediate mode if it has been "stuck" ~3 frames
- * fixes some JIT game incompatibilities
- */
+ /* "free" blitter in immediate mode if it has been "stuck" ~3 frames
+ * fixes some JIT game incompatibilities
+ */
+ //debugtest(DEBUGTEST_BLITTER, _T("force-unstuck!\n"));
}
blitter_stuck = 0;
if (blit_slowdown > 0 && !immediate_blits) {
- event_newevent (ev_blitter, blit_slowdown);
+ event2_newevent(ev2_blitter, blit_slowdown, 0);
blit_slowdown = -1;
return;
}
- blitter_doit ();
+ blitter_doit();
}
-static void blitter_force_finish (void)
+#ifdef CPUEMU_13
+
+static uae_u32 preva, prevb;
+STATIC_INLINE uae_u16 blitter_doblit(void)
{
- uae_u16 odmacon;
- if (bltstate == BLT_done)
- return;
- if (bltstate != BLT_done) {
- /* blitter is currently running
- * force finish (no blitter state support yet)
- */
- odmacon = dmacon;
- dmacon |= DMA_MASTER | DMA_BLITTER;
- actually_do_blit ();
- blitter_done ();
- dmacon = odmacon;
- }
+ uae_u32 blitahold;
+ uae_u16 bltadat, ddat;
+ uae_u8 mt = bltcon0 & 0xFF;
+
+ bltadat = blt_info.bltadat;
+ if (blitter_hcounter1 == 0)
+ bltadat &= blt_info.bltafwm;
+ if (blitter_hcounter1 == blt_info.hblitsize - 1)
+ bltadat &= blt_info.bltalwm;
+ if (blitdesc)
+ blitahold = (((uae_u32)bltadat << 16) | preva) >> blt_info.blitdownashift;
+ else
+ blitahold = (((uae_u32)preva << 16) | bltadat) >> blt_info.blitashift;
+ preva = bltadat;
+
+ ddat = blit_func(blitahold, blt_info.bltbhold, blt_info.bltcdat, mt) & 0xFFFF;
+
+ if ((bltcon1 & 0x18)) {
+ uae_u16 d = ddat;
+ int ifemode = blitife ? 2 : 0;
+ int fc1 = blit_filltable[d & 255][ifemode + blitfc][1];
+ ddat = (blit_filltable[d & 255][ifemode + blitfc][0]
+ + (blit_filltable[d >> 8][ifemode + fc1][0] << 8));
+ blitfc = blit_filltable[d >> 8][ifemode + fc1][1];
+ }
+
+ if (ddat)
+ blt_info.blitzero = 0;
+
+ return ddat;
}
-static bool invstate (void)
+
+STATIC_INLINE void blitter_doddma(int hpos)
+{
+ uae_u16 d;
+
+ if (blit_dmacount2 == 0) {
+ d = blitter_doblit();
+ }
+ else if (ddat2use) {
+ d = ddat2;
+ ddat2use = 0;
+ }
+ else if (ddat1use) {
+ d = ddat1;
+ ddat1use = 0;
+ }
+ else {
+ static int warn = 10;
+ if (warn > 0) {
+ warn--;
+ write_log(_T("BLITTER: D-channel without nothing to do?\n"));
+ }
+ return;
+ }
+ record_dma_blit(0x00, d, bltdpt, hpos);
+ //last_custom_value1 = d; blitter writes are not stored
+ chipmem_agnus_wput2(bltdpt, d);
+ alloc_cycle_blitter(hpos, &bltdpt, 4);
+ bltdpt += blit_add;
+ blitter_hcounter2++;
+ if (blitter_hcounter2 == blt_info.hblitsize) {
+ blitter_hcounter2 = 0;
+ bltdpt += blit_modaddd;
+ blitter_vcounter2++;
+ if (blit_dmacount2 == 0) // d-only
+ blitter_vcounter1++;
+ if (blitter_vcounter2 > blitter_vcounter1)
+ blitter_vcounter1 = blitter_vcounter2;
+ }
+ if (blit_ch == 1)
+ blitter_hcounter1 = blitter_hcounter2;
+}
+
+STATIC_INLINE void blitter_dodma(int ch, int hpos)
+{
+ uae_u16 dat, reg;
+ uae_u32 addr;
+
+ switch (ch)
+ {
+ case 1:
+ blt_info.bltadat = dat = chipmem_wget_indirect(bltapt);
+ last_custom_value1 = blt_info.bltadat;
+ addr = bltapt;
+ bltapt += blit_add;
+ reg = 0x74;
+ alloc_cycle_blitter(hpos, &bltapt, 1);
+ break;
+ case 2:
+ blt_info.bltbdat = dat = chipmem_wget_indirect(bltbpt);
+ last_custom_value1 = blt_info.bltbdat;
+ addr = bltbpt;
+ bltbpt += blit_add;
+ if (blitdesc)
+ blt_info.bltbhold = (((uae_u32)blt_info.bltbdat << 16) | prevb) >> blt_info.blitdownbshift;
+ else
+ blt_info.bltbhold = (((uae_u32)prevb << 16) | blt_info.bltbdat) >> blt_info.blitbshift;
+ prevb = blt_info.bltbdat;
+ reg = 0x72;
+ alloc_cycle_blitter(hpos, &bltbpt, 2);
+ break;
+ case 3:
+ blt_info.bltcdat = dat = chipmem_wget_indirect(bltcpt);
+ last_custom_value1 = blt_info.bltcdat;
+ addr = bltcpt;
+ bltcpt += blit_add;
+ reg = 0x70;
+ alloc_cycle_blitter(hpos, &bltcpt, 3);
+ break;
+ default:
+ abort();
+ }
+
+ blitter_cyclecounter++;
+ if (blitter_cyclecounter >= blit_dmacount2) {
+ blitter_cyclecounter = 0;
+ ddat2 = ddat1;
+ ddat2use = ddat1use;
+ ddat1use = 0;
+ ddat1 = blitter_doblit();
+ if (bltcon0 & 0x100)
+ ddat1use = 1;
+ blitter_hcounter1++;
+ if (blitter_hcounter1 == blt_info.hblitsize) {
+ blitter_hcounter1 = 0;
+ if (bltcon0 & 0x800)
+ bltapt += blit_modadda;
+ if (bltcon0 & 0x400)
+ bltbpt += blit_modaddb;
+ if (bltcon0 & 0x200)
+ bltcpt += blit_modaddc;
+ blitter_vcounter1++;
+ blitfc = !!(bltcon1 & 0x4);
+ }
+ }
+ record_dma_blit(reg, dat, addr, hpos);
+}
+
+int blitter_need(int hpos)
+{
+ int c;
+ if (bltstate == BLT_done)
+ return 0;
+ if (!dmaen(DMA_BLITTER))
+ return 0;
+ c = channel_state(blit_cyclecounter);
+ return c;
+}
+
+static void do_startcycles(int hpos)
+{
+ int vhpos = last_blitter_hpos;
+ while (vhpos < hpos) {
+ int v = canblit(vhpos);
+ vhpos++;
+ if (v > 0) {
+ blit_startcycles--;
+ if (blit_startcycles == 0) {
+ if (blit_faulty)
+ blit_faulty = -1;
+ bltstate = BLT_done;
+ blit_final = 0;
+ do_blitter(vhpos, 0);
+ blit_startcycles = 0;
+ blit_cyclecounter = 0;
+ blit_waitcyclecounter = 0;
+ if (blit_faulty)
+ blit_faulty = 1;
+ return;
+ }
+ }
+ else {
+ markidlecycle(hpos);
+ }
+ }
+}
+
+void decide_blitter(int hpos)
+{
+ int hsync = hpos < 0;
+
+ if (hsync && blt_delayed_irq) {
+ if (blt_delayed_irq > 0)
+ blt_delayed_irq--;
+ if (blt_delayed_irq <= 0) {
+ blt_delayed_irq = 0;
+ send_interrupt(6, 2 * CYCLE_UNIT);
+ }
+ }
+
+ if (immediate_blits) {
+ if (bltstate == BLT_done)
+ return;
+ if (dmaen(DMA_BLITTER))
+ blitter_doit();
+ return;
+ }
+
+ if (blit_startcycles > 0)
+ do_startcycles(hpos);
+
+ if (bltstate == BLT_done)
+ return;
+
+ if (log_blitter && blitter_delayed_debug) {
+ blitter_delayed_debug = 0;
+ blitter_dump();
+ }
+
+ if (!blitter_cycle_exact)
+ return;
+
+ if (hpos < 0)
+ hpos = maxhpos;
+
+ if (blitline) {
+ blt_info.got_cycle = 1;
+ decide_blitter_line(hsync, hpos);
+ return;
+ }
+
+ while (last_blitter_hpos < hpos) {
+ int c;
+
+ c = channel_state(blit_cyclecounter);
+
+ for (;;) {
+ int v;
+
+ v = canblit(last_blitter_hpos);
+
+ // copper bltsize write needs one cycle (any cycle) delay
+ if (blit_waitcyclecounter) {
+ blit_waitcyclecounter = 0;
+ markidlecycle(last_blitter_hpos);
+ break;
+ }
+ // idle cycles require free bus.
+ // Final empty cycle does not, unless it is fill mode that requires extra idle cycle
+ // (CPU can still use this cycle)
+#if 1
+ if ((blit_cyclecounter < 0 || !blit_final || (blitfill && blit_cycle_diagram_fill[blit_ch][0])) && ((c == 0 && v == 0) || v < 0)) {
+ blit_misscyclecounter++;
+ blitter_nasty++;
+ break;
+ }
+#else
+ if ((c == 0 && v == 0) || v < 0) {
+ if (blit_cyclecounter < 0 || !blit_final) {
+ blit_misscyclecounter++;
+ break;
+ }
+ if (blitfill && blit_cycle_diagram_fill[blit_ch][0]) {
+ blit_misscyclecounter++;
+ blitter_nasty++;
+ break;
+ }
+ }
+#endif
+ if (blit_frozen) {
+ blit_misscyclecounter++;
+ break;
+ }
+
+ if (c == 0) {
+ blt_info.got_cycle = 1;
+ blit_cyclecounter++;
+ if (blit_cyclecounter == 0)
+ blit_final = 0;
+ blit_totalcyclecounter++;
+ /* check if blit with zero channels has ended */
+ if (blit_ch == 0 && blit_cyclecounter >= blit_maxcyclecounter) {
+ blitter_done(last_blitter_hpos);
+ return;
+ }
+ markidlecycle(last_blitter_hpos);
+ break;
+ }
+
+ blitter_nasty++;
+
+ if (v <= 0) {
+ blit_misscyclecounter++;
+ break;
+ }
+
+ blt_info.got_cycle = 1;
+ if (c == 4) {
+ blitter_doddma(last_blitter_hpos);
+ blit_cyclecounter++;
+ blit_totalcyclecounter++;
+ }
+ else {
+ if (blitter_vcounter1 < blt_info.vblitsize) {
+ blitter_dodma(c, last_blitter_hpos);
+ }
+ blit_cyclecounter++;
+ blit_totalcyclecounter++;
+ }
+
+ if (blitter_vcounter1 >= blt_info.vblitsize && blitter_vcounter2 >= blt_info.vblitsize) {
+ if (!ddat1use && !ddat2use) {
+ blitter_done(last_blitter_hpos);
+ return;
+ }
+ }
+ // check this after end check because last D write won't cause any problems.
+ check_channel_mods(last_blitter_hpos, c);
+ break;
+ }
+
+ if (dmaen(DMA_BLITTER) && !blit_final && (blitter_vcounter1 == blt_info.vblitsize || (blitter_vcounter1 == blt_info.vblitsize - 1 && blitter_hcounter1 == blt_info.hblitsize - 1 && blit_dmacount2 == 0))) {
+ if (channel_pos(blit_cyclecounter - 1) == blit_diag[0] - 1) {
+ blitter_interrupt(last_blitter_hpos, 0);
+ blit_cyclecounter = 0;
+ blit_final = 1;
+ }
+ }
+ last_blitter_hpos++;
+ }
+ reset_channel_mods();
+ if (hsync)
+ last_blitter_hpos = 0;
+}
+#else
+void decide_blitter(int hpos) { }
+#endif
+
+static void blitter_force_finish(void)
+{
+ uae_u16 odmacon;
+ if (bltstate == BLT_done)
+ return;
+ if (bltstate != BLT_done) {
+ /* blitter is currently running
+ * force finish (no blitter state support yet)
+ */
+ odmacon = dmacon;
+ dmacon |= DMA_MASTER | DMA_BLITTER;
+ write_log(_T("forcing blitter finish\n"));
+ if (blitter_cycle_exact && !immediate_blits) {
+ int rounds = 10000;
+ while (bltstate != BLT_done && rounds > 0) {
+#ifdef CPUEMU_13
+ memset(cycle_line, 0, sizeof cycle_line);
+#endif
+ decide_blitter(-1);
+ rounds--;
+ }
+ if (rounds == 0)
+ write_log(_T("blitter froze!?\n"));
+ blit_startcycles = 0;
+ }
+ else {
+ actually_do_blit();
+ }
+ blitter_done(current_hpos());
+ dmacon = odmacon;
+ }
+}
+
+static bool invstate(void)
{
return bltstate != BLT_done && bltstate != BLT_init;
}
-static void blit_bltset (int con)
+static void blit_bltset(int con)
{
int i;
+ const int *olddiag = blit_diag;
if (con & 2) {
blitdesc = bltcon1 & 2;
blt_info.blitbshift = bltcon1 >> 12;
blt_info.blitdownbshift = 16 - blt_info.blitbshift;
if ((bltcon1 & 1) && !blitline_started) {
- write_log (_T("BLITTER: linedraw enabled after starting normal blit! %08x\n"), M68K_GETPC);
+ write_log(_T("BLITTER: linedraw enabled after starting normal blit! %08x\n"), M68K_GETPC);
return;
}
- if (bltstate != BLT_done) {
- return;
- }
}
if (con & 1) {
@@ -652,25 +1334,87 @@ static void blit_bltset (int con)
blitline = 0;
bltstate = BLT_done;
blit_interrupt = 1;
- write_log (_T("BLITTER: register modification during linedraw! %08x\n"), M68K_GETPC);
+ write_log(_T("BLITTER: register modification during linedraw! %08x\n"), M68K_GETPC);
+ //if (log_blitter & 16)
+ // activate_debugger();
}
if (blitline) {
+ //if (blt_info.hblitsize != 2) {
+ //debugtest(DEBUGTEST_BLITTER, _T("weird blt_info.hblitsize in linemode: %d vsize=%d\n"),
+ // blt_info.hblitsize, blt_info.vblitsize);
+ //if (log_blitter & 16)
+ // activate_debugger();
+ //}
blit_diag = blit_cycle_diagram_line;
- } else {
+ }
+ else {
if (con & 2) {
blitfc = !!(bltcon1 & 0x4);
blitife = !!(bltcon1 & 0x8);
if ((bltcon1 & 0x18) == 0x18) {
+ //debugtest(DEBUGTEST_BLITTER, _T("weird fill mode\n"));
blitife = 0;
}
}
+ //if (blitfill && !blitdesc) {
+ //debugtest(DEBUGTEST_BLITTER, _T("fill without desc\n"));
+ //if (log_blitter & 16)
+ // activate_debugger();
+ //}
blit_diag = blitfill && blit_cycle_diagram_fill[blit_ch][0] ? blit_cycle_diagram_fill[blit_ch] : blit_cycle_diagram[blit_ch];
}
+ //if ((bltcon1 & 0x80) && (currprefs.chipset_mask & CSMASK_ECS_AGNUS)) {
+ //debugtest(DEBUGTEST_BLITTER, _T("ECS BLTCON1 DOFF-bit set\n"));
+ //if (log_blitter & 16)
+ // activate_debugger();
+ //}
+
+ // on the fly switching fillmode from extra cycle to non-extra: blitter freezes
+ // non-extra cycle to extra cycle: does not freeze but cycle diagram goes weird,
+ // extra free cycle changes to another D write..
+ // (Absolute Inebriation vector cube inside semi-filled vector object requires freezing blitter.)
+ if (!savestate_state && invstate()) {
+ static int freezes = 10;
+ int isen = blit_diag >= &blit_cycle_diagram_fill[0][0] && blit_diag <= &blit_cycle_diagram_fill[15][0];
+ int iseo = olddiag >= &blit_cycle_diagram_fill[0][0] && olddiag <= &blit_cycle_diagram_fill[15][0];
+ if (iseo != isen) {
+ if (freezes > 0) {
+ write_log(_T("BLITTER: on the fly %d (%d) -> %d (%d) switch! PC=%08x\n"), original_ch, iseo, blit_ch, isen, M68K_GETPC);
+ freezes--;
+ }
+ }
+ if (original_fill == isen) {
+ blit_frozen = 0; // switched back to original fill mode? unfreeze
+ }
+ else if (iseo && !isen) {
+ blit_frozen = 1;
+ write_log(_T("BLITTER: frozen! %d (%d) -> %d (%d) %08X\n"), original_ch, iseo, blit_ch, isen, M68K_GETPC);
+ //if (log_blitter & 16)
+ // activate_debugger();
+ }
+ else if (!iseo && isen) {
+ if (!dmaen(DMA_BLITTER)) // subtle shades / nuance bootblock bug
+ blit_frozen = 1;
+ if (log_blitter)
+ write_log(_T("BLITTER: on the fly %d (%d) -> %d (%d) switch\n"), original_ch, iseo, blit_ch, isen);
+ }
+ }
// on the fly switching from CH=1 to CH=D -> blitter stops writing (Rampage/TEK)
// currently just switch to no-channels mode, better than crashing the demo..
- if (!savestate_state && invstate ()) {
+ if (!savestate_state && invstate()) {
+ static uae_u8 changetable[32 * 32];
+ int o = original_ch + (original_fill ? 16 : 0);
+ int n = blit_ch + (blitfill ? 16 : 0);
+ if (o != n) {
+ if (changetable[o * 32 + n] < 10) {
+ changetable[o * 32 + n]++;
+ write_log(_T("BLITTER: channel mode changed while active (%02X->%02X) PC=%08x\n"), o, n, M68K_GETPC);
+ //if (log_blitter & 16)
+ // activate_debugger();
+ }
+ }
if (blit_ch == 13 && original_ch == 1) {
blit_faulty = 1;
}
@@ -693,164 +1437,331 @@ static void blit_bltset (int con)
blit_nod = 0;
}
if (blit_dmacount2 == 0) {
+ ddat2use = 0;
ddat1use = 0;
}
}
-void reset_blit (int bltcon)
+static void blit_modset(void)
{
- if (bltstate == BLT_done)
- return;
- blit_bltset (bltcon);
+ int mult;
+
+ blit_add = blitdesc ? -2 : 2;
+ mult = blitdesc ? -1 : 1;
+ blit_modadda = mult * blt_info.bltamod;
+ blit_modaddb = mult * blt_info.bltbmod;
+ blit_modaddc = mult * blt_info.bltcmod;
+ blit_modaddd = mult * blt_info.bltdmod;
}
-static bool waitingblits (void)
+void reset_blit(int bltcon)
{
- while (bltstate != BLT_done && dmaen (DMA_BLITTER)) {
- x_do_cycles (8 * CYCLE_UNIT);
+ if (bltcon & 1)
+ blinea_shift = bltcon0 >> 12;
+ if (bltcon & 2)
+ blitsign = bltcon1 & 0x40;
+ if (bltstate == BLT_done)
+ return;
+ if (bltcon)
+ blit_bltset(bltcon);
+ blit_modset();
+}
+
+static bool waitingblits(void)
+{
+ //static int warned = 10;
+
+ //bool waited = false;
+ while (bltstate != BLT_done && dmaen(DMA_BLITTER)) {
+ //waited = true;
+ x_do_cycles(8 * CYCLE_UNIT);
}
+ //if (warned && waited) {
+ // warned--;
+ // write_log(_T("waiting_blits detected PC=%08x\n"), M68K_GETPC);
+ //}
if (bltstate == BLT_done)
return true;
return false;
}
-static void blitter_start_init (void)
+static void blitter_start_init(void)
{
blt_info.blitzero = 1;
+#ifdef CPUEMU_13
+ preva = 0;
+ prevb = 0;
+#endif
+ blit_frozen = 0;
blitline_started = bltcon1 & 1;
- blit_bltset (1 | 2);
- ddat1use = 0;
+ blit_bltset(1 | 2);
+ blit_modset();
+ ddat1use = ddat2use = 0;
blit_interrupt = 0;
- blt_info.bltaold = 0;
- blt_info.bltbold = 0;
-
if (blitline) {
- blinea_shift = bltcon0 >> 12;
blinea = blt_info.bltadat;
blineb = (blt_info.bltbdat >> blt_info.blitbshift) | (blt_info.bltbdat << (16 - blt_info.blitbshift));
blitonedot = 0;
+ blitlinepixel = 0;
blitsing = bltcon1 & 0x2;
- blitsign = bltcon1 & 0x40;
}
}
-void do_blitter ()
+static void do_blitter2(int hpos, int copper)
{
int cycles;
int cleanstart;
+ //if ((log_blitter & 2)) {
+ // if (bltstate != BLT_done) {
+ // if (blit_final) {
+ // write_log(_T("blitter was already active! PC=%08x\n"), M68K_GETPC);
+ // //activate_debugger();
+ // }
+ // }
+ //}
+
cleanstart = 0;
if (bltstate == BLT_done) {
- blit_faulty = 0;
+ if (blit_faulty > 0)
+ blit_faulty = 0;
cleanstart = 1;
}
bltstate = BLT_done;
+ blitter_cycle_exact = currprefs.blitter_cycle_exact;
immediate_blits = currprefs.immediate_blits;
- blit_firstline_cycles = blit_first_cycle = get_cycles ();
+ blt_info.got_cycle = 0;
+ last_blitter_hpos = hpos + 1;
+ blit_firstline_cycles = blit_first_cycle = get_cycles();
+ blit_misscyclecounter = 0;
blit_last_cycle = 0;
+ blit_maxcyclecounter = 0;
blit_cyclecounter = 0;
+ blit_totalcyclecounter = 0;
- blitter_start_init ();
+ blitter_start_init();
if (blitline) {
cycles = blt_info.vblitsize;
- } else {
+ }
+ else {
cycles = blt_info.vblitsize * blt_info.hblitsize;
blit_firstline_cycles = blit_first_cycle + (blit_diag[0] * blt_info.hblitsize) * CYCLE_UNIT + cpu_cycles;
}
if (cleanstart) {
original_ch = blit_ch;
+ original_fill = blitfill;
+ original_line = blitline;
}
- bltstate = BLT_init;
+ //if ((log_blitter & 1) || ((log_blitter & 32) && !blitline)) {
+ // blitter_dontdo = 0;
+ // if (1) {
+ // int ch = 0;
+ // if (blit_ch & 1)
+ // ch++;
+ // if (blit_ch & 2)
+ // ch++;
+ // if (blit_ch & 4)
+ // ch++;
+ // if (blit_ch & 8)
+ // ch++;
+ // write_log(_T("blitstart: %dx%d ch=%d %d*%d=%d d=%d f=%02x n=%d pc=%08x l=%d dma=%04x %s\n"),
+ // blt_info.hblitsize, blt_info.vblitsize, ch, blit_diag[0], cycles, blit_diag[0] * cycles,
+ // blitdesc ? 1 : 0, blitfill, dmaen(DMA_BLITPRI) ? 1 : 0, M68K_GETPC, blitline,
+ // dmacon, ((dmacon & (DMA_MASTER | DMA_BLITTER)) == (DMA_MASTER | DMA_BLITTER)) ? _T("") : _T(" off!"));
+ // blitter_dump();
+ // }
+ //}
+
+ bltstate = BLT_init;
blit_slowdown = 0;
- if (dmaen(DMA_BLITPRI))
- set_special (SPCFLAG_BLTNASTY);
- else
- unset_special (SPCFLAG_BLTNASTY);
+ if (dmaen(DMA_BLITPRI))
+ set_special(SPCFLAG_BLTNASTY);
+ else
+ unset_special(SPCFLAG_BLTNASTY);
- if (blt_info.vblitsize == 0 || (blitline && blt_info.hblitsize != 2)) {
- if (dmaen (DMA_BLITTER))
- blitter_done ();
+ if (dmaen(DMA_BLITTER))
+ bltstate = BLT_work;
+
+ blit_maxcyclecounter = 0x7fffffff;
+ blit_waitcyclecounter = 0;
+
+ if (blitter_cycle_exact) {
+ if (immediate_blits) {
+ if (dmaen(DMA_BLITTER))
+ blitter_doit();
+ return;
+ }
+ if (log_blitter & 8) {
+ blitter_handler(0);
+ }
+ else {
+#ifdef CPUEMU_13
+ blitter_hcounter1 = blitter_hcounter2 = 0;
+ blitter_vcounter1 = blitter_vcounter2 = 0;
+ if (blit_nod)
+ blitter_vcounter2 = blt_info.vblitsize;
+#endif
+ blit_cyclecounter = -BLITTER_STARTUP_CYCLES;
+ blit_waitcyclecounter = copper;
+ blit_startcycles = 0;
+ blit_maxcyclecounter = blt_info.hblitsize * blt_info.vblitsize + 2;
+ }
return;
}
- blit_cyclecounter = cycles * (blit_dmacount2 + (blit_nod ? 0 : 1));
- if (!dmaen (DMA_BLITTER))
- return;
-
- bltstate = BLT_work;
-
- if (immediate_blits) {
- blitter_doit ();
- return;
+ if (blt_info.vblitsize == 0 || (blitline && blt_info.hblitsize != 2)) {
+ if (dmaen(DMA_BLITTER))
+ blitter_done(hpos);
+ return;
}
- event_newevent(ev_blitter, blit_cyclecounter);
+ if (dmaen(DMA_BLITTER)) {
+ blt_info.got_cycle = 1;
+ }
- if (dmaen (DMA_BLITTER)) {
+ if (immediate_blits) {
+ if (dmaen(DMA_BLITTER))
+ blitter_doit();
+ return;
+ }
+
+ blit_cyclecounter = cycles * (blit_dmacount2 + (blit_nod ? 0 : 1));
+ event2_newevent(ev2_blitter, blit_cyclecounter, 0);
+
+ if (dmaen(DMA_BLITTER) && (currprefs.cpu_model >= 68020 || !currprefs.cpu_memory_cycle_exact)) {
if (currprefs.waiting_blits) {
// wait immediately if all cycles in use and blitter nastry
if (blit_dmacount == blit_diag[0] && (regs.spcflags & SPCFLAG_BLTNASTY)) {
- waitingblits ();
+ waitingblits();
}
}
}
}
-void blitter_check_start (void)
+void blitter_check_start(void)
{
- blitter_start_init ();
+ if (bltstate != BLT_init)
+ return;
+ blitter_start_init();
bltstate = BLT_work;
-
if (immediate_blits) {
- blitter_doit ();
- } else {
- event_newevent(ev_blitter, blit_cyclecounter);
- }
+ blitter_doit();
+ }
}
-void maybe_blit2 (int hack)
+void do_blitter(int hpos, int copper)
{
- if (dmaen (DMA_BLITTER)) {
+ if (bltstate == BLT_done || !blitter_cycle_exact) {
+ do_blitter2(hpos, copper);
+ return;
+ }
+ if (!dmaen(DMA_BLITTER) || !blt_info.got_cycle)
+ return;
+ // previous blit may have last write cycle left
+ // and we must let it finish
+ blit_startcycles = BLITTER_STARTUP_CYCLES;
+ blit_waitcyclecounter = copper;
+}
+
+void maybe_blit(int hpos, int hack)
+{
+ static int warned = 10;
+
+ reset_channel_mods();
+
+ if (bltstate == BLT_done)
+ return;
+
+ if (savestate_state)
+ return;
+
+ if (dmaen(DMA_BLITTER) && (currprefs.cpu_model >= 68020 || !currprefs.cpu_memory_cycle_exact)) {
bool doit = false;
- if (currprefs.waiting_blits) { // automatic
+ if (currprefs.waiting_blits == 3) { // always
+ doit = true;
+ }
+ else if (currprefs.waiting_blits == 2) { // noidle
+ if (blit_dmacount == blit_diag[0] && (regs.spcflags & SPCFLAG_BLTNASTY))
+ doit = true;
+ }
+ else if (currprefs.waiting_blits == 1) { // automatic
if (blit_dmacount == blit_diag[0] && (regs.spcflags & SPCFLAG_BLTNASTY))
doit = true;
else if (currprefs.m68k_speed < 0)
doit = true;
}
if (doit) {
- if (waitingblits ())
+ if (waitingblits())
return;
}
}
- if (hack == 1 && (int)get_cycles() - (int)blit_firstline_cycles < 0)
- return;
+ if (warned && dmaen(DMA_BLITTER) && blt_info.got_cycle) {
+ warned--;
+ //debugtest(DEBUGTEST_BLITTER, _T("program does not wait for blitter tc=%d\n"), blit_cyclecounter);
+ if (log_blitter)
+ warned = 0;
+ if (log_blitter & 2) {
+ warned = 10;
+ write_log(_T("program does not wait for blitter PC=%08x\n"), M68K_GETPC);
+ }
+ }
- blitter_handler ();
+ if (blitter_cycle_exact) {
+ decide_blitter(hpos);
+ goto end;
+ }
+
+ if (hack == 1 && int(get_cycles()) - int(blit_firstline_cycles) < 0)
+ goto end;
+
+ blitter_handler(0);
+end:;
+ if (log_blitter)
+ blitter_delayed_debug = 1;
}
-int blitnasty (void)
+void check_is_blit_dangerous(uaecptr *bplpt, int planes, int words)
+{
+ blitter_dangerous_bpl = 0;
+ if (bltstate == BLT_done || !blitter_cycle_exact)
+ return;
+ // too simple but better than nothing
+ for (int i = 0; i < planes; i++) {
+ uaecptr bpl = bplpt[i];
+ uaecptr dpt = bltdpt & chipmem_bank.mask;
+ if (dpt >= bpl - 2 * words && dpt < bpl + 2 * words) {
+ blitter_dangerous_bpl = 1;
+ return;
+ }
+ }
+}
+
+int blitnasty(void)
{
int cycles, ccnt;
if (bltstate == BLT_done)
return 0;
- if (!dmaen (DMA_BLITTER))
+ if (!dmaen(DMA_BLITTER))
return 0;
+ if (blitter_cycle_exact) {
+ blitter_force_finish();
+ return -1;
+ }
if (blit_last_cycle >= blit_diag[0] && blit_dmacount == blit_diag[0])
return 0;
- cycles = (get_cycles () - blit_first_cycle) / CYCLE_UNIT;
+ cycles = (get_cycles() - blit_first_cycle) / CYCLE_UNIT;
ccnt = 0;
while (blit_last_cycle < cycles) {
- int c = channel_state (blit_last_cycle++);
+ int c = channel_state(blit_last_cycle++);
if (!c)
ccnt++;
}
@@ -858,171 +1769,266 @@ int blitnasty (void)
}
/* very approximate emulation of blitter slowdown caused by bitplane DMA */
-void blitter_slowdown (int ddfstrt, int ddfstop, int totalcycles, int freecycles)
+void blitter_slowdown(int ddfstrt, int ddfstop, int totalcycles, int freecycles)
{
- static int oddfstrt, oddfstop, ototal, ofree;
- static int slow;
+ static int oddfstrt, oddfstop, ototal, ofree;
+ static int slow;
- if (!totalcycles || ddfstrt < 0 || ddfstop < 0)
- return;
- if (ddfstrt != oddfstrt || ddfstop != oddfstop || totalcycles != ototal || ofree != freecycles) {
- int linecycles = ((ddfstop - ddfstrt + totalcycles - 1) / totalcycles) * totalcycles;
- int freelinecycles = ((ddfstop - ddfstrt + totalcycles - 1) / totalcycles) * freecycles;
- int dmacycles = (linecycles * blit_dmacount) / blit_diag[0];
- oddfstrt = ddfstrt;
- oddfstop = ddfstop;
- ototal = totalcycles;
- ofree = freecycles;
- slow = 0;
- if (dmacycles > freelinecycles)
- slow = dmacycles - freelinecycles;
- }
- if (blit_slowdown < 0 || blitline)
- return;
- blit_slowdown += slow;
+ if (!totalcycles || ddfstrt < 0 || ddfstop < 0)
+ return;
+ if (ddfstrt != oddfstrt || ddfstop != oddfstop || totalcycles != ototal || ofree != freecycles) {
+ int linecycles = ((ddfstop - ddfstrt + totalcycles - 1) / totalcycles) * totalcycles;
+ int freelinecycles = ((ddfstop - ddfstrt + totalcycles - 1) / totalcycles) * freecycles;
+ int dmacycles = (linecycles * blit_dmacount) / blit_diag[0];
+ oddfstrt = ddfstrt;
+ oddfstop = ddfstop;
+ ototal = totalcycles;
+ ofree = freecycles;
+ slow = 0;
+ if (dmacycles > freelinecycles)
+ slow = dmacycles - freelinecycles;
+ }
+ if (blit_slowdown < 0 || blitline)
+ return;
+ blit_slowdown += slow;
+ blit_misscyclecounter += slow;
+}
+
+void blitter_reset(void)
+{
+ bltptxpos = -1;
}
#ifdef SAVESTATE
-uae_u8 *restore_blitter (uae_u8 *src)
+void restore_blitter_finish(void)
{
- uae_u32 flags = restore_u32();
-
- bltstate = BLT_done;
- if (flags & 4) {
- bltstate = (flags & 1) ? BLT_done : BLT_init;
- }
- return src;
+ //record_dma_reset();
+ //record_dma_reset();
+ if (blt_statefile_type == 0) {
+ blit_interrupt = 1;
+ if (bltstate == BLT_init) {
+ write_log(_T("blitter was started but DMA was inactive during save\n"));
+ //do_blitter (0);
+ }
+ if (blt_delayed_irq < 0) {
+ if (intreq & 0x0040)
+ blt_delayed_irq = 3;
+ intreq &= ~0x0040;
+ }
+ }
+ else {
+ last_blitter_hpos = 0;
+ blit_modset();
+ }
}
-uae_u8 *save_blitter (int *len, uae_u8 *dstptr)
+uae_u8 *restore_blitter(uae_u8 *src)
{
- uae_u8 *dstbak,*dst;
- int forced;
+ uae_u32 flags = restore_u32();
+
+ blt_statefile_type = 0;
+ blt_delayed_irq = 0;
+ bltstate = BLT_done;
+ if (flags & 4) {
+ bltstate = (flags & 1) ? BLT_done : BLT_init;
+ }
+ if (flags & 2) {
+ write_log(_T("blitter was force-finished when this statefile was saved\n"));
+ write_log(_T("contact the author if restored program freezes\n"));
+ // there is a problem. if system ks vblank is active, we must not activate
+ // "old" blit's intreq until vblank is handled or ks 1.x thinks it was blitter
+ // interrupt..
+ blt_delayed_irq = -1;
+ }
+ return src;
+}
+
+uae_u8 *save_blitter(int *len, uae_u8 *dstptr)
+{
+ uae_u8 *dstbak, *dst;
+ int forced;
+
+ forced = 0;
+ if (bltstate != BLT_done && bltstate != BLT_init) {
+ write_log(_T("blitter is active, forcing immediate finish\n"));
+ /* blitter is active just now but we don't have blitter state support yet */
+ blitter_force_finish();
+ forced = 2;
+ }
+ if (dstptr)
+ dstbak = dst = dstptr;
+ else
+ dstbak = dst = xmalloc(uae_u8, 16);
+ save_u32(((bltstate != BLT_done) ? 0 : 1) | forced | 4);
+ *len = dst - dstbak;
+ return dstbak;
- forced = 0;
- if (bltstate != BLT_done && bltstate != BLT_init) {
- write_log (_T("blitter is active, forcing immediate finish\n"));
- /* blitter is active just now but we don't have blitter state support yet */
- blitter_force_finish ();
- forced = 2;
- }
- if (dstptr)
- dstbak = dst = dstptr;
- else
- dstbak = dst = xmalloc (uae_u8, 16);
- save_u32(((bltstate != BLT_done) ? 0 : 1) | forced | 4);
- *len = dst - dstbak;
- return dstbak;
}
// totally non-real-blitter-like state save but better than nothing..
-uae_u8 *restore_blitter_new (uae_u8 *src)
+uae_u8 *restore_blitter_new(uae_u8 *src)
{
uae_u8 state;
- state = restore_u8 ();
+ blt_statefile_type = 1;
+ blitter_cycle_exact = restore_u8();
+ state = restore_u8();
- blit_first_cycle = restore_u32 ();
- blit_last_cycle = restore_u32 ();
- blit_firstline_cycles = restore_u32 ();
- blit_cyclecounter = restore_u32 ();
- blit_slowdown = restore_u32 ();
+ blit_first_cycle = restore_u32();
+ blit_last_cycle = restore_u32();
+ blit_waitcyclecounter = restore_u32();
+ blit_startcycles = restore_u32();
+ blit_maxcyclecounter = restore_u32();
+ blit_firstline_cycles = restore_u32();
+ blit_cyclecounter = restore_u32();
+ blit_slowdown = restore_u32();
+ blit_misscyclecounter = restore_u32();
+#ifdef CPUEMU_13
+ blitter_hcounter1 = restore_u16();
+ blitter_hcounter2 = restore_u16();
+ blitter_vcounter1 = restore_u16();
+ blitter_vcounter2 = restore_u16();
+#endif
+ blit_ch = restore_u8();
+ blit_dmacount = restore_u8();
+ blit_dmacount2 = restore_u8();
+ blit_nod = restore_u8();
+ blit_final = restore_u8();
+ blitfc = restore_u8();
+ blitife = restore_u8();
- blit_ch = restore_u8 ();
- blit_dmacount = restore_u8 ();
- blit_dmacount2 = restore_u8 ();
- blit_nod = restore_u8 ();
- blitfc = restore_u8 ();
- blitife = restore_u8 ();
+ blt_info.blitbshift = restore_u8();
+ blt_info.blitdownbshift = restore_u8();
+ blt_info.blitashift = restore_u8();
+ blt_info.blitdownashift = restore_u8();
- blt_info.blitbshift = restore_u8 ();
- blt_info.blitdownbshift = restore_u8 ();
- blt_info.blitashift = restore_u8 ();
- blt_info.blitdownashift = restore_u8 ();
+ ddat1use = restore_u8();
+ ddat2use = restore_u8();
+ ddat1 = restore_u16();
+ ddat2 = restore_u16();
- ddat1use = restore_u8 ();
+ blitline = restore_u8();
+ blitfill = restore_u8();
+ blinea = restore_u16();
+ blineb = restore_u16();
+ blinea_shift = restore_u8();
+ blitonedot = restore_u8();
+ blitlinepixel = restore_u8();
+ blitsing = restore_u8();
+ blitlinepixel = restore_u8();
+ blit_interrupt = restore_u8();
+ blt_delayed_irq = restore_u8();
+ blt_info.blitzero = restore_u8();
+ blt_info.got_cycle = restore_u8();
- blitline = restore_u8 ();
- blitfill = restore_u8 ();
- blinea = restore_u16 ();
- blineb = restore_u16 ();
- blinea_shift = restore_u8 ();
- blitonedot = restore_u8 ();
- blitsing = restore_u8 ();
- blit_interrupt = restore_u8 ();
- blt_info.blitzero = restore_u8 ();
+ blit_frozen = restore_u8();
+ blit_faulty = restore_u8();
+ original_ch = restore_u8();
+ original_fill = restore_u8();
+ original_line = restore_u8();
- blit_faulty = restore_u8 ();
- original_ch = restore_u8 ();
+ blit_diag = set_cycle_diagram_type(restore_u8());
- blit_diag = set_cycle_diagram_type (restore_u8 ());
+ if (restore_u16() != 0x1234)
+ write_log(_T("error\n"));
- if (restore_u16 () != 0x1234)
- write_log (_T("error\n"));
+ blitter_nasty = restore_u8();
bltstate = BLT_done;
- if (state > 0)
- do_blitter ();
+ if (!blitter_cycle_exact) {
+ if (state > 0)
+ do_blitter(0, 0);
+ }
+ else {
+ if (state == 1)
+ bltstate = BLT_init;
+ else if (state == 2)
+ bltstate = BLT_work;
+ }
return src;
}
-uae_u8 *save_blitter_new (int *len, uae_u8 *dstptr)
+uae_u8 *save_blitter_new(int *len, uae_u8 *dstptr)
{
- uae_u8 *dstbak,*dst;
+ uae_u8 *dstbak, *dst;
if (dstptr)
dstbak = dst = dstptr;
else
- dstbak = dst = xmalloc (uae_u8, 1000);
+ dstbak = dst = xmalloc(uae_u8, 1000);
uae_u8 state;
+ save_u8(blitter_cycle_exact ? 1 : 0);
if (bltstate == BLT_done)
state = 0;
else if (bltstate == BLT_init)
state = 1;
else
state = 2;
- save_u8 (state);
+ save_u8(state);
if (bltstate != BLT_done) {
- write_log (_T("BLITTER active while saving state\n"));
+ //write_log(_T("BLITTER active while saving state\n"));
+ //blitter_dump();
}
- save_u32 (blit_first_cycle);
- save_u32 (blit_last_cycle);
- save_u32 (blit_firstline_cycles);
- save_u32 (blit_cyclecounter);
- save_u32 (blit_slowdown);
+ save_u32(blit_first_cycle);
+ save_u32(blit_last_cycle);
+ save_u32(blit_waitcyclecounter);
+ save_u32(blit_startcycles);
+ save_u32(blit_maxcyclecounter);
+ save_u32(blit_firstline_cycles);
+ save_u32(blit_cyclecounter);
+ save_u32(blit_slowdown);
+ save_u32(blit_misscyclecounter);
+#ifdef CPUEMU_13
+ save_u16(blitter_hcounter1);
+ save_u16(blitter_hcounter2);
+ save_u16(blitter_vcounter1);
+ save_u16(blitter_vcounter2);
+#endif
+ save_u8(blit_ch);
+ save_u8(blit_dmacount);
+ save_u8(blit_dmacount2);
+ save_u8(blit_nod);
+ save_u8(blit_final);
+ save_u8(blitfc);
+ save_u8(blitife);
- save_u8 (blit_ch);
- save_u8 (blit_dmacount);
- save_u8 (blit_dmacount2);
- save_u8 (blit_nod);
- save_u8 (blitfc);
- save_u8 (blitife);
+ save_u8(blt_info.blitbshift);
+ save_u8(blt_info.blitdownbshift);
+ save_u8(blt_info.blitashift);
+ save_u8(blt_info.blitdownashift);
- save_u8 (blt_info.blitbshift);
- save_u8 (blt_info.blitdownbshift);
- save_u8 (blt_info.blitashift);
- save_u8 (blt_info.blitdownashift);
+ save_u8(ddat1use);
+ save_u8(ddat2use);
+ save_u16(ddat1);
+ save_u16(ddat2);
- save_u8 (ddat1use);
+ save_u8(blitline);
+ save_u8(blitfill);
+ save_u16(blinea);
+ save_u16(blineb);
+ save_u8(blinea_shift);
+ save_u8(blitonedot);
+ save_u8(blitlinepixel);
+ save_u8(blitsing);
+ save_u8(blitlinepixel);
+ save_u8(blit_interrupt);
+ save_u8(blt_delayed_irq);
+ save_u8(blt_info.blitzero);
+ save_u8(blt_info.got_cycle);
- save_u8 (blitline);
- save_u8 (blitfill);
- save_u16 (blinea);
- save_u16 (blineb);
- save_u8 (blinea_shift);
- save_u8 (blitonedot);
- save_u8 (blitsing);
- save_u8 (blit_interrupt);
- save_u8 (blt_info.blitzero);
-
- save_u8 (blit_faulty);
- save_u8 (original_ch);
- save_u8 (get_cycle_diagram_type (blit_diag));
+ save_u8(blit_frozen);
+ save_u8(blit_faulty);
+ save_u8(original_ch);
+ save_u8(original_fill);
+ save_u8(original_line);
+ save_u8(get_cycle_diagram_type(blit_diag));
- save_u16 (0x1234);
+ save_u16(0x1234);
+
+ save_u8(blitter_nasty);
*len = dst - dstbak;
return dstbak;
diff --git a/src/blkdev.cpp b/src/blkdev.cpp
index 986a297b..1f30fad0 100644
--- a/src/blkdev.cpp
+++ b/src/blkdev.cpp
@@ -10,16 +10,21 @@
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
-#include "memory.h"
+#include "include/memory.h"
-#include "traps.h"
#include "blkdev.h"
+#include "scsidev.h"
#include "savestate.h"
#include "crc32.h"
#include "threaddep/thread.h"
#include "execio.h"
#include "zfile.h"
-#include "fsdb.h"
+#include "scsi.h"
+#ifdef RETROPLATFORM
+#include "rp.h"
+#endif
+
+int log_scsiemu = 0;
#define PRE_INSERT_DELAY (3 * (currprefs.ntscmode ? 60 : 50))
@@ -45,10 +50,29 @@ struct blkdevstate
struct blkdevstate state[MAX_TOTAL_SCSI_DEVICES];
+#if 0
+static int scsiemu[MAX_TOTAL_SCSI_DEVICES];
+
+static struct device_functions *device_func[MAX_TOTAL_SCSI_DEVICES];
+static int openlist[MAX_TOTAL_SCSI_DEVICES];
+static int waspaused[MAX_TOTAL_SCSI_DEVICES];
+static int delayed[MAX_TOTAL_SCSI_DEVICES];
+static uae_sem_t unitsem[MAX_TOTAL_SCSI_DEVICES];
+static int unitsem_cnt[MAX_TOTAL_SCSI_DEVICES];
+
+static int play_end_pos[MAX_TOTAL_SCSI_DEVICES];
+static uae_u8 play_qcode[MAX_TOTAL_SCSI_DEVICES][SUBQ_SIZE];
+
+static TCHAR newimagefiles[MAX_TOTAL_SCSI_DEVICES][256];
+static int imagechangetime[MAX_TOTAL_SCSI_DEVICES];
+static bool cdimagefileinuse[MAX_TOTAL_SCSI_DEVICES];
+static int wasopen[MAX_TOTAL_SCSI_DEVICES];
+#endif
+
static bool dev_init;
/* convert minutes, seconds and frames -> logical sector number */
-int msf2lsn (int msf)
+int msf2lsn(int msf)
{
int sector = (((msf >> 16) & 0xff) * 60 * 75 + ((msf >> 8) & 0xff) * 75 + ((msf >> 0) & 0xff));
sector -= 150;
@@ -56,7 +80,7 @@ int msf2lsn (int msf)
}
/* convert logical sector number -> minutes, seconds and frames */
-int lsn2msf (int sectors)
+int lsn2msf(int sectors)
{
int msf;
sectors += 150;
@@ -66,65 +90,72 @@ int lsn2msf (int sectors)
return msf;
}
-uae_u8 frombcd (uae_u8 v)
+uae_u8 frombcd(uae_u8 v)
{
return (v >> 4) * 10 + (v & 15);
}
-uae_u8 tobcd (uae_u8 v)
+uae_u8 tobcd(uae_u8 v)
{
return ((v / 10) << 4) | (v % 10);
}
-int fromlongbcd (uae_u8 *p)
+int fromlongbcd(uae_u8 *p)
{
- return (frombcd (p[0]) << 16) | (frombcd (p[1]) << 8) | (frombcd (p[2]) << 0);
+ return (frombcd(p[0]) << 16) | (frombcd(p[1]) << 8) | (frombcd(p[2]) << 0);
}
-void tolongbcd (uae_u8 *p, int v)
+void tolongbcd(uae_u8 *p, int v)
{
- p[0] = tobcd ((v >> 16) & 0xff);
- p[1] = tobcd ((v >> 8) & 0xff);
- p[2] = tobcd ((v >> 0) & 0xff);
+ p[0] = tobcd((v >> 16) & 0xff);
+ p[1] = tobcd((v >> 8) & 0xff);
+ p[2] = tobcd((v >> 0) & 0xff);
}
-static struct cd_toc *gettoc (int unitnum, struct cd_toc_head *th, int block)
+static struct cd_toc *gettoc(struct cd_toc_head *th, int block)
{
- if (th->lastaddress == 0) {
- if (unitnum < 0)
- return NULL;
- if (!sys_command_cd_toc(unitnum, th))
- return NULL;
- }
for (int i = th->first_track_offset + 1; i <= th->last_track_offset; i++) {
struct cd_toc *t = &th->toc[i];
if (block < t->paddress)
- return t - 1;
+ return t - 1;
}
return &th->toc[th->last_track_offset];
}
-int isaudiotrack (struct cd_toc_head *th, int block)
+int isaudiotrack(struct cd_toc_head *th, int block)
{
- struct cd_toc *t = gettoc (-1, th, block);
+ struct cd_toc *t = gettoc(th, block);
if (!t)
return 0;
return (t->control & 0x0c) != 4;
}
-int isdatatrack (struct cd_toc_head *th, int block)
+int isdatatrack(struct cd_toc_head *th, int block)
{
- return !isaudiotrack (th, block);
+ return !isaudiotrack(th, block);
}
static int cdscsidevicetype[MAX_TOTAL_SCSI_DEVICES];
+//#ifdef _WIN32
+//
+//#include "od-win32/win32.h"
+//
+//extern struct device_functions devicefunc_win32_spti;
+//extern struct device_functions devicefunc_win32_ioctl;
+//
+//#endif
+
+extern struct device_functions devicefunc_cdimage;
+
static struct device_functions *devicetable[] = {
NULL,
&devicefunc_cdimage,
- NULL,
- NULL,
+//#ifdef _WIN32
+// &devicefunc_win32_ioctl,
+// &devicefunc_win32_spti,
+//#endif
+ NULL
};
-#define NUM_DEVICE_TABLE_ENTRIES 4
-static int driver_installed[NUM_DEVICE_TABLE_ENTRIES];
+static int driver_installed[6];
-static void install_driver (int flags)
+static void install_driver(int flags)
{
for (int i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
struct blkdevstate *st = &state[i];
@@ -135,49 +166,30 @@ static void install_driver (int flags)
if (flags > 0) {
state[0].device_func = devicetable[flags];
state[0].scsiemu = true;
- } else {
+ }
+ else {
for (int i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
struct blkdevstate *st = &state[i];
st->scsiemu = false;
st->device_func = NULL;
switch (cdscsidevicetype[i])
{
- case SCSI_UNIT_IMAGE:
- st->device_func = devicetable[SCSI_UNIT_IMAGE];
- st->scsiemu = true;
- break;
+ case SCSI_UNIT_IMAGE:
+ st->device_func = devicetable[SCSI_UNIT_IMAGE];
+ st->scsiemu = true;
+ break;
}
- // do not default to image mode if unit 1+ and automount
- if (i == 0) {
- // use image mode if driver disabled
- for (int j = 1; j < NUM_DEVICE_TABLE_ENTRIES; j++) {
- if (devicetable[j] == st->device_func && driver_installed[j] < 0) {
- st->device_func = devicetable[SCSI_UNIT_IMAGE];
- st->scsiemu = true;
- }
- }
- }
- }
+ }
}
- for (int j = 1; j < NUM_DEVICE_TABLE_ENTRIES; j++) {
- if (devicetable[j] == NULL) {
- continue;
- }
+ for (int j = 1; devicetable[j]; j++) {
if (!driver_installed[j]) {
for (int i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
struct blkdevstate *st = &state[i];
if (st->device_func == devicetable[j]) {
- int ok = st->device_func->openbus (0);
- if (!ok && st->device_func != devicetable[SCSI_UNIT_IMAGE]) {
- st->device_func = devicetable[SCSI_UNIT_IMAGE];
- st->scsiemu = true;
- write_log (_T("Fallback to image mode, unit %d.\n"), i);
- driver_installed[j] = -1;
- } else {
- driver_installed[j] = 1;
- }
- write_log (_T("%s driver installed, ok=%d\n"), st->device_func->name, ok);
+ int ok = st->device_func->openbus(0);
+ driver_installed[j] = 1;
+ write_log(_T("%s driver installed, ok=%d\n"), st->device_func->name, ok);
break;
}
}
@@ -186,18 +198,17 @@ static void install_driver (int flags)
}
-void blkdev_default_prefs (struct uae_prefs *p)
+void blkdev_default_prefs(struct uae_prefs *p)
{
for (int i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
p->cdslots[i].name[0] = 0;
p->cdslots[i].inuse = false;
p->cdslots[i].type = SCSI_UNIT_DEFAULT;
- p->cdslots[i].temporary = false;
cdscsidevicetype[i] = SCSI_UNIT_DEFAULT;
}
}
-void blkdev_fix_prefs (struct uae_prefs *p)
+void blkdev_fix_prefs(struct uae_prefs *p)
{
for (int i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
cdscsidevicetype[i] = p->cdslots[i].type;
@@ -215,148 +226,149 @@ void blkdev_fix_prefs (struct uae_prefs *p)
}
-static bool getsem (int unitnum, bool dowait)
+static bool getsem(int unitnum, bool dowait)
{
struct blkdevstate *st = &state[unitnum];
if (st->sema == NULL)
- uae_sem_init (&st->sema, 0, 1);
+ uae_sem_init(&st->sema, 0, 1);
bool gotit = false;
if (dowait) {
- uae_sem_wait (&st->sema);
+ uae_sem_wait(&st->sema);
gotit = true;
- } else {
- gotit = uae_sem_trywait (&st->sema) == 0;
+ }
+ else {
+ gotit = uae_sem_trywait(&st->sema) == 0;
}
if (gotit)
st->sema_cnt++;
if (st->sema_cnt > 1)
- write_log (_T("CD: unitsem%d acquire mismatch! cnt=%d\n"), unitnum, st->sema_cnt);
+ write_log(_T("CD: unitsem%d acquire mismatch! cnt=%d\n"), unitnum, st->sema_cnt);
return gotit;
}
-static bool getsem (int unitnum)
+static bool getsem(int unitnum)
{
- return getsem (unitnum, false);
+ return getsem(unitnum, false);
}
-static void freesem (int unitnum)
+static void freesem(int unitnum)
{
struct blkdevstate *st = &state[unitnum];
st->sema_cnt--;
if (st->sema_cnt < 0)
- write_log (_T("CD: unitsem%d release mismatch! cnt=%d\n"), unitnum, st->sema_cnt);
- uae_sem_post (&st->sema);
+ write_log(_T("CD: unitsem%d release mismatch! cnt=%d\n"), unitnum, st->sema_cnt);
+ uae_sem_post(&st->sema);
}
-static void sys_command_close_internal (int unitnum)
+static void sys_command_close_internal(int unitnum)
{
struct blkdevstate *st = &state[unitnum];
- getsem (unitnum, true);
+ getsem(unitnum, true);
st->waspaused = 0;
if (st->isopen <= 0)
- write_log (_T("BUG unit %d close: opencnt=%d!\n"), unitnum, st->isopen);
+ write_log(_T("BUG unit %d close: opencnt=%d!\n"), unitnum, st->isopen);
if (st->device_func) {
- state[unitnum].device_func->closedev (unitnum);
+ state[unitnum].device_func->closedev(unitnum);
if (st->isopen > 0)
st->isopen--;
}
- freesem (unitnum);
+ freesem(unitnum);
if (st->isopen == 0) {
- uae_sem_destroy (&st->sema);
+ uae_sem_destroy(&st->sema);
st->sema = NULL;
}
}
-static int sys_command_open_internal (int unitnum, const TCHAR *ident, cd_standard_unit csu)
+static int sys_command_open_internal(int unitnum, const TCHAR *ident, cd_standard_unit csu)
{
struct blkdevstate *st = &state[unitnum];
int ret = 0;
if (st->sema == NULL)
- uae_sem_init (&st->sema, 0, 1);
- getsem (unitnum, true);
+ uae_sem_init(&st->sema, 0, 1);
+ getsem(unitnum, true);
if (st->isopen)
- write_log (_T("BUG unit %d open: opencnt=%d!\n"), unitnum, st->isopen);
+ write_log(_T("BUG unit %d open: opencnt=%d!\n"), unitnum, st->isopen);
if (st->device_func) {
- ret = state[unitnum].device_func->opendev (unitnum, ident, csu != CD_STANDARD_UNIT_DEFAULT);
+ ret = state[unitnum].device_func->opendev(unitnum, ident, csu != CD_STANDARD_UNIT_DEFAULT);
if (ret)
st->isopen++;
}
- freesem (unitnum);
+ freesem(unitnum);
return ret;
}
-static int getunitinfo (int unitnum, int drive, cd_standard_unit csu, int *isaudio)
+static int getunitinfo(int unitnum, int drive, cd_standard_unit csu, int *isaudio)
{
struct device_info di;
- if (sys_command_info (unitnum, &di, 0)) {
- write_log (_T("Scanning drive %s: "), di.label);
+ if (sys_command_info(unitnum, &di, 0)) {
+ write_log(_T("Scanning drive %s: "), di.label);
if (di.media_inserted) {
- if (isaudiotrack (&di.toc, 0)) {
+ if (isaudiotrack(&di.toc, 0)) {
if (*isaudio == 0)
*isaudio = drive;
- write_log (_T("CDA"));
+ write_log(_T("CDA"));
}
uae_u8 buffer[2048];
- if (sys_command_cd_read (unitnum, buffer, 16, 1)) {
- if (!memcmp (buffer + 8, "CDTV", 4) || !memcmp (buffer + 8, "CD32", 4) || !memcmp (buffer + 8, "COMM", 4)) {
+ if (sys_command_cd_read(unitnum, buffer, 16, 1)) {
+ if (!memcmp(buffer + 8, "CDTV", 4) || !memcmp(buffer + 8, "CD32", 4) || !memcmp(buffer + 8, "COMM", 4)) {
uae_u32 crc;
- write_log (_T("CD32 or CDTV"));
- if (sys_command_cd_read (unitnum, buffer, 21, 1)) {
- crc = get_crc32 (buffer, sizeof buffer);
+ write_log(_T("CD32 or CDTV"));
+ if (sys_command_cd_read(unitnum, buffer, 21, 1)) {
+ crc = get_crc32(buffer, sizeof buffer);
if (crc == 0xe56c340f) {
- write_log (_T(" [CD32.TM]"));
+ write_log(_T(" [CD32.TM]"));
if (csu == CD_STANDARD_UNIT_CD32) {
- write_log (_T("\n"));
+ write_log(_T("\n"));
return 1;
}
}
}
if (csu == CD_STANDARD_UNIT_CDTV || csu == CD_STANDARD_UNIT_CD32) {
- write_log (_T("\n"));
+ write_log(_T("\n"));
return 1;
}
}
}
- } else {
- write_log (_T("no media"));
+ }
+ else {
+ write_log(_T("no media"));
}
}
- write_log (_T("\n"));
+ write_log(_T("\n"));
return 0;
}
-static int get_standard_cd_unit2 (struct uae_prefs *p, cd_standard_unit csu)
+static int get_standard_cd_unit2(struct uae_prefs *p, cd_standard_unit csu)
{
int unitnum = 0;
int isaudio = 0;
if (p->cdslots[unitnum].name[0] || p->cdslots[unitnum].inuse) {
if (p->cdslots[unitnum].name[0]) {
- device_func_init (SCSI_UNIT_IMAGE);
- if (!sys_command_open_internal (unitnum, p->cdslots[unitnum].name, csu))
+ device_func_init(SCSI_UNIT_IMAGE);
+ if (!sys_command_open_internal(unitnum, p->cdslots[unitnum].name, csu))
goto fallback;
- } else {
+ }
+ else {
goto fallback;
}
return unitnum;
}
- if (isaudio) {
- TCHAR vol[100];
- _stprintf (vol, _T("%c:\\"), isaudio);
- if (sys_command_open_internal (unitnum, vol, csu))
- return unitnum;
- }
+
fallback:
- device_func_init (SCSI_UNIT_IMAGE);
- if (!sys_command_open_internal (unitnum, _T(""), csu)) {
- write_log (_T("image mounter failed to open as empty!?\n"));
+ device_func_init(SCSI_UNIT_IMAGE);
+ if (!sys_command_open_internal(unitnum, _T(""), csu)) {
+ write_log(_T("image mounter failed to open as empty!?\n"));
return -1;
}
return unitnum;
}
-int get_standard_cd_unit (cd_standard_unit csu)
+int get_standard_cd_unit(cd_standard_unit csu)
{
- int unitnum = get_standard_cd_unit2 (&currprefs, csu);
+ int unitnum = get_standard_cd_unit2(&currprefs, csu);
if (unitnum < 0)
return -1;
struct blkdevstate *st = &state[unitnum];
+#ifdef RETROPLATFORM
+ rp_cd_device_enable(unitnum, true);
+#endif
st->delayed = 0;
if (currprefs.cdslots[unitnum].delayed) {
st->delayed = PRE_INSERT_DELAY;
@@ -364,23 +376,24 @@ int get_standard_cd_unit (cd_standard_unit csu)
return unitnum;
}
-void close_standard_cd_unit (int unitnum)
+void close_standard_cd_unit(int unitnum)
{
- sys_command_close (unitnum);
+ sys_command_close(unitnum);
}
-int sys_command_isopen (int unitnum)
+int sys_command_isopen(int unitnum)
{
struct blkdevstate *st = &state[unitnum];
return st->isopen;
}
-int sys_command_open (int unitnum)
+int sys_command_open(int unitnum)
{
struct blkdevstate *st = &state[unitnum];
- blkdev_fix_prefs (&currprefs);
+ blkdev_fix_prefs(&currprefs);
if (!dev_init) {
- device_func_init (0);
+ device_func_init(0);
+ dev_init = true;
}
if (st->isopen) {
@@ -388,29 +401,38 @@ int sys_command_open (int unitnum)
return -1;
}
st->waspaused = 0;
- int v = sys_command_open_internal (unitnum, currprefs.cdslots[unitnum].name[0] ? currprefs.cdslots[unitnum].name : NULL, CD_STANDARD_UNIT_DEFAULT);
+ int v = sys_command_open_internal(unitnum, currprefs.cdslots[unitnum].name[0] ? currprefs.cdslots[unitnum].name : NULL, CD_STANDARD_UNIT_DEFAULT);
if (!v)
return 0;
+#ifdef RETROPLATFORM
+ rp_cd_device_enable(unitnum, true);
+#endif
return v;
}
-void sys_command_close (int unitnum)
+void sys_command_close(int unitnum)
{
struct blkdevstate *st = &state[unitnum];
if (st->isopen > 1) {
st->isopen--;
return;
}
- sys_command_close_internal (unitnum);
+#ifdef RETROPLATFORM
+ rp_cd_device_enable(unitnum, false);
+#endif
+ sys_command_close_internal(unitnum);
}
-void blkdev_cd_change (int unitnum, const TCHAR *name)
+void blkdev_cd_change(int unitnum, const TCHAR *name)
{
struct device_info di;
- sys_command_info (unitnum, &di, 1);
+ sys_command_info(unitnum, &di, 1);
+#ifdef RETROPLATFORM
+ rp_cd_image_change(unitnum, name);
+#endif
}
-void device_func_reset (void)
+void device_func_reset(void)
{
for (int i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
struct blkdevstate *st = &state[i];
@@ -421,68 +443,65 @@ void device_func_reset (void)
st->cdimagefileinuse = false;
st->newimagefile[0] = 0;
}
- dev_init = false;
}
-int device_func_init (int flags)
+int device_func_init(int flags)
{
- blkdev_fix_prefs (&currprefs);
- install_driver (flags);
- dev_init = true;
+ blkdev_fix_prefs(&currprefs);
+ install_driver(flags);
return 1;
}
-bool blkdev_get_info (struct uae_prefs *p, int unitnum, struct device_info *di)
+bool blkdev_get_info(struct uae_prefs *p, int unitnum, struct device_info *di)
{
bool open = true, opened = false, ok = false;
struct blkdevstate *st = &state[unitnum];
if (!st->isopen) {
- blkdev_fix_prefs (p);
- install_driver (0);
+ blkdev_fix_prefs(p);
+ install_driver(0);
opened = true;
- open = sys_command_open_internal (unitnum, p->cdslots[unitnum].name[0] ? p->cdslots[unitnum].name : NULL, CD_STANDARD_UNIT_DEFAULT) != 0;
+ open = sys_command_open_internal(unitnum, p->cdslots[unitnum].name[0] ? p->cdslots[unitnum].name : NULL, CD_STANDARD_UNIT_DEFAULT) != 0;
}
if (open) {
- ok = sys_command_info (unitnum, di, true) != 0;
+ ok = sys_command_info(unitnum, di, true) != 0;
}
if (open && opened)
- sys_command_close_internal (unitnum);
+ sys_command_close_internal(unitnum);
return ok;
}
-void blkdev_entergui (void)
+void blkdev_entergui(void)
{
for (int i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
struct blkdevstate *st = &state[i];
st->waspaused = 0;
struct device_info di;
- if (sys_command_info (i, &di, 1)) {
- if (sys_command_cd_pause (i, 1) == 0)
+ if (sys_command_info(i, &di, 1)) {
+ if (sys_command_cd_pause(i, 1) == 0)
st->waspaused = 1;
}
}
}
-void blkdev_exitgui (void)
+void blkdev_exitgui(void)
{
for (int i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
struct blkdevstate *st = &state[i];
if (st->waspaused) {
struct device_info di;
- if (sys_command_info (i, &di, 1)) {
- sys_command_cd_pause (i, 0);
+ if (sys_command_info(i, &di, 1)) {
+ sys_command_cd_pause(i, 0);
}
}
st->waspaused = 0;
}
}
-void check_prefs_changed_cd (void)
+void check_prefs_changed_cd(void)
{
- if (!config_changed)
- return;
+ currprefs.sound_volume_cd = changed_prefs.sound_volume_cd;
}
-static void check_changes (int unitnum)
+static void check_changes(int unitnum)
{
struct blkdevstate *st = &state[unitnum];
bool changed = false;
@@ -494,36 +513,39 @@ static void check_changes (int unitnum)
if (st->delayed) {
st->delayed--;
if (st->delayed == 0)
- write_log (_T("CD: startup delayed insert '%s'\n"), currprefs.cdslots[unitnum].name[0] ? currprefs.cdslots[unitnum].name : _T(""));
+ write_log(_T("CD: startup delayed insert '%s'\n"), currprefs.cdslots[unitnum].name[0] ? currprefs.cdslots[unitnum].name : _T(""));
return;
}
- if (_tcscmp (changed_prefs.cdslots[unitnum].name, currprefs.cdslots[unitnum].name) != 0)
+ if (_tcscmp(changed_prefs.cdslots[unitnum].name, currprefs.cdslots[unitnum].name) != 0)
changed = true;
if (!changed && changed_prefs.cdslots[unitnum].name[0] == 0 && changed_prefs.cdslots[unitnum].inuse != currprefs.cdslots[unitnum].inuse)
changed = true;
if (changed) {
+ bool wasimage = currprefs.cdslots[unitnum].name[0] != 0;
if (st->sema)
- gotsem = getsem (unitnum, true);
+ gotsem = getsem(unitnum, true);
st->cdimagefileinuse = changed_prefs.cdslots[unitnum].inuse;
- _tcscpy (st->newimagefile, changed_prefs.cdslots[unitnum].name);
+ _tcscpy(st->newimagefile, changed_prefs.cdslots[unitnum].name);
changed_prefs.cdslots[unitnum].name[0] = currprefs.cdslots[unitnum].name[0] = 0;
currprefs.cdslots[unitnum].inuse = changed_prefs.cdslots[unitnum].inuse;
int pollmode = 0;
st->imagechangetime = 3 * 50;
struct device_info di;
- st->device_func->info (unitnum, &di, 0, -1);
+ st->device_func->info(unitnum, &di, 0, -1);
if (st->wasopen >= 0)
st->wasopen = di.open ? 1 : 0;
if (st->wasopen) {
- st->device_func->closedev (unitnum);
+ st->device_func->closedev(unitnum);
st->wasopen = -1;
}
- write_log (_T("CD: eject (%s) open=%d\n"), pollmode ? _T("slow") : _T("fast"), st->wasopen ? 1 : 0);
-
+ write_log(_T("CD: eject (%s) open=%d\n"), pollmode ? _T("slow") : _T("fast"), st->wasopen ? 1 : 0);
+#ifdef RETROPLATFORM
+ rp_cd_image_change(unitnum, NULL);
+#endif
if (gotsem) {
- freesem (unitnum);
+ freesem(unitnum);
gotsem = false;
}
}
@@ -533,51 +555,53 @@ static void check_changes (int unitnum)
if (st->imagechangetime > 0)
return;
if (st->sema)
- gotsem = getsem (unitnum, true);
- _tcscpy (currprefs.cdslots[unitnum].name, st->newimagefile);
- _tcscpy (changed_prefs.cdslots[unitnum].name, st->newimagefile);
+ gotsem = getsem(unitnum, true);
+ _tcscpy(currprefs.cdslots[unitnum].name, st->newimagefile);
+ _tcscpy(changed_prefs.cdslots[unitnum].name, st->newimagefile);
currprefs.cdslots[unitnum].inuse = changed_prefs.cdslots[unitnum].inuse = st->cdimagefileinuse;
st->newimagefile[0] = 0;
- write_log (_T("CD: delayed insert '%s' (open=%d,unit=%d)\n"), currprefs.cdslots[unitnum].name[0] ? currprefs.cdslots[unitnum].name : _T(""), st->wasopen ? 1 : 0, unitnum);
- device_func_init (0);
+ write_log(_T("CD: delayed insert '%s' (open=%d,unit=%d)\n"), currprefs.cdslots[unitnum].name[0] ? currprefs.cdslots[unitnum].name : _T(""), st->wasopen ? 1 : 0, unitnum);
+ device_func_init(0);
if (st->wasopen) {
- if (!st->device_func->opendev (unitnum, currprefs.cdslots[unitnum].name, 0)) {
- write_log (_T("-> device open failed\n"));
+ if (!st->device_func->opendev(unitnum, currprefs.cdslots[unitnum].name, 0)) {
+ write_log(_T("-> device open failed\n"));
st->wasopen = 0;
- } else {
+ }
+ else {
st->wasopen = 1;
- write_log (_T("-> device reopened\n"));
+ write_log(_T("-> device reopened\n"));
}
}
st->mediawaschanged = true;
+#ifdef RETROPLATFORM
+ rp_cd_image_change(unitnum, currprefs.cdslots[unitnum].name);
+#endif
if (gotsem) {
- freesem (unitnum);
+ freesem(unitnum);
gotsem = false;
}
-
- set_config_changed ();
}
-void blkdev_vsync (void)
+void blkdev_vsync(void)
{
for (int i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++)
- check_changes (i);
+ check_changes(i);
}
-static int do_scsi (int unitnum, uae_u8 *cmd, int cmdlen)
+static int do_scsi(int unitnum, uae_u8 *cmd, int cmdlen)
{
- uae_u8 *p = state[unitnum].device_func->exec_out (unitnum, cmd, cmdlen);
+ uae_u8 *p = state[unitnum].device_func->exec_out(unitnum, cmd, cmdlen);
return p != NULL;
}
-static int do_scsi (int unitnum, uae_u8 *cmd, int cmdlen, uae_u8 *out, int outsize)
+static int do_scsi(int unitnum, uae_u8 *cmd, int cmdlen, uae_u8 *out, int outsize)
{
- uae_u8 *p = state[unitnum].device_func->exec_in (unitnum, cmd, cmdlen, &outsize);
+ uae_u8 *p = state[unitnum].device_func->exec_in(unitnum, cmd, cmdlen, &outsize);
if (p)
- memcpy (out, p, outsize);
+ memcpy(out, p, outsize);
return p != NULL;
}
-static int failunit (int unitnum)
+static int failunit(int unitnum)
{
if (unitnum < 0 || unitnum >= MAX_TOTAL_SCSI_DEVICES)
return 1;
@@ -586,68 +610,70 @@ static int failunit (int unitnum)
return 0;
}
-static int audiostatus (int unitnum)
+static int audiostatus(int unitnum)
{
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
- uae_u8 cmd[10] = {0x42,2,0x40,1,0,0,0,(uae_u8)(DEVICE_SCSI_BUFSIZE>>8),(uae_u8)(DEVICE_SCSI_BUFSIZE&0xff),0};
- uae_u8 *p = state[unitnum].device_func->exec_in (unitnum, cmd, sizeof (cmd), 0);
- freesem (unitnum);
+ uae_u8 cmd[10] = { 0x42, 2, 0x40, 1, 0, 0, 0, (uae_u8)(DEVICE_SCSI_BUFSIZE >> 8), (uae_u8)(DEVICE_SCSI_BUFSIZE & 0xff), 0 };
+ uae_u8 *p = state[unitnum].device_func->exec_in(unitnum, cmd, sizeof(cmd), 0);
+ freesem(unitnum);
if (!p)
return 0;
return p[1];
}
/* pause/unpause CD audio */
-int sys_command_cd_pause (int unitnum, int paused)
+int sys_command_cd_pause(int unitnum, int paused)
{
- if (failunit (unitnum))
+ if (failunit(unitnum))
return -1;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
int v;
if (state[unitnum].device_func->pause == NULL) {
- int as = audiostatus (unitnum);
- uae_u8 cmd[10] = {0x4b,0,0,0,0,0,0,0,(uae_u8)(paused?0:1),0};
- do_scsi (unitnum, cmd, sizeof cmd);
+ int as = audiostatus(unitnum);
+ uae_u8 cmd[10] = { 0x4b, 0, 0, 0, 0, 0, 0, 0, paused ? static_cast(0) : static_cast(1), 0 };
+ do_scsi(unitnum, cmd, sizeof cmd);
v = as == AUDIO_STATUS_PAUSED;
- } else {
- v = state[unitnum].device_func->pause (unitnum, paused);
}
- freesem (unitnum);
+ else {
+ v = state[unitnum].device_func->pause(unitnum, paused);
+ }
+ freesem(unitnum);
return v;
}
/* stop CD audio */
-void sys_command_cd_stop (int unitnum)
+void sys_command_cd_stop(int unitnum)
{
- if (failunit (unitnum))
+ if (failunit(unitnum))
return;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return;
if (state[unitnum].device_func->stop == NULL) {
- int as = audiostatus (unitnum);
- uae_u8 cmd[6] = {0x4e,0,0,0,0,0};
- do_scsi (unitnum, cmd, sizeof cmd);
- } else {
- state[unitnum].device_func->stop (unitnum);
+ int as = audiostatus(unitnum);
+ uae_u8 cmd[6] = { 0x4e, 0, 0, 0, 0, 0 };
+ do_scsi(unitnum, cmd, sizeof cmd);
}
- freesem (unitnum);
+ else {
+ state[unitnum].device_func->stop(unitnum);
+ }
+ freesem(unitnum);
}
/* play CD audio */
-int sys_command_cd_play (int unitnum, int startlsn, int endlsn, int scan)
+int sys_command_cd_play(int unitnum, int startlsn, int endlsn, int scan)
{
int v;
- if (failunit (unitnum))
+ if (failunit(unitnum))
return 0;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
state[unitnum].play_end_pos = endlsn;
if (state[unitnum].device_func->play == NULL) {
- uae_u8 cmd[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
- int startmsf = lsn2msf (startlsn);
- int endmsf = lsn2msf (endlsn);
+ uae_u8 cmd[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ int startmsf = lsn2msf(startlsn);
+ int endmsf = lsn2msf(endlsn);
cmd[0] = 0x47;
cmd[3] = (uae_u8)(startmsf >> 16);
cmd[4] = (uae_u8)(startmsf >> 8);
@@ -655,242 +681,234 @@ int sys_command_cd_play (int unitnum, int startlsn, int endlsn, int scan)
cmd[6] = (uae_u8)(endmsf >> 16);
cmd[7] = (uae_u8)(endmsf >> 8);
cmd[8] = (uae_u8)(endmsf >> 0);
- v = do_scsi (unitnum, cmd, sizeof cmd) ? 0 : 1;
- } else {
- v = state[unitnum].device_func->play (unitnum, startlsn, endlsn, scan, NULL, NULL);
+ v = do_scsi(unitnum, cmd, sizeof cmd) ? 0 : 1;
}
- freesem (unitnum);
+ else {
+ v = state[unitnum].device_func->play(unitnum, startlsn, endlsn, scan, NULL, NULL);
+ }
+ freesem(unitnum);
return v;
}
/* play CD audio with subchannels */
-int sys_command_cd_play (int unitnum, int startlsn, int endlsn, int scan, play_status_callback statusfunc, play_subchannel_callback subfunc)
+int sys_command_cd_play(int unitnum, int startlsn, int endlsn, int scan, play_status_callback statusfunc, play_subchannel_callback subfunc)
{
int v;
- if (failunit (unitnum))
+ if (failunit(unitnum))
return 0;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
- state[unitnum].play_end_pos = endlsn;
if (state[unitnum].device_func->play == NULL)
- v = sys_command_cd_play (unitnum, startlsn, endlsn, scan);
+ v = sys_command_cd_play(unitnum, startlsn, endlsn, scan);
else
- v = state[unitnum].device_func->play (unitnum, startlsn, endlsn, scan, statusfunc, subfunc);
- freesem (unitnum);
+ v = state[unitnum].device_func->play(unitnum, startlsn, endlsn, scan, statusfunc, subfunc);
+ freesem(unitnum);
return v;
}
/* set CD audio volume */
-uae_u32 sys_command_cd_volume (int unitnum, uae_u16 volume_left, uae_u16 volume_right)
+uae_u32 sys_command_cd_volume(int unitnum, uae_u16 volume_left, uae_u16 volume_right)
{
int v;
- if (failunit (unitnum))
+ if (failunit(unitnum))
return 0;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
if (state[unitnum].device_func->volume == NULL)
v = -1;
else
- v = state[unitnum].device_func->volume (unitnum, volume_left, volume_right);
- freesem (unitnum);
+ v = state[unitnum].device_func->volume(unitnum, volume_left, volume_right);
+ freesem(unitnum);
return v;
}
/* read qcode */
-int sys_command_cd_qcode (int unitnum, uae_u8 *buf, int sector, bool all)
+int sys_command_cd_qcode(int unitnum, uae_u8 *buf)
{
int v;
- if (failunit (unitnum))
+ if (failunit(unitnum))
return 0;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
if (state[unitnum].device_func->qcode == NULL) {
- if (all) {
- v = 0;
- } else {
- uae_u8 cmd[10] = {0x42,2,0x40,1,0,0,0,(uae_u8)(SUBQ_SIZE>>8),(uae_u8)(SUBQ_SIZE&0xff),0};
- v = do_scsi (unitnum, cmd, sizeof cmd, buf, SUBQ_SIZE);
- }
- } else {
- v = state[unitnum].device_func->qcode (unitnum, buf, sector, all);
+ uae_u8 cmd[10] = { 0x42, 2, 0x40, 1, 0, 0, 0, (uae_u8)(SUBQ_SIZE >> 8), (uae_u8)(SUBQ_SIZE & 0xff), 0 };
+ v = do_scsi(unitnum, cmd, sizeof cmd, buf, SUBQ_SIZE);
}
- freesem (unitnum);
+ else {
+ v = state[unitnum].device_func->qcode(unitnum, buf, -1);
+ }
+ freesem(unitnum);
return v;
-};
+}
+;
/* read table of contents */
-int sys_command_cd_toc (int unitnum, struct cd_toc_head *toc)
+int sys_command_cd_toc(int unitnum, struct cd_toc_head *toc)
{
int v;
- if (failunit (unitnum))
+ if (failunit(unitnum))
return 0;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
if (state[unitnum].device_func->toc == NULL) {
uae_u8 buf[4 + 8 * 103];
int size = sizeof buf;
- uae_u8 cmd [10] = { 0x43,0,2,0,0,0,0,(uae_u8)(size>>8),(uae_u8)(size&0xff),0};
- if (do_scsi (unitnum, cmd, sizeof cmd, buf, size)) {
+ uae_u8 cmd[10] = { 0x43, 0, 2, 0, 0, 0, 0, (uae_u8)(size >> 8), (uae_u8)(size & 0xff), 0 };
+ if (do_scsi(unitnum, cmd, sizeof cmd, buf, size)) {
// toc parse to do
v = 0;
}
v = 0;
- } else {
- v = state[unitnum].device_func->toc (unitnum, toc);
}
- freesem (unitnum);
+ else {
+ v = state[unitnum].device_func->toc(unitnum, toc);
+ }
+ freesem(unitnum);
return v;
}
/* read one cd sector */
-int sys_command_cd_read (int unitnum, uae_u8 *data, int block, int size)
+int sys_command_cd_read(int unitnum, uae_u8 *data, int block, int size)
{
int v;
- if (failunit (unitnum))
+ if (failunit(unitnum))
return 0;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
if (state[unitnum].device_func->read == NULL) {
- uae_u8 cmd1[12] = { 0x28, 0, (uae_u8)(block >> 24), (uae_u8)(block >> 16), (uae_u8)(block >> 8), (uae_u8)(block >> 0), 0, (uae_u8)(size >> 8), (uae_u8)(size >> 0), 0, 0, 0 };
- v = do_scsi (unitnum, cmd1, sizeof cmd1, data, size * 2048);
- } else {
- v = state[unitnum].device_func->read (unitnum, data, block, size);
+
+ uae_u8 cmd1[12] = { 0x28, 0, static_cast(block >> 24), static_cast(block >> 16), static_cast(block >> 8), static_cast(block >> 0), 0, static_cast(size >> 8), static_cast(size >> 0), 0, 0, 0 };
+ v = do_scsi(unitnum, cmd1, sizeof cmd1, data, size * 2048);
+#if 0
+ if (!v) {
+ uae_u8 cmd2[12] = { 0xbe, 0, block >> 24, block >> 16, block >> 8, block >> 0, size >> 16, size >> 8, size >> 0, 0x10, 0, 0 };
+ v = do_scsi(unitnum, cmd2, sizeof cmd2, data, size * 2048);
+ }
+#endif
}
- freesem (unitnum);
+ else {
+ v = state[unitnum].device_func->read(unitnum, data, block, size);
+ }
+ freesem(unitnum);
return v;
}
-int sys_command_cd_rawread (int unitnum, uae_u8 *data, int block, int size, int sectorsize)
+int sys_command_cd_rawread(int unitnum, uae_u8 *data, int block, int size, int sectorsize)
{
int v;
- if (failunit (unitnum))
+ if (failunit(unitnum))
return -1;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
if (state[unitnum].device_func->rawread == NULL) {
- uae_u8 cmd[12] = { 0xbe, 0, (uae_u8)(block >> 24), (uae_u8)(block >> 16), (uae_u8)(block >> 8), (uae_u8)(block >> 0), (uae_u8)(size >> 16), (uae_u8)(size >> 8), (uae_u8)(size >> 0), 0x10, 0, 0 };
- v = do_scsi (unitnum, cmd, sizeof cmd, data, size * sectorsize);
- } else {
- v = state[unitnum].device_func->rawread (unitnum, data, block, size, sectorsize, 0xffffffff);
+ uae_u8 cmd[12] = { 0xbe, 0, static_cast(block >> 24), static_cast(block >> 16), static_cast(block >> 8), static_cast(block >> 0), static_cast(size >> 16), static_cast(size >> 8), static_cast(size >> 0), 0x10, 0, 0};
+ v = do_scsi(unitnum, cmd, sizeof cmd, data, size * sectorsize);
}
- freesem (unitnum);
+ else {
+ v = state[unitnum].device_func->rawread(unitnum, data, block, size, sectorsize, 0xffffffff);
+ }
+ freesem(unitnum);
return v;
}
-int sys_command_cd_rawread (int unitnum, uae_u8 *data, int block, int size, int sectorsize, uae_u8 sectortype, uae_u8 scsicmd9, uae_u8 subs)
+int sys_command_cd_rawread(int unitnum, uae_u8 *data, int block, int size, int sectorsize, uae_u8 sectortype, uae_u8 scsicmd9, uae_u8 subs)
{
int v;
- if (failunit (unitnum))
+ if (failunit(unitnum))
return -1;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
if (state[unitnum].device_func->rawread == NULL) {
- uae_u8 cmd[12] = { 0xbe, 0, (uae_u8)(block >> 24), (uae_u8)(block >> 16), (uae_u8)(block >> 8), (uae_u8)(block >> 0), (uae_u8)(size >> 16), (uae_u8)(size >> 8), (uae_u8)(size >> 0), 0x10, 0, 0 };
- v = do_scsi (unitnum, cmd, sizeof cmd, data, size * sectorsize);
- } else {
- v = state[unitnum].device_func->rawread (unitnum, data, block, size, sectorsize, (sectortype << 16) | (scsicmd9 << 8) | subs);
+ uae_u8 cmd[12] = { 0xbe, 0, static_cast(block >> 24), static_cast(block >> 16), static_cast(block >> 8), static_cast(block >> 0), static_cast(size >> 16), static_cast(size >> 8), static_cast(size >> 0), 0x10, 0, 0};
+ v = do_scsi(unitnum, cmd, sizeof cmd, data, size * sectorsize);
}
- freesem (unitnum);
+ else {
+ v = state[unitnum].device_func->rawread(unitnum, data, block, size, sectorsize, (sectortype << 16) | (scsicmd9 << 8) | subs);
+ }
+ freesem(unitnum);
return v;
}
/* read block */
-int sys_command_read (int unitnum, uae_u8 *data, int block, int size)
+int sys_command_read(int unitnum, uae_u8 *data, int block, int size)
{
int v;
- if (failunit (unitnum))
+ if (failunit(unitnum))
return 0;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
if (state[unitnum].device_func->read == NULL) {
- uae_u8 cmd[12] = { 0xa8, 0, 0, 0, 0, 0, (uae_u8)(size >> 24), (uae_u8)(size >> 16), (uae_u8)(size >> 8), (uae_u8)(size >> 0), 0, 0 };
+ uae_u8 cmd[12] = { 0xa8, 0, 0, 0, 0, 0, static_cast(size >> 24), static_cast(size >> 16), static_cast(size >> 8), static_cast(size >> 0), 0, 0};
cmd[2] = (uae_u8)(block >> 24);
cmd[3] = (uae_u8)(block >> 16);
cmd[4] = (uae_u8)(block >> 8);
cmd[5] = (uae_u8)(block >> 0);
- v = do_scsi (unitnum, cmd, sizeof cmd, data, size * 2048);
- } else {
- v = state[unitnum].device_func->read (unitnum, data, block, size);
+ v = do_scsi(unitnum, cmd, sizeof cmd, data, size * 2048);
}
- freesem (unitnum);
+ else {
+ v = state[unitnum].device_func->read(unitnum, data, block, size);
+ }
+ freesem(unitnum);
return v;
}
/* write block */
-int sys_command_write (int unitnum, uae_u8 *data, int offset, int size)
+int sys_command_write(int unitnum, uae_u8 *data, int offset, int size)
{
int v;
- if (failunit (unitnum))
+ if (failunit(unitnum))
return 0;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
if (state[unitnum].device_func->write == NULL) {
v = 0;
- } else {
- v = state[unitnum].device_func->write (unitnum, data, offset, size);
}
- freesem (unitnum);
+ else {
+ v = state[unitnum].device_func->write(unitnum, data, offset, size);
+ }
+ freesem(unitnum);
return v;
}
-int sys_command_ismedia (int unitnum, int quick)
+int sys_command_ismedia(int unitnum, int quick)
{
int v;
struct blkdevstate *st = &state[unitnum];
- if (failunit (unitnum))
+ if (failunit(unitnum))
return -1;
if (st->delayed)
return 0;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
if (state[unitnum].device_func->ismedia == NULL) {
uae_u8 cmd[6] = { 0, 0, 0, 0, 0, 0 };
- v = do_scsi (unitnum, cmd, sizeof cmd);
- } else {
- v = state[unitnum].device_func->ismedia (unitnum, quick);
+ v = do_scsi(unitnum, cmd, sizeof cmd);
}
- freesem (unitnum);
+ else {
+ v = state[unitnum].device_func->ismedia(unitnum, quick);
+ }
+ freesem(unitnum);
return v;
}
-struct device_info *sys_command_info_session (int unitnum, struct device_info *di, int quick, int session)
+struct device_info *sys_command_info_session(int unitnum, struct device_info *di, int quick, int session)
{
struct blkdevstate *st = &state[unitnum];
- if (failunit (unitnum))
+ if (failunit(unitnum))
return NULL;
- if (!getsem (unitnum))
+ if (!getsem(unitnum))
return 0;
if (st->device_func->info == NULL)
return 0;
- struct device_info *di2 = st->device_func->info (unitnum, di, quick, -1);
+ struct device_info *di2 = st->device_func->info(unitnum, di, quick, -1);
if (di2)
st->type = di2->type;
if (di2 && st->delayed)
di2->media_inserted = 0;
- freesem (unitnum);
+ freesem(unitnum);
return di2;
}
-struct device_info *sys_command_info (int unitnum, struct device_info *di, int quick)
+struct device_info *sys_command_info(int unitnum, struct device_info *di, int quick)
{
- struct device_info *dix;
-
- dix = sys_command_info_session (unitnum, di, quick, -1);
- if (dix && dix->media_inserted && !quick && !dix->audio_playing) {
- TCHAR *name = NULL;
- uae_u8 buf[2048];
- if (sys_command_cd_read(unitnum, buf, 16, 1)) {
- if ((buf[0] == 1 || buf[0] == 2) && !memcmp(buf + 1, "CD001", 5)) {
- TCHAR *p;
- au_copy(dix->volume_id, 32, (uae_char*)buf + 40);
- au_copy(dix->system_id, 32, (uae_char*)buf + 8);
- p = dix->volume_id + _tcslen(dix->volume_id) - 1;
- while (p > dix->volume_id && *p == ' ')
- *p-- = 0;
- p = dix->system_id + _tcslen(dix->system_id) - 1;
- while (p > dix->system_id && *p == ' ')
- *p-- = 0;
- }
- }
- }
- return dix;
+ return sys_command_info_session(unitnum, di, quick, -1) ;
}
#define MODE_SELECT_6 0x15
@@ -898,1206 +916,1239 @@ struct device_info *sys_command_info (int unitnum, struct device_info *di, int q
#define MODE_SELECT_10 0x55
#define MODE_SENSE_10 0x5a
-void scsi_atapi_fixup_pre (uae_u8 *scsi_cmd, int *len, uae_u8 **datap, int *datalenp, int *parm)
+void scsi_atapi_fixup_pre(uae_u8 *scsi_cmd, int *len, uae_u8 **datap, int *datalenp, int *parm)
{
- uae_u8 cmd, *p, *data = *datap;
- int l, datalen = *datalenp;
+ uae_u8 cmd,
+ *p,
+ *data = *datap ;
+ int l,
+ datalen = *datalenp ;
- *parm = 0;
- cmd = scsi_cmd[0];
- if (cmd != MODE_SELECT_6 && cmd != MODE_SENSE_6)
- return;
- l = scsi_cmd[4];
- if (l > 4)
- l += 4;
- scsi_cmd[7] = l >> 8;
- scsi_cmd[8] = l;
- if (cmd == MODE_SELECT_6) {
- scsi_cmd[0] = MODE_SELECT_10;
- scsi_cmd[9] = scsi_cmd[5];
- scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[4] = scsi_cmd[5] = scsi_cmd[6] = 0;
- *len = 10;
- p = xmalloc (uae_u8, 8 + datalen + 4);
- if (datalen > 4)
- memcpy (p + 8, data + 4, datalen - 4);
- p[0] = 0;
- p[1] = data[0];
- p[2] = data[1];
- p[3] = data[2];
- p[4] = p[5] = p[6] = 0;
- p[7] = data[3];
- if (l > 8)
- datalen += 4;
- *parm = MODE_SELECT_10;
- *datap = p;
- } else {
- scsi_cmd[0] = MODE_SENSE_10;
- scsi_cmd[9] = scsi_cmd[5];
- scsi_cmd[3] = scsi_cmd[4] = scsi_cmd[5] = scsi_cmd[6] = 0;
- if (l > 8)
- datalen += 4;
- *datap = xmalloc (uae_u8, datalen);
- *len = 10;
- *parm = MODE_SENSE_10;
- }
- *datalenp = datalen;
+ *parm = 0 ;
+ cmd = scsi_cmd[0] ;
+ if(cmd != MODE_SELECT_6 && cmd != MODE_SENSE_6)
+ return ;
+ l = scsi_cmd[4] ;
+ if(l > 4)
+ l += 4 ;
+ scsi_cmd[7] = l >> 8 ;
+ scsi_cmd[8] = l ;
+ if(cmd == MODE_SELECT_6) {
+ scsi_cmd[0] = MODE_SELECT_10 ;
+ scsi_cmd[9] = scsi_cmd[5] ;
+ scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[4] = scsi_cmd[5] = scsi_cmd[6] = 0 ;
+ *len = 10 ;
+ p = xmalloc(uae_u8, 8 + datalen + 4) ;
+ if(datalen > 4)
+ memcpy(p + 8, data + 4, datalen - 4) ;
+p[0] = 0 ;
+p[1] = data[0] ;
+p[2] = data[1] ;
+p[3] = data[2] ;
+p[4] = p[5] = p[6] = 0 ;
+p[7] = data[3] ;
+if(l > 8)
+ datalen += 4 ;
+*parm = MODE_SELECT_10 ;
+*datap = p ;
+} else {
+ scsi_cmd[0] = MODE_SENSE_10 ;
+ scsi_cmd[9] = scsi_cmd[5] ;
+ scsi_cmd[3] = scsi_cmd[4] = scsi_cmd[5] = scsi_cmd[6] = 0 ;
+ if(l > 8)
+ datalen += 4 ;
+*datap = xmalloc(uae_u8, datalen) ;
+*len = 10 ;
+*parm = MODE_SENSE_10 ;
+}
+*datalenp = datalen ;
}
-void scsi_atapi_fixup_post (uae_u8 *scsi_cmd, int len, uae_u8 *olddata, uae_u8 *data, int *datalenp, int parm)
+void scsi_atapi_fixup_post(uae_u8 *scsi_cmd, int len, uae_u8 *olddata, uae_u8 *data, int *datalenp, int parm)
{
- int datalen = *datalenp;
- if (!data || !datalen)
- return;
- if (parm == MODE_SENSE_10) {
- olddata[0] = data[1];
- olddata[1] = data[2];
- olddata[2] = data[3];
- olddata[3] = data[7];
- datalen -= 4;
- if (datalen > 4)
- memcpy (olddata + 4, data + 8, datalen - 4);
- *datalenp = datalen;
- }
+ int datalen = *datalenp ;
+ if(!data || !datalen)
+ return ;
+ if(parm == MODE_SENSE_10) {
+ olddata[0] = data[1] ;
+ olddata[1] = data[2] ;
+ olddata[2] = data[3] ;
+ olddata[3] = data[7] ;
+ datalen -= 4 ;
+ if(datalen > 4)
+ memcpy(olddata + 4, data + 8, datalen - 4) ;
+*datalenp = datalen ;
+}
}
-static void scsi_atapi_fixup_inquiry (struct amigascsi *as)
+static void scsi_atapi_fixup_inquiry(struct amigascsi *as)
{
- uae_u8 *scsi_data = as->data;
- uae_u32 scsi_len = as->len;
- uae_u8 *scsi_cmd = as->cmd;
- uae_u8 cmd;
+ uae_u8 *scsi_data = as->data ;
+ uae_u32 scsi_len = as->len ;
+ uae_u8 *scsi_cmd = as->cmd ;
+ uae_u8 cmd ;
- cmd = scsi_cmd[0];
+ cmd = scsi_cmd[0] ;
/* CDROM INQUIRY: most Amiga programs expect ANSI version == 2
* (ATAPI normally responds with zero)
*/
- if (cmd == 0x12 && scsi_len > 2 && scsi_data) {
- uae_u8 per = scsi_data[0];
- uae_u8 b = scsi_data[2];
- /* CDROM and ANSI version == 0 ? */
- if ((per & 31) == 5 && (b & 7) == 0) {
- b |= 2;
- scsi_data[2] = b;
- }
- }
+ if(cmd == 0x12 && scsi_len > 2 && scsi_data) {
+ uae_u8 per = scsi_data[0] ;
+ uae_u8 b = scsi_data[2] ;
+ /* CDROM and ANSI version == 0 ? */
+ if((per & 31) == 5 && (b & 7) == 0) {
+ b |= 2 ;
+ scsi_data[2] = b ;
+}
+}
}
-void scsi_log_before (uae_u8 *cdb, int cdblen, uae_u8 *data, int datalen)
+void scsi_log_before(uae_u8 *cdb, int cdblen, uae_u8 *data, int datalen)
{
- int i;
- for (i = 0; i < cdblen; i++) {
- write_log (_T("%s%02X"), i > 0 ? _T(".") : _T(""), cdb[i]);
- }
- write_log (_T("\n"));
- if (data) {
- write_log (_T("DATAOUT: %d\n"), datalen);
- for (i = 0; i < datalen && i < 100; i++)
- write_log (_T("%s%02X"), i > 0 ? _T(".") : _T(""), data[i]);
- if (datalen > 0)
- write_log (_T("\n"));
- }
+ int i ;
+ for(i = 0 ; i < cdblen ; i++) {
+ write_log(_T("%s%02X"), i > 0 ? _T(".") : _T(""), cdb[i]) ;
+}
+write_log(_T("\n")) ;
+if(data) {
+ write_log(_T("DATAOUT: %d\n"), datalen) ;
+ for(i = 0 ; i < datalen && i < 100 ; i++)
+ write_log(_T("%s%02X"), i > 0 ? _T(".") : _T(""), data[i]) ;
+if(datalen > 0)
+ write_log(_T("\n")) ;
+}
}
-void scsi_log_after (uae_u8 *data, int datalen, uae_u8 *sense, int senselen)
+void scsi_log_after(uae_u8 *data, int datalen, uae_u8 *sense, int senselen)
{
- int i;
- write_log (_T("DATAIN: %d\n"), datalen);
- for (i = 0; i < datalen && i < 100 && data; i++)
- write_log (_T("%s%02X"), i > 0 ? _T(".") : _T(""), data[i]);
- if (data && datalen > 0)
- write_log (_T("\n"));
- if (senselen > 0) {
- write_log (_T("SENSE: %d,"), senselen);
- for (i = 0; i < senselen && i < 32; i++) {
- write_log (_T("%s%02X"), i > 0 ? _T(".") : _T(""), sense[i]);
- }
- write_log (_T("\n"));
- }
+ int i ;
+ write_log(_T("DATAIN: %d\n"), datalen) ;
+ for(i = 0 ; i < datalen && i < 100 && data ; i++)
+ write_log(_T("%s%02X"), i > 0 ? _T(".") : _T(""), data[i]) ;
+ if(data && datalen > 0)
+ write_log(_T("\n")) ;
+ if(senselen > 0) {
+ write_log(_T("SENSE: %d,"), senselen) ;
+ for(i = 0 ; i < senselen && i < 32 ; i++) {
+ write_log(_T("%s%02X"), i > 0 ? _T(".") : _T(""), sense[i]) ;
+}
+write_log(_T("\n")) ;
+}
}
-static bool nodisk (struct device_info *di)
+static bool nodisk(struct device_info *di)
{
- return di->media_inserted == 0;
+ return di->media_inserted == 0 ;
}
-static int cmd_readx (int unitnum, uae_u8 *dataptr, int offset, int len)
+static int cmd_readx(int unitnum, uae_u8 *dataptr, int offset, int len)
{
- if (!getsem (unitnum))
- return 0;
- int v = state[unitnum].device_func->read (unitnum, dataptr, offset, len);
- freesem (unitnum);
- if (v >= 0)
- return len;
- return v;
+ if(!getsem(unitnum))
+ return 0 ;
+ int v = state[unitnum].device_func->read(unitnum, dataptr, offset, len) ;
+ freesem(unitnum) ;
+ if(v >= 0)
+ return len ;
+ return v ;
}
-static void wl (uae_u8 *p, int v)
+static void wl(uae_u8 *p, int v)
{
- p[0] = v >> 24;
- p[1] = v >> 16;
- p[2] = v >> 8;
- p[3] = v;
+ p[0] = v >> 24 ;
+ p[1] = v >> 16 ;
+ p[2] = v >> 8 ;
+ p[3] = v ;
}
-static void ww (uae_u8 *p, int v)
+static void ww(uae_u8 *p, int v)
{
- p[0] = v >> 8;
- p[1] = v;
+ p[0] = v >> 8 ;
+ p[1] = v ;
}
-static int rl (uae_u8 *p)
+static int rl(uae_u8 *p)
{
- return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3]);
+ return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3]) ;
}
-static int rw (uae_u8 *p)
+static int rw(uae_u8 *p)
{
- return (p[0] << 8) | (p[1]);
+ return (p[0] << 8) | (p[1]) ;
}
-static void stopplay (int unitnum)
+static void stopplay(int unitnum)
{
- sys_command_cd_stop (unitnum);
+ sys_command_cd_stop(unitnum) ;
}
-static int addtocentry (uae_u8 **dstp, int *len, int point, int newpoint, int msf, uae_u8 *head, struct cd_toc_head *th)
+static int addtocentry(uae_u8 **dstp, int *len, int point, int newpoint, int msf, uae_u8 *head, struct cd_toc_head *th)
{
- uae_u8 *dst = *dstp;
+ uae_u8 *dst = *dstp ;
- for (int i = 0; i < th->points; i++) {
- struct cd_toc *t = &th->toc[i];
- if (t->point == point) {
- if (*len < 8)
- return 0;
- int addr = t->paddress;
- if (msf)
- addr = lsn2msf (addr);
- dst[0] = 0;
- dst[1] = (t->adr << 4) | t->control;
- dst[2] = newpoint >= 0 ? newpoint : point;
- dst[3] = 0;
- dst[4] = addr >> 24;
- dst[5] = addr >> 16;
- dst[6] = addr >> 8;
- dst[7] = addr >> 0;
+ for(int i = 0 ; i < th->points ; i++) {
+ struct cd_toc *t = &th->toc[i] ;
+ if(t->point == point) {
+ if(*len < 8)
+ return 0 ;
+ int addr = t->paddress ;
+ if(msf)
+ addr = lsn2msf(addr) ;
+ dst[0] = 0 ;
+ dst[1] = (t->adr << 4) | t->control ;
+ dst[2] = newpoint >= 0 ? newpoint : point ;
+ dst[3] = 0 ;
+ dst[4] = addr >> 24 ;
+ dst[5] = addr >> 16 ;
+ dst[6] = addr >> 8 ;
+ dst[7] = addr >> 0 ;
- if (point >= 1 && point <= 99) {
- if (head[2] == 0)
- head[2] = point;
- head[3] = point;
- }
-
- *len -= 8;
- *dstp = dst + 8;
- return 1;
- }
- }
- return -1;
+ if(point >= 1 && point <= 99) {
+ if(head[2] == 0)
+ head[2] = point ;
+ head[3] = point ;
}
-static int scsiemudrv (int unitnum, uae_u8 *cmd)
-{
- if (failunit (unitnum))
- return -1;
- if (!getsem (unitnum))
- return 0;
- int v = 0;
- if (state[unitnum].device_func->scsiemu)
- v = state[unitnum].device_func->scsiemu (unitnum, cmd);
- freesem (unitnum);
- return v;
+ *len -= 8 ;
+ *dstp = dst + 8 ;
+ return 1 ;
+}
+}
+return - 1 ;
}
-static int scsi_read_cd (int unitnum, uae_u8 *cmd, uae_u8 *data, struct device_info *di)
+static int scsiemudrv(int unitnum, uae_u8 *cmd)
{
- struct blkdevstate *st = &state[unitnum];
- int msf = cmd[0] == 0xb9;
- int start = msf ? msf2lsn (rl (cmd + 2) & 0x00ffffff) : rl (cmd + 2);
- int len = rl (cmd + 5) & 0x00ffffff;
- if (msf) {
- int end = msf2lsn (len);
- len = end - start;
- if (len < 0)
- return -1;
- }
- int subs = cmd[10] & 7;
- if (len == 0)
- return 0;
- int v = sys_command_cd_rawread (unitnum, data, start, len, 0, (cmd[1] >> 2) & 7, cmd[9], subs);
- if (v > 0)
- st->current_pos = start + len;
- return v;
+ if(failunit(unitnum))
+ return - 1 ;
+ if(!getsem(unitnum))
+ return 0 ;
+ int v = 0 ;
+ if(state[unitnum].device_func->scsiemu)
+ v = state[unitnum].device_func->scsiemu(unitnum, cmd) ;
+ freesem(unitnum) ;
+ return v ;
}
-static int scsi_read_cd_data (int unitnum, uae_u8 *scsi_data, uae_u32 offset, uae_u32 len, struct device_info *di, int *scsi_len, struct cd_toc *t)
+static int scsi_read_cd(int unitnum, uae_u8 *cmd, uae_u8 *data, struct device_info *di)
{
- struct blkdevstate *st = &state[unitnum];
- int end = t[1].paddress;
-
- if (len == 0) {
- if (offset >= end)
- return -1;
- *scsi_len = 0;
- return 0;
- } else {
- if (offset >= end)
- return -1;
- int v = cmd_readx (unitnum, scsi_data, offset, len) * di->bytespersector;
- if (v > 0) {
- st->current_pos = offset + len;
- *scsi_len = v;
- return 0;
- }
- return -2;
- }
+ struct blkdevstate *st = &state[unitnum] ;
+ int msf = cmd[0] == 0xb9 ;
+ int start = msf ? msf2lsn(rl(cmd + 2) & 0x00ffffff) : rl(cmd + 2) ;
+ int len = rl(cmd + 5) & 0x00ffffff ;
+ if(msf) {
+ int end = msf2lsn(len) ;
+ len = end - start ;
+ if(len < 0)
+ return - 1 ;
+}
+int subs = cmd[10] & 7 ;
+if(len == 0)
+ return 0 ;
+int v = sys_command_cd_rawread(unitnum, data, start, len, 0, (cmd[1] >> 2) & 7, cmd[9], subs) ;
+if(v > 0)
+ st->current_pos = start + len ;
+return v ;
}
-int scsi_cd_emulate (int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len,
- uae_u8 *scsi_data, int *data_len, uae_u8 *r, int *reply_len, uae_u8 *s, int *sense_len, bool atapi)
+static int scsi_read_cd_data(int unitnum, uae_u8 *scsi_data, uae_u32 offset, uae_u32 len, struct device_info *di, int *scsi_len)
{
- struct blkdevstate *st = &state[unitnum];
- uae_u32 len, offset;
- int lr = 0, ls = 0;
- int scsi_len = -1;
- int v;
- int status = 0;
- struct device_info di;
- uae_u8 cmd;
- int dlen, lun;
+ struct blkdevstate *st = &state[unitnum] ;
+ if(len == 0) {
+ if(offset >= di->sectorspertrack * di->cylinders * di->trackspercylinder)
+ return - 1 ;
+*scsi_len = 0 ;
+return 0 ;
+} else {
+ if(len * di->bytespersector > SCSI_DATA_BUFFER_SIZE)
+ return - 3 ;
+if(offset >= di->sectorspertrack * di->cylinders * di->trackspercylinder)
+ return - 1 ;
+int v = cmd_readx(unitnum, scsi_data, offset, len) * di->bytespersector ;
+if(v > 0) {
+ st->current_pos = offset + len ;
+ *scsi_len = v ;
+ return 0 ;
+}
+return - 2 ;
+}
+}
- if (cmdbuf == NULL) {
- if (st->mediawaschanged) {
- st->mediawaschanged = false;
- return (0x28 << 8) | (0x00);
- }
- return 0;
- }
+int scsi_cd_emulate(int unitnum,
+ uae_u8 *cmdbuf,
+ int scsi_cmd_len,
+ uae_u8 *scsi_data,
+ int *data_len,
+ uae_u8 *r,
+ int *reply_len,
+ uae_u8 *s,
+ int *sense_len,
+ bool atapi)
+{
+ struct blkdevstate *st = &state[unitnum] ;
+ uae_u32 len,
+ offset ;
+ int lr = 0,
+ ls = 0 ;
+ int scsi_len = -1 ;
+ int v ;
+ int status = 0 ;
+ struct device_info di ;
+ uae_u8 cmd = cmdbuf[0] ;
+ int dlen ;
- cmd = cmdbuf[0];
-
- if (cmd == 0x03) {
- return 0;
- }
+ if(cmd == 0x03) { /* REQUEST SENSE */
+ st->mediawaschanged = false ;
+ return 0 ;
+}
- dlen = *data_len;
- *reply_len = *sense_len = 0;
+dlen = *data_len ;
+*reply_len = *sense_len = 0 ;
- lun = cmdbuf[1] >> 5;
- if (cmdbuf[0] != 0x03 && cmdbuf[0] != 0x12 && lun) {
- status = 2; /* CHECK CONDITION */
- s[0] = 0x70;
- s[2] = 5; /* ILLEGAL REQUEST */
- s[12] = 0x25; /* INVALID LUN */
- ls = 0x12;
- write_log (_T("CD SCSIEMU %d: CMD=%02X LUN=%d ignored\n"), unitnum, cmdbuf[0], lun);
- goto end;
- }
+ sys_command_info(unitnum, &di, 1) ;
- sys_command_info (unitnum, &di, 1);
-
- switch (cmdbuf[0])
- {
- case 0x00: /* TEST UNIT READY */
- if (nodisk (&di))
- goto nodisk;
- scsi_len = 0;
- break;
- case 0x1e: /* PREVENT/ALLOW MEDIUM REMOVAL */
- scsi_len = 0;
- break;
- case 0xbd: /* MECHANISM STATUS */
- len = (cmdbuf[8] << 8) | cmdbuf[9];
- if (len > 8)
- len = 8;
- scsi_len = len;
- r[2] = st->current_pos >> 16;
- r[3] = st->current_pos >> 8;
- r[4] = st->current_pos >> 0;
- break;
- case 0x12: /* INQUIRY */
- {
- if ((cmdbuf[1] & 1) || cmdbuf[2] != 0)
- goto err;
- len = cmdbuf[4];
- if (cmdbuf[1] >> 5) {
- r[0] = 0x7f;
- } else {
- r[0] = 5; // CDROM
- }
- r[1] |= 0x80; // removable
- r[2] = 2; /* supports SCSI-2 */
- r[3] = 2; /* response data format */
- if (atapi)
- r[3] |= 3 << 5; // atapi transport version
- r[4] = 32; /* additional length */
- r[7] = 0;
- scsi_len = lr = len < 36 ? len : 36;
- r[2] = 2;
- r[3] = 2;
- char *s = ua (di.vendorid);
- memcpy (r + 8, s, strlen (s));
- xfree (s);
- s = ua (di.productid);
- memcpy (r + 16, s, strlen (s));
- xfree (s);
- s = ua (di.revision);
- memcpy (r + 32, s, strlen (s));
- xfree (s);
- for (int i = 8; i < 36; i++) {
- if (r[i] == 0)
- r[i] = 32;
- }
- }
- break;
- case 0xbe: // READ CD
- case 0xb9: // READ CD MSF
- if (nodisk (&di))
- goto nodisk;
- scsi_len = scsi_read_cd (unitnum, cmdbuf, scsi_data, &di);
- if (scsi_len == -2)
- goto notdatatrack;
- if (scsi_len == -1)
- goto errreq;
- break;
- case 0x55: // MODE SELECT(10)
- case 0x15: // MODE SELECT(6)
- {
- uae_u8 *p;
- bool mode10 = cmdbuf[0] == 0x55;
- p = scsi_data + 4;
- if (mode10)
- p += 4;
- int pcode = p[0] & 0x3f;
- if (pcode == 14) { // CD audio control
- uae_u16 vol_left = (p[9] << 7) | (p[9] >> 1);
- uae_u16 vol_right = (p[11] << 7) | (p[11] >> 1);
- sys_command_cd_volume (unitnum, vol_left, vol_right);
- scsi_len = 0;
- } else {
- goto errreq;
- }
- }
- break;
- case 0x5a: // MODE SENSE(10)
- case 0x1a: /* MODE SENSE(6) */
- {
- uae_u8 *p;
- int maxlen;
- bool pcodeloop = false;
- bool sense10 = cmdbuf[0] == 0x5a;
- int psize, totalsize, bdsize;
- int pc = cmdbuf[2] >> 6;
- int pcode = cmdbuf[2] & 0x3f;
- int dbd = cmdbuf[1] & 8;
-
- if (atapi) {
- if (!sense10)
- goto err;
- dbd = 1;
- }
- p = r;
- if (sense10) {
- totalsize = 8 - 2;
- maxlen = (cmdbuf[7] << 8) | cmdbuf[8];
- p[2] = 0;
- p[3] = 0;
- p[4] = 0;
- p[5] = 0;
- p[6] = 0;
- p[7] = 0;
- p += 8;
- } else {
- totalsize = 4 - 1;
- maxlen = cmdbuf[4];
- p[1] = 0;
- p[2] = 0;
- p[3] = 0;
- p += 4;
- }
- bdsize = 0;
- if (!dbd) {
- wl(p + 0, 0);
- wl(p + 4, di.bytespersector);
- bdsize = 8;
- p += bdsize;
- }
- if (pcode == 0x3f) {
- pcode = 1; // page = 0 must be last
- pcodeloop = true;
- }
- for (;;) {
- psize = 0;
- if (pcode == 0) {
- p[0] = 0;
- p[1] = 0;
- p[2] = 0x20;
- p[3] = 0;
- psize = 4;
- } else if (pcode == 14) { // CD audio control
- uae_u32 vol = sys_command_cd_volume (unitnum, 0xffff, 0xffff);
- p[0] = 0x0e;
- p[1] = 0x0e;
- p[2] = 4|1;
- p[3] = 4;
- p[6] = 0;
- p[7] = 75;
- p[8] = 1;
- p[9] = pc == 0 ? (vol >> 7) & 0xff : 0xff;
- p[10] = 2;
- p[11] = pc == 0 ? (vol >> (16 + 7)) & 0xff : 0xff;
- psize = p[1] + 2;
- } else if (pcode == 0x2a) { // cd/dvd capabilities
- p[0] = 0x2a;
- p[1] = 0x18;
- p[2] = 1; // | 0x10 | 0x20; // read: CD-R/DVD-ROM/DVD-R
- p[3] = 0; // write: nothing
- p[4] = 0x40 | 0x20 | 0x10 | 0x01;
- p[5] = 0x08 | 0x04 | 0x02 | 0x01;
- p[6] = (1 << 5) | 0x10; // type = tray, eject supported
- p[7] = 3; // separate channel mute and volume
- p[8] = 2; p[9] = 0;
- p[10] = 0xff; p[11] = 0xff; // number of volume levels
- p[12] = 4; p[13] = 0; // "1M buffer"
- p[14] = 2; p[15] = 0;
- p[16] = 0;
- p[17] = 0;
- p[18] = p[19] = 0;
- p[20] = p[21] = 0;
- p[22] = p[23] = 0;
- psize = p[1] + 2;
- } else {
- if (!pcodeloop)
- goto err;
- }
- totalsize += psize;
- p += psize;
- if (!pcodeloop)
- break;
- if (pcode == 0)
- break;
- pcode++;
- if (pcode == 0x3f)
- pcode = 0;
- }
- if (sense10) {
- totalsize += bdsize;
- r[6] = bdsize >> 8;
- r[7] = bdsize & 0xff;
- r[0] = totalsize >> 8;
- r[1] = totalsize & 0xff;
- } else {
- totalsize += bdsize;
- r[3] = bdsize & 0xff;
- r[0] = totalsize & 0xff;
- }
- scsi_len = totalsize + 1;
- if (scsi_len > maxlen)
- scsi_len = maxlen;
- lr = scsi_len;
- }
- break;
- case 0x01: /* REZERO UNIT */
- scsi_len = 0;
- break;
- case 0x1d: /* SEND DIAGNOSTICS */
- scsi_len = 0;
- break;
- case 0x25: /* READ CAPACITY */
- {
- int pmi = cmdbuf[8] & 1;
- uae_u32 lba = (cmdbuf[2] << 24) | (cmdbuf[3] << 16) | (cmdbuf[4] << 8) | cmdbuf[5];
- int cyl, cylsec, head, tracksec;
- if (nodisk (&di))
- goto nodisk;
- uae_u32 blocks = di.sectorspertrack * di.cylinders * di.trackspercylinder - 1;
- cyl = di.cylinders;
- head = 1;
- cylsec = tracksec = di.trackspercylinder;
- if (pmi == 0 && lba != 0)
- goto errreq;
- if (pmi) {
- lba += tracksec * head;
- lba /= tracksec * head;
- lba *= tracksec * head;
- if (lba > blocks)
- lba = blocks;
- blocks = lba;
- }
- wl (r, blocks);
- wl (r + 4, di.bytespersector);
- scsi_len = lr = 8;
- }
- break;
- case 0x0b: /* SEEK (6) */
- {
- if (nodisk (&di))
- goto nodisk;
- stopplay (unitnum);
- offset = ((cmdbuf[1] & 31) << 16) | (cmdbuf[2] << 8) | cmdbuf[3];
- struct cd_toc *t = gettoc (unitnum, &di.toc, offset);
- if (!t)
- goto readerr;
- v = scsi_read_cd_data (unitnum, scsi_data, offset, 0, &di, &scsi_len, t);
- if (v == -1)
- goto outofbounds;
- }
- break;
- case 0x08: /* READ (6) */
- {
- if (nodisk (&di))
- goto nodisk;
- stopplay (unitnum);
- offset = ((cmdbuf[1] & 31) << 16) | (cmdbuf[2] << 8) | cmdbuf[3];
- struct cd_toc *t = gettoc (unitnum, &di.toc, offset);
- if (!t)
- goto readerr;
- if ((t->control & 0x0c) == 0x04) {
- len = cmdbuf[4];
- if (!len)
- len = 256;
- v = scsi_read_cd_data (unitnum, scsi_data, offset, len, &di, &scsi_len, t);
- if (v == -1)
- goto outofbounds;
- if (v == -2)
- goto readerr;
- } else {
- goto notdatatrack;
- }
- }
- break;
- case 0x0a: /* WRITE (6) */
- goto readprot;
- case 0x2b: /* SEEK (10) */
- {
- if (nodisk (&di))
- goto nodisk;
- stopplay (unitnum);
- offset = rl (cmdbuf + 2);
- struct cd_toc *t = gettoc (unitnum, &di.toc, offset);
- if (!t)
- goto readerr;
- v = scsi_read_cd_data (unitnum, scsi_data, offset, 0, &di, &scsi_len, t);
- if (v == -1)
- goto outofbounds;
- }
- break;
- case 0x28: /* READ (10) */
- {
- if (nodisk (&di))
- goto nodisk;
- stopplay (unitnum);
- offset = rl (cmdbuf + 2);
- struct cd_toc *t = gettoc (unitnum, &di.toc, offset);
- if (!t)
- goto readerr;
- if ((t->control & 0x0c) == 0x04) {
- len = rl (cmdbuf + 7 - 2) & 0xffff;
- v = scsi_read_cd_data (unitnum, scsi_data, offset, len, &di, &scsi_len, t);
- if (v == -1)
- goto outofbounds;
- if (v == -2)
- goto readerr;
- } else {
- goto notdatatrack;
- }
- }
- break;
- case 0x2a: /* WRITE (10) */
- goto readprot;
- case 0xa8: /* READ (12) */
- {
- if (nodisk (&di))
- goto nodisk;
- stopplay (unitnum);
- offset = rl (cmdbuf + 2);
- struct cd_toc *t = gettoc (unitnum, &di.toc, offset);
- if (!t)
- goto readerr;
- if ((t->control & 0x0c) == 0x04) {
- len = rl (cmdbuf + 6);
- v = scsi_read_cd_data (unitnum, scsi_data, offset, len, &di, &scsi_len, t);
- if (v == -1)
- goto outofbounds;
- if (v == -2)
- goto readerr;
- } else {
- goto notdatatrack;
- }
- }
- break;
- case 0xaa: /* WRITE (12) */
- goto readprot;
- case 0x51: /* READ DISC INFORMATION */
- {
- struct cd_toc_head ttoc;
- int maxlen = (cmdbuf[7] << 8) | cmdbuf[8];
- if (nodisk (&di))
- goto nodisk;
- if (!sys_command_cd_toc (unitnum, &ttoc))
- goto readerr;
- struct cd_toc_head *toc = &ttoc;
- uae_u8 *p = scsi_data;
- p[0] = 0;
- p[1] = 34 - 2;
- p[2] = 2 | (3 << 2); // complete cd rom, last session is complete
- p[3] = toc->first_track;
- p[4] = 1;
- p[5] = toc->first_track;
- p[6] = toc->last_track;
- wl (p + 16, lsn2msf (toc->lastaddress));
- wl (p + 20, 0x00ffffff);
- scsi_len = p[1] + 2;
- if (scsi_len > maxlen)
- scsi_len = maxlen;
- }
- break;
- case 0x52: /* READ TRACK INFORMATION */
- {
- struct cd_toc_head ttoc;
- int maxlen = (cmdbuf[7] << 8) | cmdbuf[8];
- if (nodisk (&di))
- goto nodisk;
- if (!sys_command_cd_toc (unitnum, &ttoc))
- goto readerr;
- struct cd_toc_head *toc = &ttoc;
- uae_u8 *p = scsi_data;
- int lsn;
- if (cmdbuf[1] & 1) {
- int track = cmdbuf[5];
- lsn = toc->toc[track].address;
- } else {
- lsn = rl (p + 2);
- }
- struct cd_toc *t = gettoc (unitnum, toc, lsn);
- if (!t)
- goto readerr;
- p[0] = 0;
- p[1] = 28 - 2;
- p[2] = t->track;
- p[3] = 1;
- p[5] = t->control;
- p[6] = 0; // data mode, fixme
- wl (p + 8, t->address);
- wl (p + 24, t[1].address - t->address);
- scsi_len = p[1] + 2;
- if (scsi_len > maxlen)
- scsi_len = maxlen;
- }
- break;
- case 0x43: // READ TOC
- {
- if (nodisk (&di))
- goto nodisk;
- uae_u8 *p = scsi_data;
- int strack = cmdbuf[6];
- int msf = cmdbuf[1] & 2;
- int format = cmdbuf[2] & 7;
- if (format >= 3)
- goto errreq;
- int maxlen = (cmdbuf[7] << 8) | cmdbuf[8];
- int maxlen2 = maxlen;
- struct cd_toc_head ttoc;
- if (!sys_command_cd_toc (unitnum, &ttoc))
- goto readerr;
- struct cd_toc_head *toc = &ttoc;
- if (format == 1) {
- p[0] = 0;
- p[1] = 2 + 8;
- p[2] = 1;
- p[3] = 1;
- p[4] = 0;
- p[5] = (toc->toc[0].adr << 4) | toc->toc[0].control;
- p[6] = toc->first_track;
- p[7] = 0;
- if (msf)
- wl (p + 8, lsn2msf (toc->toc[0].address));
- else
- wl (p + 8 , toc->toc[0].address);
- scsi_len = 12;
- } else if (format == 2 || format == 0) {
- if (format == 2 && !msf)
- goto errreq;
- if (strack == 0)
- strack = toc->first_track;
- if (format == 0 && strack >= 100 && strack != 0xaa)
- goto errreq;
- uae_u8 *p2 = p + 4;
- p[2] = 0;
- p[3] = 0;
- maxlen -= 4;
- if (format == 2) {
- if (!addtocentry (&p2, &maxlen, 0xa0, -1, msf, p, toc))
- break;
- if (!addtocentry (&p2, &maxlen, 0xa1, -1, msf, p, toc))
- break;
- if (!addtocentry (&p2, &maxlen, 0xa2, -1, msf, p, toc))
- break;
- }
- while (strack < 100) {
- if (!addtocentry (&p2, &maxlen, strack, -1, msf, p, toc))
- break;
- strack++;
- }
- addtocentry (&p2, &maxlen, 0xa2, 0xaa, msf, p, toc);
- int tlen = p2 - (p + 2);
- p[0] = tlen >> 8;
- p[1] = tlen >> 0;
- scsi_len = tlen + 2;
- }
- if (scsi_len > maxlen2)
- scsi_len = maxlen2;
- }
- break;
- case 0x42: // READ SUB-CHANNEL
- {
- int msf = cmdbuf[1] & 2;
- int subq = cmdbuf[2] & 0x40;
- int format = cmdbuf[3];
- int track = cmdbuf[6];
- int maxlen = rw(cmdbuf + 7);
- uae_u8 buf[SUBQ_SIZE] = { 0 };
-
- if (nodisk (&di))
- goto nodisk;
- sys_command_cd_qcode (unitnum, buf, -1, false);
- scsi_len = 4;
- scsi_data[0] = 0;
- scsi_data[1] = buf[1];
- if (subq && format == 1) {
- scsi_data[2] = 0;
- scsi_data[3] = 12;
- scsi_len += 12;
- scsi_data[4] = 1;
- scsi_data[5] = (buf[4 + 0] << 4) | (buf[4 + 0] >> 4);
- scsi_data[6] = frombcd (buf[4 + 1]); // track
- scsi_data[7] = frombcd (buf[4 + 2]); // index
- int reladdr = fromlongbcd (&buf[4 + 3]);
- int absaddr = fromlongbcd (&buf[4 + 7]);
- if (!msf) {
- reladdr = msf2lsn (reladdr);
- absaddr = msf2lsn (absaddr);
- }
- wl (scsi_data + 8, absaddr);
- wl (scsi_data + 12, reladdr);
- } else {
- scsi_data[2] = 0;
- scsi_data[3] = 0;
- }
- if (scsi_len > maxlen)
- scsi_len = maxlen;
- }
- break;
- case 0x1b: // START/STOP
- sys_command_cd_stop (unitnum);
- scsiemudrv (unitnum, cmdbuf);
- scsi_len = 0;
- break;
- case 0x4e: // STOP PLAY/SCAN
- if (nodisk (&di))
- goto nodisk;
- sys_command_cd_stop (unitnum);
- scsi_len = 0;
- break;
- case 0xba: // SCAN
- {
- if (nodisk (&di))
- goto nodisk;
- struct cd_toc_head ttoc;
- if (!sys_command_cd_toc (unitnum, &ttoc))
- goto readerr;
- struct cd_toc_head *toc = &ttoc;
- int scan = (cmdbuf[1] & 0x10) ? -1 : 1;
- int start = rl (cmdbuf + 1) & 0x00ffffff;
- int end = scan > 0 ? toc->lastaddress : toc->toc[toc->first_track_offset].paddress;
- int type = cmdbuf[9] >> 6;
- if (type == 1)
- start = lsn2msf (start);
- if (type == 3)
- goto errreq;
- if (type == 2) {
- if (toc->first_track_offset + start >= toc->last_track_offset)
- goto errreq;
- start = toc->toc[toc->first_track_offset + start].paddress;
- }
- sys_command_cd_pause (unitnum, 0);
- sys_command_cd_play (unitnum, start, end, scan);
- scsi_len = 0;
- }
- break;
- case 0x48: // PLAY AUDIO TRACK/INDEX
- {
- if (nodisk (&di))
- goto nodisk;
- int strack = cmdbuf[4];
- int etrack = cmdbuf[7];
- struct cd_toc_head ttoc;
- if (!sys_command_cd_toc (unitnum, &ttoc))
- goto readerr;
- struct cd_toc_head *toc = &ttoc;
- if (strack < toc->first_track || strack > toc->last_track ||
- etrack < toc->first_track || etrack > toc->last_track ||
- strack > etrack)
- goto errreq;
- int start = toc->toc[toc->first_track_offset + strack - 1].paddress;
- int end = etrack == toc->last_track ? toc->lastaddress : toc->toc[toc->first_track_offset + etrack - 1 + 1].paddress;
- sys_command_cd_pause (unitnum, 0);
- if (!sys_command_cd_play (unitnum, start, end, 0))
- goto notdatatrack;
- scsi_len = 0;
- }
- break;
- case 0x49: // PLAY AUDIO TRACK RELATIVE (10)
- case 0xa9: // PLAY AUDIO TRACK RELATIVE (12)
- {
- if (nodisk (&di))
- goto nodisk;
- int len = cmd == 0xa9 ? rl (cmdbuf + 6) : rw (cmdbuf + 7);
- int track = cmd == 0xa9 ? cmdbuf[10] : cmdbuf[6];
- if (track < di.toc.first_track || track > di.toc.last_track)
- goto errreq;
- int start = di.toc.toc[di.toc.first_track_offset + track - 1].paddress;
- int rel = rl (cmdbuf + 2);
- start += rel;
- int end = start + len;
- if (end > di.toc.lastaddress)
- end = di.toc.lastaddress;
- if (len > 0) {
- sys_command_cd_pause (unitnum, 0);
- if (!sys_command_cd_play (unitnum, start, start + len, 0))
- goto notdatatrack;
- }
- scsi_len = 0;
- }
- break;
- case 0x47: // PLAY AUDIO MSF
- {
- if (nodisk (&di))
- goto nodisk;
- int start = rl (cmdbuf + 2) & 0x00ffffff;
- if (start == 0x00ffffff) {
- uae_u8 buf[SUBQ_SIZE] = { 0 };
- sys_command_cd_qcode (unitnum, buf, -1, false);
- start = fromlongbcd (buf + 4 + 7);
- }
- int end = msf2lsn (rl (cmdbuf + 5) & 0x00ffffff);
- if (end > di.toc.lastaddress)
- end = di.toc.lastaddress;
- start = msf2lsn (start);
- if (start > end)
- goto errreq;
- if (start < end)
- sys_command_cd_pause (unitnum, 0);
- if (!sys_command_cd_play (unitnum, start, end, 0))
- goto notdatatrack;
- scsi_len = 0;
- }
- break;
- case 0x45: // PLAY AUDIO (10)
- case 0xa5: // PLAY AUDIO (12)
- {
- if (nodisk (&di))
- goto nodisk;
- int start = rl (cmdbuf + 2);
- int len;
- if (cmd == 0xa5)
- len = rl (cmdbuf + 6);
- else
- len = rw (cmdbuf + 7);
- if (len > 0) {
- if (start == -1) {
- uae_u8 buf[SUBQ_SIZE] = { 0 };
- sys_command_cd_qcode (unitnum, buf, -1, false);
- start = msf2lsn (fromlongbcd (buf + 4 + 7));
- }
- int end = start + len;
- if (end > di.toc.lastaddress)
- end = di.toc.lastaddress;
- sys_command_cd_pause (unitnum, 0);
- if (!sys_command_cd_play (unitnum, start, end, 0))
- goto notdatatrack;
- }
- scsi_len = 0;
- }
- break;
- case 0xbc: // PLAY CD
- {
- if (nodisk (&di))
- goto nodisk;
- int start = -1;
- int end = -1;
- if (cmdbuf[1] & 2) {
- start = msf2lsn (rl (cmdbuf + 2) & 0x00ffffff);
- end = msf2lsn (rl (cmdbuf + 5) & 0x00ffffff);
- } else {
- start = rl (cmdbuf + 2);
- end = start + rl (cmdbuf + 6);
- }
- if (end > di.toc.lastaddress)
- end = di.toc.lastaddress;
- if (start > end)
- goto errreq;
- if (start < end) {
- sys_command_cd_pause (unitnum, 0);
- if (!sys_command_cd_play (unitnum, start, end, 0))
- goto notdatatrack;
- }
- }
- break;
- case 0x4b: // PAUSE/RESUME
- {
- if (nodisk (&di))
- goto nodisk;
- uae_u8 buf[SUBQ_SIZE] = { 0 };
- int resume = cmdbuf[8] & 1;
- sys_command_cd_qcode (unitnum, buf, -1, false);
- if (buf[1] != AUDIO_STATUS_IN_PROGRESS && buf[1] != AUDIO_STATUS_PAUSED)
- goto errreq;
- sys_command_cd_pause (unitnum, resume ? 0 : 1);
- scsi_len = 0;
- }
- break;
- case 0x35: /* SYNCRONIZE CACHE (10) */
- scsi_len = 0;
- break;
-
- default:
-err:
- write_log (_T("CD SCSIEMU: unsupported scsi command 0x%02X\n"), cmdbuf[0]);
-readprot:
- status = 2; /* CHECK CONDITION */
- s[0] = 0x70;
- s[2] = 5;
- s[12] = 0x20; /* INVALID COMMAND */
- ls = 0x12;
- break;
-nodisk:
- status = 2; /* CHECK CONDITION */
- s[0] = 0x70;
- s[2] = 2; /* NOT READY */
- s[12] = 0x3A; /* MEDIUM NOT PRESENT */
- ls = 0x12;
- break;
-readerr:
- status = 2; /* CHECK CONDITION */
- s[0] = 0x70;
- s[2] = 2; /* NOT READY */
- s[12] = 0x11; /* UNRECOVERED READ ERROR */
- ls = 0x12;
- break;
-notdatatrack:
- status = 2;
- s[0] = 0x70;
- s[2] = 5;
- s[12] = 0x64; /* ILLEGAL MODE FOR THIS TRACK */
- ls = 0x12;
- break;
-outofbounds:
- status = 2; /* CHECK CONDITION */
- s[0] = 0x70;
- s[2] = 5; /* ILLEGAL REQUEST */
- s[12] = 0x21; /* LOGICAL BLOCK OUT OF RANGE */
- ls = 0x12;
- break;
-errreq:
- lr = -1;
- status = 2; /* CHECK CONDITION */
- s[0] = 0x70;
- s[2] = 5; /* ILLEGAL REQUEST */
- s[12] = 0x24; /* ILLEGAL FIELD IN CDB */
- ls = 0x12;
- break;
- }
-end:
- *data_len = scsi_len;
- *reply_len = lr;
- *sense_len = ls;
- if (ls) {
- //s[0] |= 0x80;
- if (ls > 7)
- s[7] = ls - 8; // additional sense length
- }
- return status;
+ if(log_scsiemu) {
+ write_log(_T("SCSIEMU %d: %02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X.%02X CMDLEN=%d DATA=%08X LEN=%d\n"),
+ unitnum,
+ cmdbuf[0],
+ cmdbuf[1],
+ cmdbuf[2],
+ cmdbuf[3],
+ cmdbuf[4],
+ cmdbuf[5],
+ cmdbuf[6],
+ cmdbuf[7],
+ cmdbuf[8],
+ cmdbuf[9],
+ cmdbuf[10],
+ cmdbuf[11],
+ scsi_cmd_len,
+ scsi_data,
+ dlen) ;
}
-static int execscsicmd_direct (int unitnum, int type, struct amigascsi *as)
-{
- int io_error = 0;
- uae_u8 *scsi_datap, *scsi_datap_org;
- uae_u32 scsi_cmd_len_orig = as->cmd_len;
- uae_u8 cmd[16] = { 0 };
- uae_u8 replydata[256] = { 0 };
- int datalen = as->len;
- int senselen = as->sense_len;
- int replylen = 0;
+ // media changed and not inquiry
+ if(st->mediawaschanged && cmd != 0x12) {
+ if(log_scsiemu) {
+ write_log(_T("SCSIEMU %d: MEDIUM MAY HAVE CHANGED STATE\n")) ;
+}
+lr = -1 ;
+status = 2 ; /* CHECK CONDITION */
+s[0] = 0x70 ;
+s[2] = 6 ; /* UNIT ATTENTION */
+s[12] = 0x28 ; /* MEDIUM MAY HAVE CHANGED */
+ls = 0x12 ;
+if(cmd == 0x00)
+ st->mediawaschanged = false ;
+goto end ;
+}
- memcpy (cmd, as->cmd, as->cmd_len);
- scsi_datap = scsi_datap_org = as->len ? as->data : 0;
- if (as->sense_len > 32)
- as->sense_len = 32;
+ switch(cmdbuf[0])
+{
+ case 0x00 : /* TEST UNIT READY */
+ if(nodisk(&di))
+ goto nodisk ;
+ scsi_len = 0 ;
+ break ;
+ case 0x1e : /* PREVENT/ALLOW MEDIUM REMOVAL */
+ scsi_len = 0 ;
+ break ;
+ case 0xbd : /* MECHANISM STATUS */
+ len = (cmdbuf[8] << 8) | cmdbuf[9] ;
+ if(len > 8)
+ len = 8 ;
+ scsi_len = len ;
+ r[2] = st->current_pos >> 16 ;
+ r[3] = st->current_pos >> 8 ;
+ r[4] = st->current_pos >> 0 ;
+ break ;
+ case 0x12 : /* INQUIRY */
+{
+ if((cmdbuf[1] & 1) || cmdbuf[2] != 0)
+ goto err ;
+len = cmdbuf[4] ;
+if(cmdbuf[1] >> 5) {
+ r[0] = 0x7f ;
+} else {
+ r[0] = 5 ; // CDROM
+}
+r[1] |= 0x80 ; // removable
+r[2] = 2 ; /* supports SCSI-2 */
+r[3] = 2 ; /* response data format */
+if(atapi)
+ r[3] |= 3 << 5 ; // atapi transport version
+r[4] = 32 ; /* additional length */
+r[7] = 0 ;
+scsi_len = lr = len < 36 ? len : 36 ;
+r[2] = 2 ;
+r[3] = 2 ;
+char *s = ua(di.vendorid) ;
+memcpy(r + 8, s, strlen(s)) ;
+xfree(s) ;
+s = ua(di.productid) ;
+memcpy(r + 16, s, strlen(s)) ;
+xfree(s) ;
+s = ua(di.revision) ;
+memcpy(r + 32, s, strlen(s)) ;
+xfree(s) ;
+for(int i = 8 ; i < 36 ; i++) {
+ if(r[i] == 0)
+ r[i] = 32 ;
+}
+}
+break ;
+case 0xbe : // READ CD
+case 0xb9 : // READ CD MSF
+ if(nodisk(&di))
+ goto nodisk ;
+scsi_len = scsi_read_cd(unitnum, cmdbuf, scsi_data, &di) ;
+if(scsi_len == -2)
+ goto notdatatrack ;
+if(scsi_len == -1)
+ goto errreq ;
+break ;
+case 0x55 : // MODE SELECT(10)
+case 0x15 : // MODE SELECT(6)
+{
+ uae_u8 *p ;
+ bool mode10 = cmdbuf[0] == 0x55 ;
+ p = scsi_data + 4 ;
+ if(mode10)
+ p += 4 ;
+int pcode = p[0] & 0x3f ;
+if(pcode == 14) { // CD audio control
+ uae_u16 vol_left = (p[9] << 7) | (p[9] >> 1) ;
+ uae_u16 vol_right = (p[11] << 7) | (p[11] >> 1) ;
+ sys_command_cd_volume(unitnum, vol_left, vol_right) ;
+ scsi_len = 0 ;
+} else {
+ if(log_scsiemu)
+ write_log(_T("MODE SELECT PC=%d not supported\n"), pcode) ;
+ goto errreq ;
+}
+}
+break ;
+case 0x5a : // MODE SENSE(10)
+case 0x1a : /* MODE SENSE(6) */
+{
+ uae_u8 *p ;
+ int maxlen ;
+ bool pcodeloop = false ;
+ bool sense10 = cmdbuf[0] == 0x5a ;
+ int psize,
+ totalsize,
+ bdsize ;
+ int pc = cmdbuf[2] >> 6 ;
+ int pcode = cmdbuf[2] & 0x3f ;
+ int dbd = cmdbuf[1] & 8 ;
+
+ if(atapi) {
+ if(!sense10)
+ goto err ;
+ dbd = 1 ;
+}
+if(log_scsiemu)
+ write_log(_T("MODE SENSE PC=%d CODE=%d DBD=%d\n"), pc, pcode, dbd) ;
+p = r ;
+if(sense10) {
+ totalsize = 8 - 2 ;
+ maxlen = (cmdbuf[7] << 8) | cmdbuf[8] ;
+ p[2] = 0 ;
+ p[3] = 0 ;
+ p[4] = 0 ;
+ p[5] = 0 ;
+ p[6] = 0 ;
+ p[7] = 0 ;
+ p += 8 ;
+} else {
+ totalsize = 4 - 1 ;
+ maxlen = cmdbuf[4] ;
+ p[1] = 0 ;
+ p[2] = 0 ;
+ p[3] = 0 ;
+ p += 4 ;
+}
+bdsize = 0 ;
+if(!dbd) {
+ wl(p + 0, 0) ;
+ wl(p + 4, di.bytespersector) ;
+ bdsize = 8 ;
+ p += bdsize ;
+}
+if(pcode == 0x3f) {
+ pcode = 1 ; // page = 0 must be last
+ pcodeloop = true ;
+}
+for(; ;) {
+ psize = 0 ;
+ if(pcode == 0) {
+ p[0] = 0 ;
+ p[1] = 0 ;
+ p[2] = 0x20 ;
+ p[3] = 0 ;
+ psize = 4 ;
+} else if(pcode == 14) { // CD audio control
+ uae_u32 vol = sys_command_cd_volume(unitnum, 0xffff, 0xffff) ;
+ p[0] = 0x0e ;
+ p[1] = 0x0e ;
+ p[2] = 4 | 1 ;
+ p[3] = 4 ;
+ p[6] = 0 ;
+ p[7] = 75 ;
+ p[8] = 1 ;
+ p[9] = pc == 0 ? (vol >> 7) & 0xff : 0xff ;
+ p[10] = 2 ;
+ p[11] = pc == 0 ? (vol >> (16 + 7)) & 0xff : 0xff ;
+ psize = p[1] + 2 ;
+} else if(pcode == 0x2a) { // cd/dvd capabilities
+ p[0] = 0x2a ;
+ p[1] = 0x18 ;
+ p[2] = 1 ; // | 0x10 | 0x20; // read: CD-R/DVD-ROM/DVD-R
+ p[3] = 0 ; // write: nothing
+ p[4] = 0x40 | 0x20 | 0x10 | 0x01 ;
+ p[5] = 0x08 | 0x04 | 0x02 | 0x01 ;
+ p[6] = (1 << 5) | 0x10 ; // type = tray, eject supported
+ p[7] = 3 ; // separate channel mute and volume
+ p[8] = 2 ; p[9] = 0 ;
+ p[10] = 0xff ; p[11] = 0xff ; // number of volume levels
+ p[12] = 4 ; p[13] = 0 ; // "1M buffer"
+ p[14] = 2 ; p[15] = 0 ;
+ p[16] = 0 ;
+ p[17] = 0 ;
+ p[18] = p[19] = 0 ;
+ p[20] = p[21] = 0 ;
+ p[22] = p[23] = 0 ;
+ psize = p[1] + 2 ;
+} else {
+ if(!pcodeloop)
+ goto err ;
+}
+ totalsize += psize ;
+ p += psize ;
+ if(!pcodeloop)
+ break ;
+if(pcode == 0)
+ break ;
+pcode++ ;
+if(pcode == 0x3f)
+ pcode = 0 ;
+}
+ if(sense10) {
+ totalsize += bdsize ;
+ r[6] = bdsize >> 8 ;
+ r[7] = bdsize & 0xff ;
+ r[0] = totalsize >> 8 ;
+ r[1] = totalsize & 0xff ;
+} else {
+ totalsize += bdsize ;
+ r[3] = bdsize & 0xff ;
+ r[0] = totalsize & 0xff ;
+}
+scsi_len = totalsize + 1 ;
+if(scsi_len > maxlen)
+ scsi_len = maxlen ;
+lr = scsi_len ;
+}
+break ;
+case 0x01 : /* REZERO UNIT */
+ scsi_len = 0 ;
+break ;
+case 0x1d : /* SEND DIAGNOSTICS */
+ scsi_len = 0 ;
+ break ;
+case 0x25 : /* READ CAPACITY */
+{
+ int pmi = cmdbuf[8] & 1 ;
+ uae_u32 lba = (cmdbuf[2] << 24) | (cmdbuf[3] << 16) | (cmdbuf[4] << 8) | cmdbuf[5] ;
+ int cyl,
+ cylsec,
+ head,
+ tracksec ;
+ if(nodisk(&di))
+ goto nodisk ;
+ uae_u32 blocks = di.sectorspertrack * di.cylinders * di.trackspercylinder - 1 ;
+ cyl = di.cylinders ;
+ head = 1 ;
+ cylsec = tracksec = di.trackspercylinder ;
+ if(pmi == 0 && lba != 0)
+ goto errreq ;
+ if(pmi) {
+ lba += tracksec * head ;
+ lba /= tracksec * head ;
+ lba *= tracksec * head ;
+ if(lba > blocks)
+ lba = blocks ;
+ blocks = lba ;
+}
+wl(r, blocks) ;
+wl(r + 4, di.bytespersector) ;
+scsi_len = lr = 8 ;
+}
+break ;
+case 0x0b : /* SEEK (6) */
+{
+ if(nodisk(&di))
+ goto nodisk ;
+ stopplay(unitnum) ;
+ offset = ((cmdbuf[1] & 31) << 16) | (cmdbuf[2] << 8) | cmdbuf[3] ;
+ struct cd_toc *t = gettoc(&di.toc, offset) ;
+ v = scsi_read_cd_data(unitnum, scsi_data, offset, 0, &di, &scsi_len) ;
+ if(v == -1)
+ goto outofbounds ;
+}
+break ;
+case 0x08 : /* READ (6) */
+{
+ if(nodisk(&di))
+ goto nodisk ;
+stopplay(unitnum) ;
+offset = ((cmdbuf[1] & 31) << 16) | (cmdbuf[2] << 8) | cmdbuf[3] ;
+struct cd_toc *t = gettoc(&di.toc, offset) ;
+if((t->control & 0x0c) == 0x04) {
+ len = cmdbuf[4] ;
+ if(!len)
+ len = 256 ;
+ v = scsi_read_cd_data(unitnum, scsi_data, offset, len, &di, &scsi_len) ;
+ if(v == -1)
+ goto outofbounds ;
+ if(v == -2)
+ goto readerr ;
+ if(v == -3)
+ goto toolarge ;
+} else {
+ goto notdatatrack ;
+}
+}
+break ;
+case 0x0a : /* WRITE (6) */
+ goto readprot ;
+case 0x2b : /* SEEK (10) */
+{
+ if(nodisk(&di))
+ goto nodisk ;
+ stopplay(unitnum) ;
+ offset = rl(cmdbuf + 2) ;
+ struct cd_toc *t = gettoc(&di.toc, offset) ;
+ v = scsi_read_cd_data(unitnum, scsi_data, offset, 0, &di, &scsi_len) ;
+ if(v == -1)
+ goto outofbounds ;
+}
+break ;
+case 0x28 : /* READ (10) */
+{
+ if(nodisk(&di))
+ goto nodisk ;
+stopplay(unitnum) ;
+offset = rl(cmdbuf + 2) ;
+struct cd_toc *t = gettoc(&di.toc, offset) ;
+if((t->control & 0x0c) == 0x04) {
+ len = rl(cmdbuf + 7 - 2) & 0xffff ;
+ v = scsi_read_cd_data(unitnum, scsi_data, offset, len, &di, &scsi_len) ;
+ if(v == -1)
+ goto outofbounds ;
+ if(v == -2)
+ goto readerr ;
+ if(v == -3)
+ goto toolarge ;
+} else {
+ goto notdatatrack ;
+}
+}
+break ;
+case 0x2a : /* WRITE (10) */
+ goto readprot ;
+case 0xa8 : /* READ (12) */
+{
+ if(nodisk(&di))
+ goto nodisk ;
+stopplay(unitnum) ;
+offset = rl(cmdbuf + 2) ;
+struct cd_toc *t = gettoc(&di.toc, offset) ;
+if((t->control & 0x0c) == 0x04) {
+ len = rl(cmdbuf + 6) ;
+ v = scsi_read_cd_data(unitnum, scsi_data, offset, len, &di, &scsi_len) ;
+ if(v == -1)
+ goto outofbounds ;
+ if(v == -2)
+ goto readerr ;
+ if(v == -3)
+ goto toolarge ;
+} else {
+ goto notdatatrack ;
+}
+}
+break ;
+case 0xaa : /* WRITE (12) */
+ goto readprot ;
+case 0x51 : /* READ DISC INFORMATION */
+{
+ struct cd_toc_head ttoc ;
+ int maxlen = (cmdbuf[7] << 8) | cmdbuf[8] ;
+ if(nodisk(&di))
+ goto nodisk ;
+ if(!sys_command_cd_toc(unitnum, &ttoc))
+ goto readerr ;
+ struct cd_toc_head *toc = &ttoc ;
+ uae_u8 *p = scsi_data ;
+ p[0] = 0 ;
+ p[1] = 34 - 2 ;
+ p[2] = 2 | (3 << 2) ; // complete cd rom, last session is complete
+ p[3] = toc->first_track ;
+ p[4] = 1 ;
+ p[5] = toc->first_track ;
+ p[6] = toc->last_track ;
+ wl(p + 16, lsn2msf(toc->lastaddress)) ;
+ wl(p + 20, 0x00ffffff) ;
+ scsi_len = p[1] + 2 ;
+ if(scsi_len > maxlen)
+ scsi_len = maxlen ;
+}
+break ;
+case 0x52 : /* READ TRACK INFORMATION */
+{
+ struct cd_toc_head ttoc ;
+ int maxlen = (cmdbuf[7] << 8) | cmdbuf[8] ;
+ if(nodisk(&di))
+ goto nodisk ;
+ if(!sys_command_cd_toc(unitnum, &ttoc))
+ goto readerr ;
+ struct cd_toc_head *toc = &ttoc ;
+ uae_u8 *p = scsi_data ;
+ int lsn ;
+ if(cmdbuf[1] & 1) {
+ int track = cmdbuf[5] ;
+ lsn = toc->toc[track].address ;
+} else {
+ lsn = rl(p + 2) ;
+}
+struct cd_toc *t = gettoc(toc, lsn) ;
+p[0] = 0 ;
+p[1] = 28 - 2 ;
+p[2] = t->track ;
+p[3] = 1 ;
+p[5] = t->control ;
+p[6] = 0 ; // data mode, fixme
+wl(p + 8, t->address) ;
+wl(p + 24, t[1].address - t->address) ;
+scsi_len = p[1] + 2 ;
+if(scsi_len > maxlen)
+ scsi_len = maxlen ;
+}
+break ;
+case 0x43 : // READ TOC
+{
+ if(nodisk(&di))
+ goto nodisk ;
+ uae_u8 *p = scsi_data ;
+ int strack = cmdbuf[6] ;
+ int msf = cmdbuf[1] & 2 ;
+ int format = cmdbuf[2] & 7 ;
+ if(format >= 3)
+ goto errreq ;
+ int maxlen = (cmdbuf[7] << 8) | cmdbuf[8] ;
+ int maxlen2 = maxlen ;
+ struct cd_toc_head ttoc ;
+ if(!sys_command_cd_toc(unitnum, &ttoc))
+ goto readerr ;
+ struct cd_toc_head *toc = &ttoc ;
+ if(maxlen < 4)
+ goto errreq ;
+ if(format == 1) {
+ p[0] = 0 ;
+ p[1] = 2 + 8 ;
+ p[2] = 1 ;
+ p[3] = 1 ;
+ p[4] = 0 ;
+ p[5] = (toc->toc[0].adr << 4) | toc->toc[0].control ;
+ p[6] = toc->first_track ;
+ p[7] = 0 ;
+ if(msf)
+ wl(p + 8, lsn2msf(toc->toc[0].address)) ;
+ else
+ wl(p + 8, toc->toc[0].address) ;
+ scsi_len = 12 ;
+} else if(format == 2 || format == 0) {
+ if(format == 2 && !msf)
+ goto errreq ;
+ if(strack == 0)
+ strack = toc->first_track ;
+ if(format == 0 && strack >= 100 && strack != 0xaa)
+ goto errreq ;
+ uae_u8 *p2 = p + 4 ;
+ p[2] = 0 ;
+ p[3] = 0 ;
+ maxlen -= 4 ;
+ if(format == 2) {
+ if(!addtocentry(&p2, &maxlen, 0xa0, -1, msf, p, toc))
+ break ;
+ if(!addtocentry(&p2, &maxlen, 0xa1, -1, msf, p, toc))
+ break ;
+ if(!addtocentry(&p2, &maxlen, 0xa2, -1, msf, p, toc))
+ break ;
+}
+while(strack < 100) {
+ if(!addtocentry(&p2, &maxlen, strack, -1, msf, p, toc))
+ break ;
+ strack++ ;
+}
+addtocentry(&p2, &maxlen, 0xa2, 0xaa, msf, p, toc) ;
+int tlen = p2 - (p + 2) ;
+p[0] = tlen >> 8 ;
+p[1] = tlen >> 0 ;
+scsi_len = tlen + 2 ;
+if(scsi_len > maxlen2)
+ scsi_len = maxlen2 ;
+}
+}
+break ;
+case 0x42 : // READ SUB-CHANNEL
+{
+ int msf = cmdbuf[1] & 2 ;
+ int subq = cmdbuf[2] & 0x40 ;
+ int format = cmdbuf[3] ;
+ int track = cmdbuf[6] ;
+ int len = rw(cmdbuf + 7) ;
+ uae_u8 buf[SUBQ_SIZE] = { 0 } ;
+
+ if(nodisk(&di))
+ goto nodisk ;
+ sys_command_cd_qcode(unitnum, buf) ;
+ if(len < 4)
+ goto errreq ;
+scsi_len = 4 ;
+scsi_data[0] = 0 ;
+scsi_data[1] = buf[1] ;
+if(subq && format == 1) {
+ if(len < 4 + 12)
+ goto errreq ;
+ scsi_data[2] = 0 ;
+ scsi_data[3] = 12 ;
+ scsi_len += 12 ;
+ scsi_data[4] = 1 ;
+ scsi_data[5] = (buf[4 + 0] << 4) | (buf[4 + 0] >> 4) ;
+ scsi_data[6] = frombcd(buf[4 + 1]) ; // track
+ scsi_data[7] = frombcd(buf[4 + 2]) ; // index
+ int reladdr = fromlongbcd(&buf[4 + 3]) ;
+ int absaddr = fromlongbcd(&buf[4 + 7]) ;
+ if(!msf) {
+ reladdr = msf2lsn(reladdr) ;
+ absaddr = msf2lsn(absaddr) ;
+}
+wl(scsi_data + 8, absaddr) ;
+wl(scsi_data + 12, reladdr) ;
+} else {
+ scsi_data[2] = 0 ;
+ scsi_data[3] = 0 ;
+}
+}
+break ;
+case 0x1b : // START/STOP
+ sys_command_cd_stop(unitnum) ;
+ scsiemudrv(unitnum, cmdbuf) ;
+ scsi_len = 0 ;
+break ;
+case 0x4e : // STOP PLAY/SCAN
+ if(nodisk(&di))
+ goto nodisk ;
+ sys_command_cd_stop(unitnum) ;
+ scsi_len = 0 ;
+break ;
+case 0xba : // SCAN
+{
+ if(nodisk(&di))
+ goto nodisk ;
+ struct cd_toc_head ttoc ;
+ if(!sys_command_cd_toc(unitnum, &ttoc))
+ goto readerr ;
+ struct cd_toc_head *toc = &ttoc ;
+ int scan = (cmdbuf[1] & 0x10) ? -1 : 1 ;
+ int start = rl(cmdbuf + 1) & 0x00ffffff ;
+ int end = scan > 0 ? toc->lastaddress : toc->toc[toc->first_track_offset].paddress ;
+ int type = cmdbuf[9] >> 6 ;
+ if(type == 1)
+ start = lsn2msf(start) ;
+ if(type == 3)
+ goto errreq ;
+ if(type == 2) {
+ if(toc->first_track_offset + start >= toc->last_track_offset)
+ goto errreq ;
+ start = toc->toc[toc->first_track_offset + start].paddress ;
+}
+sys_command_cd_pause(unitnum, 0) ;
+sys_command_cd_play(unitnum, start, end, scan) ;
+scsi_len = 0 ;
+}
+break ;
+case 0x48 : // PLAY AUDIO TRACK/INDEX
+{
+ if(nodisk(&di))
+ goto nodisk ;
+ int strack = cmdbuf[4] ;
+ int etrack = cmdbuf[7] ;
+ struct cd_toc_head ttoc ;
+ if(!sys_command_cd_toc(unitnum, &ttoc))
+ goto readerr ;
+ struct cd_toc_head *toc = &ttoc ;
+ if(strack < toc->first_track || strack > toc->last_track ||
+ etrack < toc->first_track || etrack > toc->last_track ||
+ strack > etrack)
+ goto errreq ;
+ int start = toc->toc[toc->first_track_offset + strack - 1].paddress ;
+ int end = etrack == toc->last_track ? toc->lastaddress : toc->toc[toc->first_track_offset + etrack - 1 + 1].paddress ;
+ sys_command_cd_pause(unitnum, 0) ;
+ if(!sys_command_cd_play(unitnum, start, end, 0))
+ goto notdatatrack ;
+ scsi_len = 0 ;
+}
+break ;
+case 0x49 : // PLAY AUDIO TRACK RELATIVE (10)
+case 0xa9 : // PLAY AUDIO TRACK RELATIVE (12)
+{
+ if(nodisk(&di))
+ goto nodisk ;
+ int len = cmd == 0xa9 ? rl(cmdbuf + 6) : rw(cmdbuf + 7) ;
+ int track = cmd == 0xa9 ? cmdbuf[10] : cmdbuf[6] ;
+ if(track < di.toc.first_track || track > di.toc.last_track)
+ goto errreq ;
+ int start = di.toc.toc[di.toc.first_track_offset + track - 1].paddress ;
+ int rel = rl(cmdbuf + 2) ;
+ start += rel ;
+ int end = start + len ;
+ if(end > di.toc.lastaddress)
+ end = di.toc.lastaddress ;
+ if(len > 0) {
+ sys_command_cd_pause(unitnum, 0) ;
+ if(!sys_command_cd_play(unitnum, start, start + len, 0))
+ goto notdatatrack ;
+}
+scsi_len = 0 ;
+}
+break ;
+case 0x47 : // PLAY AUDIO MSF
+{
+ if(nodisk(&di))
+ goto nodisk ;
+ int start = rl(cmdbuf + 2) & 0x00ffffff ;
+ if(start == 0x00ffffff) {
+ uae_u8 buf[SUBQ_SIZE] = { 0 } ;
+ sys_command_cd_qcode(unitnum, buf) ;
+ start = fromlongbcd(buf + 4 + 7) ;
+}
+int end = msf2lsn(rl(cmdbuf + 5) & 0x00ffffff) ;
+if(end > di.toc.lastaddress)
+ end = di.toc.lastaddress ;
+start = msf2lsn(start) ;
+if(start > end)
+ goto errreq ;
+if(start < end)
+ sys_command_cd_pause(unitnum, 0) ;
+ if(!sys_command_cd_play(unitnum, start, end, 0))
+ goto notdatatrack ;
+scsi_len = 0 ;
+}
+break ;
+case 0x45 : // PLAY AUDIO (10)
+case 0xa5 : // PLAY AUDIO (12)
+{
+ if(nodisk(&di))
+ goto nodisk ;
+ int start = rl(cmdbuf + 2) ;
+ int len ;
+ if(cmd == 0xa5)
+ len = rl(cmdbuf + 6) ;
+ else
+ len = rw(cmdbuf + 7) ;
+ if(len > 0) {
+ if(start == -1) {
+ uae_u8 buf[SUBQ_SIZE] = { 0 } ;
+ sys_command_cd_qcode(unitnum, buf) ;
+ start = msf2lsn(fromlongbcd(buf + 4 + 7)) ;
+}
+int end = start + len ;
+if(end > di.toc.lastaddress)
+ end = di.toc.lastaddress ;
+sys_command_cd_pause(unitnum, 0) ;
+if(!sys_command_cd_play(unitnum, start, end, 0))
+ goto notdatatrack ;
+}
+scsi_len = 0 ;
+}
+break ;
+case 0xbc : // PLAY CD
+{
+ if(nodisk(&di))
+ goto nodisk ;
+ int start = -1 ;
+ int end = -1 ;
+ if(cmdbuf[1] & 2) {
+ start = msf2lsn(rl(cmdbuf + 2) & 0x00ffffff) ;
+ end = msf2lsn(rl(cmdbuf + 5) & 0x00ffffff) ;
+} else {
+ start = rl(cmdbuf + 2) ;
+ end = start + rl(cmdbuf + 6) ;
+}
+if(end > di.toc.lastaddress)
+ end = di.toc.lastaddress ;
+if(start > end)
+ goto errreq ;
+if(start < end) {
+ sys_command_cd_pause(unitnum, 0) ;
+ if(!sys_command_cd_play(unitnum, start, end, 0))
+ goto notdatatrack ;
+}
+}
+break ;
+case 0x4b : // PAUSE/RESUME
+{
+ if(nodisk(&di))
+ goto nodisk ;
+ uae_u8 buf[SUBQ_SIZE] = { 0 } ;
+ int resume = cmdbuf[8] & 1 ;
+ sys_command_cd_qcode(unitnum, buf) ;
+ if(buf[1] != AUDIO_STATUS_IN_PROGRESS && buf[1] != AUDIO_STATUS_PAUSED)
+ goto errreq ;
+ sys_command_cd_pause(unitnum, resume ? 0 : 1) ;
+ scsi_len = 0 ;
+}
+break ;
+case 0x35 : /* SYNCRONIZE CACHE (10) */
+ scsi_len = 0 ;
+break ;
+
+ default :
+err :
+ write_log(_T("CDEMU: unsupported scsi command 0x%02X\n"), cmdbuf[0]) ;
+readprot :
+ status = 2 ; /* CHECK CONDITION */
+ s[0] = 0x70 ;
+ s[2] = 5 ;
+ s[12] = 0x20 ; /* INVALID COMMAND */
+ ls = 0x12 ;
+ break ;
+nodisk :
+ status = 2 ; /* CHECK CONDITION */
+ s[0] = 0x70 ;
+ s[2] = 2 ; /* NOT READY */
+ s[12] = 0x3A ; /* MEDIUM NOT PRESENT */
+ ls = 0x12 ;
+ break ;
+readerr :
+ status = 2 ; /* CHECK CONDITION */
+ s[0] = 0x70 ;
+ s[2] = 2 ; /* NOT READY */
+ s[12] = 0x11 ; /* UNRECOVERED READ ERROR */
+ ls = 0x12 ;
+ break ;
+notdatatrack :
+ status = 2 ;
+ s[0] = 0x70 ;
+ s[2] = 5 ;
+ s[12] = 0x64 ; /* ILLEGAL MODE FOR THIS TRACK */
+ ls = 0x12 ;
+ break ;
+outofbounds :
+ status = 2 ; /* CHECK CONDITION */
+ s[0] = 0x70 ;
+ s[2] = 5 ; /* ILLEGAL REQUEST */
+ s[12] = 0x21 ; /* LOGICAL BLOCK OUT OF RANGE */
+ ls = 0x12 ;
+ break ;
+toolarge :
+ write_log(_T("CDEMU: too large scsi data tranfer %d > %d\n"), len, dlen) ;
+ status = 2 ; /* CHECK CONDITION */
+ s[0] = 0x70 ;
+ s[2] = 2 ; /* NOT READY */
+ s[12] = 0x11 ; /* UNRECOVERED READ ERROR */
+ ls = 0x12 ;
+ break ;
+errreq :
+ lr = -1 ;
+ status = 2 ; /* CHECK CONDITION */
+ s[0] = 0x70 ;
+ s[2] = 5 ; /* ILLEGAL REQUEST */
+ s[12] = 0x24 ; /* ILLEGAL FIELD IN CDB */
+ ls = 0x12 ;
+ break ;
+}
+end :
+ *data_len = scsi_len ;
+ *reply_len = lr ;
+ *sense_len = ls ;
+ if(ls) {
+ //s[0] |= 0x80;
+ s[7] = ls - 7 ; // additional sense length
+ if(log_scsiemu) {
+ write_log(_T("-> SENSE STATUS: KEY=%d ASC=%02X ASCQ=%02X\n"), s[2], s[12], s[13]) ;
+}
+}
+if(cmdbuf[0] && log_scsiemu)
+ write_log(_T("-> DATAOUT=%d ST=%d SENSELEN=%d\n"), scsi_len, status, ls) ;
+return status ;
+}
+
+static int execscsicmd_direct(int unitnum, int type, struct amigascsi *as)
+{
+ int io_error = 0 ;
+ uae_u8 *scsi_datap,
+ *scsi_datap_org ;
+ uae_u32 scsi_cmd_len_orig = as->cmd_len ;
+ uae_u8 cmd[16] = { 0 } ;
+ uae_u8 replydata[256] = { 0 } ;
+ int datalen = as->len ;
+ int senselen = as->sense_len ;
+ int replylen = 0 ;
+
+ memcpy(cmd, as->cmd, as->cmd_len) ;
+ scsi_datap = scsi_datap_org = as->len ? as->data : 0 ;
+ if(as->sense_len > 32)
+ as->sense_len = 32 ;
/* never report media change state if uaescsi.device */
- state[unitnum].mediawaschanged = false;
+ state[unitnum].mediawaschanged = false ;
- switch (type)
- {
- case INQ_ROMD:
- as->status = scsi_cd_emulate (unitnum, cmd, as->cmd_len, scsi_datap, &datalen, replydata, &replylen, as->sensedata, &senselen, false);
- break;
- default:
- as->status = 2;
- break;
- }
-
- as->cmdactual = as->status != 0 ? 0 : as->cmd_len; /* fake scsi_CmdActual */
- if (as->status) {
- io_error = IOERR_BadStatus;
- as->sactual = senselen;
- as->actual = 0; /* scsi_Actual */
- } else {
- int i;
- if (replylen > 0) {
- for (int i = 0; i < replylen; i++) {
- scsi_datap[i] = replydata[i];
- }
- datalen = replylen;
- }
- for (i = 0; i < as->sense_len; i++)
- as->sensedata[i] = 0;
- if (datalen < 0) {
- io_error = IOERR_NotSpecified;
- as->actual = 0; /* scsi_Actual */
- } else {
- as->len = datalen;
- io_error = 0;
- as->actual = as->len; /* scsi_Actual */
- }
- }
-
- return io_error;
+ switch(type)
+{
+ case INQ_ROMD :
+ as->status = scsi_cd_emulate(unitnum, cmd, as->cmd_len, scsi_datap, &datalen, replydata, &replylen, as->sensedata, &senselen, false) ;
+ break ;
+ default :
+ as->status = 2 ;
+ break ;
}
-int sys_command_scsi_direct_native (int unitnum, int type, struct amigascsi *as)
-{
- struct blkdevstate *st = &state[unitnum];
- if (st->scsiemu || (type >= 0 && st->type != type)) {
- return execscsicmd_direct (unitnum, type, as);
- } else {
- if (!st->device_func->exec_direct)
- return -1;
- }
- int ret = st->device_func->exec_direct (unitnum, as);
- if (!ret && st->device_func->isatapi(unitnum))
- scsi_atapi_fixup_inquiry (as);
- return ret;
+ as->cmdactual = as->status != 0 ? 0 : as->cmd_len ; /* fake scsi_CmdActual */
+ if(as->status) {
+ io_error = IOERR_BadStatus ;
+ as->sactual = senselen ;
+ as->actual = 0 ; /* scsi_Actual */
+} else {
+ int i ;
+ if(replylen > 0) {
+ for(i = 0 ; i < replylen ; i++)
+ scsi_datap[i] = replydata[i] ;
+ datalen = replylen ;
+}
+for(i = 0 ; i < as->sense_len ; i++)
+ as->sensedata[i] = 0 ;
+if(datalen < 0) {
+ io_error = IOERR_NotSpecified ;
+ as->actual = 0 ; /* scsi_Actual */
+} else {
+ as->len = datalen ;
+ io_error = 0 ;
+ as->actual = as->len ; /* scsi_Actual */
+}
}
-int sys_command_scsi_direct(TrapContext *ctx, int unitnum, int type, uaecptr acmd)
+ return io_error ;
+}
+
+int sys_command_scsi_direct_native(int unitnum, int type, struct amigascsi *as)
{
- int ret;
- struct amigascsi as = { 0 };
- uaecptr ap;
- addrbank *bank;
- uae_u8 scsicmd[30];
+ struct blkdevstate *st = &state[unitnum] ;
+ if(st->scsiemu || (type >= 0 && st->type != type)) {
+ return execscsicmd_direct(unitnum, type, as) ;
+} else {
+ if(!st->device_func->exec_direct)
+ return - 1 ;
+}
+int ret = st->device_func->exec_direct(unitnum, as) ;
+if(!ret && st->device_func->isatapi(unitnum))
+ scsi_atapi_fixup_inquiry(as) ;
+return ret ;
+}
- trap_get_bytes(ctx, scsicmd, acmd, sizeof scsicmd);
+int sys_command_scsi_direct(int unitnum, int type, uaecptr acmd)
+{
+ int ret,
+ i ;
+ struct amigascsi as = { 0 } ;
+ uaecptr ap ;
+ addrbank *bank ;
- as.cmd_len = get_word_host(scsicmd + 16);
- if (as.cmd_len > sizeof as.cmd)
- return IOERR_BADLENGTH;
- as.flags = get_byte_host(scsicmd + 20);
- ap = get_long_host(scsicmd + 0);
- as.len = get_long_host(scsicmd + 4);
+ ap = get_long(acmd + 0) ;
+ as.len = get_long(acmd + 4) ;
- bank = &get_mem_bank (ap);
- if (!bank || !bank->check(ap, as.len))
- return IOERR_BADADDRESS;
- as.data = bank->xlateaddr (ap);
+ bank = &get_mem_bank(ap) ;
+ if(!bank || !bank->check(ap, as.len))
+ return IOERR_BADADDRESS ;
+ as.data = bank->xlateaddr(ap) ;
- ap = get_long_host(scsicmd + 12);
- trap_get_bytes(ctx, as.cmd, ap, as.cmd_len);
- as.sense_len = get_word_host(scsicmd + 26);
+ ap = get_long(acmd + 12) ;
+ as.cmd_len = get_word(acmd + 16) ;
+ if(as.cmd_len > sizeof as.cmd)
+ return IOERR_BADLENGTH ;
+ for(i = 0 ; i < as.cmd_len ; i++)
+ as.cmd[i] = get_byte(ap++) ;
+ while(i < sizeof as.cmd)
+ as.cmd[i++] = 0 ;
+ as.flags = get_byte(acmd + 20) ;
+ as.sense_len = get_word(acmd + 26) ;
- ret = sys_command_scsi_direct_native (unitnum, type, &as);
+ ret = sys_command_scsi_direct_native(unitnum, type, &as) ;
- put_long_host(scsicmd + 8, as.actual);
- put_word_host(scsicmd + 18, as.cmdactual);
- put_byte_host(scsicmd + 21, as.status);
- put_word_host(scsicmd + 28, as.sactual);
+ put_long(acmd + 8, as.actual) ;
+ put_word(acmd + 18, as.cmdactual) ;
+ put_byte(acmd + 21, as.status) ;
+ put_word(acmd + 28, as.sactual) ;
- if (as.flags & (2 | 4)) { // autosense
- ap = get_long_host(scsicmd + 22);
- if (as.sactual)
- trap_put_bytes(ctx, as.sensedata, ap, as.sactual > as.sense_len ? as.sense_len : as.sactual);
- if (as.sense_len > as.sactual)
- trap_set_bytes(ctx, ap + as.sactual, 0, as.sense_len - as.sactual);
- }
+ if(as.flags & (2 | 4)) { // autosense
+ ap = get_long(acmd + 22) ;
+ for(i = 0 ; i < as.sactual && i < as.sense_len ; i++)
+ put_byte(ap + i, as.sensedata[i]) ;
+}
- trap_put_bytes(ctx, scsicmd, acmd, sizeof scsicmd);
-
- return ret;
+ return ret ;
}
#ifdef SAVESTATE
-void restore_blkdev_start(void)
+uae_u8 *save_cd(int num, int *len)
{
- for (int i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
- struct cdslot *cd = &currprefs.cdslots[i];
- if (cd->temporary) {
- memset(cd, 0, sizeof(struct cdslot));
- memset(&changed_prefs.cdslots[i], 0, sizeof(struct cdslot));
- }
- }
+ struct blkdevstate *st = &state[num] ;
+ uae_u8 *dstbak,
+ *dst ;
+
+ memset(st->play_qcode, 0, SUBQ_SIZE) ;
+ if(!currprefs.cdslots[num].inuse || num >= MAX_TOTAL_SCSI_DEVICES)
+ return NULL ;
+ if(!currprefs.cs_cd32cd)
+ return NULL ;
+ dstbak = dst = xmalloc(uae_u8, 4 + 256 + 4 + 4) ;
+ save_u32(4 | 8) ;
+ save_path(currprefs.cdslots[num].name, SAVESTATE_PATH_CD) ;
+ save_u32(currprefs.cdslots[num].type) ;
+ save_u32(0) ;
+ save_u32(0) ;
+ sys_command_cd_qcode(num, st->play_qcode) ;
+ for(int i = 0 ; i < SUBQ_SIZE ; i++)
+ save_u8(st->play_qcode[i]) ;
+ save_u32(st->play_end_pos) ;
+ *len = dst - dstbak ;
+ return dstbak ;
}
-uae_u8 *save_cd (int num, int *len)
+uae_u8 *restore_cd(int num, uae_u8 *src)
{
- struct blkdevstate *st = &state[num];
- uae_u8 *dstbak, *dst;
+ struct blkdevstate *st = &state[num] ;
+ uae_u32 flags ;
+ TCHAR *s ;
- memset(st->play_qcode, 0, SUBQ_SIZE);
- if (!currprefs.cdslots[num].inuse || num >= MAX_TOTAL_SCSI_DEVICES)
- return NULL;
- if (!currprefs.cs_cd32cd)
- return NULL;
- dstbak = dst = xmalloc (uae_u8, 4 + 256 + 4 + 4);
- save_u32 (4 | 8);
- save_path (currprefs.cdslots[num].name, SAVESTATE_PATH_CD);
- save_u32 (currprefs.cdslots[num].type);
- save_u32 (0);
- save_u32 (0);
- sys_command_cd_qcode (num, st->play_qcode, -1, false);
- for (int i = 0; i < SUBQ_SIZE; i++)
- save_u8 (st->play_qcode[i]);
- save_u32 (st->play_end_pos);
- *len = dst - dstbak;
- return dstbak;
+ if(num >= MAX_TOTAL_SCSI_DEVICES)
+ return NULL ;
+ flags = restore_u32() ;
+ s = restore_path(SAVESTATE_PATH_CD) ;
+ int type = restore_u32() ;
+ restore_u32() ;
+ if(flags & 4) {
+ if(currprefs.cdslots[num].name[0] == 0 || zfile_exists(s)) {
+ _tcscpy(changed_prefs.cdslots[num].name, s) ;
+ _tcscpy(currprefs.cdslots[num].name, s) ;
}
-
-uae_u8 *restore_cd (int num, uae_u8 *src)
-{
- struct blkdevstate *st = &state[num];
- uae_u32 flags;
- TCHAR *s;
-
- if (num >= MAX_TOTAL_SCSI_DEVICES)
- return NULL;
- flags = restore_u32 ();
- s = restore_path (SAVESTATE_PATH_CD);
- int type = restore_u32 ();
- restore_u32 ();
- if (flags & 4) {
- if (currprefs.cdslots[num].name[0] == 0 || zfile_exists (s)) {
- _tcscpy (changed_prefs.cdslots[num].name, s);
- _tcscpy (currprefs.cdslots[num].name, s);
- }
- changed_prefs.cdslots[num].type = currprefs.cdslots[num].type = type;
- changed_prefs.cdslots[num].temporary = currprefs.cdslots[num].temporary = true;
- }
- if (flags & 8) {
- restore_u32 ();
- for (int i = 0; i < SUBQ_SIZE; i++)
- st->play_qcode[i] = restore_u8 ();
- st->play_end_pos = restore_u32 ();
- }
- return src;
+changed_prefs.cdslots[num].type = currprefs.cdslots[num].type = type ;
+}
+if(flags & 8) {
+ restore_u32() ;
+ for(int i = 0 ; i < SUBQ_SIZE ; i++)
+ st->play_qcode[i] = restore_u8() ;
+st->play_end_pos = restore_u32() ;
+}
+return src ;
}
#endif
-
diff --git a/src/cfgfile.cpp b/src/cfgfile.cpp
index 12367d22..1d9c41de 100644
--- a/src/cfgfile.cpp
+++ b/src/cfgfile.cpp
@@ -1,4 +1,4 @@
- /*
+/*
* UAE - The Un*x Amiga Emulator
*
* Config file handling
@@ -15,11 +15,11 @@
#include "options.h"
#include "uae.h"
#include "audio.h"
+#include "autoconf.h"
#include "custom.h"
#include "inputdevice.h"
#include "savestate.h"
#include "include/memory.h"
-#include "autoconf.h"
#include "rommgr.h"
#include "gui.h"
#include "newcpu.h"
@@ -28,9 +28,9 @@
#include "fsdb.h"
#include "disk.h"
#include "blkdev.h"
+#include "statusline.h"
#include "calc.h"
#include "gfxboard.h"
-#include "native2amiga_api.h"
#define cfgfile_warning write_log
#define cfgfile_warning_obsolete write_log
@@ -40,102 +40,193 @@ static struct strlist *temp_lines;
static struct strlist *error_lines;
static struct zfile *default_file, *configstore;
static int uaeconfig;
+static int unicode_config = 0;
/* @@@ need to get rid of this... just cut part of the manual and print that
* as a help text. */
struct cfg_lines
{
- const TCHAR *config_label, *config_help;
+ const TCHAR *config_label, *config_help;
+};
+
+static const struct cfg_lines opttable[] =
+{
+ { _T("help"), _T("Prints this help") },
+ { _T("config_description"), _T("") },
+ { _T("config_info"), _T("") },
+ { _T("use_gui"), _T("Enable the GUI? If no, then goes straight to emulator") },
+ { _T("use_debugger"), _T("Enable the debugger?") },
+ { _T("cpu_speed"), _T("can be max, real, or a number between 1 and 20") },
+ { _T("cpu_model"), _T("Can be 68000, 68010, 68020, 68030, 68040, 68060") },
+ { _T("fpu_model"), _T("Can be 68881, 68882, 68040, 68060") },
+ { _T("cpu_compatible"), _T("yes enables compatibility-mode") },
+ { _T("cpu_24bit_addressing"), _T("must be set to 'no' in order for Z3mem or P96mem to work") },
+ { _T("autoconfig"), _T("yes = add filesystems and extra ram") },
+ { _T("log_illegal_mem"), _T("print illegal memory access by Amiga software?") },
+ { _T("fastmem_size"), _T("Size in megabytes of fast-memory") },
+ { _T("chipmem_size"), _T("Size in megabytes of chip-memory") },
+ { _T("bogomem_size"), _T("Size in megabytes of bogo-memory at 0xC00000") },
+ { _T("a3000mem_size"), _T("Size in megabytes of A3000 memory") },
+ { _T("gfxcard_size"), _T("Size in megabytes of Picasso96 graphics-card memory") },
+ { _T("z3mem_size"), _T("Size in megabytes of Zorro-III expansion memory") },
+ { _T("gfx_test_speed"), _T("Test graphics speed?") },
+ { _T("gfx_framerate"), _T("Print every nth frame") },
+ { _T("gfx_width"), _T("Screen width") },
+ { _T("gfx_height"), _T("Screen height") },
+ { _T("gfx_refreshrate"), _T("Fullscreen refresh rate") },
+ { _T("gfx_vsync"), _T("Sync screen refresh to refresh rate") },
+ { _T("gfx_lores"), _T("Treat display as lo-res?") },
+ { _T("gfx_linemode"), _T("Can be none, double, or scanlines") },
+ { _T("gfx_fullscreen_amiga"), _T("Amiga screens are fullscreen?") },
+ { _T("gfx_fullscreen_picasso"), _T("Picasso screens are fullscreen?") },
+ { _T("gfx_center_horizontal"), _T("Center display horizontally?") },
+ { _T("gfx_center_vertical"), _T("Center display vertically?") },
+ { _T("gfx_colour_mode"), _T("") },
+ { _T("32bit_blits"), _T("Enable 32 bit blitter emulation") },
+ { _T("immediate_blits"), _T("Perform blits immediately") },
+ { _T("show_leds"), _T("LED display") },
+ { _T("keyboard_leds"), _T("Keyboard LEDs") },
+ { _T("gfxlib_replacement"), _T("Use graphics.library replacement?") },
+ { _T("sound_output"), _T("") },
+ { _T("sound_frequency"), _T("") },
+ { _T("sound_bits"), _T("") },
+ { _T("sound_channels"), _T("") },
+ { _T("sound_max_buff"), _T("") },
+ { _T("comp_trustbyte"), _T("How to access bytes in compiler (direct/indirect/indirectKS/afterPic") },
+ { _T("comp_trustword"), _T("How to access words in compiler (direct/indirect/indirectKS/afterPic") },
+ { _T("comp_trustlong"), _T("How to access longs in compiler (direct/indirect/indirectKS/afterPic") },
+ { _T("comp_nf"), _T("Whether to optimize away flag generation where possible") },
+ { _T("comp_fpu"), _T("Whether to provide JIT FPU emulation") },
+ { _T("cachesize"), _T("How many MB to use to buffer translated instructions") },
+ { _T("override_dga_address"),_T("Address from which to map the frame buffer (upper 16 bits) (DANGEROUS!)") },
+ { _T("avoid_dga"), _T("Set to yes if the use of DGA extension creates problems") },
+ { _T("avoid_vid"), _T("Set to yes if the use of the Vidmode extension creates problems") },
+ { _T("parallel_on_demand"), _T("") },
+ { _T("serial_on_demand"), _T("") },
+ { _T("scsi"), _T("scsi.device emulation") },
+ { _T("joyport0"), _T("") },
+ { _T("joyport1"), _T("") },
+ { _T("pci_devices"), _T("List of PCI devices to make visible to the emulated Amiga") },
+ { _T("kickstart_rom_file"), _T("Kickstart ROM image, (C) Copyright Amiga, Inc.") },
+ { _T("kickstart_ext_rom_file"), _T("Extended Kickstart ROM image, (C) Copyright Amiga, Inc.") },
+ { _T("kickstart_key_file"), _T("Key-file for encrypted ROM images (from Cloanto's Amiga Forever)") },
+ { _T("flash_ram_file"), _T("Flash/battery backed RAM image file.") },
+ { _T("cart_file"), _T("Freezer cartridge ROM image file.") },
+ { _T("floppy0"), _T("Diskfile for drive 0") },
+ { _T("floppy1"), _T("Diskfile for drive 1") },
+ { _T("floppy2"), _T("Diskfile for drive 2") },
+ { _T("floppy3"), _T("Diskfile for drive 3") },
+ { _T("hardfile"), _T("access,sectors, surfaces, reserved, blocksize, path format") },
+ { _T("filesystem"), _T("access,'Amiga volume-name':'host directory path' - where 'access' can be 'read-only' or 'read-write'") },
+ { _T("catweasel"), _T("Catweasel board io base address") }
};
static const TCHAR *guimode1[] = { _T("no"), _T("yes"), _T("nowait"), 0 };
static const TCHAR *guimode2[] = { _T("false"), _T("true"), _T("nowait"), 0 };
static const TCHAR *guimode3[] = { _T("0"), _T("1"), _T("nowait"), 0 };
static const TCHAR *csmode[] = { _T("ocs"), _T("ecs_agnus"), _T("ecs_denise"), _T("ecs"), _T("aga"), 0 };
+static const TCHAR *linemode[] = {
+ _T("none"),
+ _T("double"), _T("scanlines"), _T("scanlines2p"), _T("scanlines3p"),
+ _T("double2"), _T("scanlines2"), _T("scanlines2p2"), _T("scanlines2p3"),
+ _T("double3"), _T("scanlines3"), _T("scanlines3p2"), _T("scanlines3p3"),
+ 0 };
static const TCHAR *speedmode[] = { _T("max"), _T("real"), 0 };
+static const TCHAR *colormode1[] = { _T("8bit"), _T("15bit"), _T("16bit"), _T("8bit_dither"), _T("4bit_dither"), _T("32bit"), 0 };
+static const TCHAR *colormode2[] = { _T("8"), _T("15"), _T("16"), _T("8d"), _T("4d"), _T("32"), 0 };
static const TCHAR *soundmode1[] = { _T("none"), _T("interrupts"), _T("normal"), _T("exact"), 0 };
static const TCHAR *soundmode2[] = { _T("none"), _T("interrupts"), _T("good"), _T("best"), 0 };
+static const TCHAR *centermode1[] = { _T("none"), _T("simple"), _T("smart"), 0 };
+static const TCHAR *centermode2[] = { _T("false"), _T("true"), _T("smart"), 0 };
static const TCHAR *stereomode[] = { _T("mono"), _T("stereo"), _T("clonedstereo"), _T("4ch"), _T("clonedstereo6ch"), _T("6ch"), _T("mixed"), 0 };
static const TCHAR *interpolmode[] = { _T("none"), _T("anti"), _T("sinc"), _T("rh"), _T("crux"), 0 };
static const TCHAR *collmode[] = { _T("none"), _T("sprites"), _T("playfields"), _T("full"), 0 };
+static const TCHAR *compmode[] = { _T("direct"), _T("indirect"), _T("indirectKS"), _T("afterPic"), 0 };
+static const TCHAR *flushmode[] = { _T("soft"), _T("hard"), 0 };
+static const TCHAR *kbleds[] = { _T("none"), _T("POWER"), _T("DF0"), _T("DF1"), _T("DF2"), _T("DF3"), _T("HD"), _T("CD"), _T("DFx"), 0 };
+static const TCHAR *onscreenleds[] = { _T("false"), _T("true"), _T("rtg"), _T("both"), 0 };
static const TCHAR *soundfiltermode1[] = { _T("off"), _T("emulated"), _T("on"), 0 };
static const TCHAR *soundfiltermode2[] = { _T("standard"), _T("enhanced"), 0 };
static const TCHAR *lorestype1[] = { _T("lores"), _T("hires"), _T("superhires"), 0 };
static const TCHAR *lorestype2[] = { _T("true"), _T("false"), 0 };
+static const TCHAR *loresmode[] = { _T("normal"), _T("filtered"), 0 };
+static const TCHAR *horizmode[] = { _T("vertical"), _T("lores"), _T("hires"), _T("superhires"), 0 };
+static const TCHAR *vertmode[] = { _T("horizontal"), _T("single"), _T("double"), _T("quadruple"), 0 };
+#ifdef GFXFILTER
+static const TCHAR *filtermode2[] = { _T("1x"), _T("2x"), _T("3x"), _T("4x"), 0 };
+#endif
static const TCHAR *cartsmode[] = { _T("none"), _T("hrtmon"), 0 };
static const TCHAR *idemode[] = { _T("none"), _T("a600/a1200"), _T("a4000"), 0 };
static const TCHAR *rtctype[] = { _T("none"), _T("MSM6242B"), _T("RP5C01A"), _T("MSM6242B_A2000"), 0 };
static const TCHAR *ciaatodmode[] = { _T("vblank"), _T("50hz"), _T("60hz"), 0 };
+static const TCHAR *ksmirrortype[] = { _T("none"), _T("e0"), _T("a8+e0"), 0 };
static const TCHAR *cscompa[] = {
- _T("-"), _T("Generic"), _T("CD32"), _T("A500"), _T("A500+"), _T("A600"),
- _T("A1200"), _T("A2000"), _T("A4000"),
+ _T("-"), _T("Generic"), _T("CDTV"), _T("CDTV-CR"), _T("CD32"), _T("A500"), _T("A500+"), _T("A600"),
+ _T("A1000"), _T("A1200"), _T("A2000"), _T("A3000"), _T("A3000T"), _T("A4000"), _T("A4000T"),
+ _T("Velvet"),
NULL
};
static const TCHAR *qsmodes[] = {
- _T("A500"), _T("A500+"), _T("A600"), _T("A1200"), _T("A4000"), _T("CD32"), NULL };
+ _T("A500"), _T("A500+"), _T("A600"), _T("A1000"), _T("A1200"), _T("A3000"), _T("A4000"), _T(""), _T("CD32"), _T("CDTV"), _T("CDTV-CR"), _T("ARCADIA"), NULL };
+/* 3-state boolean! */
+static const TCHAR *fullmodes[] = { _T("false"), _T("true"), /* "FILE_NOT_FOUND", */ _T("fullwindow"), 0 };
+/* bleh for compatibility */
+static const TCHAR *scsimode[] = { _T("false"), _T("true"), _T("scsi"), 0 };
+static const TCHAR *maxhoriz[] = { _T("lores"), _T("hires"), _T("superhires"), 0 };
+static const TCHAR *maxvert[] = { _T("nointerlace"), _T("interlace"), 0 };
static const TCHAR *abspointers[] = { _T("none"), _T("mousehack"), _T("tablet"), 0 };
-static const TCHAR *joyportmodes[] = { _T(""), _T("mouse"), _T("mousenowheel"), _T("djoy"), _T("gamepad"), _T("ajoy"), _T("cdtvjoy"), _T("cd32joy"), 0 };
-#ifdef AMIBERRY
-static const TCHAR *mousemaps[] = { _T(""), _T("left"), _T("right"), _T("both"), 0 };
-#endif
+static const TCHAR *magiccursors[] = { _T("both"), _T("native"), _T("host"), 0 };
+static const TCHAR *autoscale[] = { _T("none"), _T("auto"), _T("standard"), _T("max"), _T("scale"), _T("resize"), _T("center"), _T("manual"),
+_T("integer"), _T("integer_auto"), _T("separator"), _T("overscan_blanking"), 0 };
+static const TCHAR *autoscale_rtg[] = { _T("resize"), _T("scale"), _T("center"), _T("integer"), 0 };
+static const TCHAR *autoscalelimit[] = { _T("1/1"), _T("1/2"), _T("1/4"), _T("1/8"), 0 };
+static const TCHAR *joyportmodes[] = { _T(""), _T("mouse"), _T("mousenowheel"), _T("djoy"), _T("gamepad"), _T("ajoy"), _T("cdtvjoy"), _T("cd32joy"), _T("lightpen"), 0 };
static const TCHAR *joyaf[] = { _T("none"), _T("normal"), _T("toggle"), _T("always"), 0 };
+static const TCHAR *epsonprinter[] = { _T("none"), _T("ascii"), _T("epson_matrix_9pin"), _T("epson_matrix_24pin"), _T("epson_matrix_48pin"), 0 };
+static const TCHAR *aspects[] = { _T("none"), _T("vga"), _T("tv"), 0 };
static const TCHAR *vsyncmodes[] = { _T("adaptive"), _T("false"), _T("true"), _T("autoswitch"), 0 };
+static const TCHAR *vsyncmodes2[] = { _T("normal"), _T("busywait"), 0 };
+static const TCHAR *filterapi[] = { _T("directdraw"), _T("direct3d"), 0 };
+static const TCHAR *dongles[] =
+{
+ _T("none"),
+ _T("robocop 3"), _T("leaderboard"), _T("b.a.t. ii"), _T("italy'90 soccer"), _T("dames grand maitre"),
+ _T("rugby coach"), _T("cricket captain"), _T("leviathan"),
+ NULL
+};
static const TCHAR *cdmodes[] = { _T("disabled"), _T(""), _T("image"), _T("ioctl"), _T("spti"), _T("aspi"), 0 };
static const TCHAR *cdconmodes[] = { _T(""), _T("uae"), _T("ide"), _T("scsi"), _T("cdtv"), _T("cd32"), 0 };
+static const TCHAR *specialmonitors[] = { _T("none"), _T("autodetect"), _T("a2024"), _T("graffiti"),
+_T("ham_e"), _T("ham_e_plus"), _T("videodac18"), _T("avideo12"), _T("avideo24"), _T("firecracker24"), _T("dctv"), _T("opalvision"), _T("colorburst"), 0 };
+static const TCHAR *genlockmodes[] = { _T("none"), _T("noise"), _T("testcard"), _T("image"), _T("video"), _T("stream"), _T("ld"), _T("sony_ld"), _T("pioneer_ld"), NULL };
+static const TCHAR *ppc_implementations[] = {
+ _T("auto"),
+ _T("dummy"),
+ _T("pearpc"),
+ _T("qemu"),
+ NULL
+};
+static const TCHAR *ppc_cpu_idle[] = {
+ _T("disabled"),
+ _T("1"),
+ _T("2"),
+ _T("3"),
+ _T("4"),
+ _T("5"),
+ _T("6"),
+ _T("7"),
+ _T("8"),
+ _T("9"),
+ _T("max"),
+ NULL
+};
static const TCHAR *waitblits[] = { _T("disabled"), _T("automatic"), _T("noidleonly"), _T("always"), 0 };
static const TCHAR *autoext2[] = { _T("disabled"), _T("copy"), _T("replace"), 0 };
-
-static const TCHAR *button_remap_name[] = {_T("dpad_up"), _T("dpad_down") , _T("dpad_left"), _T("dpad_right"),
- _T("select"), _T("left_shoulder"), _T("left_stick"),
- _T("north"), _T("south"), _T("east"), _T("west"),
- _T("start"), _T("right_shoulder"), _T("right_stick") ,0 };
-
-
-
-
-const TCHAR* find_inputevent_name(int key)
-{
- int index = -1;
- const struct inputevent *tempevent;
-
- const TCHAR* output;
-
- for(int i=0; iname);
- break;
- }
- else
- {output = "None";}
- }
- return output;
- }
-
-static int find_inputevent(TCHAR* key)
-{
- int index = -1;
- const struct inputevent *tempevent;
- char tmp1[255], tmp2[255];
-
- for(int i=0; iname);
- snprintf(tmp2, 255, "%s", key);
-
- if(!_tcscmp (tmp1, tmp2))
- {
- index=i;
- break;
- }
- }
- return index;
- }
-
+static const TCHAR *leds[] = { _T("power"), _T("df0"), _T("df1"), _T("df2"), _T("df3"), _T("hd"), _T("cd"), _T("fps"), _T("cpu"), _T("snd"), _T("md"), 0 };
+static const int leds_order[] = { 3, 6, 7, 8, 9, 4, 5, 2, 1, 0, 9 };
+static const TCHAR *lacer[] = { _T("off"), _T("i"), _T("p"), 0 };
+/* another boolean to choice update.. */
+static const TCHAR *cycleexact[] = { _T("false"), _T("memory"), _T("true"), 0 };
struct hdcontrollerconfig
{
@@ -145,9 +236,15 @@ struct hdcontrollerconfig
static const struct hdcontrollerconfig hdcontrollers[] = {
{ _T("uae"), 0 },
+
{ _T("ide%d"), 0 },
{ _T("ide%d_mainboard"), ROMTYPE_MB_IDE },
+ { _T("scsi%d"), 0 },
+ { _T("scsi%d_a3000"), ROMTYPE_SCSI_A3000 },
+ { _T("scsi%d_a4000t"), ROMTYPE_SCSI_A4000T },
+ { _T("scsi%d_cdtv"), ROMTYPE_CDTVSCSI },
+
{ NULL }
};
static const TCHAR *z3mapping[] = {
@@ -156,9 +253,14 @@ static const TCHAR *z3mapping[] = {
_T("real"),
NULL
};
+static const TCHAR *uaescsidevmodes[] = {
+ _T("original"),
+ _T("rename_scsi"),
+ NULL
+};
static const TCHAR *uaebootrom[] = {
_T("automatic"),
- _T("disabled"),
+ _T("disabled"),
_T("min"),
_T("full"),
NULL
@@ -171,30 +273,57 @@ static const TCHAR *uaeboard[] = {
NULL
};
+static const TCHAR *serialcrlf[] = {
+ _T("disabled"),
+ _T("crlf_cr"),
+ NULL
+};
+static const TCHAR *threebitcolors[] = {
+ _T("disabled"),
+ _T("3to4to8bit"),
+ _T("3to4bit"),
+ _T("3to8bit"),
+ NULL
+};
+
static const TCHAR *obsolete[] = {
_T("accuracy"), _T("gfx_opengl"), _T("gfx_32bit_blits"), _T("32bit_blits"),
_T("gfx_immediate_blits"), _T("gfx_ntsc"), _T("win32"), _T("gfx_filter_bits"),
_T("sound_pri_cutoff"), _T("sound_pri_time"), _T("sound_min_buff"), _T("sound_bits"),
_T("gfx_test_speed"), _T("gfxlib_replacement"), _T("enforcer"), _T("catweasel_io"),
- _T("kickstart_key_file"), _T("sound_adjust"), _T("sound_latency"),
+ _T("kickstart_key_file"), _T("fast_copper"), _T("sound_adjust"), _T("sound_latency"),
_T("serial_hardware_dtrdsr"), _T("gfx_filter_upscale"),
- _T("gfx_autoscale"), _T("parallel_sampler"), _T("parallel_ascii_emulation"),
+ _T("gfx_correct_aspect"), _T("gfx_autoscale"), _T("parallel_sampler"), _T("parallel_ascii_emulation"),
_T("avoid_vid"), _T("avoid_dga"), _T("z3chipmem_size"), _T("state_replay_buffer"), _T("state_replay"),
_T("z3realmapping"), _T("force_0x10000000_z3"),
- _T("fpu_arithmetic_exceptions"),
+
_T("gfx_filter_vert_zoom"),_T("gfx_filter_horiz_zoom"),
_T("gfx_filter_vert_zoom_mult"), _T("gfx_filter_horiz_zoom_mult"),
_T("gfx_filter_vert_offset"), _T("gfx_filter_horiz_offset"),
+
+ // created by some buggy beta
+ _T("uaehf0%s,%s"),
+ _T("uaehf1%s,%s"),
+ _T("uaehf2%s,%s"),
+ _T("uaehf3%s,%s"),
+ _T("uaehf4%s,%s"),
+ _T("uaehf5%s,%s"),
+ _T("uaehf6%s,%s"),
+ _T("uaehf7%s,%s"),
+
_T("pcibridge_rom_file"),
_T("pcibridge_rom_options"),
+
_T("cpuboard_ext_rom_file"),
_T("uaeboard_mode"),
+
_T("comp_oldsegv"),
_T("comp_midopt"),
_T("comp_lowopt"),
_T("avoid_cmov"),
_T("compforcesettings"),
- NULL
+
+ NULL
};
#define UNEXPANDED _T("$(FILE_PATH)")
@@ -218,7 +347,7 @@ static TCHAR *cfgfile_option_find_it(const TCHAR *s, const TCHAR *option, bool c
if (tmpp2)
*tmpp2++ = 0;
}
- if (!_tcsicmp(p, option)) {
+ if (!strcasecmp(p, option)) {
if (checkequals && tmpp2)
return tmpp2;
return p;
@@ -237,25 +366,25 @@ static TCHAR *cfgfile_option_get(const TCHAR *s, const TCHAR *option)
return cfgfile_option_find_it(s, option, true);
}
-static void trimwsa (char *s)
+static void trimwsa(char *s)
{
- /* Delete trailing whitespace. */
- int len = strlen (s);
- while (len > 0 && strcspn (s + len - 1, "\t \r\n") == 0)
- s[--len] = '\0';
+ /* Delete trailing whitespace. */
+ int len = strlen(s);
+ while (len > 0 && strcspn(s + len - 1, "\t \r\n") == 0)
+ s[--len] = '\0';
}
-static int match_string (const TCHAR *table[], const TCHAR *str)
+static int match_string(const TCHAR *table[], const TCHAR *str)
{
- int i;
- for (i = 0; table[i] != 0; i++)
- if (_tcsicmp (table[i], str) == 0)
- return i;
- return -1;
+ int i;
+ for (i = 0; table[i] != 0; i++)
+ if (strcasecmp(table[i], str) == 0)
+ return i;
+ return -1;
}
// escape config file separators and control characters
-static TCHAR *cfgfile_escape (const TCHAR *s, const TCHAR *escstr, bool quote)
+static TCHAR *cfgfile_escape(const TCHAR *s, const TCHAR *escstr, bool quote)
{
bool doquote = false;
int cnt = 0;
@@ -276,9 +405,7 @@ static TCHAR *cfgfile_escape (const TCHAR *s, const TCHAR *escstr, bool quote)
}
}
}
- if (escstr == NULL && quote)
- doquote = true;
- TCHAR *s2 = xmalloc (TCHAR, _tcslen (s) + cnt * 4 + 1);
+ TCHAR *s2 = xmalloc(TCHAR, _tcslen(s) + cnt * 4 + 1);
TCHAR *p = s2;
if (doquote)
*p++ = '\"';
@@ -289,7 +416,8 @@ static TCHAR *cfgfile_escape (const TCHAR *s, const TCHAR *escstr, bool quote)
if (c == '\\' || c == '\"' || c == '\'') {
*p++ = '\\';
*p++ = c;
- } else if (c >= 32 && !quote) {
+ }
+ else if (c >= 32 && !quote) {
bool escaped = false;
for (int j = 0; escstr && escstr[j]; j++) {
if (c == escstr[j]) {
@@ -301,26 +429,28 @@ static TCHAR *cfgfile_escape (const TCHAR *s, const TCHAR *escstr, bool quote)
}
if (!escaped)
*p++ = c;
- } else if (c < 32) {
+ }
+ else if (c < 32) {
*p++ = '\\';
switch (c)
{
- case '\t':
+ case '\t':
*p++ = 't';
break;
- case '\n':
+ case '\n':
*p++ = 'n';
break;
- case '\r':
+ case '\r':
*p++ = 'r';
break;
- default:
+ default:
*p++ = 'x';
*p++ = (c >> 4) >= 10 ? (c >> 4) + 'a' : (c >> 4) + '0';
*p++ = (c & 15) >= 10 ? (c & 15) + 'a' : (c & 15) + '0';
break;
}
- } else {
+ }
+ else {
*p++ = c;
}
}
@@ -329,23 +459,10 @@ static TCHAR *cfgfile_escape (const TCHAR *s, const TCHAR *escstr, bool quote)
*p = 0;
return s2;
}
-
-// escape only , and "
-static TCHAR *cfgfile_escape_min(const TCHAR *s)
-{
- for (int i = 0; s[i]; i++) {
- TCHAR c = s[i];
- if (c == ',' || c == '\"') {
- return cfgfile_escape(s, _T(","), true);
- }
- }
- return my_strdup(s);
-}
-
-static TCHAR *cfgfile_unescape (const TCHAR *s, const TCHAR **endpos, TCHAR separator)
+static TCHAR *cfgfile_unescape(const TCHAR *s, const TCHAR **endpos, TCHAR separator)
{
bool quoted = false;
- TCHAR *s2 = xmalloc (TCHAR, _tcslen (s) + 1);
+ TCHAR *s2 = xmalloc(TCHAR, _tcslen(s) + 1);
TCHAR *p = s2;
if (s[0] == '\"') {
s++;
@@ -368,27 +485,28 @@ static TCHAR *cfgfile_unescape (const TCHAR *s, const TCHAR **endpos, TCHAR sepa
c = s[i + 1];
switch (c)
{
- case 'X':
- case 'x':
- c2 = _totupper (s[i + 2]);
+ case 'X':
+ case 'x':
+ c2 = _totupper(s[i + 2]);
v = ((c2 >= 'A') ? c2 - 'A' : c2 - '0') << 4;
- c2 = _totupper (s[i + 3]);
+ c2 = _totupper(s[i + 3]);
v |= (c2 >= 'A') ? c2 - 'A' : c2 - '0';
*p++ = c2;
i += 2;
break;
- case 'r':
+ case 'r':
*p++ = '\r';
break;
- case '\n':
+ case '\n':
*p++ = '\n';
break;
- default:
+ default:
*p++ = c;
break;
}
i++;
- } else {
+ }
+ else {
*p++ = c;
}
}
@@ -397,308 +515,388 @@ static TCHAR *cfgfile_unescape (const TCHAR *s, const TCHAR **endpos, TCHAR sepa
*endpos = &s[i];
return s2;
}
-static TCHAR *cfgfile_unescape (const TCHAR *s, const TCHAR **endpos)
+static TCHAR *cfgfile_unescape(const TCHAR *s, const TCHAR **endpos)
{
- return cfgfile_unescape (s, endpos, 0);
+ return cfgfile_unescape(s, endpos, 0);
}
-static TCHAR *getnextentry (const TCHAR **valuep, const TCHAR separator)
+static TCHAR *getnextentry(const TCHAR **valuep, const TCHAR separator)
{
TCHAR *s;
const TCHAR *value = *valuep;
if (value[0] == '\"') {
- s = cfgfile_unescape (value, valuep);
+ s = cfgfile_unescape(value, valuep);
value = *valuep;
if (*value != 0 && *value != separator) {
- xfree (s);
+ xfree(s);
return NULL;
}
value++;
*valuep = value;
- } else {
- s = cfgfile_unescape (value, valuep, separator);
+ }
+ else {
+ s = cfgfile_unescape(value, valuep, separator);
}
return s;
}
-static TCHAR *cfgfile_subst_path2 (const TCHAR *path, const TCHAR *subst, const TCHAR *file)
+static TCHAR *cfgfile_subst_path2(const TCHAR *path, const TCHAR *subst, const TCHAR *file)
{
- /* @@@ use strcasecmp for some targets. */
- if (_tcslen (path) > 0 && _tcsncmp (file, path, _tcslen (path)) == 0) {
- int l;
- TCHAR *p2, *p = xmalloc (TCHAR, _tcslen (file) + _tcslen (subst) + 2);
- _tcscpy (p, subst);
- l = _tcslen (p);
- while (l > 0 && p[l - 1] == '/')
- p[--l] = '\0';
- l = _tcslen (path);
- while (file[l] == '/')
- l++;
- _tcscat (p, _T("/"));
- _tcscat (p, file + l);
- p2 = target_expand_environment (p, NULL, 0);
- xfree (p);
- return p2;
- }
+ /* @@@ use strcasecmp for some targets. */
+ if (_tcslen(path) > 0 && _tcsncmp(file, path, _tcslen(path)) == 0) {
+ int l;
+ TCHAR *p2, *p = xmalloc(TCHAR, _tcslen(file) + _tcslen(subst) + 2);
+ _tcscpy(p, subst);
+ l = _tcslen(p);
+ while (l > 0 && p[l - 1] == '/')
+ p[--l] = '\0';
+ l = _tcslen(path);
+ while (file[l] == '/')
+ l++;
+ _tcscat(p, _T("/"));
+ _tcscat(p, file + l);
+ p2 = target_expand_environment(p);
+ xfree(p);
+ return p2;
+ }
return NULL;
}
-TCHAR *cfgfile_subst_path (const TCHAR *path, const TCHAR *subst, const TCHAR *file)
+TCHAR* cfgfile_subst_path(const TCHAR* path, const TCHAR* subst, const TCHAR* file)
{
- TCHAR *s = cfgfile_subst_path2 (path, subst, file);
+ TCHAR* s = cfgfile_subst_path2(path, subst, file);
if (s)
return s;
- s = target_expand_environment (file, NULL, 0);
+ s = target_expand_environment(file);
return s;
}
-static bool isdefault (const TCHAR *s)
+static TCHAR *cfgfile_get_multipath2(struct multipath *mp, const TCHAR *path, const TCHAR *file, bool dir)
{
- TCHAR tmp[MAX_DPATH];
- if (!default_file || uaeconfig)
- return false;
- zfile_fseek (default_file, 0, SEEK_SET);
- while (zfile_fgets (tmp, sizeof tmp / sizeof (TCHAR), default_file)) {
- if (tmp[0] && tmp[_tcslen (tmp) - 1] == '\n')
- tmp[_tcslen (tmp) - 1] = 0;
- if (!_tcscmp (tmp, s))
- return true;
- }
- return false;
+ for (int i = 0; i < MAX_PATHS; i++) {
+ if (mp->path[i][0] && _tcscmp(mp->path[i], _T(".\\")) != 0 && _tcscmp(mp->path[i], _T("./")) != 0 && (file[0] != '/' && file[0] != '\\' && !_tcschr(file, ':'))) {
+ TCHAR *s = NULL;
+ if (path)
+ s = cfgfile_subst_path2(path, mp->path[i], file);
+ if (!s) {
+ TCHAR np[MAX_DPATH];
+ _tcscpy(np, mp->path[i]);
+ fixtrailing(np);
+ _tcscat(np, file);
+ s = target_expand_environment(np);
+ }
+ if (dir) {
+ if (my_existsdir(s))
+ return s;
+ }
+ else {
+ if (zfile_exists(s))
+ return s;
+ }
+ xfree(s);
+ }
+ }
+ return NULL;
}
-static size_t cfg_write (const void *b, struct zfile *z)
+static TCHAR *cfgfile_get_multipath(struct multipath *mp, const TCHAR *path, const TCHAR *file, bool dir)
{
- size_t v;
- TCHAR lf = 10;
- v = zfile_fwrite (b, _tcslen ((TCHAR*)b), sizeof (TCHAR), z);
- zfile_fwrite (&lf, 1, 1, z);
- return v;
+ TCHAR *s = cfgfile_get_multipath2(mp, path, file, dir);
+ if (s)
+ return s;
+ return my_strdup(file);
+}
+
+static TCHAR *cfgfile_put_multipath(struct multipath *mp, const TCHAR *s)
+{
+ for (int i = 0; i < MAX_PATHS; i++) {
+ if (mp->path[i][0] && _tcscmp(mp->path[i], _T(".\\")) != 0 && _tcscmp(mp->path[i], _T("./")) != 0) {
+ if (_tcsnicmp(mp->path[i], s, _tcslen(mp->path[i])) == 0) {
+ return my_strdup(s + _tcslen(mp->path[i]));
+ }
+ }
+ }
+ return my_strdup(s);
+}
+
+static TCHAR *cfgfile_subst_path_load(const TCHAR *path, struct multipath *mp, const TCHAR *file, bool dir)
+{
+ TCHAR *s = cfgfile_get_multipath2(mp, path, file, dir);
+ if (s)
+ return s;
+ return cfgfile_subst_path(path, mp->path[0], file);
+}
+
+static bool isdefault(const TCHAR *s)
+{
+ TCHAR tmp[MAX_DPATH];
+ if (!default_file || uaeconfig)
+ return false;
+ zfile_fseek(default_file, 0, SEEK_SET);
+ while (zfile_fgets(tmp, sizeof tmp / sizeof(TCHAR), default_file)) {
+ if (tmp[0] && tmp[_tcslen(tmp) - 1] == '\n')
+ tmp[_tcslen(tmp) - 1] = 0;
+ if (!_tcscmp(tmp, s))
+ return true;
+ }
+ return false;
+}
+
+static size_t cfg_write(const void* b, struct zfile* z)
+{
+ size_t v;
+ TCHAR lf = 10;
+ v = zfile_fwrite(b, _tcslen((TCHAR*)b), sizeof(TCHAR), z);
+ zfile_fwrite(&lf, 1, 1, z);
+ return v;
}
#define UTF8NAME _T(".utf8")
-static void cfg_dowrite (struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *value, int d, int target)
+static void cfg_dowrite(struct zfile* f, const TCHAR* option, const TCHAR* optionext, const TCHAR* value, int d, int target)
{
- TCHAR tmp[CONFIG_BLEN], tmpext[CONFIG_BLEN];
- const TCHAR *optionp;
+ TCHAR tmp[CONFIG_BLEN], tmpext[CONFIG_BLEN];
+ const TCHAR* optionp;
if (value == NULL)
return;
- if (optionext) {
- _tcscpy (tmpext, option);
- _tcscat (tmpext, optionext);
+
+ if (optionext)
+ {
+ _tcscpy(tmpext, option);
+ _tcscat(tmpext, optionext);
optionp = tmpext;
- } else {
+ }
+ else
+ {
optionp = option;
}
- if (target)
- _stprintf (tmp, _T("%s.%s=%s"), TARGET_NAME, optionp, value);
- else
- _stprintf (tmp, _T("%s=%s"), optionp, value);
- if (d && isdefault (tmp))
- return;
- cfg_write (tmp, f);
+ if (target)
+ _stprintf(tmp, _T("%s.%s=%s"), TARGET_NAME, optionp, value);
+ else
+ _stprintf(tmp, _T("%s=%s"), optionp, value);
+
+ if (d && isdefault(tmp))
+ return;
+
+ cfg_write(tmp, f);
}
-static void cfg_dowrite (struct zfile *f, const TCHAR *option, const TCHAR *value, int d, int target)
+static void cfg_dowrite(struct zfile *f, const TCHAR *option, const TCHAR *value, int d, int target)
{
- cfg_dowrite (f, option, NULL, value, d, target);
+ cfg_dowrite(f, option, NULL, value, d, target);
}
-void cfgfile_write_bool (struct zfile *f, const TCHAR *option, bool b)
+void cfgfile_write_bool(struct zfile *f, const TCHAR *option, bool b)
{
- cfg_dowrite (f, option, b ? _T("true") : _T("false"), 0, 0);
+ cfg_dowrite(f, option, b ? _T("true") : _T("false"), 0, 0);
}
-void cfgfile_dwrite_bool (struct zfile *f, const TCHAR *option, bool b)
+void cfgfile_dwrite_bool(struct zfile *f, const TCHAR *option, bool b)
{
- cfg_dowrite (f, option, b ? _T("true") : _T("false"), 1, 0);
+ cfg_dowrite(f, option, b ? _T("true") : _T("false"), 1, 0);
}
-static void cfgfile_dwrite_bool (struct zfile *f, const TCHAR *option, const TCHAR *optionext, bool b)
+void cfgfile_dwrite_bool(struct zfile *f, const TCHAR *option, const TCHAR *optionext, bool b)
{
- cfg_dowrite (f, option, optionext, b ? _T("true") : _T("false"), 1, 0);
+ cfg_dowrite(f, option, optionext, b ? _T("true") : _T("false"), 1, 0);
}
-static void cfgfile_dwrite_bool (struct zfile *f, const TCHAR *option, int b)
+void cfgfile_dwrite_bool(struct zfile *f, const TCHAR *option, int b)
{
- cfgfile_dwrite_bool (f, option, b != 0);
+ cfgfile_dwrite_bool(f, option, b != 0);
}
-void cfgfile_write_str (struct zfile *f, const TCHAR *option, const TCHAR *value)
+void cfgfile_write_str(struct zfile *f, const TCHAR *option, const TCHAR *value)
{
- cfg_dowrite (f, option, value, 0, 0);
+ cfg_dowrite(f, option, value, 0, 0);
}
-static void cfgfile_write_str (struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *value)
+void cfgfile_write_str(struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *value)
{
- cfg_dowrite (f, option, optionext, value, 0, 0);
+ cfg_dowrite(f, option, optionext, value, 0, 0);
}
-void cfgfile_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *value)
+void cfgfile_dwrite_str(struct zfile *f, const TCHAR *option, const TCHAR *value)
{
- cfg_dowrite (f, option, value, 1, 0);
+ cfg_dowrite(f, option, value, 1, 0);
}
-static void cfgfile_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *value)
+void cfgfile_dwrite_str(struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *value)
{
- cfg_dowrite (f, option, optionext, value, 1, 0);
+ cfg_dowrite(f, option, optionext, value, 1, 0);
}
-void cfgfile_target_write_bool (struct zfile *f, const TCHAR *option, bool b)
+void cfgfile_target_write_bool(struct zfile *f, const TCHAR *option, bool b)
{
- cfg_dowrite (f, option, b ? _T("true") : _T("false"), 0, 1);
+ cfg_dowrite(f, option, b ? _T("true") : _T("false"), 0, 1);
}
-void cfgfile_target_dwrite_bool (struct zfile *f, const TCHAR *option, bool b)
+void cfgfile_target_dwrite_bool(struct zfile *f, const TCHAR *option, bool b)
{
- cfg_dowrite (f, option, b ? _T("true") : _T("false"), 1, 1);
+ cfg_dowrite(f, option, b ? _T("true") : _T("false"), 1, 1);
}
-void cfgfile_target_write_str (struct zfile *f, const TCHAR *option, const TCHAR *value)
+void cfgfile_target_write_str(struct zfile *f, const TCHAR *option, const TCHAR *value)
{
- cfg_dowrite (f, option, value, 0, 1);
+ cfg_dowrite(f, option, value, 0, 1);
}
-void cfgfile_target_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *value)
+void cfgfile_target_dwrite_str(struct zfile *f, const TCHAR *option, const TCHAR *value)
{
- cfg_dowrite (f, option, value, 1, 1);
+ cfg_dowrite(f, option, value, 1, 1);
}
-static void cfgfile_write_ext (struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *format,...)
+void cfgfile_write_ext(struct zfile* f, const TCHAR* option, const TCHAR* optionext, const TCHAR* format, ...)
{
va_list parms;
TCHAR tmp[CONFIG_BLEN], tmp2[CONFIG_BLEN];
- if (optionext) {
- _tcscpy (tmp2, option);
- _tcscat (tmp2, optionext);
+ if (optionext)
+ {
+ _tcscpy(tmp2, option);
+ _tcscat(tmp2, optionext);
}
- va_start (parms, format);
- _vsntprintf (tmp, CONFIG_BLEN, format, parms);
- cfg_dowrite (f, optionext ? tmp2 : option, tmp, 0, 0);
- va_end (parms);
+
+ va_start(parms, format);
+ _vsntprintf(tmp, CONFIG_BLEN, format, parms);
+ cfg_dowrite(f, optionext ? tmp2 : option, tmp, 0, 0);
+ va_end(parms);
}
-void cfgfile_write (struct zfile *f, const TCHAR *option, const TCHAR *format,...)
+
+void cfgfile_write(struct zfile* f, const TCHAR* option, const TCHAR* format, ...)
{
- va_list parms;
- TCHAR tmp[CONFIG_BLEN];
-
- va_start (parms, format);
- _vsntprintf (tmp, CONFIG_BLEN, format, parms);
- cfg_dowrite (f, option, tmp, 0, 0);
- va_end (parms);
+ va_list parms;
+ TCHAR tmp[CONFIG_BLEN];
+ va_start(parms, format);
+ _vsntprintf(tmp, CONFIG_BLEN, format, parms);
+ cfg_dowrite(f, option, tmp, 0, 0);
+ va_end(parms);
}
-static void cfgfile_dwrite_ext (struct zfile *f, const TCHAR *option, const TCHAR *optionext, const TCHAR *format,...)
+void cfgfile_dwrite_ext(struct zfile* f, const TCHAR* option, const TCHAR* optionext, const TCHAR* format, ...)
{
va_list parms;
TCHAR tmp[CONFIG_BLEN], tmp2[CONFIG_BLEN];
- if (optionext) {
- _tcscpy (tmp2, option);
- _tcscat (tmp2, optionext);
+ if (optionext)
+ {
+ _tcscpy(tmp2, option);
+ _tcscat(tmp2, optionext);
}
- va_start (parms, format);
- _vsntprintf (tmp, CONFIG_BLEN, format, parms);
- cfg_dowrite (f, optionext ? tmp2 : option, tmp, 1, 0);
- va_end (parms);
-}
-void cfgfile_dwrite (struct zfile *f, const TCHAR *option, const TCHAR *format,...)
-{
- va_list parms;
- TCHAR tmp[CONFIG_BLEN];
- va_start (parms, format);
- _vsntprintf (tmp, CONFIG_BLEN, format, parms);
- cfg_dowrite (f, option, tmp, 1, 0);
- va_end (parms);
-}
-void cfgfile_target_write (struct zfile *f, const TCHAR *option, const TCHAR *format,...)
-{
- va_list parms;
- TCHAR tmp[CONFIG_BLEN];
-
- va_start (parms, format);
- _vsntprintf (tmp, CONFIG_BLEN, format, parms);
- cfg_dowrite (f, option, tmp, 0, 1);
- va_end (parms);
-}
-void cfgfile_target_dwrite (struct zfile *f, const TCHAR *option, const TCHAR *format,...)
-{
- va_list parms;
- TCHAR tmp[CONFIG_BLEN];
-
- va_start (parms, format);
- _vsntprintf (tmp, CONFIG_BLEN, format, parms);
- cfg_dowrite (f, option, tmp, 1, 1);
- va_end (parms);
+ va_start(parms, format);
+ _vsntprintf(tmp, CONFIG_BLEN, format, parms);
+ cfg_dowrite(f, optionext ? tmp2 : option, tmp, 1, 0);
+ va_end(parms);
}
-static void cfgfile_write_rom (struct zfile *f, const TCHAR *path, const TCHAR *romfile, const TCHAR *name)
+void cfgfile_dwrite(struct zfile* f, const TCHAR* option, const TCHAR* format, ...)
{
- TCHAR *str = cfgfile_subst_path (path, UNEXPANDED, romfile);
- cfgfile_write_str (f, name, str);
- struct zfile *zf = zfile_fopen (str, _T("rb"), ZFD_ALL);
+ va_list parms;
+ TCHAR tmp[CONFIG_BLEN];
+ va_start(parms, format);
+ _vsntprintf(tmp, CONFIG_BLEN, format, parms);
+ cfg_dowrite(f, option, tmp, 1, 0);
+ va_end(parms);
+}
+
+void cfgfile_target_write(struct zfile* f, const TCHAR* option, const TCHAR* format, ...)
+{
+ va_list parms;
+ TCHAR tmp[CONFIG_BLEN];
+ va_start(parms, format);
+ _vsntprintf(tmp, CONFIG_BLEN, format, parms);
+ cfg_dowrite(f, option, tmp, 0, 1);
+ va_end(parms);
+}
+
+void cfgfile_target_dwrite(struct zfile* f, const TCHAR* option, const TCHAR* format, ...)
+{
+ va_list parms;
+ TCHAR tmp[CONFIG_BLEN];
+ va_start(parms, format);
+ _vsntprintf(tmp, CONFIG_BLEN, format, parms);
+ cfg_dowrite(f, option, tmp, 1, 1);
+ va_end(parms);
+}
+
+static void cfgfile_write_rom(struct zfile *f, struct multipath *mp, const TCHAR *romfile, const TCHAR *name)
+{
+ TCHAR *str = cfgfile_subst_path(mp->path[0], UNEXPANDED, romfile);
+ str = cfgfile_put_multipath(mp, str);
+ cfgfile_write_str(f, name, str);
+ struct zfile *zf = zfile_fopen(str, _T("rb"), ZFD_ALL);
if (zf) {
- struct romdata *rd = getromdatabyzfile (zf);
+ struct romdata *rd = getromdatabyzfile(zf);
if (rd) {
TCHAR name2[MAX_DPATH], str2[MAX_DPATH];
- _tcscpy (name2, name);
- _tcscat (name2, _T("_id"));
- _stprintf (str2, _T("%08X,%s"), rd->crc32, rd->name);
- cfgfile_write_str (f, name2, str2);
+ _tcscpy(name2, name);
+ _tcscat(name2, _T("_id"));
+ _stprintf(str2, _T("%08X,%s"), rd->crc32, rd->name);
+ cfgfile_write_str(f, name2, str2);
}
- zfile_fclose (zf);
+ zfile_fclose(zf);
}
- xfree (str);
+ xfree(str);
}
-static void cfgfile_write_path (struct zfile *f, const TCHAR *path, const TCHAR *option, const TCHAR *value)
+static void cfgfile_write_path(struct zfile *f, struct multipath *mp, const TCHAR *option, const TCHAR *value)
{
- TCHAR *s = cfgfile_subst_path (path, UNEXPANDED, value);
- cfgfile_write_str (f, option, s);
- xfree (s);
+ TCHAR *s = cfgfile_put_multipath(mp, value);
+ cfgfile_write_str(f, option, s);
+ xfree(s);
}
-static void write_filesys_config (struct uae_prefs *p, const TCHAR *unexpanded,
- const TCHAR *default_path, struct zfile *f)
+static void cfgfile_dwrite_path(struct zfile *f, struct multipath *mp, const TCHAR *option, const TCHAR *value)
+{
+ TCHAR *s = cfgfile_put_multipath(mp, value);
+ cfgfile_dwrite_str(f, option, s);
+ xfree(s);
+}
+
+static void write_filesys_config(struct uae_prefs *p, struct zfile *f)
{
TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH], tmp3[MAX_DPATH], hdcs[MAX_DPATH];
- for (int i = 0; i < p->mountitems; i++) {
- struct uaedev_config_data *uci = &p->mountconfig[i];
+ for (int i = 0; i < p->mountitems; i++) {
+ struct uaedev_config_data *uci = &p->mountconfig[i];
struct uaedev_config_info *ci = &uci->ci;
- TCHAR *str1, *str1b, *str1c, *str2b;
+ TCHAR *str1, *str1b, *str2b;
const TCHAR *str2;
- int bp = ci->bootpri;
+ int bp = ci->bootpri;
str2 = _T("");
if (ci->rootdir[0] == ':') {
TCHAR *ptr;
// separate harddrive names
- str1 = my_strdup (ci->rootdir);
- ptr = _tcschr (str1 + 1, ':');
+ str1 = my_strdup(ci->rootdir);
+ ptr = _tcschr(str1 + 1, ':');
if (ptr) {
*ptr++ = 0;
str2 = ptr;
- ptr = (TCHAR *) _tcschr (str2, ',');
+ ptr = (TCHAR *)_tcschr(str2, ',');
if (ptr)
*ptr = 0;
}
- } else {
- str1 = cfgfile_subst_path (default_path, unexpanded, ci->rootdir);
- }
+ }
+ else {
+ str1 = cfgfile_put_multipath(&p->path_hardfile, ci->rootdir);
+ }
int ct = ci->controller_type;
int romtype = 0;
if (ct >= HD_CONTROLLER_TYPE_SCSI_EXPANSION_FIRST && ct <= HD_CONTROLLER_TYPE_SCSI_LAST) {
_stprintf(hdcs, _T("scsi%d_%s"), ci->controller_unit, expansionroms[ct - HD_CONTROLLER_TYPE_SCSI_EXPANSION_FIRST].name);
romtype = expansionroms[ct - HD_CONTROLLER_TYPE_SCSI_EXPANSION_FIRST].romtype;
- } else if (ct >= HD_CONTROLLER_TYPE_IDE_EXPANSION_FIRST && ct <= HD_CONTROLLER_TYPE_IDE_LAST) {
+ }
+ else if (ct >= HD_CONTROLLER_TYPE_IDE_EXPANSION_FIRST && ct <= HD_CONTROLLER_TYPE_IDE_LAST) {
_stprintf(hdcs, _T("ide%d_%s"), ci->controller_unit, expansionroms[ct - HD_CONTROLLER_TYPE_IDE_EXPANSION_FIRST].name);
romtype = expansionroms[ct - HD_CONTROLLER_TYPE_IDE_EXPANSION_FIRST].romtype;
- } else if (ct == HD_CONTROLLER_TYPE_SCSI_AUTO) {
+ }
+ else if (ct == HD_CONTROLLER_TYPE_SCSI_AUTO) {
_stprintf(hdcs, _T("scsi%d"), ci->controller_unit);
- } else if (ct == HD_CONTROLLER_TYPE_IDE_AUTO) {
+ }
+ else if (ct == HD_CONTROLLER_TYPE_IDE_AUTO) {
_stprintf(hdcs, _T("ide%d"), ci->controller_unit);
- } else if (ct == HD_CONTROLLER_TYPE_PCMCIA) {
+ }
+ else if (ct == HD_CONTROLLER_TYPE_PCMCIA) {
if (ci->controller_type_unit == 0)
_tcscpy(hdcs, _T("scsram"));
else
_tcscpy(hdcs, _T("scide"));
- } else if (ct == HD_CONTROLLER_TYPE_UAE) {
+ }
+ else if (ct == HD_CONTROLLER_TYPE_UAE) {
_tcscpy(hdcs, _T("uae"));
}
if (romtype) {
@@ -712,44 +910,64 @@ static void write_filesys_config (struct uae_prefs *p, const TCHAR *unexpanded,
if (ci->controller_type_unit > 0 && ct != HD_CONTROLLER_TYPE_PCMCIA)
_stprintf(hdcs + _tcslen(hdcs), _T("-%d"), ci->controller_type_unit + 1);
- str1b = cfgfile_escape (str1, _T(":,"), true);
- str1c = cfgfile_escape_min(str1);
- str2b = cfgfile_escape (str2, _T(":,"), true);
- if (ci->type == UAEDEV_DIR) {
- _stprintf (tmp, _T("%s,%s:%s:%s,%d"), ci->readonly ? _T("ro") : _T("rw"),
- ci->devname ? ci->devname : _T(""), ci->volname, str1c, bp);
- cfgfile_write_str (f, _T("filesystem2"), tmp);
- _tcscpy (tmp3, tmp);
- } else if (ci->type == UAEDEV_HDF || ci->type == UAEDEV_CD) {
- _stprintf (tmp, _T("%s,%s:%s,%d,%d,%d,%d,%d,%s,%s"),
- ci->readonly ? _T("ro") : _T("rw"),
- ci->devname ? ci->devname : _T(""), str1c,
+ str1b = cfgfile_escape(str1, _T(":,"), true);
+ str2b = cfgfile_escape(str2, _T(":,"), true);
+ if (ci->type == UAEDEV_DIR) {
+ _stprintf(tmp, _T("%s,%s:%s:%s,%d"), ci->readonly ? _T("ro") : _T("rw"),
+ ci->devname ? ci->devname : _T(""), ci->volname, str1, bp);
+ cfgfile_write_str(f, _T("filesystem2"), tmp);
+ _tcscpy(tmp3, tmp);
+#if 0
+ _stprintf(tmp2, _T("filesystem=%s,%s:%s"), uci->readonly ? _T("ro") : _T("rw"),
+ uci->volname, str);
+ zfile_fputs(f, tmp2);
+#endif
+ }
+ else if (ci->type == UAEDEV_HDF || ci->type == UAEDEV_CD || ci->type == UAEDEV_TAPE) {
+ _stprintf(tmp, _T("%s,%s:%s,%d,%d,%d,%d,%d,%s,%s"),
+ ci->readonly ? _T("ro") : _T("rw"),
+ ci->devname ? ci->devname : _T(""), str1,
ci->sectors, ci->surfaces, ci->reserved, ci->blocksize,
bp, ci->filesys ? ci->filesys : _T(""), hdcs);
- _stprintf (tmp3, _T("%s,%s:%s%s%s,%d,%d,%d,%d,%d,%s,%s"),
+ _stprintf(tmp3, _T("%s,%s:%s%s%s,%d,%d,%d,%d,%d,%s,%s"),
ci->readonly ? _T("ro") : _T("rw"),
ci->devname ? ci->devname : _T(""), str1b, str2b[0] ? _T(":") : _T(""), str2b,
- ci->sectors, ci->surfaces, ci->reserved, ci->blocksize,
+ ci->sectors, ci->surfaces, ci->reserved, ci->blocksize,
bp, ci->filesys ? ci->filesys : _T(""), hdcs);
if (ci->highcyl || ci->physical_geometry) {
- TCHAR *s = tmp + _tcslen (tmp);
+ TCHAR *s = tmp + _tcslen(tmp);
TCHAR *s2 = s;
- _stprintf (s2, _T(",%d"), ci->highcyl);
+ _stprintf(s2, _T(",%d"), ci->highcyl);
if (ci->physical_geometry && ci->pheads && ci->psecs) {
- TCHAR *s = tmp + _tcslen (tmp);
- _stprintf (s, _T(",%d/%d/%d"), ci->pcyls, ci->pheads, ci->psecs);
+ TCHAR *s = tmp + _tcslen(tmp);
+ _stprintf(s, _T(",%d/%d/%d"), ci->pcyls, ci->pheads, ci->psecs);
}
- _tcscat (tmp3, s2);
+ _tcscat(tmp3, s2);
}
if (ci->controller_media_type) {
_tcscat(tmp, _T(",CF"));
_tcscat(tmp3, _T(",CF"));
}
const TCHAR *extras = NULL;
- if (ct >= HD_CONTROLLER_TYPE_IDE_FIRST && ct <= HD_CONTROLLER_TYPE_IDE_LAST) {
+ if (ct >= HD_CONTROLLER_TYPE_SCSI_FIRST && ct <= HD_CONTROLLER_TYPE_SCSI_LAST) {
+ if (ci->unit_feature_level == HD_LEVEL_SCSI_1) {
+ extras = _T("SCSI1");
+ }
+ else if (ci->unit_feature_level == HD_LEVEL_SASI) {
+ extras = _T("SASI");
+ }
+ else if (ci->unit_feature_level == HD_LEVEL_SASI_ENHANCED) {
+ extras = _T("SASIE");
+ }
+ else if (ci->unit_feature_level == HD_LEVEL_SASI_CHS) {
+ extras = _T("SASI_CHS");
+ }
+ }
+ else if (ct >= HD_CONTROLLER_TYPE_IDE_FIRST && ct <= HD_CONTROLLER_TYPE_IDE_LAST) {
if (ci->unit_feature_level == HD_LEVEL_ATA_1) {
extras = _T("ATA1");
- } else if (ci->unit_feature_level == HD_LEVEL_ATA_2S) {
+ }
+ else if (ci->unit_feature_level == HD_LEVEL_ATA_2S) {
extras = _T("ATA2+S");
}
}
@@ -771,13 +989,23 @@ static void write_filesys_config (struct uae_prefs *p, const TCHAR *unexpanded,
}
if (ci->type == UAEDEV_HDF)
- cfgfile_write_str (f, _T("hardfile2"), tmp);
- }
- _stprintf (tmp2, _T("uaehf%d"), i);
+ cfgfile_write_str(f, _T("hardfile2"), tmp);
+#if 0
+ _stprintf(tmp2, _T("hardfile=%s,%d,%d,%d,%d,%s"),
+ uci->readonly ? "ro" : "rw", uci->sectors,
+ uci->surfaces, uci->reserved, uci->blocksize, str);
+ zfile_fputs(f, tmp2);
+#endif
+ }
+ _stprintf(tmp2, _T("uaehf%d"), i);
if (ci->type == UAEDEV_CD) {
- cfgfile_write (f, tmp2, _T("cd%d,%s"), ci->device_emu_unit, tmp);
- } else {
- cfgfile_write (f, tmp2, _T("%s,%s"), ci->type == UAEDEV_HDF ? _T("hdf") : _T("dir"), tmp3);
+ cfgfile_write(f, tmp2, _T("cd%d,%s"), ci->device_emu_unit, tmp);
+ }
+ else if (ci->type == UAEDEV_TAPE) {
+ cfgfile_write(f, tmp2, _T("tape%d,%s"), ci->device_emu_unit, tmp);
+ }
+ else {
+ cfgfile_write(f, tmp2, _T("%s,%s"), ci->type == UAEDEV_HDF ? _T("hdf") : _T("dir"), tmp3);
}
if (ci->type == UAEDEV_DIR) {
bool add_extra = false;
@@ -789,36 +1017,66 @@ static void write_filesys_config (struct uae_prefs *p, const TCHAR *unexpanded,
cfgfile_write(f, _T("filesystem_extra"), tmp2);
}
}
- xfree (str1b);
- xfree (str1c);
- xfree (str2b);
- xfree (str1);
- }
+ xfree(str1b);
+ xfree(str2b);
+ xfree(str1);
+
+ }
}
static void write_compatibility_cpu(struct zfile *f, struct uae_prefs *p)
{
- TCHAR tmp[100];
- int model;
+ TCHAR tmp[100];
+ int model;
- model = p->cpu_model;
- if (model == 68030)
- model = 68020;
- if (model == 68060)
- model = 68040;
- if (p->address_space_24 && model == 68020)
- _tcscpy (tmp, _T("68ec020"));
- else
- _stprintf(tmp, _T("%d"), model);
- if (model == 68020 && (p->fpu_model == 68881 || p->fpu_model == 68882))
- _tcscat(tmp, _T("/68881"));
- cfgfile_write (f, _T("cpu_type"), tmp);
+ model = p->cpu_model;
+ if (model == 68030)
+ model = 68020;
+ if (model == 68060)
+ model = 68040;
+ if (p->address_space_24 && model == 68020)
+ _tcscpy(tmp, _T("68ec020"));
+ else
+ _stprintf(tmp, _T("%d"), model);
+ if (model == 68020 && (p->fpu_model == 68881 || p->fpu_model == 68882))
+ _tcscat(tmp, _T("/68881"));
+ cfgfile_write(f, _T("cpu_type"), tmp);
}
-static void write_resolution (struct zfile *f, const TCHAR *ws, const TCHAR *hs, struct wh *wh)
+static void write_leds(struct zfile *f, const TCHAR *name, int mask)
{
- cfgfile_write (f, ws, _T("%d"), wh->width);
- cfgfile_write (f, hs, _T("%d"), wh->height);
+ TCHAR tmp[MAX_DPATH];
+ tmp[0] = 0;
+ for (int i = 0; leds[i]; i++) {
+ bool got = false;
+ for (int j = 0; leds[j]; j++) {
+ if (leds_order[j] == i) {
+ if (mask & (1 << j)) {
+ if (got)
+ _tcscat(tmp, _T(":"));
+ _tcscat(tmp, leds[j]);
+ got = true;
+ }
+ }
+ }
+ if (leds[i + 1] && got)
+ _tcscat(tmp, _T(","));
+ }
+ while (tmp[0] && tmp[_tcslen(tmp) - 1] == ',')
+ tmp[_tcslen(tmp) - 1] = 0;
+ cfgfile_dwrite_str(f, name, tmp);
+}
+
+static void write_resolution(struct zfile *f, const TCHAR *ws, const TCHAR *hs, struct wh *wh)
+{
+ if (wh->width <= 0 || wh->height <= 0 || wh->special == WH_NATIVE) {
+ cfgfile_write_str(f, ws, _T("native"));
+ cfgfile_write_str(f, hs, _T("native"));
+ }
+ else {
+ cfgfile_write(f, ws, _T("%d"), wh->width);
+ cfgfile_write(f, hs, _T("%d"), wh->height);
+ }
}
static int cfgfile_read_rom_settings(const struct expansionboardsettings *ebs, const TCHAR *buf, TCHAR *configtext)
@@ -831,6 +1089,7 @@ static int cfgfile_read_rom_settings(const struct expansionboardsettings *ebs, c
TCHAR *ct = configtext;
for (int i = 0; ebs[i].name; i++) {
const struct expansionboardsettings *eb = &ebs[i];
+ bitcnt += eb->bitshift;
if (eb->type == EXPANSIONBOARD_STRING) {
const TCHAR *p = cfgfile_option_get(buf, eb->configname);
if (p) {
@@ -838,7 +1097,8 @@ static int cfgfile_read_rom_settings(const struct expansionboardsettings *ebs, c
ct += _tcslen(ct);
}
*ct++ = 0;
- } else if (eb->type == EXPANSIONBOARD_MULTI) {
+ }
+ else if (eb->type == EXPANSIONBOARD_MULTI) {
int itemcnt = -1;
int itemfound = 0;
const TCHAR *p = eb->configname;
@@ -866,7 +1126,8 @@ static int cfgfile_read_rom_settings(const struct expansionboardsettings *ebs, c
itemfound &= multimask;
settings |= itemfound << bitcnt;
bitcnt += bits;
- } else {
+ }
+ else {
int mask = 1 << bitcnt;
if (cfgfile_option_find(buf, eb->configname)) {
settings |= mask;
@@ -885,6 +1146,7 @@ static void cfgfile_write_rom_settings(const struct expansionboardsettings *ebs,
int sstr = 0;
for (int j = 0; ebs[j].name; j++) {
const struct expansionboardsettings *eb = &ebs[j];
+ bitcnt += eb->bitshift;
if (eb->type == EXPANSIONBOARD_STRING) {
if (settingstring) {
const TCHAR *p = settingstring;
@@ -896,7 +1158,8 @@ static void cfgfile_write_rom_settings(const struct expansionboardsettings *ebs,
_stprintf(buf, _T("%s=%s"), eb->configname, p);
sstr++;
}
- } else if (eb->type == EXPANSIONBOARD_MULTI) {
+ }
+ else if (eb->type == EXPANSIONBOARD_MULTI) {
int itemcnt = -1;
const TCHAR *p = eb->configname;
while (p[0]) {
@@ -926,7 +1189,8 @@ static void cfgfile_write_rom_settings(const struct expansionboardsettings *ebs,
_tcscat(buf, _T(","));
_tcscat(buf, p);
bitcnt += bits;
- } else {
+ }
+ else {
int value = settings;
if (eb->invert)
value ^= 0x7fffffff;
@@ -940,12 +1204,12 @@ static void cfgfile_write_rom_settings(const struct expansionboardsettings *ebs,
}
}
-static void cfgfile_write_board_rom(struct uae_prefs *prefs, struct zfile *f, const TCHAR *path, struct boardromconfig *br)
+static void cfgfile_write_board_rom(struct uae_prefs *prefs, struct zfile *f, struct multipath *mp, struct boardromconfig *br)
{
TCHAR buf[256];
TCHAR name[256];
const struct expansionromtype *ert;
-
+
if (br->device_type == 0)
return;
ert = get_device_expansion_rom(br->device_type);
@@ -958,26 +1222,47 @@ static void cfgfile_write_board_rom(struct uae_prefs *prefs, struct zfile *f, co
_stprintf(name, _T("%s-%d"), ert->name, br->device_num + 1);
if (i == 0 || _tcslen(br->roms[i].romfile)) {
_stprintf(buf, _T("%s%s_rom_file"), name, i ? _T("_ext") : _T(""));
- cfgfile_write_rom (f, path, br->roms[i].romfile, buf);
+ cfgfile_write_rom(f, mp, br->roms[i].romfile, buf);
if (br->roms[i].romident[0]) {
_stprintf(buf, _T("%s%s_rom"), name, i ? _T("_ext") : _T(""));
- cfgfile_dwrite_str (f, buf, br->roms[i].romident);
+ cfgfile_dwrite_str(f, buf, br->roms[i].romident);
}
- if (br->roms[i].autoboot_disabled || ert->settings || br->device_order > 0) {
+ if (br->roms[i].autoboot_disabled || ert->subtypes || ert->settings || ert->id_jumper || br->device_order > 0) {
TCHAR buf2[256], *p;
buf2[0] = 0;
p = buf2;
_stprintf(buf, _T("%s%s_rom_options"), name, i ? _T("_ext") : _T(""));
+ if (ert->subtypes) {
+ const struct expansionsubromtype *srt = ert->subtypes;
+ int k = br->roms[i].subtype;
+ while (k && srt[1].name) {
+ srt++;
+ k--;
+ }
+ _stprintf(p, _T("subtype=%s"), srt->configname);
+ }
+ if (br->device_order > 0 && prefs->autoconfig_custom_sort) {
+ if (buf2[0])
+ _tcscat(buf2, _T(","));
+ _stprintf(buf2, _T("order=%d"), br->device_order);
+ }
if (br->roms[i].autoboot_disabled) {
if (buf2[0])
_tcscat(buf2, _T(","));
_tcscat(buf2, _T("autoboot_disabled=true"));
}
+ if (ert->id_jumper) {
+ TCHAR tmp[256];
+ _stprintf(tmp, _T("id=%d"), br->roms[i].device_id);
+ if (buf2[0])
+ _tcscat(buf2, _T(","));
+ _tcscat(buf2, tmp);
+ }
if (br->roms[i].device_settings && ert->settings) {
cfgfile_write_rom_settings(ert->settings, buf2, br->roms[i].device_settings, br->roms[i].configtext);
}
if (buf2[0])
- cfgfile_dwrite_str (f, buf, buf2);
+ cfgfile_dwrite_str(f, buf, buf2);
}
if (br->roms[i].board_ram_size) {
@@ -1019,20 +1304,52 @@ static bool cfgfile_readramboard(const TCHAR *option, const TCHAR *value, const
else
_stprintf(tmp1, _T("%s_options"), name);
if (!_tcsicmp(option, tmp1)) {
- TCHAR *s;
+ TCHAR *s, *s1, *s2;
s = cfgfile_option_get(value, _T("order"));
if (s)
rb->device_order = _tstol(s);
s = cfgfile_option_get(value, _T("mid"));
if (s)
- rb->manufacturer = (uae_u16)_tstol(s);
+ rb->manufacturer = _tstol(s);
s = cfgfile_option_get(value, _T("pid"));
if (s)
- rb->product = (uae_u8)_tstol(s);
+ rb->product = _tstol(s);
+ s = cfgfile_option_get(value, _T("no_reset_unmap"));
+ if (s)
+ rb->no_reset_unmap = true;
+ s = cfgfile_option_get(value, _T("data"));
+ if (s && _tcslen(s) >= 3 * 16 - 1) {
+ rb->autoconfig_inuse = true;
+ for (int i = 0; i < sizeof rb->autoconfig; i++) {
+ TCHAR *s2 = &s[i * 3];
+ if (i + 1 < sizeof rb->autoconfig && s2[2] != '.')
+ break;
+ TCHAR *endptr;
+ s[2] = 0;
+ rb->autoconfig[i] = (uae_u8)_tcstol(s2, &endptr, 16);
+ }
+ }
+ s1 = cfgfile_option_get(value, _T("start"));
+ s2 = cfgfile_option_get(value, _T("end"));
+ if (s1 && s2) {
+ TCHAR *endptr;
+ rb->start_address = _tcstol(s1, &endptr, 16);
+ rb->end_address = _tcstol(s2, &endptr, 16);
+ if (rb->start_address && rb->end_address > rb->start_address) {
+ rb->manual_config = true;
+ rb->autoconfig_inuse = false;
+ }
+ }
+ s1 = cfgfile_option_get(value, _T("write_address"));
+ if (s1) {
+ TCHAR *endptr;
+ rb->write_address = _tcstol(s1, &endptr, 16);
+ }
+
return true;
}
- }
- return false;
+ }
+ return false;
}
static void cfgfile_writeramboard(struct uae_prefs *prefs, struct zfile *f, const TCHAR *name, int num, struct ramboard *rb)
@@ -1044,195 +1361,679 @@ static void cfgfile_writeramboard(struct uae_prefs *prefs, struct zfile *f, cons
_stprintf(tmp1, _T("%s_options"), name);
tmp2[0] = 0;
TCHAR *p = tmp2;
+ if (rb->device_order > 0 && prefs->autoconfig_custom_sort) {
+ if (tmp2[0])
+ *p++ = ',';
+ _stprintf(p, _T("order=%d"), rb->device_order);
+ p += _tcslen(p);
+ }
if (rb->manufacturer) {
if (tmp2[0])
*p++ = ',';
_stprintf(p, _T("mid=%u,pid=%u"), rb->manufacturer, rb->product);
p += _tcslen(p);
}
+ if (rb->no_reset_unmap) {
+ if (tmp2[0])
+ *p++ = ',';
+ _tcscpy(p, _T("no_reset_unmap=true"));
+ p += _tcslen(p);
+ }
+ if (rb->autoconfig_inuse) {
+ uae_u8 *ac = rb->autoconfig;
+ if (tmp2[0])
+ *p++ = ',';
+ _stprintf(p, _T("data=%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x"),
+ ac[0], ac[1], ac[2], ac[3], ac[4], ac[5], ac[6], ac[7],
+ ac[8], ac[9], ac[10], ac[11], ac[12], ac[13], ac[14], ac[15]);
+ p += _tcslen(p);
+ }
+ if (rb->manual_config && rb->start_address && rb->end_address) {
+ if (tmp2[0])
+ *p++ = ',';
+ _stprintf(p, _T("start=%08x,end=%08x"), rb->start_address, rb->end_address);
+ p += _tcslen(p);
+ }
+ if (rb->write_address) {
+ _stprintf(p, _T(",write_address=%08x"), rb->write_address);
+ p += _tcslen(p);
+ }
if (tmp2[0]) {
cfgfile_write(f, tmp1, tmp2);
}
}
-void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
+void cfgfile_save_options(struct zfile *f, struct uae_prefs *p, int type)
{
- struct strlist *sl;
- TCHAR tmp[MAX_DPATH];
- int i;
+ struct strlist *sl;
+ TCHAR tmp[MAX_DPATH];
+ int i;
- cfgfile_write_str (f, _T("config_description"), p->description);
- cfgfile_write_bool (f, _T("config_hardware"), type & CONFIG_TYPE_HARDWARE);
- cfgfile_write_bool (f, _T("config_host"), !!(type & CONFIG_TYPE_HOST));
- if (p->info[0])
- cfgfile_write (f, _T("config_info"), p->info);
- cfgfile_write (f, _T("config_version"), _T("%d.%d.%d"), UAEMAJOR, UAEMINOR, UAESUBREV);
-
- for (sl = p->all_lines; sl; sl = sl->next) {
- if (sl->unknown) {
+ cfgfile_write_str(f, _T("config_description"), p->description);
+ cfgfile_write_bool(f, _T("config_hardware"), type & CONFIG_TYPE_HARDWARE);
+ cfgfile_write_bool(f, _T("config_host"), !!(type & CONFIG_TYPE_HOST));
+ if (p->info[0])
+ cfgfile_write(f, _T("config_info"), p->info);
+ cfgfile_write(f, _T("config_version"), _T("%d.%d.%d"), UAEMAJOR, UAEMINOR, UAESUBREV);
+ cfgfile_write_str(f, _T("config_hardware_path"), p->config_hardware_path);
+ cfgfile_write_str(f, _T("config_host_path"), p->config_host_path);
+ cfgfile_write_str(f, _T("config_all_path"), p->config_all_path);
+ if (p->config_window_title[0])
+ cfgfile_write_str(f, _T("config_window_title"), p->config_window_title);
+
+ for (sl = p->all_lines; sl; sl = sl->next) {
+ if (sl->unknown) {
if (sl->option)
- cfgfile_write_str (f, sl->option, sl->value);
- }
- }
+ cfgfile_write_str(f, sl->option, sl->value);
+ }
+ }
- _stprintf (tmp, _T("%s.rom_path"), TARGET_NAME);
- cfgfile_write_str (f, tmp, p->path_rom);
- _stprintf (tmp, _T("%s.floppy_path"), TARGET_NAME);
- cfgfile_write_str (f, tmp, p->path_floppy);
- _stprintf (tmp, _T("%s.hardfile_path"), TARGET_NAME);
- cfgfile_write_str (f, tmp, p->path_hardfile);
- _stprintf (tmp, _T("%s.cd_path"), TARGET_NAME);
- cfgfile_write_str (f, tmp, p->path_cd);
+ for (i = 0; i < MAX_PATHS; i++) {
+ if (p->path_rom.path[i][0]) {
+ _stprintf(tmp, _T("%s.rom_path"), TARGET_NAME);
+ cfgfile_write_str(f, tmp, p->path_rom.path[i]);
+ }
+ }
+ for (i = 0; i < MAX_PATHS; i++) {
+ if (p->path_floppy.path[i][0]) {
+ _stprintf(tmp, _T("%s.floppy_path"), TARGET_NAME);
+ cfgfile_write_str(f, tmp, p->path_floppy.path[i]);
+ }
+ }
+ for (i = 0; i < MAX_PATHS; i++) {
+ if (p->path_hardfile.path[i][0]) {
+ _stprintf(tmp, _T("%s.hardfile_path"), TARGET_NAME);
+ cfgfile_write_str(f, tmp, p->path_hardfile.path[i]);
+ }
+ }
+ for (i = 0; i < MAX_PATHS; i++) {
+ if (p->path_cd.path[i][0]) {
+ _stprintf(tmp, _T("%s.cd_path"), TARGET_NAME);
+ cfgfile_write_str(f, tmp, p->path_cd.path[i]);
+ }
+ }
-
- cfg_write (_T("; "), f);
- cfg_write (_T("; *** Controller/Input Configuration"), f);
- cfg_write (_T("; "), f);
-
- for (i = 0; i < MAX_JPORTS; i++) {
+ cfg_write(_T("; host-specific"), f);
+
+ target_save_options(f, p);
+
+ cfg_write(_T("; common"), f);
+
+ cfgfile_write_str(f, _T("use_gui"), guimode1[p->start_gui]);
+ cfgfile_write_bool(f, _T("use_debugger"), p->start_debugger);
+
+ cfgfile_write_rom(f, &p->path_rom, p->romfile, _T("kickstart_rom_file"));
+ cfgfile_write_rom(f, &p->path_rom, p->romextfile, _T("kickstart_ext_rom_file"));
+ if (p->romextfile2addr) {
+ cfgfile_write(f, _T("kickstart_ext_rom_file2_address"), _T("%x"), p->romextfile2addr);
+ cfgfile_write_rom(f, &p->path_rom, p->romextfile2, _T("kickstart_ext_rom_file2"));
+ }
+ if (p->romident[0])
+ cfgfile_dwrite_str(f, _T("kickstart_rom"), p->romident);
+ if (p->romextident[0])
+ cfgfile_write_str(f, _T("kickstart_ext_rom="), p->romextident);
+
+ for (int i = 0; i < MAX_EXPANSION_BOARDS; i++) {
+ cfgfile_write_board_rom(p, f, &p->path_rom, &p->expansionboard[i]);
+ }
+
+ cfgfile_write_path(f, &p->path_rom, _T("flash_file"), p->flashfile);
+ cfgfile_write_path(f, &p->path_rom, _T("cart_file"), p->cartfile);
+ cfgfile_write_path(f, &p->path_rom, _T("rtc_file"), p->rtcfile);
+ if (p->cartident[0])
+ cfgfile_write_str(f, _T("cart"), p->cartident);
+ cfgfile_dwrite_path(f, &p->path_rom, _T("picassoiv_rom_file"), p->picassoivromfile);
+
+ cfgfile_write_bool(f, _T("kickshifter"), p->kickshifter);
+ cfgfile_dwrite_bool(f, _T("ks_write_enabled"), p->rom_readwrite);
+
+ cfgfile_write(f, _T("floppy_volume"), _T("%d"), p->dfxclickvolume_disk[0]);
+
+ p->nr_floppies = 4;
+ for (i = 0; i < 4; i++) {
+ _stprintf(tmp, _T("floppy%d"), i);
+ cfgfile_write_path(f, &p->path_floppy, tmp, p->floppyslots[i].df);
+ _stprintf(tmp, _T("floppy%dwp"), i);
+ cfgfile_dwrite_bool(f, tmp, p->floppyslots[i].forcedwriteprotect);
+ _stprintf(tmp, _T("floppy%dtype"), i);
+ cfgfile_dwrite(f, tmp, _T("%d"), p->floppyslots[i].dfxtype);
+ _stprintf(tmp, _T("floppy%dsound"), i);
+ cfgfile_dwrite(f, tmp, _T("%d"), p->floppyslots[i].dfxclick);
+ if (p->floppyslots[i].dfxclick < 0 && p->floppyslots[i].dfxclickexternal[0]) {
+ _stprintf(tmp, _T("floppy%dsoundext"), i);
+ cfgfile_dwrite(f, tmp, p->floppyslots[i].dfxclickexternal);
+ }
+ if (p->floppyslots[i].dfxclick) {
+ _stprintf(tmp, _T("floppy%dsoundvolume_disk"), i);
+ cfgfile_write(f, tmp, _T("%d"), p->dfxclickvolume_disk[i]);
+ _stprintf(tmp, _T("floppy%dsoundvolume_empty"), i);
+ cfgfile_write(f, tmp, _T("%d"), p->dfxclickvolume_empty[i]);
+ }
+ if (p->floppyslots[i].dfxtype < 0 && p->nr_floppies > i)
+ p->nr_floppies = i;
+ }
+ for (i = 0; i < MAX_SPARE_DRIVES; i++) {
+ if (p->dfxlist[i][0]) {
+ _stprintf(tmp, _T("diskimage%d"), i);
+ cfgfile_dwrite_path(f, &p->path_floppy, tmp, p->dfxlist[i]);
+ }
+ }
+
+ for (i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
+ if (p->cdslots[i].name[0] || p->cdslots[i].inuse) {
+ TCHAR tmp2[MAX_DPATH];
+ _stprintf(tmp, _T("cdimage%d"), i);
+ TCHAR *s = cfgfile_put_multipath(&p->path_cd, p->cdslots[i].name);
+ _tcscpy(tmp2, s);
+ xfree(s);
+ if (p->cdslots[i].type != SCSI_UNIT_DEFAULT || _tcschr(p->cdslots[i].name, ',') || p->cdslots[i].delayed) {
+ _tcscat(tmp2, _T(","));
+ if (p->cdslots[i].delayed) {
+ _tcscat(tmp2, _T("delay"));
+ _tcscat(tmp2, _T(":"));
+ }
+ if (p->cdslots[i].type != SCSI_UNIT_DEFAULT) {
+ _tcscat(tmp2, cdmodes[p->cdslots[i].type + 1]);
+ }
+ }
+ cfgfile_write_str(f, tmp, tmp2);
+ }
+ }
+
+ for (i = 0; i < MAX_LUA_STATES; i++) {
+ if (p->luafiles[i][0]) {
+ cfgfile_write_str(f, _T("lua"), p->luafiles[i]);
+ }
+ }
+
+ if (p->statefile[0])
+ cfgfile_write_str(f, _T("statefile"), p->statefile);
+ if (p->quitstatefile[0])
+ cfgfile_write_str(f, _T("statefile_quit"), p->quitstatefile);
+
+ cfgfile_write(f, _T("nr_floppies"), _T("%d"), p->nr_floppies);
+ cfgfile_dwrite_bool(f, _T("floppy_write_protect"), p->floppy_read_only);
+ cfgfile_write(f, _T("floppy_speed"), _T("%d"), p->floppy_speed);
+ cfgfile_dwrite(f, _T("floppy_channel_mask"), _T("0x%x"), p->dfxclickchannelmask);
+ cfgfile_write(f, _T("cd_speed"), _T("%d"), p->cd_speed);
+ cfgfile_write_bool(f, _T("parallel_on_demand"), p->parallel_demand);
+ cfgfile_write_bool(f, _T("serial_on_demand"), p->serial_demand);
+ cfgfile_write_bool(f, _T("serial_hardware_ctsrts"), p->serial_hwctsrts);
+ cfgfile_write_bool(f, _T("serial_direct"), p->serial_direct);
+ cfgfile_dwrite(f, _T("serial_stopbits"), _T("%d"), p->serial_stopbits);
+ cfgfile_dwrite_str(f, _T("serial_translate"), serialcrlf[p->serial_crlf]);
+ cfgfile_write_str(f, _T("scsi"), scsimode[p->scsi]);
+ cfgfile_write_bool(f, _T("uaeserial"), p->uaeserial);
+ cfgfile_write_bool(f, _T("sana2"), p->sana2);
+
+ cfgfile_write_str(f, _T("sound_output"), soundmode1[p->produce_sound]);
+ cfgfile_write_str(f, _T("sound_channels"), stereomode[p->sound_stereo]);
+ cfgfile_write(f, _T("sound_stereo_separation"), _T("%d"), p->sound_stereo_separation);
+ cfgfile_write(f, _T("sound_stereo_mixing_delay"), _T("%d"), p->sound_mixed_stereo_delay >= 0 ? p->sound_mixed_stereo_delay : 0);
+ cfgfile_write(f, _T("sound_max_buff"), _T("%d"), p->sound_maxbsiz);
+ cfgfile_write(f, _T("sound_frequency"), _T("%d"), p->sound_freq);
+ cfgfile_write_str(f, _T("sound_interpol"), interpolmode[p->sound_interpol]);
+ cfgfile_write_str(f, _T("sound_filter"), soundfiltermode1[p->sound_filter]);
+ cfgfile_write_str(f, _T("sound_filter_type"), soundfiltermode2[p->sound_filter_type]);
+ cfgfile_write(f, _T("sound_volume"), _T("%d"), p->sound_volume_master);
+ cfgfile_write(f, _T("sound_volume_paula"), _T("%d"), p->sound_volume_paula);
+ if (p->sound_volume_cd >= 0)
+ cfgfile_write(f, _T("sound_volume_cd"), _T("%d"), p->sound_volume_cd);
+ if (p->sound_volume_board >= 0)
+ cfgfile_write(f, _T("sound_volume_ahi"), _T("%d"), p->sound_volume_board);
+ if (p->sound_volume_midi >= 0)
+ cfgfile_write(f, _T("sound_volume_midi"), _T("%d"), p->sound_volume_midi);
+ if (p->sound_volume_genlock >= 0)
+ cfgfile_write(f, _T("sound_volume_genlock"), _T("%d"), p->sound_volume_genlock);
+ cfgfile_write_bool(f, _T("sound_auto"), p->sound_auto);
+ cfgfile_write_bool(f, _T("sound_cdaudio"), p->sound_cdaudio);
+ cfgfile_write_bool(f, _T("sound_stereo_swap_paula"), p->sound_stereo_swap_paula);
+ cfgfile_write_bool(f, _T("sound_stereo_swap_ahi"), p->sound_stereo_swap_ahi);
+ cfgfile_dwrite(f, _T("sampler_frequency"), _T("%d"), p->sampler_freq);
+ cfgfile_dwrite(f, _T("sampler_buffer"), _T("%d"), p->sampler_buffer);
+ cfgfile_dwrite_bool(f, _T("sampler_stereo"), p->sampler_stereo);
+
+ cfgfile_write_str(f, _T("comp_trustbyte"), compmode[p->comptrustbyte]);
+ cfgfile_write_str(f, _T("comp_trustword"), compmode[p->comptrustword]);
+ cfgfile_write_str(f, _T("comp_trustlong"), compmode[p->comptrustlong]);
+ cfgfile_write_str(f, _T("comp_trustnaddr"), compmode[p->comptrustnaddr]);
+ cfgfile_write_bool(f, _T("comp_nf"), p->compnf);
+ cfgfile_write_bool(f, _T("comp_constjump"), p->comp_constjump);
+ cfgfile_write_str(f, _T("comp_flushmode"), flushmode[p->comp_hardflush]);
+#ifdef USE_JIT_FPU
+ cfgfile_write_bool(f, _T("compfpu"), p->compfpu);
+#endif
+ cfgfile_write(f, _T("cachesize"), _T("%d"), p->cachesize);
+
+ for (i = 0; i < MAX_JPORTS; i++) {
struct jport *jp = &p->jports[i];
int v = jp->id;
TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH];
if (v == JPORT_NONE) {
- _tcscpy (tmp2, _T("none"));
- } else if (v < JSEM_CUSTOM) {
+ _tcscpy(tmp2, _T("none"));
+ }
+ else if (v < JSEM_CUSTOM) {
_stprintf(tmp2, _T("kbd%d"), v + 1);
- } else if (v < JSEM_JOYS) {
+ }
+ else if (v < JSEM_JOYS) {
_stprintf(tmp2, _T("custom%d"), v - JSEM_CUSTOM);
- } else if (v < JSEM_MICE) {
- _stprintf (tmp2, _T("joy%d"), v - JSEM_JOYS);
- } else {
- _tcscpy (tmp2, _T("mouse"));
+ }
+ else if (v < JSEM_MICE) {
+ _stprintf(tmp2, _T("joy%d"), v - JSEM_JOYS);
+ }
+ else {
+ _tcscpy(tmp2, _T("mouse"));
if (v - JSEM_MICE > 0)
- _stprintf (tmp2, _T("mouse%d"), v - JSEM_MICE);
+ _stprintf(tmp2, _T("mouse%d"), v - JSEM_MICE);
}
if (i < 2 || jp->id >= 0) {
- _stprintf (tmp1, _T("joyport%d"), i);
- cfgfile_write (f, tmp1, tmp2);
-
- _stprintf (tmp1, _T("joyport%d_autofire"), i);
- cfgfile_write (f, tmp1, joyaf[jp->autofire]);
-
- if (jp->mode > 0) {
- _stprintf (tmp1, _T("joyport%d_mode"), i);
- cfgfile_dwrite_str (f, tmp1, joyportmodes[jp->mode]);
+ _stprintf(tmp1, _T("joyport%d"), i);
+ cfgfile_write(f, tmp1, tmp2);
+ _stprintf(tmp1, _T("joyport%dautofire"), i);
+ cfgfile_write(f, tmp1, joyaf[jp->autofire]);
+ if (i < 2 && jp->mode > 0) {
+ _stprintf(tmp1, _T("joyport%dmode"), i);
+ cfgfile_write(f, tmp1, joyportmodes[jp->mode]);
}
-#ifndef PANDORA
- if (jp->mousemap > 0) {
- _stprintf (tmp1, _T("joyport%d_mousemap"), i);
- cfgfile_dwrite_str (f, tmp1, mousemaps[jp->mousemap]);
- }
-#endif
if (jp->idc.name[0]) {
- _stprintf (tmp1, _T("joyport%d_friendlyname"), i);
- cfgfile_write (f, tmp1, jp->idc.name);
+ _stprintf(tmp1, _T("joyportfriendlyname%d"), i);
+ cfgfile_write(f, tmp1, jp->idc.name);
}
-
if (jp->idc.configname[0]) {
- _stprintf (tmp1, _T("joyport%d_name"), i);
- cfgfile_write (f, tmp1, jp->idc.configname);
+ _stprintf(tmp1, _T("joyportname%d"), i);
+ cfgfile_write(f, tmp1, jp->idc.configname);
}
-
if (jp->nokeyboardoverride) {
- _stprintf (tmp1, _T("joyport%d_keyboardoverride"), i);
- cfgfile_write_bool (f, tmp1, !jp->nokeyboardoverride);
- }
- }
-
-#ifndef PANDORA
- // custom options SAVING
- if (i < 4 ) {
-
- struct joypad_map_layout tempcustom;
- const TCHAR *namecustom;
-
- // this allows us to go through the available function keys
- // currently only 'none' and 'hotkey'
- for (int m=0; m<2 ; ++m)
- {
-
- switch (m) {
- case 0:
- { tempcustom = jp->amiberry_custom_none;
- namecustom = _T("_amiberry_custom_none_");
- break; }
- case 1:
- { tempcustom = jp->amiberry_custom_hotkey;
- namecustom = _T("_amiberry_custom_hotkey_");
- break; }
- }
-
- // get all of the custom actions
- for (int n=0; n < 14; ++n) // loop through all buttons
- {
- int b = 0;
- switch (n)
- {
- case 0: {b = tempcustom.dpad_up_action; break;}
- case 1: {b = tempcustom.dpad_down_action; break;}
- case 2: {b = tempcustom.dpad_left_action; break;}
- case 3: {b = tempcustom.dpad_right_action; break;}
- case 4: {b = tempcustom.select_action; break;}
- case 5: {b = tempcustom.left_shoulder_action; break;}
- case 6: {b = tempcustom.lstick_select_action; break;}
- case 7: {b = tempcustom.north_action; break;}
- case 8: {b = tempcustom.south_action; break;}
- case 9: {b = tempcustom.east_action; break;}
- case 10: {b = tempcustom.west_action; break;}
- case 11: {b = tempcustom.start_action; break;}
- case 12: {b = tempcustom.right_shoulder_action; break;}
- case 13: {b = tempcustom.rstick_select_action; break;}
- }
-
- if ( b > 0) {_tcscpy (tmp2, _T(find_inputevent_name(b)));}
- else {snprintf(tmp2, 1, "%s", "");}
-
- _stprintf (tmp1, "joyport%d%s%s",i, namecustom , button_remap_name[n]);
-
- // cfgfile_write (f, tmp1, tmp2); }
- cfgfile_dwrite_str (f, tmp1, tmp2); }
- }
- }
-#endif
- cfg_write (_T("; "), f);
- }
-
- cfgfile_dwrite_str (f, _T("absolute_mouse"), abspointers[p->input_tablet]);
-
- write_inputdevice_config (p, f);
-
- cfgfile_write_str (f, _T("kbd_lang"), (p->keyboard_lang == KBD_LANG_DE ? _T("de")
- : p->keyboard_lang == KBD_LANG_DK ? _T("dk")
- : p->keyboard_lang == KBD_LANG_ES ? _T("es")
- : p->keyboard_lang == KBD_LANG_US ? _T("us")
- : p->keyboard_lang == KBD_LANG_SE ? _T("se")
- : p->keyboard_lang == KBD_LANG_FR ? _T("fr")
- : p->keyboard_lang == KBD_LANG_IT ? _T("it")
- : _T("FOO")));
-
-
- cfg_write (_T("; "), f);
- cfg_write (_T("; *** Host-Specific"), f);
- cfg_write (_T("; "), f);
-
- target_save_options (f, p);
-
- cfg_write (_T("; "), f);
- cfg_write (_T("; *** Common / Paths"), f);
- cfg_write (_T("; "), f);
-
- cfgfile_write_str (f, _T("use_gui"), guimode1[p->start_gui]);
- cfgfile_dwrite_bool (f, _T("show_leds"), p->leds_on_screen);
-
- cfgfile_write_rom (f, p->path_rom, p->romfile, _T("kickstart_rom_file"));
- cfgfile_write_rom (f, p->path_rom, p->romextfile, _T("kickstart_ext_rom_file"));
-
- for (int i = 0; i < MAX_EXPANSION_BOARDS; i++) {
- cfgfile_write_board_rom(p, f, p->path_rom, &p->expansionboard[i]);
+ _stprintf(tmp1, _T("joyport%dkeyboardoverride"), i);
+ cfgfile_write_bool(f, tmp1, !jp->nokeyboardoverride);
+ }
+ }
+ }
+ for (i = 0; i < MAX_JPORTS_CUSTOM; i++) {
+ struct jport_custom *jp = &p->jports_custom[i];
+ if (jp->custom[0]) {
+ TCHAR tmp1[MAX_DPATH];
+ _stprintf(tmp1, _T("joyportcustom%d"), i);
+ cfgfile_write(f, tmp1, jp->custom);
+ }
}
- cfgfile_write_str (f, _T("flash_file"), p->flashfile);
- cfgfile_write_str (f, _T("cart_file"), p->cartfile);
+ if (p->dongle) {
+ if (p->dongle + 1 >= sizeof(dongles) / sizeof(TCHAR*))
+ cfgfile_write(f, _T("dongle"), _T("%d"), p->dongle);
+ else
+ cfgfile_write_str(f, _T("dongle"), dongles[p->dongle]);
+ }
+
+ cfgfile_write_bool(f, _T("bsdsocket_emu"), p->socket_emu);
+
+ //{
+ // // backwards compatibility
+ // const TCHAR *name;
+ // struct romconfig *rc;
+ // rc = get_device_romconfig(p, ROMTYPE_A2065, 0);
+ // if (rc) {
+ // name = ethernet_getselectionname(rc ? rc->device_settings : 0);
+ // cfgfile_write_str(f, _T("a2065"), name);
+ // }
+ // rc = get_device_romconfig(p, ROMTYPE_NE2KPCMCIA, 0);
+ // if (rc) {
+ // name = ethernet_getselectionname(rc ? rc->device_settings : 0);
+ // cfgfile_write_str(f, _T("ne2000_pcmcia"), name);
+ // }
+ // rc = get_device_romconfig(p, ROMTYPE_NE2KPCI, 0);
+ // if (rc) {
+ // name = ethernet_getselectionname(rc ? rc->device_settings : 0);
+ // cfgfile_write_str(f, _T("ne2000_pci"), name);
+ // }
+ //}
+
+#ifdef WITH_SLIRP
+ tmp[0] = 0;
+ for (i = 0; i < MAX_SLIRP_REDIRS; i++) {
+ struct slirp_redir *sr = &p->slirp_redirs[i];
+ if (sr->proto && !sr->srcport) {
+ TCHAR *p = tmp + _tcslen(tmp);
+ if (p > tmp)
+ *p++ = ',';
+ _stprintf(p, _T("%d"), sr->dstport);
+ }
+ }
+ if (tmp[0])
+ cfgfile_write_str(f, _T("slirp_ports"), tmp);
+ for (i = 0; i < MAX_SLIRP_REDIRS; i++) {
+ struct slirp_redir *sr = &p->slirp_redirs[i];
+ if (sr->proto && sr->srcport) {
+ uae_u32 v = htonl(sr->addr);
+ if (v) {
+ _stprintf(tmp, _T("%s:%d:%d:%d.%d.%d.%d"),
+ sr->proto == 1 ? _T("tcp") : _T("udp"),
+ sr->dstport, sr->srcport,
+ (v >> 24) & 0xff, (v >> 16) & 0xff, (v >> 8) & 0xff, v & 0xff);
+ }
+ else {
+ _stprintf(tmp, _T("%s:%d:%d"),
+ sr->proto == 1 ? _T("tcp") : _T("udp"),
+ sr->dstport, sr->srcport);
+ }
+ cfgfile_write_str(f, _T("slirp_redir"), tmp);
+ }
+ }
+#endif /* WITH_SLIRP */
+
+ cfgfile_write_bool(f, _T("synchronize_clock"), p->tod_hack);
+ cfgfile_write(f, _T("maprom"), _T("0x%x"), p->maprom);
+ cfgfile_dwrite_str(f, _T("boot_rom_uae"), uaebootrom[p->boot_rom]);
+ cfgfile_dwrite_str(f, _T("uaeboard"), uaeboard[p->uaeboard]);
+ if (p->autoconfig_custom_sort)
+ cfgfile_dwrite(f, _T("uaeboard_options"), _T("order=%d"), p->uaeboard_order);
+ cfgfile_dwrite_str(f, _T("parallel_matrix_emulation"), epsonprinter[p->parallel_matrix_emulation]);
+ cfgfile_write_bool(f, _T("parallel_postscript_emulation"), p->parallel_postscript_emulation);
+ cfgfile_write_bool(f, _T("parallel_postscript_detection"), p->parallel_postscript_detection);
+ cfgfile_write_str(f, _T("ghostscript_parameters"), p->ghostscript_parameters);
+ cfgfile_write(f, _T("parallel_autoflush"), _T("%d"), p->parallel_autoflush_time);
+ cfgfile_dwrite(f, _T("uae_hide"), _T("%d"), p->uae_hide);
+ cfgfile_dwrite_bool(f, _T("uae_hide_autoconfig"), p->uae_hide_autoconfig);
+ cfgfile_dwrite_bool(f, _T("magic_mouse"), (p->input_mouse_untrap & MOUSEUNTRAP_MAGIC) != 0);
+ cfgfile_dwrite_str(f, _T("magic_mousecursor"), magiccursors[p->input_magic_mouse_cursor]);
+ cfgfile_dwrite_str(f, _T("absolute_mouse"), abspointers[p->input_tablet]);
+ cfgfile_dwrite_bool(f, _T("tablet_library"), p->tablet_library);
+ cfgfile_dwrite_bool(f, _T("clipboard_sharing"), p->clipboard_sharing);
+ cfgfile_dwrite_bool(f, _T("native_code"), p->native_code);
+
+ cfgfile_write(f, _T("gfx_display"), _T("%d"), p->gfx_apmode[APMODE_NATIVE].gfx_display);
+ cfgfile_write_str(f, _T("gfx_display_friendlyname"), target_get_display_name(p->gfx_apmode[APMODE_NATIVE].gfx_display, true));
+ cfgfile_write_str(f, _T("gfx_display_name"), target_get_display_name(p->gfx_apmode[APMODE_NATIVE].gfx_display, false));
+ cfgfile_write(f, _T("gfx_display_rtg"), _T("%d"), p->gfx_apmode[APMODE_RTG].gfx_display);
+ cfgfile_write_str(f, _T("gfx_display_friendlyname_rtg"), target_get_display_name(p->gfx_apmode[APMODE_RTG].gfx_display, true));
+ cfgfile_write_str(f, _T("gfx_display_name_rtg"), target_get_display_name(p->gfx_apmode[APMODE_RTG].gfx_display, false));
+
+ cfgfile_write(f, _T("gfx_framerate"), _T("%d"), p->gfx_framerate);
+ write_resolution(f, _T("gfx_width"), _T("gfx_height"), &p->gfx_size_win); /* compatibility with old versions */
+ cfgfile_write(f, _T("gfx_top_windowed"), _T("%d"), p->gfx_size_win.x);
+ cfgfile_write(f, _T("gfx_left_windowed"), _T("%d"), p->gfx_size_win.y);
+ write_resolution(f, _T("gfx_width_windowed"), _T("gfx_height_windowed"), &p->gfx_size_win);
+ write_resolution(f, _T("gfx_width_fullscreen"), _T("gfx_height_fullscreen"), &p->gfx_size_fs);
+ cfgfile_write(f, _T("gfx_refreshrate"), _T("%d"), p->gfx_apmode[0].gfx_refreshrate);
+ cfgfile_dwrite(f, _T("gfx_refreshrate_rtg"), _T("%d"), p->gfx_apmode[1].gfx_refreshrate);
+ cfgfile_write(f, _T("gfx_autoresolution"), _T("%d"), p->gfx_autoresolution);
+ cfgfile_dwrite(f, _T("gfx_autoresolution_delay"), _T("%d"), p->gfx_autoresolution_delay);
+ cfgfile_dwrite(f, _T("gfx_autoresolution_min_vertical"), vertmode[p->gfx_autoresolution_minv + 1]);
+ cfgfile_dwrite(f, _T("gfx_autoresolution_min_horizontal"), horizmode[p->gfx_autoresolution_minh + 1]);
+ cfgfile_write_bool(f, _T("gfx_autoresolution_vga"), p->gfx_autoresolution_vga);
+
+ cfgfile_write(f, _T("gfx_backbuffers"), _T("%d"), p->gfx_apmode[0].gfx_backbuffers);
+ cfgfile_write(f, _T("gfx_backbuffers_rtg"), _T("%d"), p->gfx_apmode[1].gfx_backbuffers);
+ if (p->gfx_apmode[APMODE_NATIVE].gfx_interlaced)
+ cfgfile_write_bool(f, _T("gfx_interlace"), p->gfx_apmode[APMODE_NATIVE].gfx_interlaced);
+ cfgfile_write_str(f, _T("gfx_vsync"), vsyncmodes[p->gfx_apmode[0].gfx_vsync + 1]);
+ cfgfile_write_str(f, _T("gfx_vsyncmode"), vsyncmodes2[p->gfx_apmode[0].gfx_vsyncmode]);
+ cfgfile_write_str(f, _T("gfx_vsync_picasso"), vsyncmodes[p->gfx_apmode[1].gfx_vsync + 1]);
+ cfgfile_write_str(f, _T("gfx_vsyncmode_picasso"), vsyncmodes2[p->gfx_apmode[1].gfx_vsyncmode]);
+ cfgfile_write_bool(f, _T("gfx_lores"), p->gfx_resolution == 0);
+ cfgfile_write_str(f, _T("gfx_resolution"), lorestype1[p->gfx_resolution]);
+ cfgfile_write_str(f, _T("gfx_lores_mode"), loresmode[p->gfx_lores_mode]);
+ cfgfile_write_bool(f, _T("gfx_flickerfixer"), p->gfx_scandoubler);
+ cfgfile_write_str(f, _T("gfx_linemode"), p->gfx_vresolution > 0 ? linemode[p->gfx_iscanlines * 4 + p->gfx_pscanlines + 1] : linemode[0]);
+ cfgfile_write_str(f, _T("gfx_fullscreen_amiga"), fullmodes[p->gfx_apmode[0].gfx_fullscreen]);
+ cfgfile_write_str(f, _T("gfx_fullscreen_picasso"), fullmodes[p->gfx_apmode[1].gfx_fullscreen]);
+ cfgfile_write_str(f, _T("gfx_center_horizontal"), centermode1[p->gfx_xcenter]);
+ cfgfile_write_str(f, _T("gfx_center_vertical"), centermode1[p->gfx_ycenter]);
+ cfgfile_write_str(f, _T("gfx_colour_mode"), colormode1[p->color_mode]);
+ cfgfile_write_bool(f, _T("gfx_blacker_than_black"), p->gfx_blackerthanblack);
+ cfgfile_dwrite_bool(f, _T("gfx_monochrome"), p->gfx_grayscale);
+ cfgfile_dwrite_str(f, _T("gfx_atari_palette_fix"), threebitcolors[p->gfx_threebitcolors]);
+ cfgfile_dwrite_bool(f, _T("gfx_black_frame_insertion"), p->lightboost_strobo);
+ cfgfile_dwrite(f, _T("gfx_black_frame_insertion_ratio"), _T("%d"), p->lightboost_strobo_ratio);
+ cfgfile_write_str(f, _T("gfx_api"), filterapi[p->gfx_api]);
+ cfgfile_dwrite(f, _T("gfx_horizontal_tweak"), _T("%d"), p->gfx_extrawidth);
+
+#ifdef GFXFILTER
+ for (int j = 0; j < 2; j++) {
+ struct gfx_filterdata *gf = &p->gf[j];
+ const TCHAR *ext = j == 0 ? NULL : _T("_rtg");
+ for (int i = 0; i gfx_filtershader[i][0])
+ cfgfile_write_ext(f, _T("gfx_filter_pre"), ext, _T("D3D:%s"), gf->gfx_filtershader[i]);
+ if (gf->gfx_filtermask[i][0])
+ cfgfile_write_str(f, _T("gfx_filtermask_pre"), ext, gf->gfx_filtermask[i]);
+ }
+ for (int i = 0; i < MAX_FILTERSHADERS; i++) {
+ if (gf->gfx_filtershader[i + MAX_FILTERSHADERS][0])
+ cfgfile_write_ext(f, _T("gfx_filter_post"), ext, _T("D3D:%s"), gf->gfx_filtershader[i + MAX_FILTERSHADERS]);
+ if (gf->gfx_filtermask[i + MAX_FILTERSHADERS][0])
+ cfgfile_write_str(f, _T("gfx_filtermask_post"), ext, gf->gfx_filtermask[i + MAX_FILTERSHADERS]);
+ }
+ cfgfile_dwrite_str(f, _T("gfx_filter_mask"), ext, gf->gfx_filtermask[2 * MAX_FILTERSHADERS]);
+ {
+ bool d3dfound = false;
+ if (gf->gfx_filtershader[2 * MAX_FILTERSHADERS][0] && p->gfx_api) {
+ cfgfile_dwrite_ext(f, _T("gfx_filter"), ext, _T("D3D:%s"), gf->gfx_filtershader[2 * MAX_FILTERSHADERS]);
+ d3dfound = true;
+ }
+ if (!d3dfound) {
+ if (gf->gfx_filter > 0) {
+ int i = 0;
+ struct uae_filter *uf;
+ while (uaefilters[i].name) {
+ uf = &uaefilters[i];
+ if (uf->type == gf->gfx_filter) {
+ cfgfile_dwrite_str(f, _T("gfx_filter"), ext, uf->cfgname);
+ }
+ i++;
+ }
+ }
+ else {
+ cfgfile_dwrite_ext(f, _T("gfx_filter"), ext, _T("no"));
+ }
+ }
+ }
+ cfgfile_dwrite_str(f, _T("gfx_filter_mode"), ext, filtermode2[gf->gfx_filter_filtermode]);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_vert_zoomf"), ext, _T("%f"), gf->gfx_filter_vert_zoom);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_horiz_zoomf"), ext, _T("%f"), gf->gfx_filter_horiz_zoom);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_vert_zoom_multf"), ext, _T("%f"), gf->gfx_filter_vert_zoom_mult);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_horiz_zoom_multf"), ext, _T("%f"), gf->gfx_filter_horiz_zoom_mult);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_vert_offsetf"), ext, _T("%f"), gf->gfx_filter_vert_offset);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_horiz_offsetf"), ext, _T("%f"), gf->gfx_filter_horiz_offset);
+
+ cfgfile_dwrite_ext(f, _T("gfx_filter_left_border"), ext, _T("%d"), gf->gfx_filter_left_border);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_right_border"), ext, _T("%d"), gf->gfx_filter_right_border);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_top_border"), ext, _T("%d"), gf->gfx_filter_top_border);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_bottom_border"), ext, _T("%d"), gf->gfx_filter_bottom_border);
+
+ cfgfile_dwrite_ext(f, _T("gfx_filter_scanlines"), ext, _T("%d"), gf->gfx_filter_scanlines);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_scanlinelevel"), ext, _T("%d"), gf->gfx_filter_scanlinelevel);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_scanlineratio"), ext, _T("%d"), gf->gfx_filter_scanlineratio);
+
+ cfgfile_dwrite_ext(f, _T("gfx_filter_luminance"), ext, _T("%d"), gf->gfx_filter_luminance);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_contrast"), ext, _T("%d"), gf->gfx_filter_contrast);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_saturation"), ext, _T("%d"), gf->gfx_filter_saturation);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_gamma"), ext, _T("%d"), gf->gfx_filter_gamma);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_gamma_r"), ext, _T("%d"), gf->gfx_filter_gamma_ch[0]);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_gamma_g"), ext, _T("%d"), gf->gfx_filter_gamma_ch[1]);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_gamma_b"), ext, _T("%d"), gf->gfx_filter_gamma_ch[2]);
+
+ cfgfile_dwrite_ext(f, _T("gfx_filter_blur"), ext, _T("%d"), gf->gfx_filter_blur);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_noise"), ext, _T("%d"), gf->gfx_filter_noise);
+ cfgfile_dwrite_bool(f, _T("gfx_filter_bilinear"), ext, gf->gfx_filter_bilinear != 0);
+
+ cfgfile_dwrite_ext(f, _T("gfx_filter_keep_autoscale_aspect"), ext, _T("%d"), gf->gfx_filter_keep_autoscale_aspect);
+ cfgfile_dwrite_str(f, _T("gfx_filter_keep_aspect"), ext, aspects[gf->gfx_filter_keep_aspect]);
+ cfgfile_dwrite_str(f, _T("gfx_filter_autoscale"), ext, ext == NULL ? autoscale[gf->gfx_filter_autoscale] : autoscale_rtg[gf->gfx_filter_autoscale]);
+ cfgfile_dwrite_str(f, _T("gfx_filter_autoscale_limit"), ext, autoscalelimit[gf->gfx_filter_integerscalelimit]);
+ cfgfile_dwrite_ext(f, _T("gfx_filter_aspect_ratio"), ext, _T("%d:%d"),
+ gf->gfx_filter_aspect >= 0 ? (gf->gfx_filter_aspect / ASPECTMULT) : -1,
+ gf->gfx_filter_aspect >= 0 ? (gf->gfx_filter_aspect & (ASPECTMULT - 1)) : -1);
+ if (gf->gfx_filteroverlay[0]) {
+ cfgfile_dwrite_ext(f, _T("gfx_filter_overlay"), ext, _T("%s%s"),
+ gf->gfx_filteroverlay, _tcschr(gf->gfx_filteroverlay, ',') ? _T(",") : _T(""));
+ }
+ }
+ cfgfile_dwrite(f, _T("gfx_luminance"), _T("%d"), p->gfx_luminance);
+ cfgfile_dwrite(f, _T("gfx_contrast"), _T("%d"), p->gfx_contrast);
+ cfgfile_dwrite(f, _T("gfx_gamma"), _T("%d"), p->gfx_gamma);
+ cfgfile_dwrite(f, _T("gfx_gamma_r"), _T("%d"), p->gfx_gamma_ch[0]);
+ cfgfile_dwrite(f, _T("gfx_gamma_g"), _T("%d"), p->gfx_gamma_ch[1]);
+ cfgfile_dwrite(f, _T("gfx_gamma_b"), _T("%d"), p->gfx_gamma_ch[2]);
+
+ cfgfile_dwrite(f, _T("gfx_center_horizontal_position"), _T("%d"), p->gfx_xcenter_pos);
+ cfgfile_dwrite(f, _T("gfx_center_vertical_position"), _T("%d"), p->gfx_ycenter_pos);
+ cfgfile_dwrite(f, _T("gfx_center_horizontal_size"), _T("%d"), p->gfx_xcenter_size);
+ cfgfile_dwrite(f, _T("gfx_center_vertical_size"), _T("%d"), p->gfx_ycenter_size);
+
+ cfgfile_dwrite(f, _T("rtg_vert_zoom_multf"), _T("%.f"), p->rtg_vert_zoom_mult);
+ cfgfile_dwrite(f, _T("rtg_horiz_zoom_multf"), _T("%.f"), p->rtg_horiz_zoom_mult);
+
+#endif
+
+ cfgfile_write_bool(f, _T("immediate_blits"), p->immediate_blits);
+ cfgfile_dwrite_str(f, _T("waiting_blits"), waitblits[p->waiting_blits]);
+ cfgfile_write_bool(f, _T("ntsc"), p->ntscmode);
+ cfgfile_write_bool(f, _T("genlock"), p->genlock);
+ cfgfile_dwrite_bool(f, _T("genlock_alpha"), p->genlock_alpha);
+ cfgfile_dwrite_bool(f, _T("genlock_aspect"), p->genlock_aspect);
+ cfgfile_dwrite_str(f, _T("genlockmode"), genlockmodes[p->genlock_image]);
+ cfgfile_dwrite_str(f, _T("genlock_image"), p->genlock_image_file);
+ cfgfile_dwrite_str(f, _T("genlock_video"), p->genlock_video_file);
+ cfgfile_dwrite(f, _T("genlock_mix"), _T("%d"), p->genlock_mix);
+ cfgfile_dwrite(f, _T("genlock_scale"), _T("%d"), p->genlock_scale);
+ cfgfile_dwrite_str(f, _T("monitoremu"), specialmonitors[p->monitoremu]);
+
+ cfgfile_dwrite_bool(f, _T("show_leds"), !!(p->leds_on_screen & STATUSLINE_CHIPSET));
+ cfgfile_dwrite_bool(f, _T("show_leds_rtg"), !!(p->leds_on_screen & STATUSLINE_RTG));
+ write_leds(f, _T("show_leds_enabled"), p->leds_on_screen_mask[0]);
+ write_leds(f, _T("show_leds_enabled_rtg"), p->leds_on_screen_mask[1]);
+ cfgfile_dwrite_bool(f, _T("show_refresh_indicator"), p->refresh_indicator);
+
+ if (p->osd_pos.y || p->osd_pos.x) {
+ cfgfile_dwrite(f, _T("osd_position"), _T("%.1f%s:%.1f%s"),
+ p->osd_pos.x >= 20000 ? (p->osd_pos.x - 30000) / 10.0 : (float)p->osd_pos.x, p->osd_pos.x >= 20000 ? _T("%") : _T(""),
+ p->osd_pos.y >= 20000 ? (p->osd_pos.y - 30000) / 10.0 : (float)p->osd_pos.y, p->osd_pos.y >= 20000 ? _T("%") : _T(""));
+ }
+ cfgfile_dwrite(f, _T("keyboard_leds"), _T("numlock:%s,capslock:%s,scrolllock:%s"),
+ kbleds[p->keyboard_leds[0]], kbleds[p->keyboard_leds[1]], kbleds[p->keyboard_leds[2]]);
+ if (p->chipset_mask & CSMASK_AGA)
+ cfgfile_write(f, _T("chipset"), _T("aga"));
+ else if ((p->chipset_mask & CSMASK_ECS_AGNUS) && (p->chipset_mask & CSMASK_ECS_DENISE))
+ cfgfile_write(f, _T("chipset"), _T("ecs"));
+ else if (p->chipset_mask & CSMASK_ECS_AGNUS)
+ cfgfile_write(f, _T("chipset"), _T("ecs_agnus"));
+ else if (p->chipset_mask & CSMASK_ECS_DENISE)
+ cfgfile_write(f, _T("chipset"), _T("ecs_denise"));
+ else
+ cfgfile_write(f, _T("chipset"), _T("ocs"));
+ if (p->chipset_refreshrate > 0)
+ cfgfile_write(f, _T("chipset_refreshrate"), _T("%f"), p->chipset_refreshrate);
+
+ for (int i = 0; i < MAX_CHIPSET_REFRESH_TOTAL; i++) {
+ struct chipset_refresh *cr = &p->cr[i];
+ if (!cr->inuse)
+ continue;
+ cr->index = i;
+ if (cr->rate == 0)
+ _tcscpy(tmp, _T("0"));
+ else
+ _stprintf(tmp, _T("%f"), cr->rate);
+ TCHAR *s = tmp + _tcslen(tmp);
+ if (cr->label[0] > 0 && i < MAX_CHIPSET_REFRESH)
+ s += _stprintf(s, _T(",t=%s"), cr->label);
+ if (cr->horiz > 0)
+ s += _stprintf(s, _T(",h=%d"), cr->horiz);
+ if (cr->vert > 0)
+ s += _stprintf(s, _T(",v=%d"), cr->vert);
+ if (cr->locked)
+ _tcscat(s, _T(",locked"));
+ if (cr->ntsc == 1)
+ _tcscat(s, _T(",ntsc"));
+ else if (cr->ntsc == 0)
+ _tcscat(s, _T(",pal"));
+ else if (cr->ntsc == 2)
+ _tcscat(s, _T(",custom"));
+ if (cr->lace > 0)
+ _tcscat(s, _T(",lace"));
+ else if (cr->lace == 0)
+ _tcscat(s, _T(",nlace"));
+ if ((cr->resolution & 7) != 7) {
+ if (cr->resolution & 1)
+ _tcscat(s, _T(",lores"));
+ if (cr->resolution & 2)
+ _tcscat(s, _T(",hires"));
+ if (cr->resolution & 4)
+ _tcscat(s, _T(",shres"));
+ if (cr->resolution_pct > 0 && cr->resolution_pct < 100)
+ s += _stprintf(s, _T("rpct=%d"), cr->resolution_pct);
+ }
+ if (cr->framelength > 0)
+ _tcscat(s, _T(",lof"));
+ else if (cr->framelength == 0)
+ _tcscat(s, _T(",shf"));
+ if (cr->vsync > 0)
+ _tcscat(s, _T(",vsync"));
+ else if (cr->vsync == 0)
+ _tcscat(s, _T(",nvsync"));
+ if (cr->rtg)
+ _tcscat(s, _T(",rtg"));
+ if (cr->exit)
+ _tcscat(s, _T(",exit"));
+ if (cr->defaultdata)
+ _tcscat(s, _T(",default"));
+ if (cr->filterprofile[0]) {
+ TCHAR *se = cfgfile_escape(cr->filterprofile, _T(","), true);
+ s += _stprintf(s, _T(",filter=%s"), cr->filterprofile);
+ xfree(se);
+ }
+ if (cr->commands[0]) {
+ _tcscat(s, _T(",cmd="));
+ _tcscat(s, cr->commands);
+ for (int j = 0; j < _tcslen(s); j++) {
+ if (s[j] == '\n')
+ s[j] = ',';
+ }
+ s[_tcslen(s) - 1] = 0;
+ }
+ if (i == CHIPSET_REFRESH_PAL) {
+ if (cr->locked)
+ cfgfile_dwrite(f, _T("displaydata_pal"), tmp);
+ }
+ else if (i == CHIPSET_REFRESH_NTSC) {
+ if (cr->locked)
+ cfgfile_dwrite(f, _T("displaydata_ntsc"), tmp);
+ }
+ else {
+ cfgfile_dwrite(f, _T("displaydata"), tmp);
+ }
+ }
+
+ cfgfile_write_str(f, _T("collision_level"), collmode[p->collision_level]);
+
+ cfgfile_write_str(f, _T("chipset_compatible"), cscompa[p->cs_compatible]);
+ cfgfile_dwrite_str(f, _T("ciaatod"), ciaatodmode[p->cs_ciaatod]);
+ cfgfile_dwrite_str(f, _T("rtc"), rtctype[p->cs_rtc]);
+ //cfgfile_dwrite (f, _T("chipset_rtc_adjust"), _T("%d"), p->cs_rtc_adjust);
+ cfgfile_dwrite_bool(f, _T("ksmirror_e0"), p->cs_ksmirror_e0);
+ cfgfile_dwrite_bool(f, _T("ksmirror_a8"), p->cs_ksmirror_a8);
+ cfgfile_dwrite_bool(f, _T("cd32cd"), p->cs_cd32cd);
+ cfgfile_dwrite_bool(f, _T("cd32c2p"), p->cs_cd32c2p);
+ cfgfile_dwrite_bool(f, _T("cd32nvram"), p->cs_cd32nvram);
+ cfgfile_dwrite(f, _T("cd32nvram_size"), _T("%d"), p->cs_cd32nvram_size / 1024);
+ cfgfile_dwrite_bool(f, _T("cdtvcd"), p->cs_cdtvcd);
+ cfgfile_dwrite_bool(f, _T("cdtv-cr"), p->cs_cdtvcr);
+ cfgfile_dwrite_bool(f, _T("cdtvram"), p->cs_cdtvram);
+ cfgfile_dwrite(f, _T("cdtvramcard"), _T("%d"), p->cs_cdtvcard);
+ cfgfile_dwrite_bool(f, _T("a1000ram"), p->cs_a1000ram);
+ cfgfile_dwrite(f, _T("fatgary"), _T("%d"), p->cs_fatgaryrev);
+ cfgfile_dwrite(f, _T("ramsey"), _T("%d"), p->cs_ramseyrev);
+ cfgfile_dwrite_bool(f, _T("pcmcia"), p->cs_pcmcia);
+ cfgfile_dwrite_bool(f, _T("bogomem_fast"), p->cs_slowmemisfast);
+ cfgfile_dwrite_bool(f, _T("resetwarning"), p->cs_resetwarning);
+ cfgfile_dwrite_bool(f, _T("denise_noehb"), p->cs_denisenoehb);
+ cfgfile_dwrite_bool(f, _T("agnus_bltbusybug"), p->cs_agnusbltbusybug);
+ cfgfile_dwrite_bool(f, _T("ics_agnus"), p->cs_dipagnus);
+ cfgfile_dwrite_bool(f, _T("cia_todbug"), p->cs_ciatodbug);
+ cfgfile_dwrite_bool(f, _T("z3_autoconfig"), p->cs_z3autoconfig);
+ cfgfile_dwrite_bool(f, _T("1mchipjumper"), p->cs_1mchipjumper);
+ cfgfile_dwrite_bool(f, _T("color_burst"), p->cs_color_burst);
+ cfgfile_dwrite(f, _T("chipset_hacks"), _T("0x%x"), p->cs_hacks);
if (is_board_enabled(p, ROMTYPE_CD32CART, 0)) {
cfgfile_dwrite_bool(f, _T("cd32fmv"), true);
@@ -1243,144 +2044,38 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
if (is_board_enabled(p, ROMTYPE_MB_IDE, 0) && p->cs_ide == 2) {
cfgfile_dwrite_str(f, _T("ide"), _T("a4000"));
}
-
- cfg_write (_T("; "), f);
- cfg_write (_T("; *** Floppy Drives"), f);
- cfg_write (_T("; "), f);
-
- p->nr_floppies = 4;
- for (i = 0; i < 4; i++) {
- _stprintf (tmp, _T("floppy%d"), i);
- cfgfile_write_path(f, p->path_floppy, tmp, p->floppyslots[i].df);
- _stprintf (tmp, _T("floppy%dwp"), i);
- cfgfile_dwrite_bool (f, tmp, p->floppyslots[i].forcedwriteprotect);
- _stprintf (tmp, _T("floppy%dtype"), i);
- cfgfile_dwrite (f, tmp, _T("%d"), p->floppyslots[i].dfxtype);
- if (p->floppyslots[i].dfxtype < 0 && p->nr_floppies > i)
- p->nr_floppies = i;
- }
-
-
- cfgfile_write (f, _T("nr_floppies"), _T("%d"), p->nr_floppies);
- cfgfile_dwrite_bool (f, _T("floppy_write_protect"), p->floppy_read_only);
- cfgfile_write (f, _T("floppy_speed"), _T("%d"), p->floppy_speed);
-
- cfg_write (_T("; "), f);
- cfg_write (_T("; *** Hard Drives"), f);
- cfg_write (_T("; "), f);
-
- #ifdef FILESYS
- write_filesys_config (p, UNEXPANDED, p->path_hardfile, f);
- cfgfile_dwrite (f, _T("filesys_max_size"), _T("%d"), p->filesys_limit);
- cfgfile_dwrite (f, _T("filesys_max_name_length"), _T("%d"), p->filesys_max_name);
- cfgfile_dwrite_bool (f, _T("filesys_inject_icons"), p->filesys_inject_icons);
- cfgfile_dwrite_str (f, _T("filesys_inject_icons_drawer"), p->filesys_inject_icons_drawer);
- cfgfile_dwrite_str (f, _T("filesys_inject_icons_project"), p->filesys_inject_icons_project);
- cfgfile_dwrite_str (f, _T("filesys_inject_icons_tool"), p->filesys_inject_icons_tool);
-#endif
- cfgfile_dwrite_bool(f, _T("harddrive_write_protect"), p->harddrive_read_only);
-
-
- cfg_write (_T("; "), f);
- cfg_write (_T("; *** CD / CD32"), f);
- cfg_write (_T("; "), f);
-
- cfgfile_write (f, _T("cd_speed"), _T("%d"), p->cd_speed);
- cfgfile_dwrite_bool (f, _T("cd32cd"), p->cs_cd32cd);
- cfgfile_dwrite_bool (f, _T("cd32c2p"), p->cs_cd32c2p);
- cfgfile_dwrite_bool (f, _T("cd32nvram"), p->cs_cd32nvram);
- cfgfile_dwrite (f, _T("cd32nvram_size"), _T("%d"), p->cs_cd32nvram_size / 1024);
-
- for (i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
- if (p->cdslots[i].name[0] || p->cdslots[i].inuse) {
- TCHAR tmp2[MAX_DPATH];
- _stprintf (tmp, _T("cdimage%d"), i);
- TCHAR *s = cfgfile_subst_path (p->path_cd, UNEXPANDED, p->cdslots[i].name);
- _tcscpy (tmp2, s);
- xfree (s);
- if (p->cdslots[i].type != SCSI_UNIT_DEFAULT || _tcschr (p->cdslots[i].name, ',') || p->cdslots[i].delayed) {
- _tcscat (tmp2, _T(","));
- if (p->cdslots[i].delayed) {
- _tcscat (tmp2, _T("delay"));
- _tcscat (tmp2, _T(":"));
- }
- if (p->cdslots[i].type != SCSI_UNIT_DEFAULT) {
- _tcscat (tmp2, cdmodes[p->cdslots[i].type + 1]);
- }
- }
- cfgfile_write_str (f, tmp, tmp2);
- }
+ if (is_board_enabled(p, ROMTYPE_CDTVSCSI, 0)) {
+ cfgfile_dwrite_bool(f, _T("scsi_cdtv"), true);
+ }
+ if (is_board_enabled(p, ROMTYPE_SCSI_A3000, 0)) {
+ cfgfile_dwrite_bool(f, _T("scsi_a3000"), true);
+ }
+ if (is_board_enabled(p, ROMTYPE_SCSI_A4000T, 0)) {
+ cfgfile_dwrite_bool(f, _T("scsi_a4000t"), true);
}
-
-
- cfg_write (_T("; "), f);
- cfg_write (_T("; *** Display / Screen Setup"), f);
- cfg_write (_T("; "), f);
-
- cfgfile_write (f, _T("gfx_framerate"), _T("%d"), p->gfx_framerate);
- write_resolution (f, _T("gfx_width"), _T("gfx_height"), &p->gfx_size); /* compatibility with old versions */
- cfgfile_write (f, _T("gfx_refreshrate"), _T("%d"), p->gfx_apmode[0].gfx_refreshrate);
- cfgfile_dwrite (f, _T("gfx_refreshrate_rtg"), _T("%d"), p->gfx_apmode[1].gfx_refreshrate);
- cfgfile_write_str (f, _T("gfx_vsync"), vsyncmodes[p->gfx_apmode[0].gfx_vsync + 1]);
- cfgfile_write_str (f, _T("gfx_vsync_picasso"), vsyncmodes[p->gfx_apmode[1].gfx_vsync + 1]);
- cfgfile_write_bool (f, _T("gfx_lores"), p->gfx_resolution == 0);
- cfgfile_write_str (f, _T("gfx_resolution"), lorestype1[p->gfx_resolution]);
-
- cfgfile_write_bool(f, _T("ntsc"), p->ntscmode);
-
- cfg_write (_T("; "), f);
- cfg_write (_T("; *** CPU options"), f);
- cfg_write (_T("; "), f);
-
- if (p->m68k_speed > 0) {
- cfgfile_write (f, _T("finegrain_cpu_speed"), _T("%d"), p->m68k_speed);
- } else {
- cfgfile_write_str (f, _T("cpu_speed"), p->m68k_speed < 0 ? _T("max") : _T("real"));
- }
-
- /* do not reorder start */
- write_compatibility_cpu(f, p);
- cfgfile_write (f, _T("cpu_model"), _T("%d"), p->cpu_model);
- if (p->fpu_model)
- cfgfile_write (f, _T("fpu_model"), _T("%d"), p->fpu_model);
- cfgfile_write_bool (f, _T("cpu_compatible"), p->cpu_compatible);
- cfgfile_write_bool (f, _T("cpu_24bit_addressing"), p->address_space_24);
- /* do not reorder end */
-
- cfgfile_dwrite_bool (f, _T("fpu_no_unimplemented"), p->fpu_no_unimplemented);
- cfgfile_write_bool (f, _T("fpu_strict"), p->fpu_strict);
- cfgfile_dwrite_bool (f, _T("fpu_softfloat"), p->fpu_softfloat);
-
- cfgfile_write (f, _T("cachesize"), _T("%d"), p->cachesize);
-
- cfg_write (_T("; "), f);
- cfg_write (_T("; *** Memory"), f);
- cfg_write (_T("; "), f);
-
- cfgfile_write (f, _T("chipmem_size"), _T("%d"), p->chipmem_size == 0x20000 ? -1 : (p->chipmem_size == 0x40000 ? 0 : p->chipmem_size / 0x80000));
-
-
- cfgfile_dwrite_bool(f, _T("z3_autoconfig"), p->cs_z3autoconfig);
- cfgfile_dwrite_str (f, _T("z3mapping"), z3mapping[p->z3_mapping_mode]);
+ cfgfile_dwrite_str(f, _T("z3mapping"), z3mapping[p->z3_mapping_mode]);
+ cfgfile_dwrite_bool(f, _T("board_custom_order"), p->autoconfig_custom_sort);
for (int i = 0; i < MAX_RAM_BOARDS; i++) {
- if (p->fastmem[i].size < 0x100000 && p->fastmem[i].size) {
+ if (p->fastmem[i].size < 0x100000 && p->fastmem[i].size) {
if (i > 0)
_stprintf(tmp, _T("fastmem%d_size_k"), i + 1);
else
_tcscpy(tmp, _T("fastmem_size_k"));
- cfgfile_write (f, tmp, _T("%d"), p->fastmem[i].size / 1024);
- } else if (p->fastmem[i].size || i == 0) {
- if (i > 0)
+ cfgfile_write(f, tmp, _T("%d"), p->fastmem[i].size / 1024);
+ }
+ else if (p->fastmem[i].size || i == 0) {
+ if (i > 0)
_stprintf(tmp, _T("fastmem%d_size"), i + 1);
else
_tcscpy(tmp, _T("fastmem_size"));
cfgfile_write(f, tmp, _T("%d"), p->fastmem[i].size / 0x100000);
- }
+ }
cfgfile_writeramboard(p, f, _T("fastmem"), i, &p->fastmem[i]);
- }
- cfgfile_write (f, _T("a3000mem_size"), _T("%d"), p->mbresmem_low_size / 0x100000);
- cfgfile_write (f, _T("mbresmem_size"), _T("%d"), p->mbresmem_high_size / 0x100000);
+ }
+ cfgfile_write(f, _T("mem25bit_size"), _T("%d"), p->mem25bit_size / 0x100000);
+ cfgfile_write(f, _T("a3000mem_size"), _T("%d"), p->mbresmem_low_size / 0x100000);
+ cfgfile_write(f, _T("mbresmem_size"), _T("%d"), p->mbresmem_high_size / 0x100000);
for (int i = 0; i < MAX_RAM_BOARDS; i++) {
if (i == 0 || p->z3fastmem[i].size) {
if (i > 0)
@@ -1391,9 +2086,28 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
}
cfgfile_writeramboard(p, f, _T("z3mem"), i, &p->z3fastmem[i]);
}
- cfgfile_write (f, _T("z3mem_start"), _T("0x%x"), p->z3autoconfig_start);
- cfgfile_write (f, _T("bogomem_size"), _T("%d"), p->bogomem_size / 0x40000);
+ cfgfile_write(f, _T("z3mem_start"), _T("0x%x"), p->z3autoconfig_start);
+ cfgfile_write(f, _T("bogomem_size"), _T("%d"), p->bogomem_size / 0x40000);
+ if (p->cpuboard_type) {
+ const struct cpuboardtype *cbt = &cpuboards[p->cpuboard_type];
+ const struct cpuboardsubtype *cbst = &cbt->subtypes[p->cpuboard_subtype];
+ const struct expansionboardsettings *cbs = cbst->settings;
+ cfgfile_dwrite_str(f, _T("cpuboard_type"), cbst->configname);
+ if (cbs && p->cpuboard_settings) {
+ tmp[0] = 0;
+ cfgfile_write_rom_settings(cbs, tmp, p->cpuboard_settings, NULL);
+ cfgfile_dwrite_str(f, _T("cpuboard_settings"), tmp);
+ }
+ }
+ else {
+ cfgfile_dwrite_str(f, _T("cpuboard_type"), _T("none"));
+ }
+ cfgfile_dwrite(f, _T("cpuboardmem1_size"), _T("%d"), p->cpuboardmem1_size / 0x100000);
+ cfgfile_dwrite(f, _T("cpuboardmem2_size"), _T("%d"), p->cpuboardmem2_size / 0x100000);
+ cfgfile_write_bool(f, _T("gfxcard_hardware_vblank"), p->rtg_hardwareinterrupt);
+ cfgfile_write_bool(f, _T("gfxcard_hardware_sprite"), p->rtg_hardwaresprite);
for (int i = 0; i < MAX_RTG_BOARDS; i++) {
+ TCHAR tmp2[100];
struct rtgboardconfig *rbc = &p->rtgboards[i];
if (rbc->rtgmem_size) {
if (i > 0)
@@ -1406,165 +2120,159 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
else
_tcscpy(tmp, _T("gfxcard_type"));
cfgfile_dwrite_str(f, tmp, gfxboard_get_configname(rbc->rtgmem_type));
+ if (rbc->device_order > 0 && p->autoconfig_custom_sort) {
+ _stprintf(tmp2, _T("order=%d"), rbc->device_order);
+ if (i > 0)
+ _stprintf(tmp, _T("gfxcard%d_options"), i + 1);
+ else
+ _tcscpy(tmp, _T("gfxcard_options"));
+ cfgfile_dwrite_str(f, tmp, tmp2);
+ }
}
}
- cfgfile_write (f, _T("rtg_modes"), _T("0x%x"), p->picasso96_modeflags);
-
-
- // do not save aros rom special space
+ cfgfile_write(f, _T("chipmem_size"), _T("%d"), p->chipmem_size == 0x20000 ? -1 : (p->chipmem_size == 0x40000 ? 0 : p->chipmem_size / 0x80000));
+ cfgfile_dwrite(f, _T("megachipmem_size"), _T("%d"), p->z3chipmem_size / 0x100000);
+ // do not save aros rom special space
if (!(p->custom_memory_sizes[0] == 512 * 1024 && p->custom_memory_sizes[1] == 512 * 1024 && p->custom_memory_addrs[0] == 0xa80000 && p->custom_memory_addrs[1] == 0xb00000)) {
if (p->custom_memory_sizes[0])
- cfgfile_write (f, _T("addmem1"), _T("0x%x,0x%x"), p->custom_memory_addrs[0], p->custom_memory_sizes[0]);
+ cfgfile_write(f, _T("addmem1"), _T("0x%x,0x%x"), p->custom_memory_addrs[0], p->custom_memory_sizes[0]);
if (p->custom_memory_sizes[1])
- cfgfile_write (f, _T("addmem2"), _T("0x%x,0x%x"), p->custom_memory_addrs[1], p->custom_memory_sizes[1]);
+ cfgfile_write(f, _T("addmem2"), _T("0x%x,0x%x"), p->custom_memory_addrs[1], p->custom_memory_sizes[1]);
}
-
- cfg_write (_T("; "), f);
- cfg_write (_T("; *** Chipset"), f);
- cfg_write (_T("; "), f);
+ if (p->m68k_speed > 0) {
+ cfgfile_write(f, _T("finegrain_cpu_speed"), _T("%d"), p->m68k_speed);
+ }
+ else {
+ cfgfile_write_str(f, _T("cpu_speed"), p->m68k_speed < 0 ? _T("max") : _T("real"));
+ }
+ cfgfile_write(f, _T("cpu_throttle"), _T("%.1f"), p->m68k_speed_throttle);
+ cfgfile_dwrite(f, _T("cpu_x86_throttle"), _T("%.1f"), p->x86_speed_throttle);
- if (p->chipset_mask & CSMASK_AGA)
- cfgfile_write (f, _T("chipset"), _T("aga"));
- else if ((p->chipset_mask & CSMASK_ECS_AGNUS) && (p->chipset_mask & CSMASK_ECS_DENISE))
- cfgfile_write (f, _T("chipset"), _T("ecs"));
- else if (p->chipset_mask & CSMASK_ECS_AGNUS)
- cfgfile_write (f, _T("chipset"), _T("ecs_agnus"));
- else if (p->chipset_mask & CSMASK_ECS_DENISE)
- cfgfile_write (f, _T("chipset"), _T("ecs_denise"));
- else
- cfgfile_write (f, _T("chipset"), _T("ocs"));
+ /* do not reorder start */
+ write_compatibility_cpu(f, p);
+ cfgfile_write(f, _T("cpu_model"), _T("%d"), p->cpu_model);
+ if (p->fpu_model)
+ cfgfile_write(f, _T("fpu_model"), _T("%d"), p->fpu_model);
+ if (p->mmu_model)
+ cfgfile_write(f, _T("mmu_model"), _T("%d"), p->mmu_model);
+ if (p->ppc_mode) {
+ cfgfile_write_str(f, _T("ppc_model"), p->ppc_model[0] ? p->ppc_model : (p->ppc_mode == 1 ? _T("automatic") : _T("manual")));
+ cfgfile_write_str(f, _T("ppc_cpu_idle"), ppc_cpu_idle[p->ppc_cpu_idle]);
+ }
+ cfgfile_write_bool(f, _T("cpu_compatible"), p->cpu_compatible);
+ cfgfile_write_bool(f, _T("cpu_24bit_addressing"), p->address_space_24);
+ /* do not reorder end */
+ cfgfile_dwrite_bool(f, _T("cpu_reset_pause"), p->reset_delay);
+ cfgfile_dwrite_bool(f, _T("cpu_threaded"), p->cpu_thread);
+ if (p->ppc_mode)
+ cfgfile_write_str(f, _T("ppc_implementation"), ppc_implementations[p->ppc_implementation]);
- if (p->chipset_refreshrate > 0)
- cfgfile_write (f, _T("chipset_refreshrate"), _T("%f"), p->chipset_refreshrate);
-
- for (int i = 0; i < MAX_CHIPSET_REFRESH_TOTAL; i++) {
- struct chipset_refresh *cr = &p->cr[i];
- if (!cr->inuse)
- continue;
- cr->index = i;
- if (cr->rate == 0)
- _tcscpy(tmp, _T("0"));
- else
- _stprintf (tmp, _T("%f"), cr->rate);
- TCHAR *s = tmp + _tcslen (tmp);
- if (cr->label[0] > 0 && i < MAX_CHIPSET_REFRESH)
- s += _stprintf (s, _T(",t=%s"), cr->label);
- if (cr->horiz > 0)
- s += _stprintf (s, _T(",h=%d"), cr->horiz);
- if (cr->vert > 0)
- s += _stprintf (s, _T(",v=%d"), cr->vert);
- if (cr->locked)
- _tcscat (s, _T(",locked"));
- if (cr->ntsc > 0)
- _tcscat (s, _T(",ntsc"));
- else if (cr->ntsc == 0)
- _tcscat (s, _T(",pal"));
- if (cr->lace > 0)
- _tcscat (s, _T(",lace"));
- else if (cr->lace == 0)
- _tcscat (s, _T(",nlace"));
- if ((cr->resolution & 7) != 7) {
- if (cr->resolution & 1)
- _tcscat(s, _T(",lores"));
- if (cr->resolution & 2)
- _tcscat(s, _T(",hires"));
- if (cr->resolution & 4)
- _tcscat(s, _T(",shres"));
+ if (p->cpu_cycle_exact) {
+ if (p->cpu_frequency)
+ cfgfile_write(f, _T("cpu_frequency"), _T("%d"), p->cpu_frequency);
+ if (p->cpu_clock_multiplier) {
+ if (p->cpu_clock_multiplier >= 256)
+ cfgfile_write(f, _T("cpu_multiplier"), _T("%d"), p->cpu_clock_multiplier >> 8);
}
- if (cr->vsync > 0)
- _tcscat (s, _T(",vsync"));
- else if (cr->vsync == 0)
- _tcscat (s, _T(",nvsync"));
- if (cr->rtg)
- _tcscat (s, _T(",rtg"));
- if (cr->defaultdata)
- _tcscat(s, _T(",default"));
- if (i == CHIPSET_REFRESH_PAL) {
- cfgfile_dwrite (f, _T("displaydata_pal"), tmp);
- } else if (i == CHIPSET_REFRESH_NTSC) {
- cfgfile_dwrite (f, _T("displaydata_ntsc"), tmp);
- } else {
- cfgfile_dwrite (f, _T("displaydata"), tmp);
- }
}
- cfgfile_write_str (f, _T("collision_level"), collmode[p->collision_level]);
+ cfgfile_write_bool(f, _T("cpu_cycle_exact"), p->cpu_cycle_exact);
+ // must be after cpu_cycle_exact
+ cfgfile_write_bool(f, _T("cpu_memory_cycle_exact"), p->cpu_memory_cycle_exact);
+ cfgfile_write_bool(f, _T("blitter_cycle_exact"), p->blitter_cycle_exact);
+ // must be after cpu_cycle_exact, cpu_memory_cycle_exact and blitter_cycle_exact
+ if (p->cpu_cycle_exact && p->blitter_cycle_exact)
+ cfgfile_write_str(f, _T("cycle_exact"), cycleexact[2]);
+ else if (p->cpu_memory_cycle_exact && p->blitter_cycle_exact)
+ cfgfile_write_str(f, _T("cycle_exact"), cycleexact[1]);
+ else
+ cfgfile_write_str(f, _T("cycle_exact"), cycleexact[0]);
- cfgfile_write_str(f, _T("chipset_compatible"), cscompa[p->cs_compatible]);
- cfgfile_dwrite_str(f, _T("ciaatod"), ciaatodmode[p->cs_ciaatod]);
- cfgfile_dwrite_str(f, _T("rtc"), rtctype[p->cs_rtc]);
- cfgfile_dwrite_bool(f, _T("ksmirror_e0"), p->cs_ksmirror_e0);
- cfgfile_dwrite_bool(f, _T("ksmirror_a8"), p->cs_ksmirror_a8);
- cfgfile_dwrite_bool (f, _T("cd32cd"), p->cs_cd32cd);
- cfgfile_dwrite_bool (f, _T("cd32c2p"), p->cs_cd32c2p);
- cfgfile_dwrite_bool (f, _T("cd32nvram"), p->cs_cd32nvram);
- cfgfile_dwrite (f, _T("cd32nvram_size"), _T("%d"), p->cs_cd32nvram_size / 1024);
- cfgfile_dwrite(f, _T("fatgary"), _T("%d"), p->cs_fatgaryrev);
- cfgfile_dwrite(f, _T("ramsey"), _T("%d"), p->cs_ramseyrev);
- cfgfile_dwrite_bool(f, _T("pcmcia"), p->cs_pcmcia);
- cfgfile_dwrite_bool(f, _T("cia_todbug"), p->cs_ciatodbug);
- cfgfile_write_bool(f, _T("immediate_blits"), p->immediate_blits);
- cfgfile_dwrite_str(f, _T("waiting_blits"), waitblits[p->waiting_blits]);
- cfgfile_write_bool(f, _T("fast_copper"), p->fast_copper);
+ cfgfile_dwrite_bool(f, _T("fpu_no_unimplemented"), p->fpu_no_unimplemented);
+ cfgfile_dwrite_bool(f, _T("cpu_no_unimplemented"), p->int_no_unimplemented);
+ cfgfile_write_bool(f, _T("fpu_strict"), p->fpu_strict);
+ cfgfile_dwrite_bool(f, _T("fpu_softfloat"), p->fpu_softfloat);
-
- cfg_write (_T("; "), f);
- cfg_write (_T("; *** Sound Options"), f);
- cfg_write (_T("; "), f);
-
- cfgfile_write_str (f, _T("sound_output"), soundmode1[p->produce_sound]);
- cfgfile_write_str (f, _T("sound_channels"), stereomode[p->sound_stereo]);
- cfgfile_write (f, _T("sound_stereo_separation"), _T("%d"), p->sound_stereo_separation);
- cfgfile_write (f, _T("sound_stereo_mixing_delay"), _T("%d"), p->sound_mixed_stereo_delay >= 0 ? p->sound_mixed_stereo_delay : 0);
- cfgfile_write (f, _T("sound_frequency"), _T("%d"), p->sound_freq);
- cfgfile_write_str (f, _T("sound_interpol"), interpolmode[p->sound_interpol]);
- cfgfile_write_str (f, _T("sound_filter"), soundfiltermode1[p->sound_filter]);
- cfgfile_write_str (f, _T("sound_filter_type"), soundfiltermode2[p->sound_filter_type]);
- if (p->sound_volume_cd >= 0)
- cfgfile_write (f, _T("sound_volume_cd"), _T("%d"), p->sound_volume_cd);
+ cfgfile_write_bool(f, _T("rtg_nocustom"), p->picasso96_nocustom);
+ cfgfile_write(f, _T("rtg_modes"), _T("0x%x"), p->picasso96_modeflags);
-
- cfg_write (_T("; "), f);
- cfg_write (_T("; *** Misc. Options"), f);
- cfg_write (_T("; "), f);
-
- cfgfile_write_bool (f, _T("bsdsocket_emu"), p->socket_emu);
- cfgfile_dwrite_str (f, _T("boot_rom_uae"), uaebootrom[p->boot_rom]);
- cfgfile_dwrite_str(f, _T("uaeboard"), uaeboard[p->uaeboard]);
+ cfgfile_write_bool(f, _T("log_illegal_mem"), p->illegal_mem);
+#if 0
+ if (p->catweasel >= 100)
+ cfgfile_dwrite(f, _T("catweasel"), _T("0x%x"), p->catweasel);
+ else
+ cfgfile_dwrite(f, _T("catweasel"), _T("%d"), p->catweasel);
+ cfgfile_write_bool(f, _T("toccata"), p->obs_sound_toccata);
+ if (p->obs_sound_toccata_mixer)
+ cfgfile_write_bool(f, _T("toccata_mixer"), p->obs_sound_toccata_mixer);
+ cfgfile_write_bool(f, _T("es1370_pci"), p->obs_sound_es1370);
+ cfgfile_write_bool(f, _T("fm801_pci"), p->obs_sound_fm801);
+#endif
-
+ cfgfile_dwrite_bool(f, _T("keyboard_connected"), p->keyboard_connected);
+ //cfgfile_write_str(f, _T("kbd_lang"), (p->keyboard_lang == KBD_LANG_DE ? _T("de")
+ // : p->keyboard_lang == KBD_LANG_DK ? _T("dk")
+ // : p->keyboard_lang == KBD_LANG_ES ? _T("es")
+ // : p->keyboard_lang == KBD_LANG_US ? _T("us")
+ // : p->keyboard_lang == KBD_LANG_SE ? _T("se")
+ // : p->keyboard_lang == KBD_LANG_FR ? _T("fr")
+ // : p->keyboard_lang == KBD_LANG_IT ? _T("it")
+ // : _T("FOO")));
+
+ cfgfile_dwrite(f, _T("state_replay_rate"), _T("%d"), p->statecapturerate);
+ cfgfile_dwrite(f, _T("state_replay_buffers"), _T("%d"), p->statecapturebuffersize);
+ cfgfile_dwrite_bool(f, _T("state_replay_autoplay"), p->inprec_autoplay);
+ cfgfile_dwrite_bool(f, _T("warp"), p->turbo_emulation);
+ cfgfile_dwrite(f, _T("warp_limit"), _T("%d"), p->turbo_emulation_limit);
+
+#ifdef FILESYS
+ write_filesys_config(p, f);
+ if (p->filesys_no_uaefsdb)
+ cfgfile_write_bool(f, _T("filesys_no_fsdb"), p->filesys_no_uaefsdb);
+ cfgfile_dwrite(f, _T("filesys_max_size"), _T("%d"), p->filesys_limit);
+ cfgfile_dwrite(f, _T("filesys_max_name_length"), _T("%d"), p->filesys_max_name);
+ cfgfile_dwrite(f, _T("filesys_max_file_size"), _T("%d"), p->filesys_max_file_size);
+ cfgfile_dwrite_bool(f, _T("filesys_inject_icons"), p->filesys_inject_icons);
+ cfgfile_dwrite_str(f, _T("filesys_inject_icons_drawer"), p->filesys_inject_icons_drawer);
+ cfgfile_dwrite_str(f, _T("filesys_inject_icons_project"), p->filesys_inject_icons_project);
+ cfgfile_dwrite_str(f, _T("filesys_inject_icons_tool"), p->filesys_inject_icons_tool);
+ cfgfile_dwrite_str(f, _T("scsidev_mode"), uaescsidevmodes[p->uaescsidevmode]);
+#endif
+ cfgfile_dwrite_bool(f, _T("harddrive_write_protect"), p->harddrive_read_only);
+
+ write_inputdevice_config(p, f);
}
-static int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, bool numbercheck)
+static int cfgfile_yesno(const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, bool numbercheck)
{
- if (name != NULL && _tcscmp (option, name) != 0)
- return 0;
- if (_tcsicmp (value, _T("yes")) == 0 || _tcsicmp (value, _T("y")) == 0
- || _tcsicmp (value, _T("true")) == 0 || _tcsicmp (value, _T("t")) == 0
- || (numbercheck && _tcsicmp (value, _T("1")) == 0))
- *location = 1;
- else if (_tcsicmp (value, _T("no")) == 0 || _tcsicmp (value, _T("n")) == 0
- || _tcsicmp (value, _T("false")) == 0 || _tcsicmp (value, _T("f")) == 0
- || (numbercheck && _tcsicmp (value, _T("0")) == 0))
- *location = 0;
- else {
+ if (name != NULL && _tcscmp(option, name) != 0)
+ return 0;
+ if (strcasecmp(value, _T("yes")) == 0 || strcasecmp(value, _T("y")) == 0
+ || strcasecmp(value, _T("true")) == 0 || strcasecmp(value, _T("t")) == 0
+ || (numbercheck && strcasecmp(value, _T("1")) == 0))
+ *location = 1;
+ else if (strcasecmp(value, _T("no")) == 0 || strcasecmp(value, _T("n")) == 0
+ || strcasecmp(value, _T("false")) == 0 || strcasecmp(value, _T("f")) == 0
+ || (numbercheck && strcasecmp(value, _T("0")) == 0))
+ *location = 0;
+ else {
cfgfile_warning(_T("Option '%s' requires a value of either 'true' or 'false' (was '%s').\n"), option, value);
- return -1;
- }
- return 1;
+ return -1;
+ }
+ return 1;
}
-static int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location)
+static int cfgfile_yesno(const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location)
{
- return cfgfile_yesno (option, value, name, location, true);
+ return cfgfile_yesno(option, value, name, location, true);
}
-static int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location, bool numbercheck)
+static int cfgfile_yesno(const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location, bool numbercheck)
{
int val;
- int ret = cfgfile_yesno (option, value, name, &val, numbercheck);
+ int ret = cfgfile_yesno(option, value, name, &val, numbercheck);
if (ret == 0)
return 0;
if (ret < 0)
@@ -1574,281 +2282,328 @@ static int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *
return 1;
}
-int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location)
+int cfgfile_yesno(const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location)
{
- return cfgfile_yesno (option, value, name, location, true);
+ return cfgfile_yesno(option, value, name, location, true);
}
-static int cfgfile_doubleval (const TCHAR *option, const TCHAR *value, const TCHAR *name, double *location)
+static int cfgfile_doubleval(const TCHAR *option, const TCHAR *value, const TCHAR *name, double *location)
{
TCHAR *endptr;
- if (name != NULL && _tcscmp (option, name) != 0)
+ if (name != NULL && _tcscmp(option, name) != 0)
return 0;
- *location = _tcstod (value, &endptr);
+ *location = _tcstod(value, &endptr);
return 1;
}
-static int cfgfile_floatval (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, float *location)
+static int cfgfile_floatval(const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, float *location)
{
TCHAR *endptr;
if (name == NULL)
return 0;
if (nameext) {
TCHAR tmp[MAX_DPATH];
- _tcscpy (tmp, name);
- _tcscat (tmp, nameext);
- if (_tcscmp (tmp, option) != 0)
- return 0;
- } else {
- if (_tcscmp (option, name) != 0)
+ _tcscpy(tmp, name);
+ _tcscat(tmp, nameext);
+ if (_tcscmp(tmp, option) != 0)
return 0;
}
- *location = (float)_tcstod (value, &endptr);
+ else {
+ if (_tcscmp(option, name) != 0)
+ return 0;
+ }
+ *location = (float)_tcstod(value, &endptr);
return 1;
}
-static int cfgfile_floatval (const TCHAR *option, const TCHAR *value, const TCHAR *name, float *location)
+static int cfgfile_floatval(const TCHAR *option, const TCHAR *value, const TCHAR *name, float *location)
{
- return cfgfile_floatval (option, value, name, NULL, location);
+ return cfgfile_floatval(option, value, name, NULL, location);
}
-static int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, unsigned int *location, int scale)
+static int cfgfile_intval(const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, unsigned int *location, int scale)
{
- int base = 10;
- TCHAR *endptr;
+ int base = 10;
+ TCHAR *endptr;
TCHAR tmp[MAX_DPATH];
if (name == NULL)
- return 0;
+ return 0;
if (nameext) {
- _tcscpy (tmp, name);
- _tcscat (tmp, nameext);
- if (_tcscmp (tmp, option) != 0)
- return 0;
- } else {
- if (_tcscmp (option, name) != 0)
+ _tcscpy(tmp, name);
+ _tcscat(tmp, nameext);
+ if (_tcscmp(tmp, option) != 0)
return 0;
}
- /* I guess octal isn't popular enough to worry about here... */
- if (value[0] == '0' && _totupper(value[1]) == 'X')
- value += 2, base = 16;
- *location = _tcstol (value, &endptr, base) * scale;
+ else {
+ if (_tcscmp(option, name) != 0)
+ return 0;
+ }
+ /* I guess octal isn't popular enough to worry about here... */
+ if (value[0] == '0' && _totupper(value[1]) == 'X')
+ value += 2, base = 16;
+ *location = _tcstol(value, &endptr, base) * scale;
- if (*endptr != '\0' || *value == '\0') {
- if (_tcsicmp (value, _T("false")) == 0 || _tcsicmp (value, _T("no")) == 0) {
+ if (*endptr != '\0' || *value == '\0') {
+ if (strcasecmp(value, _T("false")) == 0 || strcasecmp(value, _T("no")) == 0) {
*location = 0;
return 1;
}
- if (_tcsicmp (value, _T("true")) == 0 || _tcsicmp (value, _T("yes")) == 0) {
+ if (strcasecmp(value, _T("true")) == 0 || strcasecmp(value, _T("yes")) == 0) {
*location = 1;
return 1;
- }
+ }
cfgfile_warning(_T("Option '%s' requires a numeric argument but got '%s'\n"), nameext ? tmp : option, value);
- return -1;
- }
- return 1;
+ return -1;
+ }
+ return 1;
}
-static int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, unsigned int *location, int scale)
+
+static int cfgfile_intval(const TCHAR *option, const TCHAR *value, const TCHAR *name, unsigned int *location, int scale)
{
- return cfgfile_intval (option, value, name, NULL, location, scale);
+ return cfgfile_intval(option, value, name, NULL, location, scale);
}
-int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale)
+int cfgfile_intval(const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale)
{
unsigned int v = 0;
- int r = cfgfile_intval (option, value, name, NULL, &v, scale);
+ int r = cfgfile_intval(option, value, name, NULL, &v, scale);
if (!r)
return 0;
*location = (int)v;
return r;
}
-static int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, int *location, int scale)
+static int cfgfile_intval(const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, int *location, int scale)
{
unsigned int v = 0;
- int r = cfgfile_intval (option, value, name, nameext, &v, scale);
+ int r = cfgfile_intval(option, value, name, nameext, &v, scale);
if (!r)
return 0;
*location = (int)v;
return r;
}
-static int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, int *location, const TCHAR *table[], int more)
+static int cfgfile_strval(const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, int *location, const TCHAR *table[], int more)
{
- int val;
+ int val;
TCHAR tmp[MAX_DPATH];
if (name == NULL)
- return 0;
+ return 0;
if (nameext) {
- _tcscpy (tmp, name);
- _tcscat (tmp, nameext);
- if (_tcscmp (tmp, option) != 0)
- return 0;
- } else {
- if (_tcscmp (option, name) != 0)
+ _tcscpy(tmp, name);
+ _tcscat(tmp, nameext);
+ if (_tcscmp(tmp, option) != 0)
return 0;
}
- val = match_string (table, value);
- if (val == -1) {
- if (more)
- return 0;
- if (!_tcsicmp (value, _T("yes")) || !_tcsicmp (value, _T("true"))) {
+ else {
+ if (_tcscmp(option, name) != 0)
+ return 0;
+ }
+ val = match_string(table, value);
+ if (val == -1) {
+ if (more)
+ return 0;
+ if (!strcasecmp(value, _T("yes")) || !strcasecmp(value, _T("true"))) {
val = 1;
- } else if (!_tcsicmp (value, _T("no")) || !_tcsicmp (value, _T("false"))) {
- val = 0;
- } else {
- cfgfile_warning(_T("Unknown value ('%s') for option '%s'.\n"), value, nameext ? tmp : option);
- return -1;
}
- }
- *location = val;
- return 1;
+ else if (!strcasecmp(value, _T("no")) || !strcasecmp(value, _T("false"))) {
+ val = 0;
+ }
+ else {
+ cfgfile_warning(_T("Unknown value ('%s') for option '%s'.\n"), value, nameext ? tmp : option);
+ return -1;
+ }
+ }
+ *location = val;
+ return 1;
}
-int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, const TCHAR *table[], int more)
+int cfgfile_strval(const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, const TCHAR *table[], int more)
{
- return cfgfile_strval (option, value, name, NULL, location, table, more);
+ return cfgfile_strval(option, value, name, NULL, location, table, more);
}
-static int cfgfile_strboolval (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location, const TCHAR *table[], int more)
+static int cfgfile_strboolval(const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location, const TCHAR *table[], int more)
{
int locationint;
- if (!cfgfile_strval (option, value, name, &locationint, table, more))
+ if (!cfgfile_strval(option, value, name, &locationint, table, more))
return 0;
*location = locationint != 0;
return 1;
}
-int cfgfile_string (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz)
+int cfgfile_string(const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz)
{
- if (_tcscmp (option, name) != 0)
- return 0;
- _tcsncpy (location, value, maxsz - 1);
- location[maxsz - 1] = '\0';
- return 1;
-}
-
-static int cfgfile_string (const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, TCHAR *location, int maxsz)
-{
- if (nameext) {
- TCHAR tmp[MAX_DPATH];
- _tcscpy (tmp, name);
- _tcscat (tmp, nameext);
- if (_tcscmp (tmp, option) != 0)
- return 0;
- } else {
- if (_tcscmp (option, name) != 0)
- return 0;
- }
- _tcsncpy (location, value, maxsz - 1);
+ if (_tcscmp(option, name) != 0)
+ return 0;
+ _tcsncpy(location, value, maxsz - 1);
location[maxsz - 1] = '\0';
return 1;
}
-static int cfgfile_path (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz)
+static int cfgfile_string(const TCHAR *option, const TCHAR *value, const TCHAR *name, const TCHAR *nameext, TCHAR *location, int maxsz)
{
- if (!cfgfile_string (option, value, name, location, maxsz))
- return 0;
- TCHAR *s = target_expand_environment (location, NULL, 0);
- _tcsncpy (location, s, maxsz - 1);
- location[maxsz - 1] = 0;
- xfree (s);
+ if (nameext) {
+ TCHAR tmp[MAX_DPATH];
+ _tcscpy(tmp, name);
+ _tcscat(tmp, nameext);
+ if (_tcscmp(tmp, option) != 0)
+ return 0;
+ }
+ else {
+ if (_tcscmp(option, name) != 0)
+ return 0;
+ }
+ _tcsncpy(location, value, maxsz - 1);
+ location[maxsz - 1] = '\0';
return 1;
}
-static int cfgfile_rom (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz)
+static int cfgfile_path(const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz, struct multipath *mp)
+{
+ if (!cfgfile_string(option, value, name, location, maxsz))
+ return 0;
+
+ TCHAR* s = target_expand_environment(location);
+ _tcsncpy(location, s, maxsz - 1);
+ location[maxsz - 1] = 0;
+ if (mp) {
+ for (int i = 0; i < MAX_PATHS; i++) {
+ if (mp->path[i][0] && _tcscmp(mp->path[i], _T(".\\")) != 0 && _tcscmp(mp->path[i], _T("./")) != 0 && (location[0] != '/' && location[0] != '\\' && !_tcschr(location, ':'))) {
+ TCHAR np[MAX_DPATH];
+ _tcscpy(np, mp->path[i]);
+ fixtrailing(np);
+ _tcscat(np, s);
+ if (zfile_exists(np)) {
+ _tcsncpy(location, np, maxsz - 1);
+ location[maxsz - 1] = 0;
+ break;
+ }
+ }
+ }
+ }
+ xfree(s);
+ return 1;
+}
+
+static int cfgfile_path(const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz)
+{
+ return cfgfile_path(option, value, name, location, maxsz, NULL);
+}
+
+static int cfgfile_multipath(const TCHAR *option, const TCHAR *value, const TCHAR *name, struct multipath *mp)
+{
+ TCHAR tmploc[MAX_DPATH];
+ if (!cfgfile_string(option, value, name, tmploc, 256))
+ return 0;
+ for (int i = 0; i < MAX_PATHS; i++) {
+ if (mp->path[i][0] == 0 || (i == 0 && (!_tcscmp(mp->path[i], _T(".\\")) || !_tcscmp(mp->path[i], _T("./"))))) {
+ TCHAR *s = target_expand_environment(tmploc);
+ _tcsncpy(mp->path[i], s, 256 - 1);
+ mp->path[i][256 - 1] = 0;
+ fixtrailing(mp->path[i]);
+ xfree(s);
+ return 1;
+ }
+ }
+ return 1;
+}
+
+static int cfgfile_rom(const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz)
{
TCHAR id[MAX_DPATH];
- if (!cfgfile_string (option, value, name, id, sizeof id / sizeof (TCHAR)))
+ if (!cfgfile_string(option, value, name, id, sizeof id / sizeof(TCHAR)))
return 0;
- TCHAR *p = _tcschr (id, ',');
+ TCHAR *p = _tcschr(id, ',');
if (p) {
TCHAR *endptr, tmp;
*p = 0;
tmp = id[4];
id[4] = 0;
- uae_u32 crc32 = _tcstol (id, &endptr, 16) << 16;
+ uae_u32 crc32 = _tcstol(id, &endptr, 16) << 16;
id[4] = tmp;
- crc32 |= _tcstol (id + 4, &endptr, 16);
- struct romdata *rd = getromdatabycrc (crc32, true);
+ crc32 |= _tcstol(id + 4, &endptr, 16);
+ struct romdata *rd = getromdatabycrc(crc32, true);
if (rd) {
- struct romdata *rd2 = getromdatabyid (rd->id);
+ struct romdata *rd2 = getromdatabyid(rd->id);
if (rd->group == 0 && rd2 == rd) {
- if (zfile_exists (location))
+ if (zfile_exists(location))
return 1;
}
if (rd->group && rd2)
rd = rd2;
- struct romlist *rl = getromlistbyromdata (rd);
+ struct romlist *rl = getromlistbyromdata(rd);
if (rl) {
- write_log (_T("%s: %s -> %s\n"), name, location, rl->path);
- _tcsncpy (location, rl->path, maxsz);
+ write_log(_T("%s: %s -> %s\n"), name, location, rl->path);
+ _tcsncpy(location, rl->path, maxsz);
}
}
}
return 1;
}
-static int getintval (TCHAR **p, int *result, int delim)
+static int getintval(TCHAR **p, int *result, int delim)
{
- TCHAR *value = *p;
- int base = 10;
- TCHAR *endptr;
- TCHAR *p2 = _tcschr (*p, delim);
+ TCHAR *value = *p;
+ int base = 10;
+ TCHAR *endptr;
+ TCHAR *p2 = _tcschr(*p, delim);
- if (p2 == 0)
- return 0;
+ if (p2 == 0)
+ return 0;
- *p2++ = '\0';
+ *p2++ = '\0';
- if (value[0] == '0' && _totupper (value[1]) == 'X')
- value += 2, base = 16;
- *result = _tcstol (value, &endptr, base);
- *p = p2;
+ if (value[0] == '0' && _totupper(value[1]) == 'X')
+ value += 2, base = 16;
+ *result = _tcstol(value, &endptr, base);
+ *p = p2;
- if (*endptr != '\0' || *value == '\0')
- return 0;
+ if (*endptr != '\0' || *value == '\0')
+ return 0;
- return 1;
+ return 1;
}
-static int getintval2 (TCHAR **p, int *result, int delim, bool last)
+static int getintval2(TCHAR **p, int *result, int delim, bool last)
{
- TCHAR *value = *p;
- int base = 10;
- TCHAR *endptr;
+ TCHAR *value = *p;
+ int base = 10;
+ TCHAR *endptr;
TCHAR *p2;
- p2 = _tcschr (*p, delim);
- if (p2 == 0) {
+ p2 = _tcschr(*p, delim);
+ if (p2 == 0) {
if (last) {
if (delim != '.')
- p2 = _tcschr (*p, ',');
- if (p2 == 0) {
+ p2 = _tcschr(*p, ',');
+ if (p2 == 0) {
p2 = *p;
- while(*p2)
+ while (*p2)
p2++;
if (p2 == *p)
- return 0;
- }
- } else {
+ return 0;
+ }
+ }
+ else {
return 0;
- }
+ }
}
if (!_istdigit(**p) && **p != '-' && **p != '+')
return 0;
- if (*p2 != 0)
- *p2++ = '\0';
+ if (*p2 != 0)
+ *p2++ = '\0';
- if (value[0] == '0' && _totupper (value[1]) == 'X')
- value += 2, base = 16;
- *result = _tcstol (value, &endptr, base);
- *p = p2;
+ if (value[0] == '0' && _totupper(value[1]) == 'X')
+ value += 2, base = 16;
+ *result = _tcstol(value, &endptr, base);
+ *p = p2;
- if (*endptr != '\0' || *value == '\0') {
- *p = 0;
- return 0;
- }
+ if (*endptr != '\0' || *value == '\0') {
+ *p = 0;
+ return 0;
+ }
- return 1;
+ return 1;
}
static int cfgfile_option_select(TCHAR *s, const TCHAR *option, const TCHAR *select)
@@ -1860,7 +2615,7 @@ static int cfgfile_option_select(TCHAR *s, const TCHAR *option, const TCHAR *sel
_tcscat(buf, _T(","));
TCHAR *p = buf;
for (;;) {
- TCHAR *tmpp = _tcschr (p, ',');
+ TCHAR *tmpp = _tcschr(p, ',');
if (tmpp == NULL)
return -1;
*tmpp++ = 0;
@@ -1868,10 +2623,10 @@ static int cfgfile_option_select(TCHAR *s, const TCHAR *option, const TCHAR *sel
if (!tmpp2)
return -1;
*tmpp2++ = 0;
- if (!_tcsicmp(p, option)) {
+ if (!strcasecmp(p, option)) {
int idx = 0;
while (select[0]) {
- if (!_tcsicmp(select, tmpp2))
+ if (!strcasecmp(select, tmpp2))
return idx;
idx++;
select += _tcslen(select) + 1;
@@ -1890,137 +2645,94 @@ static int cfgfile_option_bool(TCHAR *s, const TCHAR *option)
_tcscat(buf, _T(","));
TCHAR *p = buf;
for (;;) {
- TCHAR *tmpp = _tcschr (p, ',');
+ TCHAR *tmpp = _tcschr(p, ',');
if (tmpp == NULL)
return -1;
*tmpp++ = 0;
TCHAR *tmpp2 = _tcschr(p, '=');
if (tmpp2)
*tmpp2++ = 0;
- if (!_tcsicmp(p, option)) {
+ if (!strcasecmp(p, option)) {
if (!tmpp2)
return 0;
- TCHAR *tmpp3 = _tcschr (tmpp2, ',');
+ TCHAR *tmpp3 = _tcschr(tmpp2, ',');
if (tmpp3)
*tmpp3 = 0;
- if (tmpp2 && !_tcsicmp(tmpp2, _T("true")))
+ if (tmpp2 && !strcasecmp(tmpp2, _T("true")))
return 1;
- if (tmpp2 && !_tcsicmp(tmpp2, _T("false")))
+ if (tmpp2 && !strcasecmp(tmpp2, _T("false")))
return 0;
return 1;
}
p = tmpp;
}
}
-static void set_chipset_mask (struct uae_prefs *p, int val)
+
+static void set_chipset_mask(struct uae_prefs *p, int val)
{
- p->chipset_mask = (val == 0 ? 0
- : val == 1 ? CSMASK_ECS_AGNUS
- : val == 2 ? CSMASK_ECS_DENISE
- : val == 3 ? CSMASK_ECS_DENISE | CSMASK_ECS_AGNUS
- : CSMASK_AGA | CSMASK_ECS_DENISE | CSMASK_ECS_AGNUS);
+ p->chipset_mask = (val == 0 ? 0
+ : val == 1 ? CSMASK_ECS_AGNUS
+ : val == 2 ? CSMASK_ECS_DENISE
+ : val == 3 ? CSMASK_ECS_DENISE | CSMASK_ECS_AGNUS
+ : CSMASK_AGA | CSMASK_ECS_DENISE | CSMASK_ECS_AGNUS);
}
-static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
+static int cfgfile_parse_host(struct uae_prefs *p, TCHAR *option, TCHAR *value)
{
- int i;
- bool vb;
- TCHAR *section = 0;
- TCHAR *tmpp;
- TCHAR tmpbuf[CONFIG_BLEN];
- const TCHAR *tmp1;
- TCHAR *tmp2;
+ int i, v;
+ bool vb;
+ TCHAR *section = 0;
+ TCHAR *tmpp;
+ TCHAR tmpbuf[CONFIG_BLEN];
- if (_tcsncmp (option, _T("input."), 6) == 0) {
- read_inputdevice_config (p, option, value);
- return 1;
- }
-
-#ifndef PANDORA
- // custom options LOADING
+ if (_tcsncmp(option, _T("input."), 6) == 0) {
+ read_inputdevice_config(p, option, value);
+ return 1;
+ }
-
- for (int i=0; i<4 ; ++i) // Loop 1 ... all 4 joyports
- {
- struct joypad_map_layout tempcustom = {};
-
- for (int m=0; m<2 ; ++m) // Loop 2 ... none/hotkey function keys
- {
- if (m == 0) {tmp1 = "none"; tempcustom = p->jports[i].amiberry_custom_none ;}
- else if (m == 1) {tmp1 = "hotkey"; tempcustom = p->jports[i].amiberry_custom_hotkey;}
-
- for (int n=0; n < 14; ++n) // Loop 3 ... all 14 buttons
- {
- _stprintf (tmpbuf, "joyport%d_amiberry_custom_%s_%s", i, tmp1, button_remap_name[n]);
-
- // this is where we need to check if we have this particular option!!
- if (!_tcsncmp (option, _T(tmpbuf), sizeof (tmpbuf) / sizeof (TCHAR)))
- {
- int b = 0;
- if (find_inputevent(value) > -1) {b = RemapEventList[find_inputevent(value)];}
- //else {b=0;}
+ for (tmpp = option; *tmpp != '\0'; tmpp++)
+ if (_istupper(*tmpp))
+ *tmpp = _totlower(*tmpp);
+ tmpp = _tcschr(option, '.');
+ if (tmpp) {
+ section = option;
+ option = tmpp + 1;
+ *tmpp = '\0';
+ if (_tcscmp(section, TARGET_NAME) == 0) {
+ /* We special case the various path options here. */
+ if (cfgfile_multipath(option, value, _T("rom_path"), &p->path_rom)
+ || cfgfile_multipath(option, value, _T("floppy_path"), &p->path_floppy)
+ || cfgfile_multipath(option, value, _T("cd_path"), &p->path_cd)
+ || cfgfile_multipath(option, value, _T("hardfile_path"), &p->path_hardfile))
+ return 1;
+ return target_parse_option(p, option, value);
+ }
+ return 0;
+ }
- if (n==0 ) {tempcustom.dpad_up_action = b;}
- if (n==1 ) {tempcustom.dpad_down_action = b;}
- if (n==2 ) {tempcustom.dpad_left_action = b;}
- if (n==3 ) {tempcustom.dpad_right_action = b;}
- if (n==4 ) {tempcustom.select_action = b;}
- if (n==5 ) {tempcustom.left_shoulder_action = b;}
- if (n==6 ) {tempcustom.lstick_select_action = b;}
- if (n==7 ) {tempcustom.north_action = b;}
- if (n==8 ) {tempcustom.south_action = b;}
- if (n==9 ) {tempcustom.east_action = b;}
- if (n==10) {tempcustom.west_action = b;}
- if (n==11) {tempcustom.start_action = b;}
- if (n==12) {tempcustom.right_shoulder_action = b;}
- if (n==13) {tempcustom.rstick_select_action = b;}
-
- if (m==0)
- { p->jports[i].amiberry_custom_none = tempcustom; }
-
- else if (m==1)
- { p->jports[i].amiberry_custom_hotkey = tempcustom; }
- return 1;
-
- } // close the IF check
- } // close loop 3
- } // close loop 2
- } // close loop 1
-
+ for (i = 0; i < MAX_SPARE_DRIVES; i++) {
+ _stprintf(tmpbuf, _T("diskimage%d"), i);
+ if (cfgfile_path(option, value, tmpbuf, p->dfxlist[i], sizeof p->dfxlist[i] / sizeof(TCHAR), &p->path_floppy)) {
+#if 0
+ if (i < 4 && !p->df[i][0])
+ _tcscpy(p->df[i], p->dfxlist[i]);
#endif
-
-
- for (tmpp = option; *tmpp != '\0'; tmpp++)
- if (_istupper (*tmpp))
- *tmpp = _totlower (*tmpp);
- tmpp = _tcschr (option, '.');
- if (tmpp) {
- section = option;
- option = tmpp + 1;
- *tmpp = '\0';
- if (_tcscmp (section, TARGET_NAME) == 0) {
- /* We special case the various path options here. */
- if (cfgfile_path (option, value, _T("rom_path"), p->path_rom, sizeof p->path_rom / sizeof (TCHAR))
- || cfgfile_path (option, value, _T("floppy_path"), p->path_floppy, sizeof p->path_floppy / sizeof (TCHAR))
- || cfgfile_path (option, value, _T("cd_path"), p->path_cd, sizeof p->path_cd / sizeof (TCHAR))
- || cfgfile_path (option, value, _T("hardfile_path"), p->path_hardfile, sizeof p->path_hardfile / sizeof (TCHAR)))
- return 1;
- return target_parse_option (p, option, value);
- }
- return 0;
- }
+ return 1;
+ }
+ }
for (i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) {
TCHAR tmp[20];
- _stprintf (tmp, _T("cdimage%d"), i);
- if (!_tcsicmp (option, tmp)) {
- if (!_tcsicmp (value, _T("autodetect"))) {
+ _stprintf(tmp, _T("cdimage%d"), i);
+ if (!_tcsicmp(option, tmp)) {
+ if (!_tcsicmp(value, _T("autodetect"))) {
p->cdslots[i].type = SCSI_UNIT_DEFAULT;
p->cdslots[i].inuse = true;
p->cdslots[i].name[0] = 0;
- } else {
+ }
+ else {
p->cdslots[i].delayed = false;
- TCHAR *next = _tcsrchr (value, ',');
+ TCHAR *next = _tcsrchr(value, ',');
int type = SCSI_UNIT_DEFAULT;
int mode = 0;
int unitnum = 0;
@@ -2028,19 +2740,19 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
if (!next)
break;
*next++ = 0;
- TCHAR *next2 = _tcschr (next, ':');
+ TCHAR *next2 = _tcschr(next, ':');
if (next2)
*next2++ = 0;
- if (!_tcsicmp (next, _T("delay"))) {
+ if (!_tcsicmp(next, _T("delay"))) {
p->cdslots[i].delayed = true;
next = next2;
if (!next)
break;
- next2 = _tcschr (next, ':');
+ next2 = _tcschr(next, ':');
if (next2)
*next2++ = 0;
}
- type = match_string (cdmodes, next);
+ type = match_string(cdmodes, next);
if (type < 0)
type = SCSI_UNIT_DEFAULT;
else
@@ -2048,24 +2760,24 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
next = next2;
if (!next)
break;
- next2 = _tcschr (next, ':');
+ next2 = _tcschr(next, ':');
if (next2)
*next2++ = 0;
- mode = match_string (cdconmodes, next);
+ mode = match_string(cdconmodes, next);
if (mode < 0)
mode = 0;
next = next2;
if (!next)
break;
- next2 = _tcschr (next, ':');
+ next2 = _tcschr(next, ':');
if (next2)
*next2++ = 0;
- cfgfile_intval (option, next, tmp, &unitnum, 1);
+ cfgfile_intval(option, next, tmp, &unitnum, 1);
}
- if (_tcslen (value) > 0) {
- TCHAR *s = cfgfile_subst_path (UNEXPANDED, p->path_cd, value);
- _tcsncpy (p->cdslots[i].name, s, sizeof p->cdslots[i].name / sizeof (TCHAR));
- xfree (s);
+ if (_tcslen(value) > 0) {
+ TCHAR *s = cfgfile_get_multipath(&p->path_cd, NULL, value, false);
+ _tcsncpy(p->cdslots[i].name, s, sizeof p->cdslots[i].name / sizeof(TCHAR));
+ xfree(s);
}
p->cdslots[i].name[sizeof p->cdslots[i].name - 1] = 0;
p->cdslots[i].inuse = true;
@@ -2081,269 +2793,779 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
}
}
- if (cfgfile_intval (option, value, _T("sound_frequency"), &p->sound_freq, 1)
- || cfgfile_intval (option, value, _T("sound_volume_cd"), &p->sound_volume_cd, 1)
- || cfgfile_intval (option, value, _T("sound_stereo_separation"), &p->sound_stereo_separation, 1)
- || cfgfile_intval (option, value, _T("sound_stereo_mixing_delay"), &p->sound_mixed_stereo_delay, 1)
+ if (!_tcsicmp(option, _T("lua"))) {
+ for (i = 0; i < MAX_LUA_STATES; i++) {
+ if (!p->luafiles[i][0]) {
+ _tcscpy(p->luafiles[i], value);
+ break;
+ }
+ }
+ return 1;
+ }
- || cfgfile_intval (option, value, _T("gfx_framerate"), &p->gfx_framerate, 1)
- || cfgfile_intval (option, value, _T("gfx_refreshrate"), &p->gfx_apmode[APMODE_NATIVE].gfx_refreshrate, 1)
- || cfgfile_intval (option, value, _T("gfx_refreshrate_rtg"), &p->gfx_apmode[APMODE_RTG].gfx_refreshrate, 1)
+ if (cfgfile_strval(option, value, _T("gfx_autoresolution_min_vertical"), &p->gfx_autoresolution_minv, vertmode, 0)) {
+ p->gfx_autoresolution_minv--;
+ return 1;
+ }
+ if (cfgfile_strval(option, value, _T("gfx_autoresolution_min_horizontal"), &p->gfx_autoresolution_minh, horizmode, 0)) {
+ p->gfx_autoresolution_minh--;
+ return 1;
+ }
+ if (!_tcsicmp(option, _T("gfx_autoresolution"))) {
+ p->gfx_autoresolution = 0;
+ cfgfile_intval(option, value, _T("gfx_autoresolution"), &p->gfx_autoresolution, 1);
+ if (!p->gfx_autoresolution) {
+ v = cfgfile_yesno(option, value, _T("gfx_autoresolution"), &vb);
+ if (v > 0)
+ p->gfx_autoresolution = vb ? 10 : 0;
+ }
+ return 1;
+ }
- || cfgfile_intval (option, value, _T("filesys_max_size"), &p->filesys_limit, 1)
- || cfgfile_intval (option, value, _T("filesys_max_name_length"), &p->filesys_max_name, 1)
- || cfgfile_yesno (option, value, _T("filesys_inject_icons"), &p->filesys_inject_icons)
- || cfgfile_string (option, value, _T("filesys_inject_icons_drawer"), p->filesys_inject_icons_drawer, sizeof p->filesys_inject_icons_drawer / sizeof (TCHAR))
- || cfgfile_string (option, value, _T("filesys_inject_icons_project"), p->filesys_inject_icons_project, sizeof p->filesys_inject_icons_project / sizeof (TCHAR))
- || cfgfile_string (option, value, _T("filesys_inject_icons_tool"), p->filesys_inject_icons_tool, sizeof p->filesys_inject_icons_tool / sizeof (TCHAR)))
- return 1;
+ if (cfgfile_intval(option, value, _T("sound_frequency"), &p->sound_freq, 1)
+ || cfgfile_intval(option, value, _T("sound_max_buff"), &p->sound_maxbsiz, 1)
+ || cfgfile_intval(option, value, _T("state_replay_rate"), &p->statecapturerate, 1)
+ || cfgfile_intval(option, value, _T("state_replay_buffers"), &p->statecapturebuffersize, 1)
+ || cfgfile_yesno(option, value, _T("state_replay_autoplay"), &p->inprec_autoplay)
+ || cfgfile_intval(option, value, _T("sound_frequency"), &p->sound_freq, 1)
+ || cfgfile_intval(option, value, _T("sound_volume"), &p->sound_volume_master, 1)
+ || cfgfile_intval(option, value, _T("sound_volume_paula"), &p->sound_volume_paula, 1)
+ || cfgfile_intval(option, value, _T("sound_volume_cd"), &p->sound_volume_cd, 1)
+ || cfgfile_intval(option, value, _T("sound_volume_ahi"), &p->sound_volume_board, 1)
+ || cfgfile_intval(option, value, _T("sound_volume_midi"), &p->sound_volume_midi, 1)
+ || cfgfile_intval(option, value, _T("sound_volume_genlock"), &p->sound_volume_genlock, 1)
+ || cfgfile_intval(option, value, _T("sound_stereo_separation"), &p->sound_stereo_separation, 1)
+ || cfgfile_intval(option, value, _T("sound_stereo_mixing_delay"), &p->sound_mixed_stereo_delay, 1)
+ || cfgfile_intval(option, value, _T("sampler_frequency"), &p->sampler_freq, 1)
+ || cfgfile_intval(option, value, _T("sampler_buffer"), &p->sampler_buffer, 1)
+ || cfgfile_intval(option, value, _T("warp_limit"), &p->turbo_emulation_limit, 1)
- if (cfgfile_string(option, value, _T("config_info"), p->info, sizeof p->info / sizeof(TCHAR))
+ || cfgfile_intval(option, value, _T("gfx_framerate"), &p->gfx_framerate, 1)
+ || cfgfile_intval(option, value, _T("gfx_top_windowed"), &p->gfx_size_win.x, 1)
+ || cfgfile_intval(option, value, _T("gfx_left_windowed"), &p->gfx_size_win.y, 1)
+ || cfgfile_intval(option, value, _T("gfx_refreshrate"), &p->gfx_apmode[APMODE_NATIVE].gfx_refreshrate, 1)
+ || cfgfile_intval(option, value, _T("gfx_refreshrate_rtg"), &p->gfx_apmode[APMODE_RTG].gfx_refreshrate, 1)
+ || cfgfile_intval(option, value, _T("gfx_autoresolution_delay"), &p->gfx_autoresolution_delay, 1)
+ || cfgfile_intval(option, value, _T("gfx_backbuffers"), &p->gfx_apmode[APMODE_NATIVE].gfx_backbuffers, 1)
+ || cfgfile_intval(option, value, _T("gfx_backbuffers_rtg"), &p->gfx_apmode[APMODE_RTG].gfx_backbuffers, 1)
+ || cfgfile_yesno(option, value, _T("gfx_interlace"), &p->gfx_apmode[APMODE_NATIVE].gfx_interlaced)
+ || cfgfile_yesno(option, value, _T("gfx_interlace_rtg"), &p->gfx_apmode[APMODE_RTG].gfx_interlaced)
+ || cfgfile_intval(option, value, _T("gfx_black_frame_insertion_ratio"), &p->lightboost_strobo_ratio, 1)
+
+ || cfgfile_intval(option, value, _T("gfx_center_horizontal_position"), &p->gfx_xcenter_pos, 1)
+ || cfgfile_intval(option, value, _T("gfx_center_vertical_position"), &p->gfx_ycenter_pos, 1)
+ || cfgfile_intval(option, value, _T("gfx_center_horizontal_size"), &p->gfx_xcenter_size, 1)
+ || cfgfile_intval(option, value, _T("gfx_center_vertical_size"), &p->gfx_ycenter_size, 1)
+
+ || cfgfile_intval(option, value, _T("filesys_max_size"), &p->filesys_limit, 1)
+ || cfgfile_intval(option, value, _T("filesys_max_name_length"), &p->filesys_max_name, 1)
+ || cfgfile_intval(option, value, _T("filesys_max_file_size"), &p->filesys_max_file_size, 1)
+ || cfgfile_yesno(option, value, _T("filesys_inject_icons"), &p->filesys_inject_icons)
+ || cfgfile_string(option, value, _T("filesys_inject_icons_drawer"), p->filesys_inject_icons_drawer, sizeof p->filesys_inject_icons_drawer / sizeof(TCHAR))
+ || cfgfile_string(option, value, _T("filesys_inject_icons_project"), p->filesys_inject_icons_project, sizeof p->filesys_inject_icons_project / sizeof(TCHAR))
+ || cfgfile_string(option, value, _T("filesys_inject_icons_tool"), p->filesys_inject_icons_tool, sizeof p->filesys_inject_icons_tool / sizeof(TCHAR))
+
+ || cfgfile_intval(option, value, _T("gfx_luminance"), &p->gfx_luminance, 1)
+ || cfgfile_intval(option, value, _T("gfx_contrast"), &p->gfx_contrast, 1)
+ || cfgfile_intval(option, value, _T("gfx_gamma"), &p->gfx_gamma, 1)
+ || cfgfile_intval(option, value, _T("gfx_gamma_r"), &p->gfx_gamma_ch[0], 1)
+ || cfgfile_intval(option, value, _T("gfx_gamma_g"), &p->gfx_gamma_ch[1], 1)
+ || cfgfile_intval(option, value, _T("gfx_gamma_b"), &p->gfx_gamma_ch[2], 1)
+ || cfgfile_floatval(option, value, _T("rtg_vert_zoom_multf"), &p->rtg_vert_zoom_mult)
+ || cfgfile_floatval(option, value, _T("rtg_horiz_zoom_multf"), &p->rtg_horiz_zoom_mult)
+ || cfgfile_intval(option, value, _T("gfx_horizontal_tweak"), &p->gfx_extrawidth, 1)
+
+ || cfgfile_intval(option, value, _T("floppy0sound"), &p->floppyslots[0].dfxclick, 1)
+ || cfgfile_intval(option, value, _T("floppy1sound"), &p->floppyslots[1].dfxclick, 1)
+ || cfgfile_intval(option, value, _T("floppy2sound"), &p->floppyslots[2].dfxclick, 1)
+ || cfgfile_intval(option, value, _T("floppy3sound"), &p->floppyslots[3].dfxclick, 1)
+ || cfgfile_intval(option, value, _T("floppy0soundvolume_disk"), &p->dfxclickvolume_disk[0], 1)
+ || cfgfile_intval(option, value, _T("floppy1soundvolume_disk"), &p->dfxclickvolume_disk[1], 1)
+ || cfgfile_intval(option, value, _T("floppy2soundvolume_disk"), &p->dfxclickvolume_disk[2], 1)
+ || cfgfile_intval(option, value, _T("floppy3soundvolume_disk"), &p->dfxclickvolume_disk[3], 1)
+ || cfgfile_intval(option, value, _T("floppy0soundvolume_empty"), &p->dfxclickvolume_empty[0], 1)
+ || cfgfile_intval(option, value, _T("floppy1soundvolume_empty"), &p->dfxclickvolume_empty[1], 1)
+ || cfgfile_intval(option, value, _T("floppy2soundvolume_empty"), &p->dfxclickvolume_empty[2], 1)
+ || cfgfile_intval(option, value, _T("floppy3soundvolume_empty"), &p->dfxclickvolume_empty[3], 1)
+ || cfgfile_intval(option, value, _T("floppy_channel_mask"), &p->dfxclickchannelmask, 1))
+ return 1;
+
+ if (cfgfile_path(option, value, _T("floppy0soundext"), p->floppyslots[0].dfxclickexternal, sizeof p->floppyslots[0].dfxclickexternal / sizeof(TCHAR))
+ || cfgfile_path(option, value, _T("floppy1soundext"), p->floppyslots[1].dfxclickexternal, sizeof p->floppyslots[1].dfxclickexternal / sizeof(TCHAR))
+ || cfgfile_path(option, value, _T("floppy2soundext"), p->floppyslots[2].dfxclickexternal, sizeof p->floppyslots[2].dfxclickexternal / sizeof(TCHAR))
+ || cfgfile_path(option, value, _T("floppy3soundext"), p->floppyslots[3].dfxclickexternal, sizeof p->floppyslots[3].dfxclickexternal / sizeof(TCHAR))
+ || cfgfile_string(option, value, _T("config_window_title"), p->config_window_title, sizeof p->config_window_title / sizeof(TCHAR))
+ || cfgfile_string(option, value, _T("config_info"), p->info, sizeof p->info / sizeof(TCHAR))
|| cfgfile_string(option, value, _T("config_description"), p->description, sizeof p->description / sizeof(TCHAR)))
return 1;
- if (cfgfile_yesno (option, value, _T("floppy0wp"), &p->floppyslots[0].forcedwriteprotect)
- || cfgfile_yesno (option, value, _T("floppy1wp"), &p->floppyslots[1].forcedwriteprotect)
- || cfgfile_yesno (option, value, _T("floppy2wp"), &p->floppyslots[2].forcedwriteprotect)
- || cfgfile_yesno (option, value, _T("floppy3wp"), &p->floppyslots[3].forcedwriteprotect)
- || cfgfile_yesno (option, value, _T("bsdsocket_emu"), &p->socket_emu))
- return 1;
-
- if (cfgfile_strval (option, value, _T("sound_output"), &p->produce_sound, soundmode1, 1)
- || cfgfile_strval (option, value, _T("sound_output"), &p->produce_sound, soundmode2, 0)
- || cfgfile_strval (option, value, _T("sound_interpol"), &p->sound_interpol, interpolmode, 0)
- || cfgfile_strval (option, value, _T("sound_filter"), &p->sound_filter, soundfiltermode1, 0)
- || cfgfile_strval (option, value, _T("sound_filter_type"), &p->sound_filter_type, soundfiltermode2, 0)
- || cfgfile_strboolval (option, value, _T("use_gui"), &p->start_gui, guimode1, 1)
- || cfgfile_strboolval (option, value, _T("use_gui"), &p->start_gui, guimode2, 1)
- || cfgfile_strboolval (option, value, _T("use_gui"), &p->start_gui, guimode3, 0)
- || cfgfile_strval (option, value, _T("gfx_resolution"), &p->gfx_resolution, lorestype1, 0)
- || cfgfile_strval (option, value, _T("gfx_lores"), &p->gfx_resolution, lorestype2, 0)
- || cfgfile_strval (option, value, _T("absolute_mouse"), &p->input_tablet, abspointers, 0))
- return 1;
-
- if (_tcscmp (option, _T("gfx_width_windowed")) == 0) {
+ if (cfgfile_yesno(option, value, _T("use_debugger"), &p->start_debugger)
+ || cfgfile_yesno(option, value, _T("floppy0wp"), &p->floppyslots[0].forcedwriteprotect)
+ || cfgfile_yesno(option, value, _T("floppy1wp"), &p->floppyslots[1].forcedwriteprotect)
+ || cfgfile_yesno(option, value, _T("floppy2wp"), &p->floppyslots[2].forcedwriteprotect)
+ || cfgfile_yesno(option, value, _T("floppy3wp"), &p->floppyslots[3].forcedwriteprotect)
+ || cfgfile_yesno(option, value, _T("sampler_stereo"), &p->sampler_stereo)
+ || cfgfile_yesno(option, value, _T("sound_auto"), &p->sound_auto)
+ || cfgfile_yesno(option, value, _T("sound_cdaudio"), &p->sound_cdaudio)
+ || cfgfile_yesno(option, value, _T("sound_stereo_swap_paula"), &p->sound_stereo_swap_paula)
+ || cfgfile_yesno(option, value, _T("sound_stereo_swap_ahi"), &p->sound_stereo_swap_ahi)
+ || cfgfile_yesno(option, value, _T("log_illegal_mem"), &p->illegal_mem)
+ || cfgfile_yesno(option, value, _T("filesys_no_fsdb"), &p->filesys_no_uaefsdb)
+ || cfgfile_yesno(option, value, _T("gfx_monochrome"), &p->gfx_grayscale)
+ || cfgfile_yesno(option, value, _T("gfx_blacker_than_black"), &p->gfx_blackerthanblack)
+ || cfgfile_yesno(option, value, _T("gfx_black_frame_insertion"), &p->lightboost_strobo)
+ || cfgfile_yesno(option, value, _T("gfx_flickerfixer"), &p->gfx_scandoubler)
+ || cfgfile_yesno(option, value, _T("gfx_autoresolution_vga"), &p->gfx_autoresolution_vga)
+ || cfgfile_yesno(option, value, _T("show_refresh_indicator"), &p->refresh_indicator)
+ || cfgfile_yesno(option, value, _T("warp"), &p->turbo_emulation)
+ || cfgfile_yesno(option, value, _T("headless"), &p->headless)
+ || cfgfile_yesno(option, value, _T("clipboard_sharing"), &p->clipboard_sharing)
+ || cfgfile_yesno(option, value, _T("native_code"), &p->native_code)
+ || cfgfile_yesno(option, value, _T("tablet_library"), &p->tablet_library)
+ || cfgfile_yesno(option, value, _T("bsdsocket_emu"), &p->socket_emu))
return 1;
- }
- if (_tcscmp (option, _T("gfx_height_windowed")) == 0) {
+
+ if (cfgfile_strval(option, value, _T("sound_output"), &p->produce_sound, soundmode1, 1)
+ || cfgfile_strval(option, value, _T("sound_output"), &p->produce_sound, soundmode2, 0)
+ || cfgfile_strval(option, value, _T("sound_interpol"), &p->sound_interpol, interpolmode, 0)
+ || cfgfile_strval(option, value, _T("sound_filter"), &p->sound_filter, soundfiltermode1, 0)
+ || cfgfile_strval(option, value, _T("sound_filter_type"), &p->sound_filter_type, soundfiltermode2, 0)
+ || cfgfile_strboolval(option, value, _T("use_gui"), &p->start_gui, guimode1, 1)
+ || cfgfile_strboolval(option, value, _T("use_gui"), &p->start_gui, guimode2, 1)
+ || cfgfile_strboolval(option, value, _T("use_gui"), &p->start_gui, guimode3, 0)
+ || cfgfile_strval(option, value, _T("gfx_resolution"), &p->gfx_resolution, lorestype1, 0)
+ || cfgfile_strval(option, value, _T("gfx_lores"), &p->gfx_resolution, lorestype2, 0)
+ || cfgfile_strval(option, value, _T("gfx_lores_mode"), &p->gfx_lores_mode, loresmode, 0)
+ || cfgfile_strval(option, value, _T("gfx_fullscreen_amiga"), &p->gfx_apmode[APMODE_NATIVE].gfx_fullscreen, fullmodes, 0)
+ || cfgfile_strval(option, value, _T("gfx_fullscreen_picasso"), &p->gfx_apmode[APMODE_RTG].gfx_fullscreen, fullmodes, 0)
+ || cfgfile_strval(option, value, _T("gfx_center_horizontal"), &p->gfx_xcenter, centermode1, 1)
+ || cfgfile_strval(option, value, _T("gfx_center_vertical"), &p->gfx_ycenter, centermode1, 1)
+ || cfgfile_strval(option, value, _T("gfx_center_horizontal"), &p->gfx_xcenter, centermode2, 0)
+ || cfgfile_strval(option, value, _T("gfx_center_vertical"), &p->gfx_ycenter, centermode2, 0)
+ || cfgfile_strval(option, value, _T("gfx_colour_mode"), &p->color_mode, colormode1, 1)
+ || cfgfile_strval(option, value, _T("gfx_colour_mode"), &p->color_mode, colormode2, 0)
+ || cfgfile_strval(option, value, _T("gfx_color_mode"), &p->color_mode, colormode1, 1)
+ || cfgfile_strval(option, value, _T("gfx_color_mode"), &p->color_mode, colormode2, 0)
+ || cfgfile_strval(option, value, _T("gfx_max_horizontal"), &p->gfx_max_horizontal, maxhoriz, 0)
+ || cfgfile_strval(option, value, _T("gfx_max_vertical"), &p->gfx_max_vertical, maxvert, 0)
+ || cfgfile_strval(option, value, _T("gfx_api"), &p->gfx_api, filterapi, 0)
+ || cfgfile_strval(option, value, _T("gfx_atari_palette_fix"), &p->gfx_threebitcolors, threebitcolors, 0)
+ || cfgfile_strval(option, value, _T("magic_mousecursor"), &p->input_magic_mouse_cursor, magiccursors, 0)
+ || cfgfile_strval(option, value, _T("absolute_mouse"), &p->input_tablet, abspointers, 0))
+ return 1;
+
+ if (cfgfile_yesno(option, value, _T("magic_mouse"), &vb)) {
+ p->input_mouse_untrap |= MOUSEUNTRAP_MAGIC;
return 1;
}
- if (_tcscmp (option, _T("gfx_width_fullscreen")) == 0) {
- return 1;
+
+#ifdef GFXFILTER
+ for (int j = 0; j < 2; j++) {
+ struct gfx_filterdata *gf = &p->gf[j];
+ const TCHAR *ext = j == 0 ? NULL : _T("_rtg");
+ if (cfgfile_strval(option, value, _T("gfx_filter_autoscale"), ext, &gf->gfx_filter_autoscale, j == 0 ? autoscale : autoscale_rtg, 0)
+ || cfgfile_strval(option, value, _T("gfx_filter_keep_aspect"), ext, &gf->gfx_filter_keep_aspect, aspects, 0)
+ || cfgfile_strval(option, value, _T("gfx_filter_autoscale_limit"), ext, &gf->gfx_filter_integerscalelimit, autoscalelimit, 0))
+ return 1;
+
+ if (cfgfile_floatval(option, value, _T("gfx_filter_vert_zoomf"), ext, &gf->gfx_filter_vert_zoom)
+ || cfgfile_floatval(option, value, _T("gfx_filter_horiz_zoomf"), ext, &gf->gfx_filter_horiz_zoom)
+ || cfgfile_floatval(option, value, _T("gfx_filter_vert_zoom_multf"), ext, &gf->gfx_filter_vert_zoom_mult)
+ || cfgfile_floatval(option, value, _T("gfx_filter_horiz_zoom_multf"), ext, &gf->gfx_filter_horiz_zoom_mult)
+ || cfgfile_floatval(option, value, _T("gfx_filter_vert_offsetf"), ext, &gf->gfx_filter_vert_offset)
+ || cfgfile_floatval(option, value, _T("gfx_filter_horiz_offsetf"), ext, &gf->gfx_filter_horiz_offset)
+ || cfgfile_intval(option, value, _T("gfx_filter_left_border"), ext, &gf->gfx_filter_left_border, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_right_border"), ext, &gf->gfx_filter_right_border, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_top_border"), ext, &gf->gfx_filter_top_border, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_bottom_border"), ext, &gf->gfx_filter_bottom_border, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_scanlines"), ext, &gf->gfx_filter_scanlines, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_scanlinelevel"), ext, &gf->gfx_filter_scanlinelevel, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_scanlineratio"), ext, &gf->gfx_filter_scanlineratio, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_luminance"), ext, &gf->gfx_filter_luminance, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_contrast"), ext, &gf->gfx_filter_contrast, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_saturation"), ext, &gf->gfx_filter_saturation, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_gamma"), ext, &gf->gfx_filter_gamma, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_gamma_r"), ext, &gf->gfx_filter_gamma_ch[0], 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_gamma_g"), ext, &gf->gfx_filter_gamma_ch[1], 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_gamma_b"), ext, &gf->gfx_filter_gamma_ch[2], 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_blur"), ext, &gf->gfx_filter_blur, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_noise"), ext, &gf->gfx_filter_noise, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_bilinear"), ext, &gf->gfx_filter_bilinear, 1)
+ || cfgfile_intval(option, value, _T("gfx_filter_keep_autoscale_aspect"), ext, &gf->gfx_filter_keep_autoscale_aspect, 1)
+ || cfgfile_string(option, value, _T("gfx_filter_mask"), ext, gf->gfx_filtermask[2 * MAX_FILTERSHADERS], sizeof gf->gfx_filtermask[2 * MAX_FILTERSHADERS] / sizeof(TCHAR)))
+ return 1;
}
- if (_tcscmp (option, _T("gfx_height_fullscreen")) == 0) {
+#endif
+
+ if (cfgfile_intval(option, value, _T("floppy_volume"), &v, 1)) {
+ for (int i = 0; i < 4; i++) {
+ p->dfxclickvolume_disk[i] = v;
+ p->dfxclickvolume_empty[i] = v;
+ }
return 1;
}
- if (_tcscmp (option, _T("gfx_vsync")) == 0) {
- if (cfgfile_strval (option, value, _T("gfx_vsync"), &p->gfx_apmode[APMODE_NATIVE].gfx_vsync, vsyncmodes, 0) >= 0) {
+ if (_tcscmp(option, _T("gfx_width_windowed")) == 0) {
+ if (!_tcscmp(value, _T("native"))) {
+ p->gfx_size_win.width = 0;
+ p->gfx_size_win.height = 0;
+ }
+ else {
+ cfgfile_intval(option, value, _T("gfx_width_windowed"), &p->gfx_size_win.width, 1);
+ }
+ return 1;
+ }
+ if (_tcscmp(option, _T("gfx_height_windowed")) == 0) {
+ if (!_tcscmp(value, _T("native"))) {
+ p->gfx_size_win.width = 0;
+ p->gfx_size_win.height = 0;
+ }
+ else {
+ cfgfile_intval(option, value, _T("gfx_height_windowed"), &p->gfx_size_win.height, 1);
+ }
+ return 1;
+ }
+ if (_tcscmp(option, _T("gfx_width_fullscreen")) == 0) {
+ if (!_tcscmp(value, _T("native"))) {
+ p->gfx_size_fs.width = 0;
+ p->gfx_size_fs.height = 0;
+ p->gfx_size_fs.special = WH_NATIVE;
+ }
+ else {
+ cfgfile_intval(option, value, _T("gfx_width_fullscreen"), &p->gfx_size_fs.width, 1);
+ p->gfx_size_fs.special = 0;
+ }
+ return 1;
+ }
+ if (_tcscmp(option, _T("gfx_height_fullscreen")) == 0) {
+ if (!_tcscmp(value, _T("native"))) {
+ p->gfx_size_fs.width = 0;
+ p->gfx_size_fs.height = 0;
+ p->gfx_size_fs.special = WH_NATIVE;
+ }
+ else {
+ cfgfile_intval(option, value, _T("gfx_height_fullscreen"), &p->gfx_size_fs.height, 1);
+ p->gfx_size_fs.special = 0;
+ }
+ return 1;
+ }
+
+ if (cfgfile_intval(option, value, _T("gfx_display"), &p->gfx_apmode[APMODE_NATIVE].gfx_display, 1)) {
+ p->gfx_apmode[APMODE_RTG].gfx_display = p->gfx_apmode[APMODE_NATIVE].gfx_display;
+ return 1;
+ }
+ if (cfgfile_intval(option, value, _T("gfx_display_rtg"), &p->gfx_apmode[APMODE_RTG].gfx_display, 1)) {
+ return 1;
+ }
+ if (_tcscmp(option, _T("gfx_display_friendlyname")) == 0 || _tcscmp(option, _T("gfx_display_name")) == 0) {
+ TCHAR tmp[MAX_DPATH];
+ if (cfgfile_string(option, value, _T("gfx_display_friendlyname"), tmp, sizeof tmp / sizeof(TCHAR))) {
+ int num = target_get_display(tmp);
+ if (num >= 0)
+ p->gfx_apmode[APMODE_RTG].gfx_display = p->gfx_apmode[APMODE_NATIVE].gfx_display = num;
+ }
+ if (cfgfile_string(option, value, _T("gfx_display_name"), tmp, sizeof tmp / sizeof(TCHAR))) {
+ int num = target_get_display(tmp);
+ if (num >= 0)
+ p->gfx_apmode[APMODE_RTG].gfx_display = p->gfx_apmode[APMODE_NATIVE].gfx_display = num;
+ }
+ return 1;
+ }
+ if (_tcscmp(option, _T("gfx_display_friendlyname_rtg")) == 0 || _tcscmp(option, _T("gfx_display_name_rtg")) == 0) {
+ TCHAR tmp[MAX_DPATH];
+ if (cfgfile_string(option, value, _T("gfx_display_friendlyname_rtg"), tmp, sizeof tmp / sizeof(TCHAR))) {
+ int num = target_get_display(tmp);
+ if (num >= 0)
+ p->gfx_apmode[APMODE_RTG].gfx_display = num;
+ }
+ if (cfgfile_string(option, value, _T("gfx_display_name_rtg"), tmp, sizeof tmp / sizeof(TCHAR))) {
+ int num = target_get_display(tmp);
+ if (num >= 0)
+ p->gfx_apmode[APMODE_RTG].gfx_display = num;
+ }
+ return 1;
+ }
+
+ if (_tcscmp(option, _T("gfx_linemode")) == 0) {
+ int v;
+ p->gfx_vresolution = VRES_DOUBLE;
+ p->gfx_pscanlines = 0;
+ p->gfx_iscanlines = 0;
+ if (cfgfile_strval(option, value, _T("gfx_linemode"), &v, linemode, 0)) {
+ p->gfx_vresolution = VRES_NONDOUBLE;
+ if (v > 0) {
+ p->gfx_iscanlines = (v - 1) / 4;
+ p->gfx_pscanlines = (v - 1) % 4;
+ p->gfx_vresolution = VRES_DOUBLE;
+ }
+ }
+ return 1;
+ }
+ if (_tcscmp(option, _T("gfx_vsync")) == 0) {
+ if (cfgfile_strval(option, value, _T("gfx_vsync"), &p->gfx_apmode[APMODE_NATIVE].gfx_vsync, vsyncmodes, 0) >= 0) {
p->gfx_apmode[APMODE_NATIVE].gfx_vsync--;
return 1;
}
- return cfgfile_yesno (option, value, _T("gfx_vsync"), &p->gfx_apmode[APMODE_NATIVE].gfx_vsync);
+ return cfgfile_yesno(option, value, _T("gfx_vsync"), &p->gfx_apmode[APMODE_NATIVE].gfx_vsync);
}
- if (_tcscmp (option, _T("gfx_vsync_picasso")) == 0) {
- if (cfgfile_strval (option, value, _T("gfx_vsync_picasso"), &p->gfx_apmode[APMODE_RTG].gfx_vsync, vsyncmodes, 0) >= 0) {
+ if (_tcscmp(option, _T("gfx_vsync_picasso")) == 0) {
+ if (cfgfile_strval(option, value, _T("gfx_vsync_picasso"), &p->gfx_apmode[APMODE_RTG].gfx_vsync, vsyncmodes, 0) >= 0) {
p->gfx_apmode[APMODE_RTG].gfx_vsync--;
return 1;
}
- return cfgfile_yesno (option, value, _T("gfx_vsync_picasso"), &p->gfx_apmode[APMODE_RTG].gfx_vsync);
+ return cfgfile_yesno(option, value, _T("gfx_vsync_picasso"), &p->gfx_apmode[APMODE_RTG].gfx_vsync);
}
-
- if(cfgfile_yesno (option, value, _T("show_leds"), &vb)) {
- p->leds_on_screen = vb;
+ if (cfgfile_strval(option, value, _T("gfx_vsyncmode"), &p->gfx_apmode[APMODE_NATIVE].gfx_vsyncmode, vsyncmodes2, 0))
return 1;
- }
-
- if (_tcscmp (option, _T("gfx_width")) == 0 || _tcscmp (option, _T("gfx_height")) == 0) {
- cfgfile_intval (option, value, _T("gfx_width"), &p->gfx_size.width, 1);
- cfgfile_intval (option, value, _T("gfx_height"), &p->gfx_size.height, 1);
- return 1;
- }
-
-// olde versions (compatibility)
-
- if (_tcscmp (option, _T("joyportfriendlyname0")) == 0 || _tcscmp (option, _T("joyportfriendlyname1")) == 0) {
- inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportfriendlyname0")) == 0 ? 0 : 1, -1, 2);
- return 1;
- }
- if (_tcscmp (option, _T("joyportfriendlyname2")) == 0 || _tcscmp (option, _T("joyportfriendlyname3")) == 0) {
- inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportfriendlyname2")) == 0 ? 2 : 3, -1, 2);
- return 1;
- }
- if (_tcscmp (option, _T("joyportname0")) == 0 || _tcscmp (option, _T("joyportname1")) == 0) {
- inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportname0")) == 0 ? 0 : 1, -1, 1);
- return 1;
- }
- if (_tcscmp (option, _T("joyportname2")) == 0 || _tcscmp (option, _T("joyportname3")) == 0) {
- inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyportname2")) == 0 ? 2 : 3, -1, 1);
- return 1;
- }
-
-
- // new versions
- if (_tcscmp (option, _T("joyport0_friendlyname")) == 0 || _tcscmp (option, _T("joyport1_friendlyname")) == 0) {
- inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyport0_friendlyname")) == 0 ? 0 : 1, -1, 2);
- return 1;
- }
- if (_tcscmp (option, _T("joyport2_friendlyname")) == 0 || _tcscmp (option, _T("joyport3_friendlyname")) == 0) {
- inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyport2_friendlyname")) == 0 ? 2 : 3, -1, 2);
- return 1;
- }
- if (_tcscmp (option, _T("joyport0_name")) == 0 || _tcscmp (option, _T("joyport1_name")) == 0) {
- inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyport0_name")) == 0 ? 0 : 1, -1, 1);
- return 1;
- }
- if (_tcscmp (option, _T("joyport2_name")) == 0 || _tcscmp (option, _T("joyport3_name")) == 0) {
- inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyport2_name")) == 0 ? 2 : 3, -1, 1);
- return 1;
- }
-
-// old version only
- if (_tcscmp (option, _T("joyport0")) == 0 || _tcscmp (option, _T("joyport1")) == 0) {
- inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyport0")) == 0 ? 0 : 1, -1, 0);
- return 1;
- }
- if (_tcscmp (option, _T("joyport2")) == 0 || _tcscmp (option, _T("joyport3")) == 0) {
- inputdevice_joyport_config_store(p, value, _tcscmp (option, _T("joyport2")) == 0 ? 2 : 3, -1, 0);
- return 1;
- }
-
- // shared version
- if (cfgfile_strval (option, value, _T("joyport0_mode"), &p->jports[0].mode, joyportmodes, 0) ||
- cfgfile_strval (option, value, _T("joyport0mode"), &p->jports[0].mode, joyportmodes, 0))
- return 1;
- if (cfgfile_strval (option, value, _T("joyport1_mode"), &p->jports[1].mode, joyportmodes, 0) ||
- cfgfile_strval (option, value, _T("joyport1mode"), &p->jports[1].mode, joyportmodes, 0) )
+ if (cfgfile_strval(option, value, _T("gfx_vsyncmode_picasso"), &p->gfx_apmode[APMODE_RTG].gfx_vsyncmode, vsyncmodes2, 0))
return 1;
- if (cfgfile_strval (option, value, _T("joyport0autofire"), &p->jports[0].autofire, joyaf, 0) ||
- cfgfile_strval (option, value, _T("joyport0_autofire"), &p->jports[0].autofire, joyaf, 0))
+ if (cfgfile_yesno(option, value, _T("show_leds"), &vb)) {
+ if (vb)
+ p->leds_on_screen |= STATUSLINE_CHIPSET;
+ else
+ p->leds_on_screen &= ~STATUSLINE_CHIPSET;
return 1;
- if (cfgfile_strval (option, value, _T("joyport1autofire"), &p->jports[1].autofire, joyaf, 0) ||
- cfgfile_strval (option, value, _T("joyport1_autofire"), &p->jports[1].autofire, joyaf, 0))
+ }
+ if (cfgfile_yesno(option, value, _T("show_leds_rtg"), &vb)) {
+ if (vb)
+ p->leds_on_screen |= STATUSLINE_RTG;
+ else
+ p->leds_on_screen &= ~STATUSLINE_RTG;
return 1;
- if (cfgfile_strval (option, value, _T("joyport2autofire"), &p->jports[2].autofire, joyaf, 0) ||
- cfgfile_strval (option, value, _T("joyport2_autofire"), &p->jports[2].autofire, joyaf, 0))
+ }
+ if (_tcscmp(option, _T("show_leds_enabled")) == 0 || _tcscmp(option, _T("show_leds_enabled_rtg")) == 0) {
+ TCHAR tmp[MAX_DPATH];
+ int idx = _tcscmp(option, _T("show_leds_enabled")) == 0 ? 0 : 1;
+ p->leds_on_screen_mask[idx] = 0;
+ _tcscpy(tmp, value);
+ _tcscat(tmp, _T(","));
+ TCHAR *s = tmp;
+ for (;;) {
+ TCHAR *s2 = s;
+ TCHAR *s3 = _tcschr(s, ':');
+ s = _tcschr(s, ',');
+ if (!s)
+ break;
+ if (s3 && s3 < s)
+ s = s3;
+ *s = 0;
+ for (int i = 0; leds[i]; i++) {
+ if (!_tcsicmp(s2, leds[i])) {
+ p->leds_on_screen_mask[idx] |= 1 << i;
+ }
+ }
+ s++;
+ }
return 1;
- if (cfgfile_strval (option, value, _T("joyport3autofire"), &p->jports[3].autofire, joyaf, 0) ||
- cfgfile_strval (option, value, _T("joyport3_autofire"), &p->jports[3].autofire, joyaf, 0))
+ }
+
+ if (!_tcscmp(option, _T("osd_position"))) {
+ TCHAR *s = value;
+ p->osd_pos.x = 0;
+ p->osd_pos.y = 0;
+ while (s) {
+ if (!_tcschr(s, ':'))
+ break;
+ p->osd_pos.x = (int)(_tstof(s) * 10.0);
+ s = _tcschr(s, ':');
+ if (!s)
+ break;
+ if (s[-1] == '%')
+ p->osd_pos.x += 30000;
+ s++;
+ p->osd_pos.y = (int)(_tstof(s) * 10.0);
+ s += _tcslen(s);
+ if (s[-1] == '%')
+ p->osd_pos.y += 30000;
+ break;
+ }
return 1;
-
-
-#ifndef PANDORA
- if (cfgfile_strval(option, value, _T("joyport0_mousemap"), &p->jports[0].mousemap, mousemaps, 0))
+ }
+
+#ifdef GFXFILTER
+ for (int j = 0; j < 2; j++) {
+ struct gfx_filterdata *gf = &p->gf[j];
+ if ((j == 0 && _tcscmp(option, _T("gfx_filter_overlay")) == 0) || (j == 1 && _tcscmp(option, _T("gfx_filter_overlay_rtg")) == 0)) {
+ TCHAR *s = _tcschr(value, ',');
+ gf->gfx_filteroverlay_overscan = 0;
+ gf->gfx_filteroverlay_pos.x = 0;
+ gf->gfx_filteroverlay_pos.y = 0;
+ gf->gfx_filteroverlay_pos.width = 0;
+ gf->gfx_filteroverlay_pos.height = 0;
+ if (s)
+ *s = 0;
+ while (s) {
+ *s++ = 0;
+ gf->gfx_filteroverlay_overscan = _tstol(s);
+ s = _tcschr(s, ':');
+ if (!s)
+ break;
+ break;
+ }
+ _tcsncpy(gf->gfx_filteroverlay, value, sizeof gf->gfx_filteroverlay / sizeof(TCHAR) - 1);
+ gf->gfx_filteroverlay[sizeof gf->gfx_filteroverlay / sizeof(TCHAR) - 1] = 0;
+ return 1;
+ }
+
+ if ((j == 0 && (_tcscmp(option, _T("gfx_filtermask_pre")) == 0 || _tcscmp(option, _T("gfx_filtermask_post")) == 0)) ||
+ (j == 1 && (_tcscmp(option, _T("gfx_filtermask_pre_rtg")) == 0 || _tcscmp(option, _T("gfx_filtermask_post_rtg")) == 0))) {
+ if (_tcscmp(option, _T("gfx_filtermask_pre")) == 0 || _tcscmp(option, _T("gfx_filtermask_pre_rtg")) == 0) {
+ for (int i = 0; i < MAX_FILTERSHADERS; i++) {
+ if (gf->gfx_filtermask[i][0] == 0) {
+ _tcscpy(gf->gfx_filtermask[i], value);
+ break;
+ }
+ }
+ }
+ else {
+ for (int i = 0; i < MAX_FILTERSHADERS; i++) {
+ if (gf->gfx_filtermask[i + MAX_FILTERSHADERS][0] == 0) {
+ _tcscpy(gf->gfx_filtermask[i + MAX_FILTERSHADERS], value);
+ break;
+ }
+ }
+ }
+ return 1;
+ }
+
+ if ((j == 0 && (_tcscmp(option, _T("gfx_filter_pre")) == 0 || _tcscmp(option, _T("gfx_filter_post")) == 0)) ||
+ (j == 1 && (_tcscmp(option, _T("gfx_filter_pre_rtg")) == 0 || _tcscmp(option, _T("gfx_filter_post_rtg")) == 0))) {
+ TCHAR *s = _tcschr(value, ':');
+ if (s) {
+ *s++ = 0;
+ if (!_tcscmp(value, _T("D3D"))) {
+ p->gfx_api = 1;
+ if (_tcscmp(option, _T("gfx_filter_pre")) == 0 || _tcscmp(option, _T("gfx_filter_pre_rtg")) == 0) {
+ for (int i = 0; i < MAX_FILTERSHADERS; i++) {
+ if (gf->gfx_filtershader[i][0] == 0) {
+ _tcscpy(gf->gfx_filtershader[i], s);
+ break;
+ }
+ }
+ }
+ else {
+ for (int i = 0; i < MAX_FILTERSHADERS; i++) {
+ if (gf->gfx_filtershader[i + MAX_FILTERSHADERS][0] == 0) {
+ _tcscpy(gf->gfx_filtershader[i + MAX_FILTERSHADERS], s);
+ break;
+ }
+ }
+ }
+ }
+ }
+ return 1;
+ }
+
+ if ((j == 0 && _tcscmp(option, _T("gfx_filter")) == 0) || (j == 1 && _tcscmp(option, _T("gfx_filter_rtg")) == 0)) {
+ TCHAR *s = _tcschr(value, ':');
+ gf->gfx_filter = 0;
+ if (s) {
+ *s++ = 0;
+ if (!_tcscmp(value, _T("D3D"))) {
+ p->gfx_api = 1;
+ _tcscpy(gf->gfx_filtershader[2 * MAX_FILTERSHADERS], s);
+ for (int i = 0; i < 2 * MAX_FILTERSHADERS; i++) {
+ if (!_tcsicmp(gf->gfx_filtershader[i], s)) {
+ gf->gfx_filtershader[i][0] = 0;
+ gf->gfx_filtermask[i][0] = 0;
+ }
+ }
+ }
+ }
+ if (!_tcscmp(value, _T("none"))) {
+ gf->gfx_filtershader[2 * MAX_FILTERSHADERS][0] = 0;
+ for (int i = 0; i < 2 * MAX_FILTERSHADERS; i++) {
+ gf->gfx_filtershader[i][0] = 0;
+ gf->gfx_filtermask[i][0] = 0;
+ }
+ }
+ else if (!_tcscmp(value, _T("direct3d"))) {
+ p->gfx_api = 1; // forwards compatibiity
+ }
+ else {
+ int i = 0;
+ while (uaefilters[i].name) {
+ if (!_tcscmp(uaefilters[i].cfgname, value)) {
+ gf->gfx_filter = uaefilters[i].type;
+ break;
+ }
+ i++;
+ }
+ }
+ return 1;
+ }
+ if (j == 0 && _tcscmp(option, _T("gfx_filter_mode")) == 0) {
+ cfgfile_strval(option, value, _T("gfx_filter_mode"), &gf->gfx_filter_filtermode, filtermode2, 0);
+ return 1;
+ }
+ if (j == 1 && _tcscmp(option, _T("gfx_filter_mode_rtg")) == 0) {
+ cfgfile_strval(option, value, _T("gfx_filter_mode_rtg"), &gf->gfx_filter_filtermode, filtermode2, 0);
+ return 1;
+ }
+
+ if ((j == 0 && cfgfile_string(option, value, _T("gfx_filter_aspect_ratio"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) ||
+ (j == 1 && cfgfile_string(option, value, _T("gfx_filter_aspect_ratio_rtg"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR)))) {
+ int v1, v2;
+ TCHAR *s;
+
+ gf->gfx_filter_aspect = -1;
+ v1 = _tstol(tmpbuf);
+ s = _tcschr(tmpbuf, ':');
+ if (s) {
+ v2 = _tstol(s + 1);
+ if (v1 < 0 || v2 < 0)
+ gf->gfx_filter_aspect = -1;
+ else if (v1 == 0 || v2 == 0)
+ gf->gfx_filter_aspect = 0;
+ else
+ gf->gfx_filter_aspect = v1 * ASPECTMULT + v2;
+ }
+ return 1;
+ }
+ }
+#endif
+
+ if (_tcscmp(option, _T("gfx_width")) == 0 || _tcscmp(option, _T("gfx_height")) == 0) {
+ cfgfile_intval(option, value, _T("gfx_width"), &p->gfx_size_win.width, 1);
+ cfgfile_intval(option, value, _T("gfx_height"), &p->gfx_size_win.height, 1);
+ p->gfx_size_fs.width = p->gfx_size_win.width;
+ p->gfx_size_fs.height = p->gfx_size_win.height;
return 1;
- if (cfgfile_strval(option, value, _T("joyport1_mousemap"), &p->jports[1].mousemap, mousemaps, 0))
+ }
+
+ if (_tcscmp(option, _T("gfx_fullscreen_multi")) == 0 || _tcscmp(option, _T("gfx_windowed_multi")) == 0) {
+ TCHAR tmp[256], *tmpp, *tmpp2;
+ struct wh *wh = p->gfx_size_win_xtra;
+ if (_tcscmp(option, _T("gfx_fullscreen_multi")) == 0)
+ wh = p->gfx_size_fs_xtra;
+ _stprintf(tmp, _T(",%s,"), value);
+ tmpp2 = tmp;
+ for (i = 0; i < 4; i++) {
+ tmpp = _tcschr(tmpp2, ',');
+ tmpp++;
+ wh[i].width = _tstol(tmpp);
+ while (*tmpp != ',' && *tmpp != 'x' && *tmpp != '*')
+ tmpp++;
+ wh[i].height = _tstol(tmpp + 1);
+ tmpp2 = tmpp;
+ }
return 1;
-#endif
-
-// shared version
- if (cfgfile_yesno (option, value, _T("joyport0keyboardoverride"), &vb) ||
- cfgfile_yesno (option, value, _T("joyport0_keyboardoverride"), &vb)) {
+ }
+
+ if (cfgfile_string(option, value, _T("joyportcustom0"), p->jports_custom[0].custom, sizeof p->jports_custom[0].custom / sizeof(TCHAR)))
+ return 1;
+ if (cfgfile_string(option, value, _T("joyportcustom1"), p->jports_custom[1].custom, sizeof p->jports_custom[1].custom / sizeof(TCHAR)))
+ return 1;
+ if (cfgfile_string(option, value, _T("joyportcustom2"), p->jports_custom[2].custom, sizeof p->jports_custom[2].custom / sizeof(TCHAR)))
+ return 1;
+ if (cfgfile_string(option, value, _T("joyportcustom3"), p->jports_custom[3].custom, sizeof p->jports_custom[3].custom / sizeof(TCHAR)))
+ return 1;
+ if (cfgfile_string(option, value, _T("joyportcustom4"), p->jports_custom[4].custom, sizeof p->jports_custom[4].custom / sizeof(TCHAR)))
+ return 1;
+ if (cfgfile_string(option, value, _T("joyportcustom5"), p->jports_custom[5].custom, sizeof p->jports_custom[5].custom / sizeof(TCHAR)))
+ return 1;
+
+ //if (_tcscmp(option, _T("joyportfriendlyname0")) == 0 || _tcscmp(option, _T("joyportfriendlyname1")) == 0) {
+ // inputdevice_joyport_config_store(p, value, _tcscmp(option, _T("joyportfriendlyname0")) == 0 ? 0 : 1, -1, 2);
+ // return 1;
+ //}
+ //if (_tcscmp(option, _T("joyportfriendlyname2")) == 0 || _tcscmp(option, _T("joyportfriendlyname3")) == 0) {
+ // inputdevice_joyport_config_store(p, value, _tcscmp(option, _T("joyportfriendlyname2")) == 0 ? 2 : 3, -1, 2);
+ // return 1;
+ //}
+ //if (_tcscmp(option, _T("joyportname0")) == 0 || _tcscmp(option, _T("joyportname1")) == 0) {
+ // inputdevice_joyport_config_store(p, value, _tcscmp(option, _T("joyportname0")) == 0 ? 0 : 1, -1, 1);
+ // return 1;
+ //}
+ //if (_tcscmp(option, _T("joyportname2")) == 0 || _tcscmp(option, _T("joyportname3")) == 0) {
+ // inputdevice_joyport_config_store(p, value, _tcscmp(option, _T("joyportname2")) == 0 ? 2 : 3, -1, 1);
+ // return 1;
+ //}
+ //if (_tcscmp(option, _T("joyport0")) == 0 || _tcscmp(option, _T("joyport1")) == 0) {
+ // inputdevice_joyport_config_store(p, value, _tcscmp(option, _T("joyport0")) == 0 ? 0 : 1, -1, 0);
+ // return 1;
+ //}
+ //if (_tcscmp(option, _T("joyport2")) == 0 || _tcscmp(option, _T("joyport3")) == 0) {
+ // inputdevice_joyport_config_store(p, value, _tcscmp(option, _T("joyport2")) == 0 ? 2 : 3, -1, 0);
+ // return 1;
+ //}
+ if (cfgfile_strval(option, value, _T("joyport0mode"), &p->jports[0].mode, joyportmodes, 0))
+ return 1;
+ if (cfgfile_strval(option, value, _T("joyport1mode"), &p->jports[1].mode, joyportmodes, 0))
+ return 1;
+ if (cfgfile_strval(option, value, _T("joyport2mode"), &p->jports[2].mode, joyportmodes, 0))
+ return 1;
+ if (cfgfile_strval(option, value, _T("joyport3mode"), &p->jports[3].mode, joyportmodes, 0))
+ return 1;
+ if (cfgfile_strval(option, value, _T("joyport0autofire"), &p->jports[0].autofire, joyaf, 0))
+ return 1;
+ if (cfgfile_strval(option, value, _T("joyport1autofire"), &p->jports[1].autofire, joyaf, 0))
+ return 1;
+ if (cfgfile_strval(option, value, _T("joyport2autofire"), &p->jports[2].autofire, joyaf, 0))
+ return 1;
+ if (cfgfile_strval(option, value, _T("joyport3autofire"), &p->jports[3].autofire, joyaf, 0))
+ return 1;
+
+ if (cfgfile_yesno(option, value, _T("joyport0keyboardoverride"), &vb)) {
p->jports[0].nokeyboardoverride = !vb;
return 1;
}
- if (cfgfile_yesno (option, value, _T("joyport1keyboardoverride"), &vb) ||
- cfgfile_yesno (option, value, _T("joyport1_keyboardoverride"), &vb)) {
+ if (cfgfile_yesno(option, value, _T("joyport1keyboardoverride"), &vb)) {
p->jports[1].nokeyboardoverride = !vb;
return 1;
}
- if (cfgfile_yesno (option, value, _T("joyport2keyboardoverride"), &vb) ||
- cfgfile_yesno (option, value, _T("joyport2_keyboardoverride"), &vb)) {
+ if (cfgfile_yesno(option, value, _T("joyport2keyboardoverride"), &vb)) {
p->jports[2].nokeyboardoverride = !vb;
return 1;
}
- if (cfgfile_yesno (option, value, _T("joyport3keyboardoverride"), &vb) ||
- cfgfile_yesno (option, value, _T("joyport3_keyboardoverride"), &vb)) {
+ if (cfgfile_yesno(option, value, _T("joyport3keyboardoverride"), &vb)) {
p->jports[3].nokeyboardoverride = !vb;
return 1;
}
- if (cfgfile_string (option, value, _T("statefile"), tmpbuf, sizeof (tmpbuf) / sizeof (TCHAR))) {
- _tcscpy (savestate_fname, tmpbuf);
- if (zfile_exists (savestate_fname)) {
- savestate_state = STATE_DORESTORE;
- } else {
- int ok = 0;
- if (savestate_fname[0]) {
- for (;;) {
- TCHAR *p;
- if (my_existsdir (savestate_fname)) {
- ok = 1;
- break;
- }
- p = _tcsrchr (savestate_fname, '\\');
- if (!p)
- p = _tcsrchr (savestate_fname, '/');
- if (!p)
- break;
- *p = 0;
- }
- }
- if (!ok) {
- savestate_fname[0] = 0;
- }
- }
- return 1;
- }
+ if (cfgfile_path(option, value, _T("statefile_quit"), p->quitstatefile, sizeof p->quitstatefile / sizeof(TCHAR)))
+ return 1;
- if (cfgfile_strval (option, value, _T("sound_channels"), &p->sound_stereo, stereomode, 1)) {
- if (p->sound_stereo == SND_NONE) { /* "mixed stereo" compatibility hack */
- p->sound_stereo = SND_STEREO;
- p->sound_mixed_stereo_delay = 5;
- p->sound_stereo_separation = 7;
- }
- return 1;
- }
-
- if (_tcscmp (option, _T("kbd_lang")) == 0) {
- KbdLang l;
- if ((l = KBD_LANG_DE, _tcsicmp (value, _T("de")) == 0)
- || (l = KBD_LANG_DK, _tcsicmp (value, _T("dk")) == 0)
- || (l = KBD_LANG_SE, _tcsicmp (value, _T("se")) == 0)
- || (l = KBD_LANG_US, _tcsicmp (value, _T("us")) == 0)
- || (l = KBD_LANG_FR, _tcsicmp (value, _T("fr")) == 0)
- || (l = KBD_LANG_IT, _tcsicmp (value, _T("it")) == 0)
- || (l = KBD_LANG_ES, _tcsicmp (value, _T("es")) == 0))
- p->keyboard_lang = l;
- else
- cfgfile_warning(_T("Unknown keyboard language\n"));
+ if (cfgfile_string(option, value, _T("statefile_name"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
+ fetch_statefilepath(savestate_fname, sizeof savestate_fname / sizeof(TCHAR));
+ _tcscat(savestate_fname, tmpbuf);
+ if (_tcslen(savestate_fname) >= 4 && _tcsicmp(savestate_fname + _tcslen(savestate_fname) - 4, _T(".uss")))
+ _tcscat(savestate_fname, _T(".uss"));
return 1;
}
- if (cfgfile_string (option, value, _T("config_version"), tmpbuf, sizeof (tmpbuf) / sizeof (TCHAR))) {
- TCHAR *tmpp2;
- tmpp = _tcschr (value, '.');
- if (tmpp) {
- *tmpp++ = 0;
- tmpp2 = tmpp;
- p->config_version = _tstol (tmpbuf) << 16;
- tmpp = _tcschr (tmpp, '.');
- if (tmpp) {
- *tmpp++ = 0;
- p->config_version |= _tstol (tmpp2) << 8;
- p->config_version |= _tstol (tmpp);
- }
- }
- return 1;
- }
+ if (cfgfile_path(option, value, _T("statefile"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
+ _tcscpy(p->statefile, tmpbuf);
+ _tcscpy(savestate_fname, tmpbuf);
+ if (zfile_exists(savestate_fname)) {
+ savestate_state = STATE_DORESTORE;
+ }
+ else {
+ int ok = 0;
+ if (savestate_fname[0]) {
+ for (;;) {
+ TCHAR *p;
+ if (my_existsdir(savestate_fname)) {
+ ok = 1;
+ break;
+ }
+ p = _tcsrchr(savestate_fname, '\\');
+ if (!p)
+ p = _tcsrchr(savestate_fname, '/');
+ if (!p)
+ break;
+ *p = 0;
+ }
+ }
+ if (!ok) {
+ TCHAR tmp[MAX_DPATH];
+ fetch_statefilepath(tmp, sizeof tmp / sizeof(TCHAR));
+ _tcscat(tmp, savestate_fname);
+ if (zfile_exists(tmp)) {
+ _tcscpy(savestate_fname, tmp);
+ savestate_state = STATE_DORESTORE;
+ }
+ else {
+ savestate_fname[0] = 0;
+ }
+ }
+ }
+ return 1;
+ }
- if (_tcscmp (option, _T("displaydata")) == 0 || _tcscmp (option, _T("displaydata_pal")) == 0 || _tcscmp (option, _T("displaydata_ntsc")) == 0) {
- _tcsncpy (tmpbuf, value, sizeof tmpbuf / sizeof (TCHAR) - 1);
- tmpbuf[sizeof tmpbuf / sizeof (TCHAR) - 1] = '\0';
+ if (cfgfile_strval(option, value, _T("sound_channels"), &p->sound_stereo, stereomode, 1)) {
+ if (p->sound_stereo == SND_NONE) { /* "mixed stereo" compatibility hack */
+ p->sound_stereo = SND_STEREO;
+ p->sound_mixed_stereo_delay = 5;
+ p->sound_stereo_separation = 7;
+ }
+ return 1;
+ }
- int vert = -1, horiz = -1, lace = -1, ntsc = -1, vsync = -1, hres = 0;
- bool locked = false, rtg = false;
- bool defaultdata = false;
- float rate = -1;
- TCHAR label[16] = { 0 };
+
+ //if (_tcscmp(option, _T("kbd_lang")) == 0) {
+ // KbdLang l;
+ // if ((l = KBD_LANG_DE, strcasecmp(value, _T("de")) == 0)
+ // || (l = KBD_LANG_DK, strcasecmp(value, _T("dk")) == 0)
+ // || (l = KBD_LANG_SE, strcasecmp(value, _T("se")) == 0)
+ // || (l = KBD_LANG_US, strcasecmp(value, _T("us")) == 0)
+ // || (l = KBD_LANG_FR, strcasecmp(value, _T("fr")) == 0)
+ // || (l = KBD_LANG_IT, strcasecmp(value, _T("it")) == 0)
+ // || (l = KBD_LANG_ES, strcasecmp(value, _T("es")) == 0))
+ // p->keyboard_lang = l;
+ // else
+ // cfgfile_warning(_T("Unknown keyboard language\n"));
+ // return 1;
+ //}
+
+ if (cfgfile_string(option, value, _T("config_version"), tmpbuf, sizeof(tmpbuf) / sizeof(TCHAR))) {
+ TCHAR *tmpp2;
+ tmpp = _tcschr(value, '.');
+ if (tmpp) {
+ *tmpp++ = 0;
+ tmpp2 = tmpp;
+ p->config_version = _tstol(tmpbuf) << 16;
+ tmpp = _tcschr(tmpp, '.');
+ if (tmpp) {
+ *tmpp++ = 0;
+ p->config_version |= _tstol(tmpp2) << 8;
+ p->config_version |= _tstol(tmpp);
+ }
+ }
+ return 1;
+ }
+
+ if (cfgfile_string(option, value, _T("keyboard_leds"), tmpbuf, sizeof(tmpbuf) / sizeof(TCHAR))) {
+ TCHAR *tmpp2 = tmpbuf;
+ int i, num;
+ p->keyboard_leds[0] = p->keyboard_leds[1] = p->keyboard_leds[2] = 0;
+ p->keyboard_leds_in_use = 0;
+ _tcscat(tmpbuf, _T(","));
+ for (i = 0; i < 3; i++) {
+ tmpp = _tcschr(tmpp2, ':');
+ if (!tmpp)
+ break;
+ *tmpp++ = 0;
+ num = -1;
+ if (!strcasecmp(tmpp2, _T("numlock")))
+ num = 0;
+ if (!strcasecmp(tmpp2, _T("capslock")))
+ num = 1;
+ if (!strcasecmp(tmpp2, _T("scrolllock")))
+ num = 2;
+ tmpp2 = tmpp;
+ tmpp = _tcschr(tmpp2, ',');
+ if (!tmpp)
+ break;
+ *tmpp++ = 0;
+ if (num >= 0) {
+ p->keyboard_leds[num] = match_string(kbleds, tmpp2);
+ if (p->keyboard_leds[num])
+ p->keyboard_leds_in_use = 1;
+ }
+ tmpp2 = tmpp;
+ }
+ return 1;
+ }
+
+ if (_tcscmp(option, _T("displaydata")) == 0 || _tcscmp(option, _T("displaydata_pal")) == 0 || _tcscmp(option, _T("displaydata_ntsc")) == 0) {
+ _tcsncpy(tmpbuf, value, sizeof tmpbuf / sizeof(TCHAR) - 1);
+ tmpbuf[sizeof tmpbuf / sizeof(TCHAR) - 1] = '\0';
+
+ int vert = -1, horiz = -1, lace = -1, ntsc = -1, framelength = -1, vsync = -1, hres = 0;
+ bool locked = false, rtg = false, exit = false;
+ bool cmdmode = false, defaultdata = false;
+ double rate = -1;
+ int rpct = 0;
+ TCHAR cmd[MAX_DPATH], filter[64] = { 0 }, label[16] = { 0 };
TCHAR *tmpp = tmpbuf;
- TCHAR *end = tmpbuf + _tcslen (tmpbuf);
+ TCHAR *end = tmpbuf + _tcslen(tmpbuf);
+ cmd[0] = 0;
for (;;) {
- TCHAR *next = _tcschr (tmpp, ',');
- TCHAR *equals = _tcschr (tmpp, '=');
+ TCHAR *next = _tcschr(tmpp, ',');
+ TCHAR *equals = _tcschr(tmpp, '=');
if (!next)
next = end;
@@ -2353,39 +3575,68 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
equals++;
*next = 0;
- if (rate < 0)
- rate = _tstof(tmpp);
- else if (!_tcsnicmp(tmpp, _T("v="), 2))
- vert = _tstol(equals);
- else if (!_tcsnicmp(tmpp, _T("h="), 2))
- horiz = _tstol(equals);
- else if (!_tcsnicmp(tmpp, _T("t="), 2))
- _tcsncpy(label, equals, sizeof label / sizeof(TCHAR) - 1);
- if (!_tcsnicmp(tmpp, _T("locked"), 4))
- locked = true;
- if (!_tcsnicmp(tmpp, _T("nlace"), 5))
- lace = 0;
- if (!_tcsnicmp(tmpp, _T("lace"), 4))
- lace = 1;
- if (!_tcsnicmp(tmpp, _T("lores"), 5))
- hres |= 1 << RES_LORES;
- if (!_tcsnicmp(tmpp, _T("hires"), 5))
- hres |= 1 << RES_HIRES;
- if (!_tcsnicmp(tmpp, _T("shres"), 5))
- hres |= 1 << RES_SUPERHIRES;
- if (!_tcsnicmp(tmpp, _T("nvsync"), 5))
- vsync = 0;
- if (!_tcsnicmp(tmpp, _T("vsync"), 4))
- vsync = 1;
- if (!_tcsnicmp(tmpp, _T("ntsc"), 4))
- ntsc = 1;
- if (!_tcsnicmp(tmpp, _T("pal"), 3))
- ntsc = 0;
- if (!_tcsnicmp(tmpp, _T("rtg"), 3))
- rtg = true;
- if (!_tcsnicmp(tmpp, _T("default"), 7))
- defaultdata = true;
-
+ if (cmdmode) {
+ if (_tcslen(cmd) + _tcslen(tmpp) + 2 < sizeof(cmd) / sizeof(TCHAR)) {
+ _tcscat(cmd, tmpp);
+ _tcscat(cmd, _T("\n"));
+ }
+ }
+ else {
+ if (!_tcsnicmp(tmpp, _T("cmd="), 4)) {
+ cmdmode = true;
+ tmpp += 4;
+ }
+ if (rate < 0)
+ rate = _tstof(tmpp);
+ else if (!_tcsnicmp(tmpp, _T("v="), 2))
+ vert = _tstol(equals);
+ else if (!_tcsnicmp(tmpp, _T("h="), 2))
+ horiz = _tstol(equals);
+ else if (!_tcsnicmp(tmpp, _T("t="), 2))
+ _tcsncpy(label, equals, sizeof label / sizeof(TCHAR) - 1);
+ else if (!_tcsnicmp(tmpp, _T("filter="), 7))
+ _tcsncpy(filter, equals, sizeof filter / sizeof(TCHAR) - 1);
+ else if (!_tcsnicmp(tmpp, _T("rpct="), 5))
+ rpct = _tstol(equals);
+ else if (equals) {
+ if (_tcslen(cmd) + _tcslen(tmpp) + 2 < sizeof(cmd) / sizeof(TCHAR)) {
+ _tcscat(cmd, tmpp);
+ _tcscat(cmd, _T("\n"));
+ }
+ }
+ if (!_tcsnicmp(tmpp, _T("locked"), 4))
+ locked = true;
+ if (!_tcsnicmp(tmpp, _T("nlace"), 5))
+ lace = 0;
+ if (!_tcsnicmp(tmpp, _T("lace"), 4))
+ lace = 1;
+ if (!_tcsnicmp(tmpp, _T("lores"), 5))
+ hres |= 1 << RES_LORES;
+ if (!_tcsnicmp(tmpp, _T("hires"), 5))
+ hres |= 1 << RES_HIRES;
+ if (!_tcsnicmp(tmpp, _T("shres"), 5))
+ hres |= 1 << RES_SUPERHIRES;
+ if (!_tcsnicmp(tmpp, _T("nvsync"), 5))
+ vsync = 0;
+ if (!_tcsnicmp(tmpp, _T("vsync"), 4))
+ vsync = 1;
+ if (!_tcsnicmp(tmpp, _T("ntsc"), 4))
+ ntsc = 1;
+ if (!_tcsnicmp(tmpp, _T("pal"), 3))
+ ntsc = 0;
+ if (!_tcsnicmp(tmpp, _T("custom"), 6))
+ ntsc = 2;
+ if (!_tcsnicmp(tmpp, _T("lof"), 3))
+ framelength = 1;
+ if (!_tcsnicmp(tmpp, _T("shf"), 3))
+ framelength = 0;
+ if (!_tcsnicmp(tmpp, _T("rtg"), 3))
+ rtg = true;
+ if (!_tcsnicmp(tmpp, _T("exit"), 4))
+ exit = true;
+ if (!_tcsnicmp(tmpp, _T("default"), 7))
+ defaultdata = true;
+ }
tmpp = next;
if (tmpp >= end)
break;
@@ -2393,16 +3644,17 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
}
for (int i = 0; i < MAX_CHIPSET_REFRESH; i++) {
struct chipset_refresh *cr = &p->cr[i];
- if (_tcscmp (option, _T("displaydata_pal")) == 0) {
+ if (_tcscmp(option, _T("displaydata_pal")) == 0) {
i = CHIPSET_REFRESH_PAL;
- cr = &p->cr[i];
- cr->rate = -1;
- _tcscpy (label, _T("PAL"));
- } else if (_tcscmp (option, _T("displaydata_ntsc")) == 0) {
+ cr = &p->cr[i];
+ cr->inuse = false;
+ _tcscpy(label, _T("PAL"));
+ }
+ else if (_tcscmp(option, _T("displaydata_ntsc")) == 0) {
i = CHIPSET_REFRESH_NTSC;
- cr = &p->cr[i];
- cr->rate = -1;
- _tcscpy (label, _T("NTSC"));
+ cr = &p->cr[i];
+ cr->inuse = false;
+ _tcscpy(label, _T("NTSC"));
}
if (!cr->inuse) {
cr->inuse = true;
@@ -2410,53 +3662,205 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
cr->vert = vert;
cr->lace = lace;
cr->resolution = hres ? hres : 1 + 2 + 4;
+ cr->resolution_pct = rpct;
cr->ntsc = ntsc;
cr->vsync = vsync;
cr->locked = locked;
cr->rtg = rtg;
+ cr->exit = exit;
+ cr->framelength = framelength;
cr->rate = rate;
cr->defaultdata = defaultdata;
+ _tcscpy(cr->commands, cmd);
_tcscpy(cr->label, label);
+ TCHAR *se = cfgfile_unescape(filter, NULL);
+ _tcscpy(cr->filterprofile, se);
+ xfree(se);
break;
}
}
return 1;
}
- return 0;
+#ifdef WITH_SLIRP
+ if (cfgfile_string(option, value, _T("slirp_ports"), tmpbuf, sizeof(tmpbuf) / sizeof(TCHAR))) {
+ TCHAR *tmpp2 = tmpbuf;
+ _tcscat(tmpbuf, _T(","));
+ for (;;) {
+ tmpp = _tcschr(tmpp2, ',');
+ if (!tmpp)
+ break;
+ *tmpp++ = 0;
+ for (i = 0; i < MAX_SLIRP_REDIRS; i++) {
+ struct slirp_redir *sr = &p->slirp_redirs[i];
+ if (sr->proto == 0) {
+ sr->dstport = _tstol(tmpp2);
+ sr->proto = 1;
+ break;
+ }
+ }
+ tmpp2 = tmpp;
+ }
+ return 1;
+ }
+ if (cfgfile_string(option, value, _T("slirp_redir"), tmpbuf, sizeof(tmpbuf) / sizeof(TCHAR))) {
+ TCHAR *tmpp2 = tmpbuf;
+ _tcscat(tmpbuf, _T(":"));
+ for (i = 0; i < MAX_SLIRP_REDIRS; i++) {
+ struct slirp_redir *sr = &p->slirp_redirs[i];
+ if (sr->proto == 0) {
+ char *s;
+ tmpp = _tcschr(tmpp2, ':');
+ if (!tmpp)
+ break;
+ *tmpp++ = 0;
+ if (!_tcsicmp(tmpp2, _T("tcp")))
+ sr->proto = 1;
+ else if (!_tcsicmp(tmpp2, _T("udp")))
+ sr->proto = 2;
+ else
+ break;
+ tmpp2 = tmpp;
+ tmpp = _tcschr(tmpp2, ':');
+ if (!tmpp) {
+ sr->proto = 0;
+ break;
+ }
+ *tmpp++ = 0;
+ sr->dstport = _tstol(tmpp2);
+ tmpp2 = tmpp;
+ tmpp = _tcschr(tmpp2, ':');
+ if (!tmpp) {
+ sr->proto = 0;
+ break;
+ }
+ *tmpp++ = 0;
+ sr->srcport = _tstol(tmpp2);
+ tmpp2 = tmpp;
+ tmpp = _tcschr(tmpp2, ':');
+ if (!tmpp)
+ break;
+ *tmpp++ = 0;
+ s = ua(tmpp2);
+ sr->addr = inet_addr(s);
+ xfree(s);
+ }
+ }
+ return 1;
+ }
+#endif
+
+ return 0;
+}
+
+static void decode_rom_ident(TCHAR *romfile, int maxlen, const TCHAR *ident, int romflags)
+{
+ const TCHAR *p;
+ int ver, rev, subver, subrev, round, i;
+ TCHAR model[64], *modelp;
+ struct romlist **rl;
+ TCHAR *romtxt;
+
+ if (!ident[0])
+ return;
+ romtxt = xmalloc(TCHAR, 10000);
+ romtxt[0] = 0;
+ for (round = 0; round < 2; round++) {
+ ver = rev = subver = subrev = -1;
+ modelp = NULL;
+ memset(model, 0, sizeof model);
+ p = ident;
+ while (*p) {
+ TCHAR c = *p++;
+ int *pp1 = NULL, *pp2 = NULL;
+ if (_totupper(c) == 'V' && _istdigit(*p)) {
+ pp1 = &ver;
+ pp2 = &rev;
+ }
+ else if (_totupper(c) == 'R' && _istdigit(*p)) {
+ pp1 = &subver;
+ pp2 = &subrev;
+ }
+ else if (!_istdigit(c) && c != ' ') {
+ _tcsncpy(model, p - 1, (sizeof model) / sizeof(TCHAR) - 1);
+ p += _tcslen(model);
+ modelp = model;
+ }
+ if (pp1) {
+ *pp1 = _tstol(p);
+ while (*p != 0 && *p != '.' && *p != ' ')
+ p++;
+ if (*p == '.') {
+ p++;
+ if (pp2)
+ *pp2 = _tstol(p);
+ }
+ }
+ if (*p == 0 || *p == ';') {
+ rl = getromlistbyident(ver, rev, subver, subrev, modelp, romflags, round > 0);
+ if (rl) {
+ for (i = 0; rl[i]; i++) {
+ if (round) {
+ TCHAR romname[MAX_DPATH];
+ getromname(rl[i]->rd, romname);
+ _tcscat(romtxt, romname);
+ _tcscat(romtxt, _T("\n"));
+ }
+ else {
+ _tcsncpy(romfile, rl[i]->path, maxlen);
+ goto end;
+ }
+ }
+ xfree(rl);
+ }
+ }
+ }
+ }
+end:
+ if (round && romtxt[0]) {
+ //notify_user_parms(NUMSG_ROMNEED, romtxt, romtxt);
+ }
+ xfree(romtxt);
}
static struct uaedev_config_data *getuci(struct uae_prefs *p)
{
- if (p->mountitems < MOUNT_CONFIG_SIZE)
- return &p->mountconfig[p->mountitems++];
- return NULL;
+ if (p->mountitems < MOUNT_CONFIG_SIZE)
+ return &p->mountconfig[p->mountitems++];
+ return NULL;
}
-struct uaedev_config_data *add_filesys_config (struct uae_prefs *p, int index, struct uaedev_config_info *ci)
+struct uaedev_config_data *add_filesys_config(struct uae_prefs *p, int index, struct uaedev_config_info *ci)
{
struct uaedev_config_data *uci;
- int i;
+ int i;
- if (index < 0 && (ci->type == UAEDEV_DIR || ci->type == UAEDEV_HDF) && ci->devname && _tcslen (ci->devname) > 0) {
+ if (index < 0 && (ci->type == UAEDEV_DIR || ci->type == UAEDEV_HDF) && ci->devname && _tcslen(ci->devname) > 0) {
for (i = 0; i < p->mountitems; i++) {
- if (p->mountconfig[i].ci.devname && !_tcscmp (p->mountconfig[i].ci.devname, ci->devname))
+ if (p->mountconfig[i].ci.devname && !_tcscmp(p->mountconfig[i].ci.devname, ci->devname))
return NULL;
}
}
for (;;) {
- if (ci->type == UAEDEV_CD) {
+ if (ci->type == UAEDEV_CD) {
if (ci->controller_type >= HD_CONTROLLER_TYPE_IDE_FIRST && ci->controller_type <= HD_CONTROLLER_TYPE_IDE_LAST)
break;
if (ci->controller_type >= HD_CONTROLLER_TYPE_SCSI_FIRST && ci->controller_type <= HD_CONTROLLER_TYPE_SCSI_LAST)
break;
- } else {
+ }
+ else if (ci->type == UAEDEV_TAPE) {
+ if (ci->controller_type == HD_CONTROLLER_TYPE_UAE)
+ break;
+ if (ci->controller_type >= HD_CONTROLLER_TYPE_SCSI_FIRST && ci->controller_type <= HD_CONTROLLER_TYPE_SCSI_LAST)
+ break;
+ }
+ else {
break;
}
return NULL;
}
- if (index < 0) {
+ if (index < 0) {
if (ci->controller_type != HD_CONTROLLER_TYPE_UAE) {
int ctrl = ci->controller_type;
int ctrlunit = ci->controller_type_unit;
@@ -2483,53 +3887,54 @@ struct uaedev_config_data *add_filesys_config (struct uae_prefs *p, int index, s
return NULL;
}
}
- uci = getuci(p);
- uci->configoffset = -1;
+ uci = getuci(p);
+ uci->configoffset = -1;
uci->unitnum = -1;
- } else {
- uci = &p->mountconfig[index];
- }
- if (!uci)
+ }
+ else {
+ uci = &p->mountconfig[index];
+ }
+ if (!uci)
return NULL;
- memcpy (&uci->ci, ci, sizeof (struct uaedev_config_info));
- validatedevicename (uci->ci.devname, NULL);
- validatevolumename (uci->ci.volname, NULL);
- if (!uci->ci.devname[0] && ci->type != UAEDEV_CD) {
- TCHAR base[32];
- TCHAR base2[32];
- int num = 0;
+ memcpy(&uci->ci, ci, sizeof(struct uaedev_config_info));
+ validatedevicename(uci->ci.devname, NULL);
+ validatevolumename(uci->ci.volname, NULL);
+ if (!uci->ci.devname[0] && ci->type != UAEDEV_CD && ci->type != UAEDEV_TAPE) {
+ TCHAR base[32];
+ TCHAR base2[32];
+ int num = 0;
if (uci->ci.rootdir[0] == 0 && ci->type == UAEDEV_DIR)
- _tcscpy (base, _T("RDH"));
- else
- _tcscpy (base, _T("DH"));
- _tcscpy (base2, base);
- for (i = 0; i < p->mountitems; i++) {
- _stprintf (base2, _T("%s%d"), base, num);
+ _tcscpy(base, _T("RDH"));
+ else
+ _tcscpy(base, _T("DH"));
+ _tcscpy(base2, base);
+ for (i = 0; i < p->mountitems; i++) {
+ _stprintf(base2, _T("%s%d"), base, num);
if (!_tcsicmp(base2, p->mountconfig[i].ci.devname)) {
- num++;
- i = -1;
- continue;
- }
- }
- _tcscpy (uci->ci.devname, base2);
- validatedevicename (uci->ci.devname, NULL);
- }
- if (ci->type == UAEDEV_DIR) {
- TCHAR *s = filesys_createvolname (uci->ci.volname, uci->ci.rootdir, NULL, _T("Harddrive"));
- _tcscpy (uci->ci.volname, s);
- xfree (s);
+ num++;
+ i = -1;
+ continue;
+ }
+ }
+ _tcscpy(uci->ci.devname, base2);
+ validatedevicename(uci->ci.devname, NULL);
}
- return uci;
+ if (ci->type == UAEDEV_DIR) {
+ TCHAR *s = filesys_createvolname(uci->ci.volname, uci->ci.rootdir, NULL, _T("Harddrive"));
+ _tcscpy(uci->ci.volname, s);
+ xfree(s);
+ }
+ return uci;
}
-static void parse_addmem (struct uae_prefs *p, TCHAR *buf, int num)
+static void parse_addmem(struct uae_prefs *p, TCHAR *buf, int num)
{
int size = 0, addr = 0;
- if (!getintval2 (&buf, &addr, ',', false))
+ if (!getintval2(&buf, &addr, ',', false))
return;
- if (!getintval2 (&buf, &size, 0, true))
+ if (!getintval2(&buf, &size, 0, true))
return;
if (addr & 0xffff)
return;
@@ -2539,17 +3944,18 @@ static void parse_addmem (struct uae_prefs *p, TCHAR *buf, int num)
p->custom_memory_sizes[num] = size;
}
-static void get_filesys_controller (const TCHAR *hdc, int *type, int *typenum, int *num)
+static void get_filesys_controller(const TCHAR *hdc, int *type, int *typenum, int *num)
{
int hdcv = HD_CONTROLLER_TYPE_UAE;
int hdunit = 0;
int idx = 0;
- if(_tcslen (hdc) >= 4 && !_tcsncmp (hdc, _T("ide"), 3)) {
+ if (_tcslen(hdc) >= 4 && !_tcsncmp(hdc, _T("ide"), 3)) {
hdcv = HD_CONTROLLER_TYPE_IDE_AUTO;
hdunit = hdc[3] - '0';
if (hdunit < 0 || hdunit >= 6)
hdunit = 0;
- } else if(_tcslen (hdc) >= 5 && !_tcsncmp (hdc, _T("scsi"), 4)) {
+ }
+ else if (_tcslen(hdc) >= 5 && !_tcsncmp(hdc, _T("scsi"), 4)) {
hdcv = HD_CONTROLLER_TYPE_SCSI_AUTO;
hdunit = hdc[4] - '0';
if (hdunit < 0 || hdunit >= 8 + 2)
@@ -2557,7 +3963,7 @@ static void get_filesys_controller (const TCHAR *hdc, int *type, int *typenum, i
}
if (hdcv > HD_CONTROLLER_TYPE_UAE) {
bool found = false;
- const TCHAR *ext = _tcsrchr (hdc, '_');
+ const TCHAR *ext = _tcsrchr(hdc, '_');
if (ext) {
ext++;
int len = _tcslen(ext);
@@ -2579,8 +3985,9 @@ static void get_filesys_controller (const TCHAR *hdc, int *type, int *typenum, i
}
}
if (hdcv == HD_CONTROLLER_TYPE_IDE_AUTO) {
- hdcv = i;
- } else if (hdcv == HD_CONTROLLER_TYPE_SCSI_AUTO) {
+ hdcv = i;
+ }
+ else if (hdcv == HD_CONTROLLER_TYPE_SCSI_AUTO) {
hdcv = i + HD_CONTROLLER_EXPANSION_MAX;
}
found = true;
@@ -2594,7 +4001,8 @@ static void get_filesys_controller (const TCHAR *hdc, int *type, int *typenum, i
if (_tcslen(ert->name) == len && !_tcsnicmp(ext, ert->name, len)) {
if (hdcv == HD_CONTROLLER_TYPE_IDE_AUTO) {
hdcv = HD_CONTROLLER_TYPE_IDE_EXPANSION_FIRST + i;
- } else {
+ }
+ else {
hdcv = HD_CONTROLLER_TYPE_SCSI_EXPANSION_FIRST + i;
}
break;
@@ -2603,164 +4011,191 @@ static void get_filesys_controller (const TCHAR *hdc, int *type, int *typenum, i
}
}
- } else if (_tcslen (hdc) >= 6 && !_tcsncmp (hdc, _T("scsram"), 6)) {
+ }
+ else if (_tcslen(hdc) >= 6 && !_tcsncmp(hdc, _T("scsram"), 6)) {
hdcv = HD_CONTROLLER_TYPE_PCMCIA;
hdunit = 0;
idx = 0;
- } else if (_tcslen (hdc) >= 5 && !_tcsncmp (hdc, _T("scide"), 6)) {
+ }
+ else if (_tcslen(hdc) >= 5 && !_tcsncmp(hdc, _T("scide"), 6)) {
hdcv = HD_CONTROLLER_TYPE_PCMCIA;
hdunit = 0;
idx = 1;
}
if (idx >= MAX_DUPLICATE_EXPANSION_BOARDS)
idx = MAX_DUPLICATE_EXPANSION_BOARDS - 1;
- if (hdunit < 0)
- hdunit = 0;
*type = hdcv;
*typenum = idx;
*num = hdunit;
}
-static bool parse_geo (const TCHAR *tname, struct uaedev_config_info *uci, struct hardfiledata *hfd, bool empty)
+static bool parse_geo(const TCHAR *tname, struct uaedev_config_info *uci, struct hardfiledata *hfd, bool empty)
{
struct zfile *f;
int found;
TCHAR buf[200];
-
- f = zfile_fopen (tname, _T("r"));
+
+ f = zfile_fopen(tname, _T("r"));
if (!f)
return false;
found = hfd == NULL && !empty ? 2 : 0;
if (found)
- write_log (_T("Geometry file '%s' detected\n"), tname);
- while (zfile_fgets (buf, sizeof buf / sizeof (TCHAR), f)) {
+ write_log(_T("Geometry file '%s' detected\n"), tname);
+ while (zfile_fgets(buf, sizeof buf / sizeof(TCHAR), f)) {
int v;
TCHAR *sep;
-
- my_trim (buf);
- if (_tcslen (buf) == 0)
+
+ my_trim(buf);
+ if (_tcslen(buf) == 0)
continue;
- if (buf[0] == '[' && buf[_tcslen (buf) - 1] == ']') {
+ if (buf[0] == '[' && buf[_tcslen(buf) - 1] == ']') {
if (found > 1) {
- zfile_fclose (f);
+ zfile_fclose(f);
return true;
}
found = 0;
- buf[_tcslen (buf) - 1] = 0;
- my_trim (buf + 1);
- if (!_tcsicmp (buf + 1, _T("empty"))) {
+ buf[_tcslen(buf) - 1] = 0;
+ my_trim(buf + 1);
+ if (!_tcsicmp(buf + 1, _T("empty"))) {
if (empty)
found = 1;
- } else if (!_tcsicmp (buf + 1, _T("default"))) {
+ }
+ else if (!_tcsicmp(buf + 1, _T("default"))) {
if (!empty)
found = 1;
- } else if (hfd) {
- uae_u64 size = _tstoi64 (buf + 1);
+ }
+ else if (hfd) {
+ uae_u64 size = _tstoi64(buf + 1);
if (size == hfd->virtsize)
found = 2;
}
if (found)
- write_log (_T("Geometry file '%s', entry '%s' detected\n"), tname, buf + 1);
+ write_log(_T("Geometry file '%s', entry '%s' detected\n"), tname, buf + 1);
continue;
}
if (!found)
continue;
- sep = _tcschr (buf, '=');
+ sep = _tcschr(buf, '=');
if (!sep)
continue;
sep[0] = 0;
- TCHAR *key = my_strdup_trim (buf);
- TCHAR *val = my_strdup_trim (sep + 1);
- if (val[0] == '0' && _totupper (val[1]) == 'X') {
+ TCHAR *key = my_strdup_trim(buf);
+ TCHAR *val = my_strdup_trim(sep + 1);
+ if (val[0] == '0' && _totupper(val[1]) == 'X') {
TCHAR *endptr;
- v = _tcstol (val, &endptr, 16);
- } else {
- v = _tstol (val);
+ v = _tcstol(val, &endptr, 16);
}
- if (!_tcsicmp (key, _T("surfaces")))
+ else {
+ v = _tstol(val);
+ }
+ if (!_tcsicmp(key, _T("surfaces")))
uci->surfaces = v;
- if (!_tcsicmp (key, _T("sectorspertrack")) || !_tcsicmp (key, _T("blockspertrack")))
+ if (!_tcsicmp(key, _T("sectorspertrack")) || !_tcsicmp(key, _T("blockspertrack")))
uci->sectors = v;
- if (!_tcsicmp (key, _T("sectorsperblock")))
+ if (!_tcsicmp(key, _T("sectorsperblock")))
uci->sectorsperblock = v;
- if (!_tcsicmp (key, _T("reserved")))
+ if (!_tcsicmp(key, _T("reserved")))
uci->reserved = v;
- if (!_tcsicmp (key, _T("lowcyl")))
+ if (!_tcsicmp(key, _T("lowcyl")))
uci->lowcyl = v;
- if (!_tcsicmp (key, _T("highcyl")) || !_tcsicmp (key, _T("cyl")))
+ if (!_tcsicmp(key, _T("highcyl")) || !_tcsicmp(key, _T("cyl")))
uci->highcyl = v;
- if (!_tcsicmp (key, _T("blocksize")) || !_tcsicmp (key, _T("sectorsize")))
+ if (!_tcsicmp(key, _T("blocksize")) || !_tcsicmp(key, _T("sectorsize")))
uci->blocksize = v;
- if (!_tcsicmp (key, _T("buffers")))
+ if (!_tcsicmp(key, _T("buffers")))
uci->buffers = v;
- if (!_tcsicmp (key, _T("maxtransfer")))
+ if (!_tcsicmp(key, _T("maxtransfer")))
uci->maxtransfer = v;
- if (!_tcsicmp (key, _T("interleave")))
+ if (!_tcsicmp(key, _T("interleave")))
uci->interleave = v;
- if (!_tcsicmp (key, _T("dostype")))
+ if (!_tcsicmp(key, _T("dostype")))
uci->dostype = v;
- if (!_tcsicmp (key, _T("bufmemtype")))
+ if (!_tcsicmp(key, _T("bufmemtype")))
uci->bufmemtype = v;
- if (!_tcsicmp (key, _T("stacksize")))
+ if (!_tcsicmp(key, _T("stacksize")))
uci->stacksize = v;
- if (!_tcsicmp (key, _T("mask")))
+ if (!_tcsicmp(key, _T("mask")))
uci->mask = v;
- if (!_tcsicmp (key, _T("unit")))
+ if (!_tcsicmp(key, _T("unit")))
uci->unit = v;
- if (!_tcsicmp (key, _T("controller")))
- get_filesys_controller (val, &uci->controller_type, &uci->controller_type_unit, &uci->controller_unit);
- if (!_tcsicmp (key, _T("flags")))
+ if (!_tcsicmp(key, _T("controller")))
+ get_filesys_controller(val, &uci->controller_type, &uci->controller_type_unit, &uci->controller_unit);
+ if (!_tcsicmp(key, _T("flags")))
uci->flags = v;
- if (!_tcsicmp (key, _T("priority")))
+ if (!_tcsicmp(key, _T("priority")))
uci->priority = v;
- if (!_tcsicmp (key, _T("forceload")))
+ if (!_tcsicmp(key, _T("forceload")))
uci->forceload = v;
- if (!_tcsicmp (key, _T("bootpri"))) {
+ if (!_tcsicmp(key, _T("bootpri"))) {
if (v < -129)
v = -129;
if (v > 127)
v = 127;
uci->bootpri = v;
}
- if (!_tcsicmp (key, _T("filesystem")))
- _tcscpy (uci->filesys, val);
- if (!_tcsicmp (key, _T("device")))
- _tcscpy (uci->devname, val);
- xfree (val);
- xfree (key);
+ if (!_tcsicmp(key, _T("filesystem")))
+ _tcscpy(uci->filesys, val);
+ if (!_tcsicmp(key, _T("device")))
+ _tcscpy(uci->devname, val);
+ if (!_tcsicmp(key, _T("badblocks"))) {
+ TCHAR *p = val;
+ while (p && *p && uci->badblock_num < MAX_UAEDEV_BADBLOCKS) {
+ struct uaedev_badblock *bb = &uci->badblocks[uci->badblock_num];
+ if (!_istdigit(*p))
+ break;
+ bb->first = _tstol(p);
+ bb->last = bb->first;
+ TCHAR *p1 = _tcschr(p, ',');
+ TCHAR *p2 = NULL;
+ if (p1) {
+ p2 = p1 + 1;
+ *p1 = 0;
+ }
+ p1 = _tcschr(p, '-');
+ if (p1) {
+ bb->last = _tstol(p1 + 1);
+ }
+ uci->badblock_num++;
+ p = p2;
+ }
+ }
+ xfree(val);
+ xfree(key);
}
- zfile_fclose (f);
+ zfile_fclose(f);
return false;
}
-bool get_hd_geometry (struct uaedev_config_info *uci)
+
+bool get_hd_geometry(struct uaedev_config_info *uci)
{
TCHAR tname[MAX_DPATH];
- fetch_configurationpath (tname, sizeof tname / sizeof (TCHAR));
- _tcscat (tname, _T("default.geo"));
- if (zfile_exists (tname)) {
+ fetch_configurationpath(tname, sizeof tname / sizeof(TCHAR));
+ _tcscat(tname, _T("default.geo"));
+ if (zfile_exists(tname)) {
struct hardfiledata hfd;
- memset (&hfd, 0, sizeof hfd);
+ memset(&hfd, 0, sizeof hfd);
hfd.ci.readonly = true;
hfd.ci.blocksize = 512;
- if (hdf_open (&hfd, uci->rootdir) > 0) {
- parse_geo (tname, uci, &hfd, false);
- hdf_close (&hfd);
- } else {
- parse_geo (tname, uci, NULL, true);
+ if (hdf_open(&hfd, uci->rootdir) > 0) {
+ parse_geo(tname, uci, &hfd, false);
+ hdf_close(&hfd);
+ }
+ else {
+ parse_geo(tname, uci, NULL, true);
}
}
if (uci->rootdir[0]) {
- _tcscpy (tname, uci->rootdir);
- _tcscat (tname, _T(".geo"));
- return parse_geo (tname, uci, NULL, false);
+ _tcscpy(tname, uci->rootdir);
+ _tcscat(tname, _T(".geo"));
+ return parse_geo(tname, uci, NULL, false);
}
return false;
}
-static int cfgfile_parse_partial_newfilesys (struct uae_prefs *p, int nr, int type, const TCHAR *value, int unit, bool uaehfentry)
+static int cfgfile_parse_partial_newfilesys(struct uae_prefs *p, int nr, int type, const TCHAR *value, int unit, bool uaehfentry)
{
TCHAR *tmpp;
TCHAR *name = NULL, *path = NULL;
@@ -2770,145 +4205,123 @@ static int cfgfile_parse_partial_newfilesys (struct uae_prefs *p, int nr, int ty
return 0;
if (type != 1)
return 0;
- tmpp = getnextentry (&value, ',');
+ tmpp = getnextentry(&value, ',');
if (!tmpp)
return 0;
- xfree (tmpp);
- tmpp = getnextentry (&value, ':');
+ xfree(tmpp);
+ tmpp = getnextentry(&value, ':');
if (!tmpp)
return 0;
- xfree (tmpp);
- name = getnextentry (&value, ':');
- if (name && _tcslen (name) > 0) {
- path = getnextentry (&value, ',');
- if (path && _tcslen (path) > 0) {
+ xfree(tmpp);
+ name = getnextentry(&value, ':');
+ if (name && _tcslen(name) > 0) {
+ path = getnextentry(&value, ',');
+ if (path && _tcslen(path) > 0) {
for (int i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
struct uaedev_config_info *uci = &p->mountconfig[i].ci;
- if (_tcsicmp (uci->rootdir, name) == 0) {
- _tcscat (uci->rootdir, _T(":"));
- _tcscat (uci->rootdir, path);
+ if (_tcsicmp(uci->rootdir, name) == 0) {
+ _tcscat(uci->rootdir, _T(":"));
+ _tcscat(uci->rootdir, path);
}
}
}
}
- xfree (path);
- xfree (name);
+ xfree(path);
+ xfree(name);
return 1;
}
-static int cfgfile_parse_newfilesys (struct uae_prefs *p, int nr, int type, TCHAR *value, int unit, bool uaehfentry)
+static int cfgfile_parse_newfilesys(struct uae_prefs *p, int nr, int type, TCHAR *value, int unit, bool uaehfentry)
{
struct uaedev_config_info uci;
- TCHAR *tmpp = _tcschr (value, ','), *tmpp2;
- TCHAR *str = NULL;
+ TCHAR *tmpp = _tcschr(value, ','), *tmpp2;
+ TCHAR *str = NULL;
TCHAR devname[MAX_DPATH], volname[MAX_DPATH];
devname[0] = volname[0] = 0;
- uci_set_defaults (&uci, false);
+ uci_set_defaults(&uci, false);
- config_newfilesystem = 1;
- if (tmpp == 0)
- goto invalid_fs;
+ config_newfilesystem = 1;
+ if (tmpp == 0)
+ goto invalid_fs;
- *tmpp++ = '\0';
- if (_tcsicmp (value, _T("ro")) == 0)
+ *tmpp++ = '\0';
+ if (strcasecmp(value, _T("ro")) == 0)
uci.readonly = true;
- else if (_tcsicmp (value, _T("rw")) == 0)
+ else if (strcasecmp(value, _T("rw")) == 0)
uci.readonly = false;
else
- goto invalid_fs;
+ goto invalid_fs;
- value = tmpp;
+ value = tmpp;
if (type == 0) {
uci.type = UAEDEV_DIR;
- tmpp = _tcschr (value, ':');
- if (tmpp == 0)
- goto empty_fs;
- *tmpp++ = 0;
- _tcscpy (devname, value);
+ tmpp = _tcschr(value, ':');
+ if (tmpp == 0)
+ goto empty_fs;
+ *tmpp++ = 0;
+ _tcscpy(devname, value);
tmpp2 = tmpp;
- tmpp = _tcschr (tmpp, ':');
- if (tmpp == 0)
- goto empty_fs;
- *tmpp++ = 0;
- _tcscpy (volname, tmpp2);
+ tmpp = _tcschr(tmpp, ':');
+ if (tmpp == 0)
+ goto empty_fs;
+ *tmpp++ = 0;
+ _tcscpy(volname, tmpp2);
tmpp2 = tmpp;
- // quoted special case
- if (tmpp2[0] == '\"') {
- const TCHAR *end;
- TCHAR *n = cfgfile_unescape (tmpp2, &end, 0);
- if (!n)
- goto invalid_fs;
- _tcscpy (uci.rootdir, n);
- xfree(n);
- tmpp = (TCHAR*)end;
- *tmpp++ = 0;
- } else {
- tmpp = _tcschr (tmpp, ',');
- if (tmpp == 0)
- goto empty_fs;
- *tmpp++ = 0;
- _tcscpy (uci.rootdir, tmpp2);
- }
- _tcscpy (uci.volname, volname);
- _tcscpy (uci.devname, devname);
- if (! getintval (&tmpp, &uci.bootpri, 0))
- goto empty_fs;
- } else if (type == 1 || ((type == 2 || type == 3) && uaehfentry)) {
- tmpp = _tcschr (value, ':');
- if (tmpp == 0)
- goto invalid_fs;
- *tmpp++ = '\0';
- _tcscpy (devname, value);
+ tmpp = _tcschr(tmpp, ',');
+ if (tmpp == 0)
+ goto empty_fs;
+ *tmpp++ = 0;
+ _tcscpy(uci.rootdir, tmpp2);
+ _tcscpy(uci.volname, volname);
+ _tcscpy(uci.devname, devname);
+ if (!getintval(&tmpp, &uci.bootpri, 0))
+ goto empty_fs;
+ }
+ else if (type == 1 || ((type == 2 || type == 3) && uaehfentry)) {
+ tmpp = _tcschr(value, ':');
+ if (tmpp == 0)
+ goto invalid_fs;
+ *tmpp++ = '\0';
+ _tcscpy(devname, value);
tmpp2 = tmpp;
- // quoted special case
- if (tmpp2[0] == '\"') {
- const TCHAR *end;
- TCHAR *n = cfgfile_unescape (tmpp2, &end, 0);
- if (!n)
- goto invalid_fs;
- _tcscpy (uci.rootdir, n);
- xfree(n);
- tmpp = (TCHAR*)end;
- *tmpp++ = 0;
- } else {
- tmpp = _tcschr (tmpp, ',');
- if (tmpp == 0)
- goto invalid_fs;
- *tmpp++ = 0;
- _tcscpy (uci.rootdir, tmpp2);
- }
+ tmpp = _tcschr(tmpp, ',');
+ if (tmpp == 0)
+ goto invalid_fs;
+ *tmpp++ = 0;
+ _tcscpy(uci.rootdir, tmpp2);
if (uci.rootdir[0] != ':')
- get_hd_geometry (&uci);
- _tcscpy (uci.devname, devname);
- if (! getintval (&tmpp, &uci.sectors, ',')
- || ! getintval (&tmpp, &uci.surfaces, ',')
- || ! getintval (&tmpp, &uci.reserved, ',')
- || ! getintval (&tmpp, &uci.blocksize, ','))
- goto invalid_fs;
- if (getintval2 (&tmpp, &uci.bootpri, ',', false)) {
+ get_hd_geometry(&uci);
+ _tcscpy(uci.devname, devname);
+ if (!getintval(&tmpp, &uci.sectors, ',')
+ || !getintval(&tmpp, &uci.surfaces, ',')
+ || !getintval(&tmpp, &uci.reserved, ',')
+ || !getintval(&tmpp, &uci.blocksize, ','))
+ goto invalid_fs;
+ if (getintval2(&tmpp, &uci.bootpri, ',', false)) {
tmpp2 = tmpp;
- tmpp = _tcschr (tmpp, ',');
- if (tmpp != 0) {
- *tmpp++ = 0;
- _tcscpy (uci.filesys, tmpp2);
- TCHAR *tmpp2 = _tcschr (tmpp, ',');
+ tmpp = _tcschr(tmpp, ',');
+ if (tmpp != 0) {
+ *tmpp++ = 0;
+ _tcscpy(uci.filesys, tmpp2);
+ TCHAR *tmpp2 = _tcschr(tmpp, ',');
if (tmpp2)
*tmpp2++ = 0;
- get_filesys_controller (tmpp, &uci.controller_type, &uci.controller_type_unit, &uci.controller_unit);
+ get_filesys_controller(tmpp, &uci.controller_type, &uci.controller_type_unit, &uci.controller_unit);
if (tmpp2) {
- if (getintval2 (&tmpp2, &uci.highcyl, ',', false)) {
- getintval (&tmpp2, &uci.pcyls, '/');
- getintval (&tmpp2, &uci.pheads, '/');
- getintval2 (&tmpp2, &uci.psecs, '/', true);
+ if (getintval2(&tmpp2, &uci.highcyl, ',', false)) {
+ getintval(&tmpp2, &uci.pcyls, '/');
+ getintval(&tmpp2, &uci.pheads, '/');
+ getintval2(&tmpp2, &uci.psecs, '/', true);
if (uci.pheads && uci.psecs) {
uci.physical_geometry = true;
- } else {
+ }
+ else {
uci.pheads = uci.psecs = uci.pcyls = 0;
uci.physical_geometry = false;
- }
- }
- }
+ }
+ }
+ }
uci.controller_media_type = 0;
uci.unit_feature_level = 1;
@@ -2941,188 +4354,214 @@ static int cfgfile_parse_newfilesys (struct uae_prefs *p, int nr, int type, TCHA
uci.unit_feature_level = HD_LEVEL_ATA_2;
else if (cfgfile_option_find(tmpp2, _T("ATA1")))
uci.unit_feature_level = HD_LEVEL_ATA_1;
- }
+ }
}
if (type == 2) {
uci.device_emu_unit = unit;
uci.blocksize = 2048;
uci.readonly = true;
uci.type = UAEDEV_CD;
- } else {
+ }
+ else if (type == 3) {
+ uci.device_emu_unit = unit;
+ uci.blocksize = 512;
+ uci.type = UAEDEV_TAPE;
+ }
+ else {
uci.type = UAEDEV_HDF;
}
- } else {
+ }
+ else {
goto invalid_fs;
}
empty_fs:
if (uci.rootdir[0]) {
- if (_tcslen (uci.rootdir) > 3 && uci.rootdir[0] == 'H' && uci.rootdir[1] == 'D' && uci.rootdir[2] == '_') {
- memmove (uci.rootdir, uci.rootdir + 2, (_tcslen (uci.rootdir + 2) + 1) * sizeof (TCHAR));
+ if (_tcslen(uci.rootdir) > 3 && uci.rootdir[0] == 'H' && uci.rootdir[1] == 'D' && uci.rootdir[2] == '_') {
+ memmove(uci.rootdir, uci.rootdir + 2, (_tcslen(uci.rootdir + 2) + 1) * sizeof(TCHAR));
uci.rootdir[0] = ':';
}
- str = cfgfile_subst_path (UNEXPANDED, p->path_hardfile, uci.rootdir);
- _tcscpy (uci.rootdir, str);
+ str = cfgfile_subst_path_load(UNEXPANDED, &p->path_hardfile, uci.rootdir, false);
+ _tcscpy(uci.rootdir, str);
}
#ifdef FILESYS
- add_filesys_config (p, nr, &uci);
+ add_filesys_config(p, nr, &uci);
#endif
- xfree (str);
- return 1;
+ xfree(str);
+ return 1;
invalid_fs:
cfgfile_warning(_T("Invalid filesystem/hardfile/cd specification.\n"));
return 1;
}
-static int cfgfile_parse_filesys (struct uae_prefs *p, const TCHAR *option, TCHAR *value)
+static int cfgfile_parse_filesys(struct uae_prefs *p, const TCHAR *option, TCHAR *value)
{
int i;
- for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
- TCHAR tmp[100];
- _stprintf (tmp, _T("uaehf%d"), i);
- if (_tcscmp (option, tmp) == 0) {
+ for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
+ TCHAR tmp[100];
+ _stprintf(tmp, _T("uaehf%d"), i);
+ if (_tcscmp(option, tmp) == 0) {
for (;;) {
int type = -1;
int unit = -1;
- TCHAR *tmpp = _tcschr (value, ',');
+ TCHAR *tmpp = _tcschr(value, ',');
if (tmpp == NULL)
- return 1;
- *tmpp++ = 0;
- if (_tcsicmp (value, _T("hdf")) == 0) {
- type = 1;
- cfgfile_parse_partial_newfilesys (p, -1, type, tmpp, unit, true);
return 1;
- } else if (_tcsnicmp (value, _T("cd"), 2) == 0 && (value[2] == 0 || value[3] == 0)) {
+ *tmpp++ = 0;
+ if (_tcsicmp(value, _T("hdf")) == 0) {
+ type = 1;
+ cfgfile_parse_partial_newfilesys(p, -1, type, tmpp, unit, true);
+ return 1;
+ }
+ else if (_tcsnicmp(value, _T("cd"), 2) == 0 && (value[2] == 0 || value[3] == 0)) {
unit = 0;
if (value[2] > 0)
unit = value[2] - '0';
if (unit >= 0 && unit <= MAX_TOTAL_SCSI_DEVICES) {
type = 2;
}
- } else if (_tcsicmp (value, _T("dir")) != 0) {
+ }
+ else if (_tcsnicmp(value, _T("tape"), 4) == 0 && (value[4] == 0 || value[5] == 0)) {
+ unit = 0;
+ if (value[4] > 0)
+ unit = value[4] - '0';
+ if (unit >= 0 && unit <= MAX_TOTAL_SCSI_DEVICES) {
+ type = 3;
+ }
+ }
+ else if (_tcsicmp(value, _T("dir")) != 0) {
type = 0;
return 1; /* ignore for now */
}
if (type >= 0)
- cfgfile_parse_newfilesys (p, -1, type, tmpp, unit, true);
+ cfgfile_parse_newfilesys(p, -1, type, tmpp, unit, true);
return 1;
}
return 1;
- } else if (!_tcsncmp (option, tmp, _tcslen (tmp)) && option[_tcslen (tmp)] == '_') {
+ }
+ else if (!_tcsncmp(option, tmp, _tcslen(tmp)) && option[_tcslen(tmp)] == '_') {
struct uaedev_config_info *uci = &currprefs.mountconfig[i].ci;
if (uci->devname) {
- const TCHAR *s = &option[_tcslen (tmp) + 1];
- if (!_tcscmp (s, _T("bootpri"))) {
- getintval (&value, &uci->bootpri, 0);
- } else if (!_tcscmp (s, _T("read-only"))) {
- cfgfile_yesno (NULL, value, NULL, &uci->readonly);
- } else if (!_tcscmp (s, _T("volumename"))) {
- _tcscpy (uci->volname, value);
- } else if (!_tcscmp (s, _T("devicename"))) {
- _tcscpy (uci->devname, value);
- } else if (!_tcscmp (s, _T("root"))) {
- _tcscpy (uci->rootdir, value);
- } else if (!_tcscmp (s, _T("filesys"))) {
- _tcscpy (uci->filesys, value);
- } else if (!_tcscmp (s, _T("controller"))) {
- get_filesys_controller (value, &uci->controller_type, &uci->controller_type_unit, &uci->controller_unit);
+ const TCHAR *s = &option[_tcslen(tmp) + 1];
+ if (!_tcscmp(s, _T("bootpri"))) {
+ getintval(&value, &uci->bootpri, 0);
+ }
+ else if (!_tcscmp(s, _T("read-only"))) {
+ cfgfile_yesno(NULL, value, NULL, &uci->readonly);
+ }
+ else if (!_tcscmp(s, _T("volumename"))) {
+ _tcscpy(uci->volname, value);
+ }
+ else if (!_tcscmp(s, _T("devicename"))) {
+ _tcscpy(uci->devname, value);
+ }
+ else if (!_tcscmp(s, _T("root"))) {
+ _tcscpy(uci->rootdir, value);
+ }
+ else if (!_tcscmp(s, _T("filesys"))) {
+ _tcscpy(uci->filesys, value);
+ }
+ else if (!_tcscmp(s, _T("controller"))) {
+ get_filesys_controller(value, &uci->controller_type, &uci->controller_type_unit, &uci->controller_unit);
}
}
}
- }
+ }
- if (_tcscmp (option, _T("filesystem")) == 0
- || _tcscmp (option, _T("hardfile")) == 0)
- {
+ if (_tcscmp(option, _T("filesystem")) == 0
+ || _tcscmp(option, _T("hardfile")) == 0)
+ {
struct uaedev_config_info uci;
- TCHAR *tmpp = _tcschr (value, ',');
- TCHAR *str;
+ TCHAR *tmpp = _tcschr(value, ',');
+ TCHAR *str;
bool hdf;
- uci_set_defaults (&uci, false);
+ uci_set_defaults(&uci, false);
- if (config_newfilesystem)
- return 1;
+ if (config_newfilesystem)
+ return 1;
- if (tmpp == 0)
- goto invalid_fs;
+ if (tmpp == 0)
+ goto invalid_fs;
- *tmpp++ = '\0';
- if (_tcscmp (value, _T("1")) == 0 || _tcsicmp (value, _T("ro")) == 0
- || _tcsicmp (value, _T("readonly")) == 0
- || _tcsicmp (value, _T("read-only")) == 0)
+ *tmpp++ = '\0';
+ if (_tcscmp(value, _T("1")) == 0 || strcasecmp(value, _T("ro")) == 0
+ || strcasecmp(value, _T("readonly")) == 0
+ || strcasecmp(value, _T("read-only")) == 0)
uci.readonly = true;
- else if (_tcscmp (value, _T("0")) == 0 || _tcsicmp (value, _T("rw")) == 0
- || _tcsicmp (value, _T("readwrite")) == 0
- || _tcsicmp (value, _T("read-write")) == 0)
+ else if (_tcscmp(value, _T("0")) == 0 || strcasecmp(value, _T("rw")) == 0
+ || strcasecmp(value, _T("readwrite")) == 0
+ || strcasecmp(value, _T("read-write")) == 0)
uci.readonly = false;
- else
- goto invalid_fs;
+ else
+ goto invalid_fs;
- value = tmpp;
- if (_tcscmp (option, _T("filesystem")) == 0) {
+ value = tmpp;
+ if (_tcscmp(option, _T("filesystem")) == 0) {
hdf = false;
- tmpp = _tcschr (value, ':');
- if (tmpp == 0)
- goto invalid_fs;
- *tmpp++ = '\0';
- _tcscpy (uci.volname, value);
- _tcscpy (uci.rootdir, tmpp);
- } else {
+ tmpp = _tcschr(value, ':');
+ if (tmpp == 0)
+ goto invalid_fs;
+ *tmpp++ = '\0';
+ _tcscpy(uci.volname, value);
+ _tcscpy(uci.rootdir, tmpp);
+ }
+ else {
hdf = true;
- if (! getintval (&value, &uci.sectors, ',')
- || ! getintval (&value, &uci.surfaces, ',')
- || ! getintval (&value, &uci.reserved, ',')
- || ! getintval (&value, &uci.blocksize, ','))
- goto invalid_fs;
- _tcscpy (uci.rootdir, value);
- }
- str = cfgfile_subst_path (UNEXPANDED, p->path_hardfile, uci.rootdir);
+ if (!getintval(&value, &uci.sectors, ',')
+ || !getintval(&value, &uci.surfaces, ',')
+ || !getintval(&value, &uci.reserved, ',')
+ || !getintval(&value, &uci.blocksize, ','))
+ goto invalid_fs;
+ _tcscpy(uci.rootdir, value);
+ }
+ str = cfgfile_subst_path_load(UNEXPANDED, &p->path_hardfile, uci.rootdir, true);
#ifdef FILESYS
uci.type = hdf ? UAEDEV_HDF : UAEDEV_DIR;
- add_filesys_config (p, -1, &uci);
+ add_filesys_config(p, -1, &uci);
#endif
- xfree (str);
- return 1;
-invalid_fs:
+ xfree(str);
+ return 1;
+ invalid_fs:
cfgfile_warning(_T("Invalid filesystem/hardfile specification.\n"));
- return 1;
+ return 1;
}
- if (_tcscmp (option, _T("filesystem2")) == 0)
- return cfgfile_parse_newfilesys (p, -1, 0, value, -1, false);
- if (_tcscmp (option, _T("hardfile2")) == 0)
- return cfgfile_parse_newfilesys (p, -1, 1, value, -1, false);
- if (_tcscmp (option, _T("filesystem_extra")) == 0) {
+ if (_tcscmp(option, _T("filesystem2")) == 0)
+ return cfgfile_parse_newfilesys(p, -1, 0, value, -1, false);
+ if (_tcscmp(option, _T("hardfile2")) == 0)
+ return cfgfile_parse_newfilesys(p, -1, 1, value, -1, false);
+ if (_tcscmp(option, _T("filesystem_extra")) == 0) {
int idx = 0;
TCHAR *s = value;
_tcscat(s, _T(","));
struct uaedev_config_info *ci = NULL;
for (;;) {
- TCHAR *tmpp = _tcschr (s, ',');
+ TCHAR *tmpp = _tcschr(s, ',');
if (tmpp == NULL)
return 1;
*tmpp++ = 0;
if (idx == 0) {
for (i = 0; i < p->mountitems; i++) {
- if (p->mountconfig[i].ci.devname && !_tcscmp (p->mountconfig[i].ci.devname, s)) {
+ if (p->mountconfig[i].ci.devname && !_tcscmp(p->mountconfig[i].ci.devname, s)) {
ci = &p->mountconfig[i].ci;
break;
}
}
if (!ci || ci->type != UAEDEV_DIR)
return 1;
- } else {
+ }
+ else {
bool b = true;
TCHAR *tmpp2 = _tcschr(s, '=');
if (tmpp2) {
*tmpp2++ = 0;
- if (!_tcsicmp(tmpp2, _T("false")))
+ if (!strcasecmp(tmpp2, _T("false")))
b = false;
}
- if (!_tcsicmp(s, _T("inject_icons"))) {
+ if (!strcasecmp(s, _T("inject_icons"))) {
ci->inject_icons = b;
}
}
@@ -3134,7 +4573,7 @@ invalid_fs:
return 0;
}
-static bool cfgfile_read_board_rom(struct uae_prefs *p, const TCHAR *option, const TCHAR *value)
+static bool cfgfile_read_board_rom(struct uae_prefs *p, const TCHAR *option, const TCHAR *value, struct multipath *mp)
{
TCHAR buf[256], buf2[MAX_DPATH], buf3[MAX_DPATH];
bool dummy;
@@ -3142,7 +4581,7 @@ static bool cfgfile_read_board_rom(struct uae_prefs *p, const TCHAR *option, con
const struct expansionromtype *ert;
for (int i = 0; expansionroms[i].name; i++) {
- struct boardromconfig *brc;
+ struct boardromconfig *brc;
int idx;
ert = &expansionroms[i];
@@ -3160,8 +4599,12 @@ static bool cfgfile_read_board_rom(struct uae_prefs *p, const TCHAR *option, con
}
_stprintf(buf, _T("%s_rom_file"), name);
- if (cfgfile_path(option, value, buf, buf2, MAX_DPATH / sizeof (TCHAR))) {
+ if (cfgfile_path(option, value, buf, buf2, MAX_DPATH / sizeof(TCHAR), mp)) {
if (buf2[0]) {
+ if (ert->deviceflags & EXPANSIONTYPE_NET) {
+ // make sure network settings are available before parsing net "rom" entries
+ //ethernet_updateselection();
+ }
brc = get_device_rom_new(p, ert->romtype, j, &idx);
_tcscpy(brc->roms[idx].romfile, buf2);
}
@@ -3170,7 +4613,7 @@ static bool cfgfile_read_board_rom(struct uae_prefs *p, const TCHAR *option, con
_stprintf(buf, _T("%s_rom_file_id"), name);
buf2[0] = 0;
- if (cfgfile_rom (option, value, buf, buf2, MAX_DPATH / sizeof (TCHAR))) {
+ if (cfgfile_rom(option, value, buf, buf2, MAX_DPATH / sizeof(TCHAR))) {
if (buf2[0]) {
brc = get_device_rom_new(p, ert->romtype, j, &idx);
_tcscpy(brc->roms[idx].romfile, buf2);
@@ -3178,8 +4621,20 @@ static bool cfgfile_read_board_rom(struct uae_prefs *p, const TCHAR *option, con
return true;
}
+ _stprintf(buf, _T("%s_rom"), name);
+ if (cfgfile_string(option, value, buf, buf2, sizeof buf2 / sizeof(TCHAR))) {
+ if (buf2[0]) {
+ decode_rom_ident(buf3, sizeof(buf3) / sizeof(TCHAR), buf2, ert->romtype);
+ if (buf3[0]) {
+ brc = get_device_rom_new(p, ert->romtype, j, &idx);
+ _tcscpy(brc->roms[idx].romident, buf3);
+ }
+ }
+ return true;
+ }
+
_stprintf(buf, _T("%s_rom_options"), name);
- if (cfgfile_string (option, value, buf, buf2, sizeof buf2 / sizeof (TCHAR))) {
+ if (cfgfile_string(option, value, buf, buf2, sizeof buf2 / sizeof(TCHAR))) {
brc = get_device_rom(p, ert->romtype, j, &idx);
if (brc) {
TCHAR *p;
@@ -3193,13 +4648,34 @@ static bool cfgfile_read_board_rom(struct uae_prefs *p, const TCHAR *option, con
if (ert->settings) {
brc->roms[idx].device_settings = cfgfile_read_rom_settings(ert->settings, buf2, brc->roms[idx].configtext);
}
+ if (ert->id_jumper) {
+ p = cfgfile_option_get(buf2, _T("id"));
+ if (p) {
+ brc->roms[idx].device_id = _tstol(p);
+ }
+ }
+ if (ert->subtypes) {
+ const struct expansionsubromtype *srt = ert->subtypes;
+ TCHAR tmp[MAX_DPATH];
+ p = tmp;
+ *p = 0;
+ while (srt->name) {
+ _tcscpy(p, srt->configname);
+ p += _tcslen(p) + 1;
+ p[0] = 0;
+ srt++;
+ }
+ int v = cfgfile_option_select(buf2, _T("subtype"), tmp);
+ if (v >= 0)
+ brc->roms[idx].subtype = v;
+ }
}
return true;
}
}
_stprintf(buf, _T("%s_mem_size"), ert->name);
- if (cfgfile_intval (option, value, buf, &val, 0x40000)) {
+ if (cfgfile_intval(option, value, buf, &val, 0x40000)) {
if (val) {
brc = get_device_rom_new(p, ert->romtype, 0, &idx);
brc->roms[idx].board_ram_size = val;
@@ -3214,7 +4690,8 @@ static void addbcromtype(struct uae_prefs *p, int romtype, bool add, const TCHAR
{
if (!add) {
clear_device_rom(p, romtype, devnum, true);
- } else {
+ }
+ else {
struct boardromconfig *brc = get_device_rom_new(p, romtype, devnum, NULL);
if (brc && !brc->roms[0].romfile[0]) {
_tcscpy(brc->roms[0].romfile, romfile ? romfile : _T(":ENABLED"));
@@ -3222,66 +4699,220 @@ static void addbcromtype(struct uae_prefs *p, int romtype, bool add, const TCHAR
}
}
-static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCHAR *value)
+static void addbcromtypenet(struct uae_prefs *p, int romtype, const TCHAR *netname, int devnum)
{
- int tmpval, dummyint, i;
- TCHAR tmpbuf[CONFIG_BLEN];
+ int is = is_device_rom(p, romtype, devnum);
+ if (netname == NULL || netname[0] == 0) {
+ if (is < 0)
+ clear_device_rom(p, romtype, devnum, true);
+ }
+ else {
+ if (is < 0) {
+ struct boardromconfig *brc = get_device_rom_new(p, romtype, devnum, NULL);
+ if (brc) {
+ if (!brc->roms[0].romfile[0]) {
+ _tcscpy(brc->roms[0].romfile, _T(":ENABLED"));
+ }
+ //ethernet_updateselection();
+ //if (!brc->roms[0].device_settings)
+ // brc->roms[0].device_settings = ethernet_getselection(netname);
+ }
+ }
+ }
+}
- if (cfgfile_yesno (option, value, _T("immediate_blits"), &p->immediate_blits)
- || cfgfile_yesno (option, value, _T("fast_copper"), &p->fast_copper)
- || cfgfile_yesno(option, value, _T("fpu_no_unimplemented"), &p->fpu_no_unimplemented)
- || cfgfile_yesno (option, value, _T("cd32cd"), &p->cs_cd32cd)
- || cfgfile_yesno (option, value, _T("cd32c2p"), &p->cs_cd32c2p)
- || cfgfile_yesno (option, value, _T("cd32nvram"), &p->cs_cd32nvram)
+static int cfgfile_parse_hardware(struct uae_prefs *p, const TCHAR *option, TCHAR *value)
+{
+ int tmpval, dummyint, i;
+ bool dummybool;
+ TCHAR tmpbuf[CONFIG_BLEN];
+
+ if (cfgfile_yesno(option, value, _T("cpu_cycle_exact"), &p->cpu_cycle_exact)) {
+ /* we don't want cycle-exact in 68020/40+JIT modes */
+ if (p->cpu_model >= 68020 && p->cachesize > 0)
+ p->cpu_cycle_exact = p->cpu_memory_cycle_exact = p->blitter_cycle_exact = false;
+ p->cpu_memory_cycle_exact = p->cpu_cycle_exact;
+ return 1;
+ }
+ if (cfgfile_yesno(option, value, _T("blitter_cycle_exact"), &p->blitter_cycle_exact)) {
+ if (p->cpu_model >= 68020 && p->cachesize > 0)
+ p->cpu_cycle_exact = p->cpu_memory_cycle_exact = p->blitter_cycle_exact = false;
+ return 1;
+ }
+ if (cfgfile_yesno(option, value, _T("cpu_memory_cycle_exact"), &p->cpu_memory_cycle_exact)) {
+ if (!p->cpu_memory_cycle_exact)
+ p->blitter_cycle_exact = p->cpu_cycle_exact = false;
+ return 1;
+ }
+ if (cfgfile_strval(option, value, _T("cycle_exact"), &tmpval, cycleexact, 0)) {
+ if (tmpval > 0) {
+ p->blitter_cycle_exact = true;
+ p->cpu_cycle_exact = tmpval > 1;
+ p->cpu_memory_cycle_exact = true;
+ }
+ else {
+ p->blitter_cycle_exact = false;
+ p->cpu_cycle_exact = false;
+ p->cpu_memory_cycle_exact = false;
+ }
+ if (p->cpu_model >= 68020 && p->cachesize > 0)
+ p->cpu_cycle_exact = p->cpu_memory_cycle_exact = p->blitter_cycle_exact = false;
+ // if old version and CE and fastest possible: set to approximate
+ if (p->cpu_cycle_exact && p->config_version < ((2 << 16) | (8 << 8) | (2 << 0)) && p->m68k_speed < 0)
+ p->m68k_speed = 0;
+ return 1;
+ }
+
+ if (cfgfile_string(option, value, _T("cpu_multiplier"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
+ p->cpu_clock_multiplier = (int)(_tstof(tmpbuf) * 256.0);
+ return 1;
+ }
+
+
+ if (cfgfile_string(option, value, _T("a2065"), p->a2065name, sizeof p->a2065name / sizeof(TCHAR))) {
+ if (p->a2065name[0])
+ addbcromtype(p, ROMTYPE_A2065, true, NULL, 0);
+ return 1;
+ }
+
+ if (cfgfile_string(option, value, _T("ne2000_pci"), p->ne2000pciname, sizeof p->ne2000pciname / sizeof(TCHAR)))
+ return 1;
+ if (cfgfile_string(option, value, _T("ne2000_pcmcia"), p->ne2000pcmcianame, sizeof p->ne2000pcmcianame / sizeof(TCHAR)))
+ return 1;
+
+ if (cfgfile_yesno(option, value, _T("immediate_blits"), &p->immediate_blits)
+ || cfgfile_yesno(option, value, _T("fpu_no_unimplemented"), &p->fpu_no_unimplemented)
+ || cfgfile_yesno(option, value, _T("cpu_no_unimplemented"), &p->int_no_unimplemented)
+ || cfgfile_yesno(option, value, _T("cd32cd"), &p->cs_cd32cd)
+ || cfgfile_yesno(option, value, _T("cd32c2p"), &p->cs_cd32c2p)
+ || cfgfile_yesno(option, value, _T("cd32nvram"), &p->cs_cd32nvram)
+ || cfgfile_yesno(option, value, _T("cdtvcd"), &p->cs_cdtvcd)
+ || cfgfile_yesno(option, value, _T("cdtv-cr"), &p->cs_cdtvcr)
+ || cfgfile_yesno(option, value, _T("cdtvram"), &p->cs_cdtvram)
+ || cfgfile_yesno(option, value, _T("a1000ram"), &p->cs_a1000ram)
+ || cfgfile_yesno(option, value, _T("scsi_cdtv"), &p->cs_cdtvscsi)
|| cfgfile_yesno(option, value, _T("cia_overlay"), &p->cs_ciaoverlay)
+ || cfgfile_yesno(option, value, _T("bogomem_fast"), &p->cs_slowmemisfast)
|| cfgfile_yesno(option, value, _T("ksmirror_e0"), &p->cs_ksmirror_e0)
|| cfgfile_yesno(option, value, _T("ksmirror_a8"), &p->cs_ksmirror_a8)
+ || cfgfile_yesno(option, value, _T("resetwarning"), &p->cs_resetwarning)
|| cfgfile_yesno(option, value, _T("cia_todbug"), &p->cs_ciatodbug)
+ || cfgfile_yesno(option, value, _T("denise_noehb"), &p->cs_denisenoehb)
+ || cfgfile_yesno(option, value, _T("ics_agnus"), &p->cs_dipagnus)
|| cfgfile_yesno(option, value, _T("z3_autoconfig"), &p->cs_z3autoconfig)
- || cfgfile_yesno (option, value, _T("ntsc"), &p->ntscmode)
- || cfgfile_yesno (option, value, _T("cpu_compatible"), &p->cpu_compatible)
- || cfgfile_yesno (option, value, _T("cpu_24bit_addressing"), &p->address_space_24)
- || cfgfile_yesno (option, value, _T("fpu_strict"), &p->fpu_strict)
- || cfgfile_yesno (option, value, _T("fpu_softfloat"), &p->fpu_softfloat)
- || cfgfile_yesno (option, value, _T("floppy_write_protect"), &p->floppy_read_only)
- || cfgfile_yesno(option, value, _T("harddrive_write_protect"), &p->harddrive_read_only))
- return 1;
+ || cfgfile_yesno(option, value, _T("color_burst"), &p->cs_color_burst)
+ || cfgfile_yesno(option, value, _T("1mchipjumper"), &p->cs_1mchipjumper)
+ || cfgfile_yesno(option, value, _T("agnus_bltbusybug"), &p->cs_agnusbltbusybug)
+ || cfgfile_yesno(option, value, _T("gfxcard_hardware_vblank"), &p->rtg_hardwareinterrupt)
+ || cfgfile_yesno(option, value, _T("gfxcard_hardware_sprite"), &p->rtg_hardwaresprite)
+ || cfgfile_yesno(option, value, _T("synchronize_clock"), &p->tod_hack)
+ || cfgfile_yesno(option, value, _T("keyboard_connected"), &p->keyboard_connected)
- if (cfgfile_intval (option, value, _T("cachesize"), &p->cachesize, 1)
- || cfgfile_intval (option, value, _T("cd32nvram_size"), &p->cs_cd32nvram_size, 1024)
- || cfgfile_intval (option, value, _T("fatgary"), &p->cs_fatgaryrev, 1)
- || cfgfile_intval (option, value, _T("ramsey"), &p->cs_ramseyrev, 1)
- || cfgfile_floatval (option, value, _T("chipset_refreshrate"), &p->chipset_refreshrate)
- || cfgfile_intval (option, value, _T("a3000mem_size"), &p->mbresmem_low_size, 0x100000)
- || cfgfile_intval (option, value, _T("mbresmem_size"), &p->mbresmem_high_size, 0x100000)
- || cfgfile_intval (option, value, _T("z3mem_start"), &p->z3autoconfig_start, 1)
- || cfgfile_intval (option, value, _T("bogomem_size"), &p->bogomem_size, 0x40000)
- || cfgfile_intval (option, value, _T("rtg_modes"), &p->picasso96_modeflags, 1)
- || cfgfile_intval (option, value, _T("floppy_speed"), &p->floppy_speed, 1)
- || cfgfile_intval (option, value, _T("cd_speed"), &p->cd_speed, 1)
- || cfgfile_intval (option, value, _T("floppy_write_length"), &p->floppy_write_length, 1)
- || cfgfile_intval (option, value, _T("nr_floppies"), &p->nr_floppies, 1)
- || cfgfile_intval (option, value, _T("floppy0type"), &p->floppyslots[0].dfxtype, 1)
- || cfgfile_intval (option, value, _T("floppy1type"), &p->floppyslots[1].dfxtype, 1)
- || cfgfile_intval (option, value, _T("floppy2type"), &p->floppyslots[2].dfxtype, 1)
- || cfgfile_intval (option, value, _T("floppy3type"), &p->floppyslots[3].dfxtype, 1))
- return 1;
+ || cfgfile_yesno(option, value, _T("kickshifter"), &p->kickshifter)
+ || cfgfile_yesno(option, value, _T("ks_write_enabled"), &p->rom_readwrite)
+ || cfgfile_yesno(option, value, _T("ntsc"), &p->ntscmode)
+ || cfgfile_yesno(option, value, _T("sana2"), &p->sana2)
+ || cfgfile_yesno(option, value, _T("genlock"), &p->genlock)
+ || cfgfile_yesno(option, value, _T("genlock_alpha"), &p->genlock_alpha)
+ || cfgfile_yesno(option, value, _T("genlock_aspect"), &p->genlock_aspect)
+ || cfgfile_yesno(option, value, _T("cpu_compatible"), &p->cpu_compatible)
+ || cfgfile_yesno(option, value, _T("cpu_threaded"), &p->cpu_thread)
+ || cfgfile_yesno(option, value, _T("cpu_24bit_addressing"), &p->address_space_24)
+ || cfgfile_yesno(option, value, _T("cpu_reset_pause"), &p->reset_delay)
+ || cfgfile_yesno(option, value, _T("parallel_on_demand"), &p->parallel_demand)
+ || cfgfile_yesno(option, value, _T("parallel_postscript_emulation"), &p->parallel_postscript_emulation)
+ || cfgfile_yesno(option, value, _T("parallel_postscript_detection"), &p->parallel_postscript_detection)
+ || cfgfile_yesno(option, value, _T("serial_on_demand"), &p->serial_demand)
+ || cfgfile_yesno(option, value, _T("serial_hardware_ctsrts"), &p->serial_hwctsrts)
+ || cfgfile_yesno(option, value, _T("serial_direct"), &p->serial_direct)
+ || cfgfile_yesno(option, value, _T("fpu_strict"), &p->fpu_strict)
+ || cfgfile_yesno(option, value, _T("fpu_softfloat"), &p->fpu_softfloat)
+ || cfgfile_yesno(option, value, _T("comp_nf"), &p->compnf)
+ || cfgfile_yesno(option, value, _T("comp_constjump"), &p->comp_constjump)
+#ifdef USE_JIT_FPU
+ || cfgfile_yesno(option, value, _T("compfpu"), &p->compfpu)
+#endif
+ || cfgfile_yesno(option, value, _T("rtg_nocustom"), &p->picasso96_nocustom)
+ || cfgfile_yesno(option, value, _T("floppy_write_protect"), &p->floppy_read_only)
+ || cfgfile_yesno(option, value, _T("harddrive_write_protect"), &p->harddrive_read_only)
+ || cfgfile_yesno(option, value, _T("uae_hide_autoconfig"), &p->uae_hide_autoconfig)
+ || cfgfile_yesno(option, value, _T("board_custom_order"), &p->autoconfig_custom_sort)
+ || cfgfile_yesno(option, value, _T("uaeserial"), &p->uaeserial))
+ return 1;
- if (cfgfile_strval (option, value, _T("rtc"), &p->cs_rtc, rtctype, 0)
- || cfgfile_strval (option, value, _T("ciaatod"), &p->cs_ciaatod, ciaatodmode, 0)
- || cfgfile_strval (option, value, _T("collision_level"), &p->collision_level, collmode, 0)
- || cfgfile_strval (option, value, _T("waiting_blits"), &p->waiting_blits, waitblits, 0)
- || cfgfile_strval (option, value, _T("floppy_auto_extended_adf"), &p->floppy_auto_ext2, autoext2, 0)
- || cfgfile_strval (option, value, _T("z3mapping"), &p->z3_mapping_mode, z3mapping, 0)
+ if (cfgfile_intval(option, value, _T("cachesize"), &p->cachesize, 1)
+ || cfgfile_intval(option, value, _T("cd32nvram_size"), &p->cs_cd32nvram_size, 1024)
+ || cfgfile_intval(option, value, _T("chipset_hacks"), &p->cs_hacks, 1)
+ || cfgfile_intval(option, value, _T("serial_stopbits"), &p->serial_stopbits, 1)
+ || cfgfile_intval(option, value, _T("cpu060_revision"), &p->cpu060_revision, 1)
+ || cfgfile_intval(option, value, _T("fpu_revision"), &p->fpu_revision, 1)
+ || cfgfile_intval(option, value, _T("cdtvramcard"), &p->cs_cdtvcard, 1)
+ || cfgfile_intval(option, value, _T("fatgary"), &p->cs_fatgaryrev, 1)
+ || cfgfile_intval(option, value, _T("ramsey"), &p->cs_ramseyrev, 1)
+ || cfgfile_doubleval(option, value, _T("chipset_refreshrate"), &p->chipset_refreshrate)
+ || cfgfile_intval(option, value, _T("cpuboardmem1_size"), &p->cpuboardmem1_size, 0x100000)
+ || cfgfile_intval(option, value, _T("cpuboardmem2_size"), &p->cpuboardmem2_size, 0x100000)
+ || cfgfile_intval(option, value, _T("mem25bit_size"), &p->mem25bit_size, 0x100000)
+ || cfgfile_intval(option, value, _T("a3000mem_size"), &p->mbresmem_low_size, 0x100000)
+ || cfgfile_intval(option, value, _T("mbresmem_size"), &p->mbresmem_high_size, 0x100000)
+ || cfgfile_intval(option, value, _T("megachipmem_size"), &p->z3chipmem_size, 0x100000)
+ || cfgfile_intval(option, value, _T("z3mem_start"), &p->z3autoconfig_start, 1)
+ || cfgfile_intval(option, value, _T("bogomem_size"), &p->bogomem_size, 0x40000)
+ || cfgfile_intval(option, value, _T("rtg_modes"), &p->picasso96_modeflags, 1)
+ || cfgfile_intval(option, value, _T("floppy_speed"), &p->floppy_speed, 1)
+ || cfgfile_intval(option, value, _T("cd_speed"), &p->cd_speed, 1)
+ || cfgfile_intval(option, value, _T("floppy_write_length"), &p->floppy_write_length, 1)
+ || cfgfile_intval(option, value, _T("floppy_random_bits_min"), &p->floppy_random_bits_min, 1)
+ || cfgfile_intval(option, value, _T("floppy_random_bits_max"), &p->floppy_random_bits_max, 1)
+ || cfgfile_intval(option, value, _T("nr_floppies"), &p->nr_floppies, 1)
+ || cfgfile_intval(option, value, _T("floppy0type"), &p->floppyslots[0].dfxtype, 1)
+ || cfgfile_intval(option, value, _T("floppy1type"), &p->floppyslots[1].dfxtype, 1)
+ || cfgfile_intval(option, value, _T("floppy2type"), &p->floppyslots[2].dfxtype, 1)
+ || cfgfile_intval(option, value, _T("floppy3type"), &p->floppyslots[3].dfxtype, 1)
+ || cfgfile_intval(option, value, _T("maprom"), &p->maprom, 1)
+ || cfgfile_intval(option, value, _T("parallel_autoflush"), &p->parallel_autoflush_time, 1)
+ || cfgfile_intval(option, value, _T("uae_hide"), &p->uae_hide, 1)
+ || cfgfile_intval(option, value, _T("cpu_frequency"), &p->cpu_frequency, 1)
+ || cfgfile_intval(option, value, _T("kickstart_ext_rom_file2addr"), &p->romextfile2addr, 1)
+ || cfgfile_intval(option, value, _T("genlock_scale"), &p->genlock_scale, 1)
+ || cfgfile_intval(option, value, _T("genlock_mix"), &p->genlock_mix, 1))
+ return 1;
+
+ if (cfgfile_strval(option, value, _T("comp_trustbyte"), &p->comptrustbyte, compmode, 0)
+ || cfgfile_strval(option, value, _T("rtc"), &p->cs_rtc, rtctype, 0)
+ || cfgfile_strval(option, value, _T("ciaatod"), &p->cs_ciaatod, ciaatodmode, 0)
+ || cfgfile_strval(option, value, _T("scsi"), &p->scsi, scsimode, 0)
+ || cfgfile_strval(option, value, _T("comp_trustword"), &p->comptrustword, compmode, 0)
+ || cfgfile_strval(option, value, _T("comp_trustlong"), &p->comptrustlong, compmode, 0)
+ || cfgfile_strval(option, value, _T("comp_trustnaddr"), &p->comptrustnaddr, compmode, 0)
+ || cfgfile_strval(option, value, _T("collision_level"), &p->collision_level, collmode, 0)
+ || cfgfile_strval(option, value, _T("parallel_matrix_emulation"), &p->parallel_matrix_emulation, epsonprinter, 0)
+ || cfgfile_strval(option, value, _T("monitoremu"), &p->monitoremu, specialmonitors, 0)
+ || cfgfile_strval(option, value, _T("genlockmode"), &p->genlock_image, genlockmodes, 0)
+ || cfgfile_strval(option, value, _T("waiting_blits"), &p->waiting_blits, waitblits, 0)
+ || cfgfile_strval(option, value, _T("floppy_auto_extended_adf"), &p->floppy_auto_ext2, autoext2, 0)
+ || cfgfile_strval(option, value, _T("z3mapping"), &p->z3_mapping_mode, z3mapping, 0)
+ || cfgfile_strval(option, value, _T("scsidev_mode"), &p->uaescsidevmode, uaescsidevmodes, 0)
|| cfgfile_strval(option, value, _T("boot_rom_uae"), &p->boot_rom, uaebootrom, 0)
- || cfgfile_strval(option, value, _T("uaeboard"), &p->uaeboard, uaeboard, 0))
- return 1;
+ || cfgfile_strval(option, value, _T("uaeboard"), &p->uaeboard, uaeboard, 0)
+ || cfgfile_strval(option, value, _T("serial_translate"), &p->serial_crlf, serialcrlf, 0)
+ || cfgfile_strboolval(option, value, _T("comp_flushmode"), &p->comp_hardflush, flushmode, 0))
+ return 1;
- if (cfgfile_path (option, value, _T("kickstart_rom_file"), p->romfile, sizeof p->romfile / sizeof (TCHAR))
- || cfgfile_path (option, value, _T("kickstart_ext_rom_file"), p->romextfile, sizeof p->romextfile / sizeof (TCHAR))
- || cfgfile_path (option, value, _T("flash_file"), p->flashfile, sizeof p->flashfile / sizeof (TCHAR))
- || cfgfile_path (option, value, _T("cart_file"), p->cartfile, sizeof p->cartfile / sizeof (TCHAR)))
- return 1;
+ if (cfgfile_path(option, value, _T("kickstart_rom_file"), p->romfile, sizeof p->romfile / sizeof(TCHAR), &p->path_rom)
+ || cfgfile_path(option, value, _T("kickstart_ext_rom_file"), p->romextfile, sizeof p->romextfile / sizeof(TCHAR), &p->path_rom)
+ || cfgfile_path(option, value, _T("kickstart_ext_rom_file2"), p->romextfile2, sizeof p->romextfile2 / sizeof(TCHAR), &p->path_rom)
+ || cfgfile_rom(option, value, _T("kickstart_rom_file_id"), p->romfile, sizeof p->romfile / sizeof(TCHAR))
+ || cfgfile_rom(option, value, _T("kickstart_ext_rom_file_id"), p->romextfile, sizeof p->romextfile / sizeof(TCHAR))
+ || cfgfile_path(option, value, _T("flash_file"), p->flashfile, sizeof p->flashfile / sizeof(TCHAR), &p->path_rom)
+ || cfgfile_path(option, value, _T("cart_file"), p->cartfile, sizeof p->cartfile / sizeof(TCHAR), &p->path_rom)
+ || cfgfile_path(option, value, _T("rtc_file"), p->rtcfile, sizeof p->rtcfile / sizeof(TCHAR), &p->path_rom)
+ || cfgfile_path(option, value, _T("picassoiv_rom_file"), p->picassoivromfile, sizeof p->picassoivromfile / sizeof(TCHAR), &p->path_rom)
+ || cfgfile_string(option, value, _T("genlock_image"), p->genlock_image_file, sizeof p->genlock_image_file / sizeof(TCHAR))
+ || cfgfile_string(option, value, _T("genlock_video"), p->genlock_video_file, sizeof p->genlock_video_file / sizeof(TCHAR))
+ || cfgfile_string(option, value, _T("pci_devices"), p->pci_devices, sizeof p->pci_devices / sizeof(TCHAR))
+ || cfgfile_string(option, value, _T("ghostscript_parameters"), p->ghostscript_parameters, sizeof p->ghostscript_parameters / sizeof(TCHAR)))
+ return 1;
if (cfgfile_string(option, value, _T("uaeboard_options"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
TCHAR *s = cfgfile_option_get(value, _T("order"));
@@ -3307,12 +4938,60 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH
addbcromtype(p, ROMTYPE_MB_IDE, true, NULL, 0);
return 1;
}
+ if (cfgfile_yesno(option, value, _T("scsi_a3000"), &dummybool)) {
+ if (dummybool) {
+ addbcromtype(p, ROMTYPE_SCSI_A3000, true, NULL, 0);
+ p->cs_mbdmac = 1;
+ }
+ return 1;
+ }
+ if (cfgfile_yesno(option, value, _T("scsi_a4000t"), &dummybool)) {
+ if (dummybool) {
+ addbcromtype(p, ROMTYPE_SCSI_A4000T, true, NULL, 0);
+ p->cs_mbdmac = 2;
+ }
+ return 1;
+ }
if (cfgfile_yesno(option, value, _T("cd32fmv"), &p->cs_cd32fmv)) {
if (p->cs_cd32fmv) {
addbcromtype(p, ROMTYPE_CD32CART, true, p->cartfile, 0);
}
return 1;
}
+ if (cfgfile_intval(option, value, _T("catweasel"), &p->catweasel, 1)) {
+ if (p->catweasel) {
+ addbcromtype(p, ROMTYPE_CATWEASEL, true, NULL, 0);
+ }
+ return 1;
+ }
+ if (cfgfile_yesno(option, value, _T("toccata"), &dummybool))
+ {
+ if (dummybool) {
+ addbcromtype(p, ROMTYPE_TOCCATA, true, NULL, 0);
+ }
+ return 1;
+ }
+ if (cfgfile_yesno(option, value, _T("es1370_pci"), &dummybool))
+ {
+ if (dummybool) {
+ addbcromtype(p, ROMTYPE_ES1370, true, NULL, 0);
+ }
+ return 1;
+ }
+ if (cfgfile_yesno(option, value, _T("fm801_pci"), &dummybool))
+ {
+ if (dummybool) {
+ addbcromtype(p, ROMTYPE_FM801, true, NULL, 0);
+ }
+ return 1;
+ }
+ if (cfgfile_yesno(option, value, _T("toccata_mixer"), &dummybool))
+ {
+ if (dummybool) {
+ addbcromtype(p, ROMTYPE_TOCCATA, true, NULL, 0);
+ }
+ return 1;
+ }
for (int i = 0; i < MAX_RTG_BOARDS; i++) {
struct rtgboardconfig *rbc = &p->rtgboards[i];
@@ -3340,6 +5019,7 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH
_tcscpy(tmp, _T("gfxcard_type"));
if (cfgfile_string(option, value, tmp, tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
rbc->rtgmem_type = 0;
+ rbc->rtg_index = i;
int j = 0;
for (;;) {
const TCHAR *t = gfxboard_get_configname(j);
@@ -3356,142 +5036,248 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH
}
}
- if (cfgfile_strval (option, value, _T("chipset_compatible"), &p->cs_compatible, cscompa, 0)) {
- built_in_chipset_prefs (p);
+ if (cfgfile_string(option, value, _T("cpuboard_type"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
+ p->cpuboard_type = 0;
+ p->cpuboard_subtype = 0;
+ for (i = 0; cpuboards[i].name && !p->cpuboard_type; i++) {
+ const struct cpuboardtype *cbt = &cpuboards[i];
+ if (cbt->subtypes) {
+ for (int j = 0; cbt->subtypes[j].name; j++) {
+ if (!_tcsicmp(cbt->subtypes[j].configname, tmpbuf)) {
+ p->cpuboard_type = i;
+ p->cpuboard_subtype = j;
+ }
+ }
+ }
+ }
return 1;
}
-
- if (cfgfile_strval (option, value, _T("cart_internal"), &p->cart_internal, cartsmode, 0)) {
- if (p->cart_internal) {
- struct romdata *rd = getromdatabyid (63);
- if (rd)
- _stprintf (p->cartfile, _T(":%s"), rd->configname);
+ if (cfgfile_string(option, value, _T("cpuboard_settings"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
+ p->cpuboard_settings = 0;
+ const struct cpuboardsubtype *cbst = &cpuboards[p->cpuboard_type].subtypes[p->cpuboard_subtype];
+ if (cbst->settings) {
+ p->cpuboard_settings = cfgfile_read_rom_settings(cbst->settings, tmpbuf, NULL);
}
return 1;
}
- if (cfgfile_read_board_rom(p, option, value))
- return 1;
-
- for (i = 0; i < 4; i++) {
- _stprintf (tmpbuf, _T("floppy%d"), i);
- if (cfgfile_path (option, value, tmpbuf, p->floppyslots[i].df, sizeof p->floppyslots[i].df / sizeof (TCHAR)))
- return 1;
- }
-
- if (cfgfile_intval (option, value, _T("chipmem_size"), &dummyint, 1)) {
- if (dummyint < 0)
- p->chipmem_size = 0x20000; /* 128k, prototype support */
- else if (dummyint == 0)
- p->chipmem_size = 0x40000; /* 256k */
- else
- p->chipmem_size = dummyint * 0x80000;
- return 1;
- }
-
- if (cfgfile_string (option, value, _T("addmem1"), tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
- parse_addmem (p, tmpbuf, 0);
- return 1;
- }
- if (cfgfile_string (option, value, _T("addmem2"), tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
- parse_addmem (p, tmpbuf, 1);
+ if (cfgfile_strval(option, value, _T("chipset_compatible"), &p->cs_compatible, cscompa, 0)) {
+ built_in_chipset_prefs(p);
return 1;
}
- if (cfgfile_strval (option, value, _T("chipset"), &tmpval, csmode, 0)) {
- set_chipset_mask (p, tmpval);
- return 1;
- }
+ if (cfgfile_strval(option, value, _T("cart_internal"), &p->cart_internal, cartsmode, 0)) {
+ if (p->cart_internal) {
+ struct romdata *rd = getromdatabyid(63);
+ if (rd)
+ _stprintf(p->cartfile, _T(":%s"), rd->configname);
+ }
+ return 1;
+ }
+ if (cfgfile_string(option, value, _T("kickstart_rom"), p->romident, sizeof p->romident / sizeof(TCHAR))) {
+ decode_rom_ident(p->romfile, sizeof p->romfile / sizeof(TCHAR), p->romident, ROMTYPE_ALL_KICK);
+ return 1;
+ }
+ if (cfgfile_string(option, value, _T("kickstart_ext_rom"), p->romextident, sizeof p->romextident / sizeof(TCHAR))) {
+ decode_rom_ident(p->romextfile, sizeof p->romextfile / sizeof(TCHAR), p->romextident, ROMTYPE_ALL_EXT);
+ return 1;
+ }
- if (cfgfile_string (option, value, _T("fpu_model"), tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
- p->fpu_model = _tstol(tmpbuf);
- return 1;
- }
+ if (cfgfile_string(option, value, _T("cart"), p->cartident, sizeof p->cartident / sizeof(TCHAR))) {
+ decode_rom_ident(p->cartfile, sizeof p->cartfile / sizeof(TCHAR), p->cartident, ROMTYPE_ALL_CART);
+ return 1;
+ }
- if (cfgfile_string (option, value, _T("cpu_model"), tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
- p->cpu_model = _tstol(tmpbuf);
- p->fpu_model = 0;
- return 1;
- }
+ if (cfgfile_read_board_rom(p, option, value, &p->path_rom))
+ return 1;
- /* old-style CPU configuration */
- if (cfgfile_string (option, value, _T("cpu_type"), tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
+ for (i = 0; i < 4; i++) {
+ _stprintf(tmpbuf, _T("floppy%d"), i);
+ if (cfgfile_path(option, value, tmpbuf, p->floppyslots[i].df, sizeof p->floppyslots[i].df / sizeof(TCHAR), &p->path_floppy))
+ return 1;
+ }
+
+ if (cfgfile_intval(option, value, _T("chipmem_size"), &dummyint, 1)) {
+ if (dummyint < 0)
+ p->chipmem_size = 0x20000; /* 128k, prototype support */
+ else if (dummyint == 0)
+ p->chipmem_size = 0x40000; /* 256k */
+ else
+ p->chipmem_size = dummyint * 0x80000;
+ return 1;
+ }
+
+ if (cfgfile_string(option, value, _T("addmem1"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
+ parse_addmem(p, tmpbuf, 0);
+ return 1;
+ }
+ if (cfgfile_string(option, value, _T("addmem2"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
+ parse_addmem(p, tmpbuf, 1);
+ return 1;
+ }
+
+ if (cfgfile_strval(option, value, _T("chipset"), &tmpval, csmode, 0)) {
+ set_chipset_mask(p, tmpval);
+ return 1;
+ }
+
+ if (cfgfile_string(option, value, _T("mmu_model"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
+ p->mmu_model = _tstol(tmpbuf);
+ return 1;
+ }
+
+ if (cfgfile_string(option, value, _T("fpu_model"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
+ p->fpu_model = _tstol(tmpbuf);
+ return 1;
+ }
+
+ if (cfgfile_string(option, value, _T("cpu_model"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
+ p->cpu_model = _tstol(tmpbuf);
+ p->fpu_model = 0;
+ return 1;
+ }
+
+ if (cfgfile_strval(option, value, _T("ppc_implementation"), &p->ppc_implementation, ppc_implementations, 0))
+ return 1;
+ if (cfgfile_string(option, value, _T("ppc_model"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
+ p->ppc_mode = 0;
+ p->ppc_model[0] = 0;
+ if (!_tcsicmp(tmpbuf, _T("automatic"))) {
+ p->ppc_mode = 1;
+ }
+ else if (!_tcsicmp(tmpbuf, _T("manual"))) {
+ p->ppc_mode = 2;
+ }
+ else {
+ if (tmpbuf[0] && _tcslen(tmpbuf) < sizeof(p->ppc_model) / sizeof(TCHAR)) {
+ _tcscpy(p->ppc_model, tmpbuf);
+ p->ppc_mode = 2;
+ }
+ }
+ return 1;
+ }
+ if (cfgfile_strval(option, value, _T("ppc_cpu_idle"), &p->ppc_cpu_idle, ppc_cpu_idle, 0))
+ return 1;
+
+ /* old-style CPU configuration */
+ if (cfgfile_string(option, value, _T("cpu_type"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) {
// 68000/010 32-bit addressing was not available until 2.8.2
bool force24bit = p->config_version <= ((2 << 16) | (8 << 8) | (1 << 0));
- p->fpu_model = 0;
- p->address_space_24 = 0;
- p->cpu_model = 680000;
- if (!_tcscmp (tmpbuf, _T("68000"))) {
- p->cpu_model = 68000;
+ p->fpu_model = 0;
+ p->address_space_24 = 0;
+ p->cpu_model = 680000;
+ if (!_tcscmp(tmpbuf, _T("68000"))) {
+ p->cpu_model = 68000;
if (force24bit)
p->address_space_24 = 1;
- } else if (!_tcscmp (tmpbuf, _T("68010"))) {
- p->cpu_model = 68010;
+ }
+ else if (!_tcscmp(tmpbuf, _T("68010"))) {
+ p->cpu_model = 68010;
if (force24bit)
p->address_space_24 = 1;
- } else if (!_tcscmp (tmpbuf, _T("68ec020"))) {
- p->cpu_model = 68020;
- } else if (!_tcscmp (tmpbuf, _T("68020"))) {
- p->cpu_model = 68020;
- } else if (!_tcscmp (tmpbuf, _T("68ec020/68881"))) {
- p->cpu_model = 68020;
- p->fpu_model = 68881;
- p->address_space_24 = 1;
- } else if (!_tcscmp (tmpbuf, _T("68020/68881"))) {
- p->cpu_model = 68020;
- p->fpu_model = 68881;
- } else if (!_tcscmp (tmpbuf, _T("68040"))) {
- p->cpu_model = 68040;
- p->fpu_model = 68040;
- }
- return 1;
- }
-
- /* Broken earlier versions used to write this out as a string. */
- if (cfgfile_strval (option, value, _T("finegraincpu_speed"), &p->m68k_speed, speedmode, 1)) {
- p->m68k_speed--;
- return 1;
- }
+ }
+ else if (!_tcscmp(tmpbuf, _T("68ec020"))) {
+ p->cpu_model = 68020;
+ }
+ else if (!_tcscmp(tmpbuf, _T("68020"))) {
+ p->cpu_model = 68020;
+ }
+ else if (!_tcscmp(tmpbuf, _T("68ec020/68881"))) {
+ p->cpu_model = 68020;
+ p->fpu_model = 68881;
+ p->address_space_24 = 1;
+ }
+ else if (!_tcscmp(tmpbuf, _T("68020/68881"))) {
+ p->cpu_model = 68020;
+ p->fpu_model = 68881;
+ }
+ else if (!_tcscmp(tmpbuf, _T("68040"))) {
+ p->cpu_model = 68040;
+ p->fpu_model = 68040;
+ }
+ else if (!_tcscmp(tmpbuf, _T("68060"))) {
+ p->cpu_model = 68060;
+ p->fpu_model = 68060;
+ }
+ return 1;
+ }
- if (cfgfile_strval (option, value, _T("cpu_speed"), &p->m68k_speed, speedmode, 1)) {
+ /* Broken earlier versions used to write this out as a string. */
+ if (cfgfile_strval(option, value, _T("finegraincpu_speed"), &p->m68k_speed, speedmode, 1)) {
p->m68k_speed--;
return 1;
}
- if (cfgfile_intval (option, value, _T("cpu_speed"), &p->m68k_speed, 1)) {
- p->m68k_speed *= CYCLE_UNIT;
- return 1;
- }
- if (cfgfile_intval (option, value, _T("finegrain_cpu_speed"), &p->m68k_speed, 1)) {
- if (OFFICIAL_CYCLE_UNIT > CYCLE_UNIT) {
- int factor = OFFICIAL_CYCLE_UNIT / CYCLE_UNIT;
- p->m68k_speed = (p->m68k_speed + factor - 1) / factor;
- }
- if (_tcsicmp (value, _T("max")) == 0)
- p->m68k_speed = -1;
- return 1;
- }
- if (_tcsicmp (option, _T("quickstart")) == 0) {
+ if (cfgfile_strval(option, value, _T("cpu_speed"), &p->m68k_speed, speedmode, 1)) {
+ p->m68k_speed--;
+ return 1;
+ }
+ if (cfgfile_intval(option, value, _T("cpu_speed"), &p->m68k_speed, 1)) {
+ p->m68k_speed *= CYCLE_UNIT;
+ return 1;
+ }
+ if (cfgfile_doubleval(option, value, _T("cpu_throttle"), &p->m68k_speed_throttle)) {
+ return 1;
+ }
+ if (cfgfile_doubleval(option, value, _T("cpu_x86_throttle"), &p->x86_speed_throttle)) {
+ return 1;
+ }
+ if (cfgfile_intval(option, value, _T("finegrain_cpu_speed"), &p->m68k_speed, 1)) {
+ if (OFFICIAL_CYCLE_UNIT > CYCLE_UNIT) {
+ int factor = OFFICIAL_CYCLE_UNIT / CYCLE_UNIT;
+ p->m68k_speed = (p->m68k_speed + factor - 1) / factor;
+ }
+ if (strcasecmp(value, _T("max")) == 0)
+ p->m68k_speed = -1;
+ return 1;
+ }
+
+ if (cfgfile_intval(option, value, _T("dongle"), &p->dongle, 1)) {
+ if (p->dongle == 0)
+ cfgfile_strval(option, value, _T("dongle"), &p->dongle, dongles, 0);
+ return 1;
+ }
+
+ if (strcasecmp(option, _T("quickstart")) == 0) {
int model = 0;
- TCHAR *tmpp = _tcschr (value, ',');
+ TCHAR *tmpp = _tcschr(value, ',');
if (tmpp) {
*tmpp++ = 0;
- TCHAR *tmpp2 = _tcschr (value, ',');
+ TCHAR *tmpp2 = _tcschr(value, ',');
if (tmpp2)
*tmpp2 = 0;
- cfgfile_strval (option, value, option, &model, qsmodes, 0);
+ cfgfile_strval(option, value, option, &model, qsmodes, 0);
if (model >= 0) {
- int config = _tstol (tmpp);
- built_in_prefs (p, model, config, 0, 0);
+ int config = _tstol(tmpp);
+ built_in_prefs(p, model, config, 0, 0);
}
}
- return 1;
- }
+ return 1;
+ }
- if (cfgfile_parse_filesys (p, option, value))
+ if (cfgfile_parse_filesys(p, option, value))
return 1;
- return 0;
+ return 0;
+}
+
+static void romtype_restricted(struct uae_prefs *p, const int *list)
+{
+ for (int i = 0; list[i]; i++) {
+ int romtype = list[i];
+ if (is_board_enabled(p, romtype, 0)) {
+ i++;
+ while (list[i]) {
+ romtype = list[i];
+ if (is_board_enabled(p, romtype, 0)) {
+ write_log(_T("ROMTYPE %08x removed\n"), romtype);
+ addbcromtype(p, romtype, false, NULL, 0);
+ }
+ i++;
+ return;
+ }
+ }
+ }
}
void cfgfile_compatibility_rtg(struct uae_prefs *p)
@@ -3500,11 +5286,12 @@ void cfgfile_compatibility_rtg(struct uae_prefs *p)
// only one uaegfx
for (int i = 0; i < MAX_RTG_BOARDS; i++) {
struct rtgboardconfig *rbc = &p->rtgboards[i];
- if (rbc->rtgmem_size) {
+ if (rbc->rtgmem_size && rbc->rtgmem_type < GFXBOARD_HARDWARE) {
if (uaegfx >= 0) {
rbc->rtgmem_size = 0;
rbc->rtgmem_type = 0;
- } else {
+ }
+ else {
uaegfx = i;
}
}
@@ -3520,6 +5307,30 @@ void cfgfile_compatibility_rtg(struct uae_prefs *p)
rbc2->rtgmem_size = size;
rbc2->rtgmem_type = type;
}
+ // allow only one a2410 and vga
+ int a2410 = -1;
+ int vga = -1;
+ //for (int i = 0; i < MAX_RTG_BOARDS; i++) {
+ // struct rtgboardconfig *rbc = &p->rtgboards[i];
+ // if (rbc->rtgmem_type == GFXBOARD_A2410) {
+ // if (a2410 >= 0) {
+ // rbc->rtgmem_size = 0;
+ // rbc->rtgmem_type = 0;
+ // }
+ // else {
+ // a2410 = i;
+ // }
+ // }
+ // if (rbc->rtgmem_type == GFXBOARD_VGA) {
+ // if (vga >= 0) {
+ // rbc->rtgmem_size = 0;
+ // rbc->rtgmem_type = 0;
+ // }
+ // else {
+ // vga = i;
+ // }
+ // }
+ //}
// empty slots last
bool reorder = true;
while (reorder) {
@@ -3539,21 +5350,94 @@ void cfgfile_compatibility_rtg(struct uae_prefs *p)
}
}
}
+ int rtgs[MAX_RTG_BOARDS] = { 0 };
+ //for (int i = 0; i < MAX_RTG_BOARDS; i++) {
+ // if (p->rtgboards[i].rtgmem_size && !rtgs[i]) {
+ // uae_u32 romtype = gfxboard_get_romtype(&p->rtgboards[i]);
+ // if (romtype) {
+ // int devnum = 0;
+ // for (int j = i; j < MAX_RTG_BOARDS; j++) {
+ // rtgs[j] = 1;
+ // if (gfxboard_get_romtype(&p->rtgboards[j]) == romtype) {
+ // TCHAR *romname = NULL;
+ // if (romtype == ROMTYPE_PICASSOIV) {
+ // romname = p->picassoivromfile;
+ // }
+ // else if (romtype == ROMTYPE_x86_VGA) {
+ // romname = _T("");
+ // }
+ // addbcromtype(p, romtype, true, romname, devnum);
+ // devnum++;
+ // }
+ // }
+ // while (devnum < MAX_DUPLICATE_EXPANSION_BOARDS) {
+ // addbcromtype(p, romtype, false, NULL, devnum);
+ // devnum++;
+ // }
+ // }
+ // }
+ //}
+ //for (int i = 0; i < MAX_RTG_BOARDS; i++) {
+ // if (!rtgs[i]) {
+ // uae_u32 romtype = gfxboard_get_romtype(&p->rtgboards[i]);
+ // if (romtype) {
+ // for (int devnum = 0; devnum < MAX_DUPLICATE_EXPANSION_BOARDS; devnum++) {
+ // addbcromtype(p, romtype, false, NULL, devnum);
+ // }
+ // }
+ // }
+ //}
}
void cfgfile_compatibility_romtype(struct uae_prefs *p)
{
- addbcromtype(p, ROMTYPE_MB_PCMCIA, p->cs_pcmcia, NULL, 0);
+ addbcromtype(p, ROMTYPE_MB_PCMCIA, p->cs_pcmcia, NULL, 0);
addbcromtype(p, ROMTYPE_MB_IDE, p->cs_ide != 0, NULL, 0);
- addbcromtype(p, ROMTYPE_CD32CART, p->cs_cd32fmv, p->cartfile,0);
+ if (p->cs_mbdmac == 1) {
+ addbcromtype(p, ROMTYPE_SCSI_A4000T, false, NULL, 0);
+ addbcromtype(p, ROMTYPE_SCSI_A3000, true, NULL, 0);
+ }
+ else if (p->cs_mbdmac == 2) {
+ addbcromtype(p, ROMTYPE_SCSI_A3000, false, NULL, 0);
+ addbcromtype(p, ROMTYPE_SCSI_A4000T, true, NULL, 0);
+ }
+ else {
+ addbcromtype(p, ROMTYPE_SCSI_A3000, false, NULL, 0);
+ addbcromtype(p, ROMTYPE_SCSI_A4000T, false, NULL, 0);
+ }
+
+ addbcromtype(p, ROMTYPE_CDTVDMAC, p->cs_cdtvcd && !p->cs_cdtvcr, NULL, 0);
+ addbcromtype(p, ROMTYPE_CDTVSCSI, p->cs_cdtvscsi, NULL, 0);
+
+ addbcromtype(p, ROMTYPE_CDTVCR, p->cs_cdtvcr, NULL, 0);
+
+ addbcromtype(p, ROMTYPE_CD32CART, p->cs_cd32fmv, p->cartfile, 0);
+
+ if (p->config_version < ((3 << 16) | (4 << 8) | (0 << 0))) {
+ // 3.3.0 or older
+ addbcromtypenet(p, ROMTYPE_A2065, p->a2065name, 0);
+ addbcromtypenet(p, ROMTYPE_NE2KPCMCIA, p->ne2000pcmcianame, 0);
+ addbcromtypenet(p, ROMTYPE_NE2KPCI, p->ne2000pciname, 0);
+ }
+
+ static const int restricted_net[] = {
+ ROMTYPE_A2065, ROMTYPE_NE2KPCMCIA, ROMTYPE_NE2KPCI, ROMTYPE_NE2KISA,
+ ROMTYPE_ARIADNE2, ROMTYPE_XSURF, ROMTYPE_XSURF100Z2, ROMTYPE_XSURF100Z3,
+ ROMTYPE_HYDRA, ROMTYPE_LANROVER,
+ 0 };
+ static const int restricted_x86[] = { ROMTYPE_A1060, ROMTYPE_A2088, ROMTYPE_A2088T, ROMTYPE_A2286, ROMTYPE_A2386, 0 };
+ static const int restricted_pci[] = { ROMTYPE_GREX, ROMTYPE_MEDIATOR, ROMTYPE_PROMETHEUS, 0 };
+ romtype_restricted(p, restricted_net);
+ romtype_restricted(p, restricted_x86);
+ romtype_restricted(p, restricted_pci);
}
-static bool createconfigstore (struct uae_prefs*);
-static int getconfigstoreline (const TCHAR *option, TCHAR *value);
+static bool createconfigstore(struct uae_prefs*);
+static int getconfigstoreline(const TCHAR *option, TCHAR *value);
-static void calcformula (struct uae_prefs *prefs, TCHAR *in)
+static void calcformula(struct uae_prefs *prefs, TCHAR *in)
{
TCHAR out[MAX_DPATH], configvalue[CONFIG_BLEN];
TCHAR *p = out;
@@ -3561,35 +5445,36 @@ static void calcformula (struct uae_prefs *prefs, TCHAR *in)
int cnt1, cnt2;
static bool updatestore;
- if (_tcslen (in) < 2 || in[0] != '[' || in[_tcslen (in) - 1] != ']')
+ if (_tcslen(in) < 2 || in[0] != '[' || in[_tcslen(in) - 1] != ']')
return;
if (!configstore || updatestore)
- createconfigstore (prefs);
+ createconfigstore(prefs);
updatestore = false;
if (!configstore)
return;
cnt1 = cnt2 = 0;
- for (int i = 1; i < _tcslen (in) - 1; i++) {
- TCHAR c = _totupper (in[i]);
- if (c >= 'A' && c <='Z') {
+ for (int i = 1; i < _tcslen(in) - 1; i++) {
+ TCHAR c = _totupper(in[i]);
+ if (c >= 'A' && c <= 'Z') {
TCHAR *start = &in[i];
- while (_istalnum (c) || c == '_' || c == '.') {
+ while (_istalnum(c) || c == '_' || c == '.') {
i++;
c = in[i];
}
TCHAR store = in[i];
in[i] = 0;
//write_log (_T("'%s'\n"), start);
- if (!getconfigstoreline (start, configvalue))
+ if (!getconfigstoreline(start, configvalue))
return;
- _tcscpy (p, configvalue);
- p += _tcslen (p);
+ _tcscpy(p, configvalue);
+ p += _tcslen(p);
in[i] = store;
i--;
cnt1++;
- } else {
+ }
+ else {
cnt2++;
- *p ++= c;
+ *p++ = c;
}
}
*p = 0;
@@ -3597,438 +5482,592 @@ static void calcformula (struct uae_prefs *prefs, TCHAR *in)
return;
/* single config entry only? */
if (cnt1 == 1 && cnt2 == 0) {
- _tcscpy (in, out);
+ _tcscpy(in, out);
updatestore = true;
return;
}
- if (calc (out, &val)) {
+ if (calc(out, &val)) {
if (val - (int)val != 0.0f)
- _stprintf (in, _T("%f"), val);
+ _stprintf(in, _T("%f"), val);
else
- _stprintf (in, _T("%d"), (int)val);
+ _stprintf(in, _T("%d"), (int)val);
updatestore = true;
return;
}
}
-int cfgfile_parse_option (struct uae_prefs *p, const TCHAR *option, TCHAR *value, int type)
+int cfgfile_parse_option(struct uae_prefs *p, const TCHAR *option, TCHAR *value, int type)
{
- calcformula (p, value);
+ calcformula(p, value);
- if (!_tcscmp (option, _T("config_hardware")))
- return 1;
- if (!_tcscmp (option, _T("config_host")))
- return 1;
- if (type == 0 || (type & CONFIG_TYPE_HARDWARE)) {
- if (cfgfile_parse_hardware (p, option, value))
- return 1;
- }
- if (type == 0 || (type & CONFIG_TYPE_HOST)) {
+ if (!_tcscmp(option, _T("debug"))) {
+ write_log(_T("CONFIG DEBUG: '%s'\n"), value);
+ return 1;
+ }
+ if (!_tcscmp(option, _T("config_hardware")))
+ return 1;
+ if (!_tcscmp(option, _T("config_host")))
+ return 1;
+ if (cfgfile_path(option, value, _T("config_all_path"), p->config_all_path, sizeof p->config_all_path / sizeof(TCHAR)))
+ return 1;
+ if (cfgfile_path(option, value, _T("config_hardware_path"), p->config_hardware_path, sizeof p->config_hardware_path / sizeof(TCHAR)))
+ return 1;
+ if (cfgfile_path(option, value, _T("config_host_path"), p->config_host_path, sizeof p->config_host_path / sizeof(TCHAR)))
+ return 1;
+ if (type == 0 || (type & CONFIG_TYPE_HARDWARE)) {
+ if (cfgfile_parse_hardware(p, option, value))
+ return 1;
+ }
+ if (type == 0 || (type & CONFIG_TYPE_HOST)) {
// cfgfile_parse_host may modify the option (convert to lowercase).
TCHAR* writable_option = my_strdup(option);
- if (cfgfile_parse_host (p, writable_option, value)) {
+ if (cfgfile_parse_host(p, writable_option, value)) {
free(writable_option);
- return 1;
+ return 1;
}
free(writable_option);
- }
+ }
if (type > 0 && (type & (CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST)) != (CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST))
- return 1;
- return 0;
+ return 1;
+ return 0;
}
-static int isutf8ext (TCHAR *s)
+static int isutf8ext(TCHAR *s)
{
- if (_tcslen (s) > _tcslen (UTF8NAME) && !_tcscmp (s + _tcslen (s) - _tcslen (UTF8NAME), UTF8NAME)) {
- s[_tcslen (s) - _tcslen (UTF8NAME)] = 0;
+ if (_tcslen(s) > _tcslen(UTF8NAME) && !_tcscmp(s + _tcslen(s) - _tcslen(UTF8NAME), UTF8NAME)) {
+ s[_tcslen(s) - _tcslen(UTF8NAME)] = 0;
return 1;
}
return 0;
}
-int cfgfile_separate_linea (const TCHAR *filename, char *line, TCHAR *line1b, TCHAR *line2b)
+static int cfgfile_separate_linea(const TCHAR *filename, char *line, TCHAR *line1b, TCHAR *line2b)
{
- char *line1, *line2;
- int i;
+ char *line1, *line2;
+ int i;
- line1 = line;
- line1 += strspn (line1, "\t \r\n");
- if (*line1 == ';')
- return 0;
- line2 = strchr (line, '=');
- if (! line2) {
- TCHAR *s = au (line1);
+ line1 = line;
+ line1 += strspn(line1, "\t \r\n");
+ if (*line1 == ';')
+ return 0;
+ line2 = strchr(line, '=');
+ if (!line2) {
+ TCHAR *s = au(line1);
cfgfile_warning(_T("CFGFILE: '%s', linea was incomplete with only %s\n"), filename, s);
- xfree (s);
- return 0;
- }
- *line2++ = '\0';
-
- /* Get rid of whitespace. */
- i = strlen (line2);
- while (i > 0 && (line2[i - 1] == '\t' || line2[i - 1] == ' '
- || line2[i - 1] == '\r' || line2[i - 1] == '\n'))
- line2[--i] = '\0';
- line2 += strspn (line2, "\t \r\n");
-
- i = strlen (line);
- while (i > 0 && (line[i - 1] == '\t' || line[i - 1] == ' '
- || line[i - 1] == '\r' || line[i - 1] == '\n'))
- line[--i] = '\0';
- line += strspn (line, "\t \r\n");
-
- au_copy (line1b, MAX_DPATH, line);
- if (isutf8ext (line1b)) {
- if (line2[0]) {
- TCHAR *s = utf8u (line2);
- _tcscpy (line2b, s);
- xfree (s);
- }
- } else {
- au_copy (line2b, MAX_DPATH, line2);
+ xfree(s);
+ return 0;
}
+ *line2++ = '\0';
- return 1;
+ /* Get rid of whitespace. */
+ i = strlen(line2);
+ while (i > 0 && (line2[i - 1] == '\t' || line2[i - 1] == ' '
+ || line2[i - 1] == '\r' || line2[i - 1] == '\n'))
+ line2[--i] = '\0';
+ line2 += strspn(line2, "\t \r\n");
+
+ i = strlen(line);
+ while (i > 0 && (line[i - 1] == '\t' || line[i - 1] == ' '
+ || line[i - 1] == '\r' || line[i - 1] == '\n'))
+ line[--i] = '\0';
+ line += strspn(line, "\t \r\n");
+ au_copy(line1b, MAX_DPATH, line);
+ if (isutf8ext(line1b)) {
+ if (line2[0]) {
+ TCHAR *s = utf8u(line2);
+ _tcscpy(line2b, s);
+ xfree(s);
+ }
+ }
+ else {
+ au_copy(line2b, MAX_DPATH, line2);
+ }
+ return 1;
}
-static int cfgfile_separate_line (TCHAR *line, TCHAR *line1b, TCHAR *line2b)
+static int cfgfile_separate_line(TCHAR *line, TCHAR *line1b, TCHAR *line2b)
{
TCHAR *line1, *line2;
int i;
line1 = line;
- line1 += _tcsspn (line1, _T("\t \r\n"));
+ line1 += _tcsspn(line1, _T("\t \r\n"));
if (*line1 == ';')
return 0;
- line2 = _tcschr (line, '=');
- if (! line2) {
+ line2 = _tcschr(line, '=');
+ if (!line2) {
cfgfile_warning(_T("CFGFILE: line was incomplete with only %s\n"), line1);
return 0;
}
*line2++ = '\0';
/* Get rid of whitespace. */
- i = _tcslen (line2);
+ i = _tcslen(line2);
while (i > 0 && (line2[i - 1] == '\t' || line2[i - 1] == ' '
|| line2[i - 1] == '\r' || line2[i - 1] == '\n'))
line2[--i] = '\0';
- line2 += _tcsspn (line2, _T("\t \r\n"));
- _tcscpy (line2b, line2);
- i = _tcslen (line);
+ line2 += _tcsspn(line2, _T("\t \r\n"));
+ _tcscpy(line2b, line2);
+ i = _tcslen(line);
while (i > 0 && (line[i - 1] == '\t' || line[i - 1] == ' '
|| line[i - 1] == '\r' || line[i - 1] == '\n'))
line[--i] = '\0';
- line += _tcsspn (line, _T("\t \r\n"));
- _tcscpy (line1b, line);
+ line += _tcsspn(line, _T("\t \r\n"));
+ _tcscpy(line1b, line);
if (line2b[0] == '"' || line2b[0] == '\"') {
TCHAR c = line2b[0];
int i = 0;
- memmove (line2b, line2b + 1, (_tcslen (line2b) + 1) * sizeof (TCHAR));
+ memmove(line2b, line2b + 1, (_tcslen(line2b) + 1) * sizeof(TCHAR));
while (line2b[i] != 0 && line2b[i] != c)
i++;
line2b[i] = 0;
}
- if (isutf8ext (line1b))
+ if (isutf8ext(line1b))
return 0;
return 1;
}
-static int isobsolete (TCHAR *s)
+static int isobsolete(TCHAR *s)
{
- int i = 0;
- while (obsolete[i]) {
- if (!_tcsicmp (s, obsolete[i])) {
+ int i = 0;
+ while (obsolete[i]) {
+ if (!strcasecmp(s, obsolete[i])) {
cfgfile_warning_obsolete(_T("obsolete config entry '%s'\n"), s);
- return 1;
- }
- i++;
- }
- if (_tcslen (s) > 2 && !_tcsncmp (s, _T("w."), 2))
- return 1;
- if (_tcslen (s) >= 10 && !_tcsncmp (s, _T("gfx_opengl"), 10)) {
+ return 1;
+ }
+ i++;
+ }
+ if (_tcslen(s) > 2 && !_tcsncmp(s, _T("w."), 2))
+ return 1;
+ if (_tcslen(s) >= 10 && !_tcsncmp(s, _T("gfx_opengl"), 10)) {
cfgfile_warning_obsolete(_T("obsolete config entry '%s\n"), s);
- return 1;
- }
- if (_tcslen (s) >= 6 && !_tcsncmp (s, _T("gfx_3d"), 6)) {
+ return 1;
+ }
+ if (_tcslen(s) >= 6 && !_tcsncmp(s, _T("gfx_3d"), 6)) {
cfgfile_warning_obsolete(_T("obsolete config entry '%s\n"), s);
- return 1;
- }
- return 0;
+ return 1;
+ }
+ return 0;
}
-static void cfgfile_parse_separated_line (struct uae_prefs *p, TCHAR *line1b, TCHAR *line2b, int type)
+static void cfgfile_parse_separated_line(struct uae_prefs *p, TCHAR *line1b, TCHAR *line2b, int type)
{
- TCHAR line3b[CONFIG_BLEN], line4b[CONFIG_BLEN];
- struct strlist *sl;
- int ret;
+ TCHAR line3b[CONFIG_BLEN], line4b[CONFIG_BLEN];
+ struct strlist *sl;
+ int ret;
- _tcscpy (line3b, line1b);
- _tcscpy (line4b, line2b);
- ret = cfgfile_parse_option (p, line1b, line2b, type);
- if (!isobsolete (line3b)) {
- for (sl = p->all_lines; sl; sl = sl->next) {
- if (sl->option && !_tcsicmp (line1b, sl->option)) break;
- }
- if (!sl) {
- struct strlist *u = xcalloc (struct strlist, 1);
- u->option = my_strdup(line3b);
- u->value = my_strdup(line4b);
- u->next = p->all_lines;
- p->all_lines = u;
- if (!ret) {
- u->unknown = 1;
+ _tcscpy(line3b, line1b);
+ _tcscpy(line4b, line2b);
+ ret = cfgfile_parse_option(p, line1b, line2b, type);
+ if (!isobsolete(line3b)) {
+ for (sl = p->all_lines; sl; sl = sl->next) {
+ if (sl->option && !strcasecmp(line1b, sl->option)) break;
+ }
+ if (!sl) {
+ struct strlist *u = xcalloc(struct strlist, 1);
+ u->option = my_strdup(line3b);
+ u->value = my_strdup(line4b);
+ u->next = p->all_lines;
+ p->all_lines = u;
+ if (!ret) {
+ u->unknown = 1;
cfgfile_warning(_T("unknown config entry: '%s=%s'\n"), u->option, u->value);
- }
- }
- }
+ }
+ }
+ }
}
-void cfgfile_parse_line (struct uae_prefs *p, TCHAR *line, int type)
+void cfgfile_parse_lines(struct uae_prefs *p, const TCHAR *lines, int type)
{
- TCHAR line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
-
- if (!cfgfile_separate_line (line, line1b, line2b))
- return;
- cfgfile_parse_separated_line (p, line1b, line2b, type);
+ TCHAR *buf = my_strdup(lines);
+ TCHAR *t = buf;
+ for (;;) {
+ if (_tcslen(t) == 0)
+ break;
+ TCHAR *t2 = _tcschr(t, '\n');
+ if (t2)
+ *t2 = 0;
+ cfgfile_parse_line(p, t, type);
+ if (!t2)
+ break;
+ t = t2 + 1;
+ }
+ xfree(buf);
}
-static void subst (TCHAR *p, TCHAR *f, int n)
+void cfgfile_parse_line(struct uae_prefs *p, TCHAR *line, int type)
+{
+ TCHAR line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
+
+ if (!cfgfile_separate_line(line, line1b, line2b))
+ return;
+ cfgfile_parse_separated_line(p, line1b, line2b, type);
+}
+
+static void subst(TCHAR *p, TCHAR *f, int n)
{
if (_tcslen(p) == 0 || _tcslen(f) == 0)
return;
- TCHAR *str = cfgfile_subst_path (UNEXPANDED, p, f);
- _tcsncpy (f, str, n - 1);
- f[n - 1] = '\0';
- free (str);
+ TCHAR *str = cfgfile_subst_path(UNEXPANDED, p, f);
+ _tcsncpy(f, str, n - 1);
+ f[n - 1] = '\0';
+ free(str);
}
-static int getconfigstoreline (const TCHAR *option, TCHAR *value)
+static int getconfigstoreline(const TCHAR *option, TCHAR *value)
{
TCHAR tmp[CONFIG_BLEN * 2], tmp2[CONFIG_BLEN * 2];
if (!configstore)
return 0;
- zfile_fseek (configstore, 0, SEEK_SET);
+ zfile_fseek(configstore, 0, SEEK_SET);
for (;;) {
- if (!zfile_fgets (tmp, sizeof tmp / sizeof (TCHAR), configstore))
+ if (!zfile_fgets(tmp, sizeof tmp / sizeof(TCHAR), configstore))
return 0;
- if (!cfgfile_separate_line (tmp, tmp2, value))
+ if (!cfgfile_separate_line(tmp, tmp2, value))
continue;
- if (!_tcsicmp (option, tmp2))
+ if (!_tcsicmp(option, tmp2))
return 1;
}
}
-static bool createconfigstore (struct uae_prefs *p)
+static bool createconfigstore(struct uae_prefs *p)
{
uae_u8 zeros[4] = { 0 };
- zfile_fclose (configstore);
- configstore = zfile_fopen_empty (NULL, _T("configstore"), 50000);
+ zfile_fclose(configstore);
+ configstore = zfile_fopen_empty(NULL, _T("configstore"), 50000);
if (!configstore)
return false;
- zfile_fseek (configstore, 0, SEEK_SET);
+ zfile_fseek(configstore, 0, SEEK_SET);
uaeconfig++;
- cfgfile_save_options (configstore, p, 0);
+ cfgfile_save_options(configstore, p, 0);
uaeconfig--;
- zfile_fwrite (zeros, 1, sizeof zeros, configstore);
- zfile_fseek (configstore, 0, SEEK_SET);
+ zfile_fwrite(zeros, 1, sizeof zeros, configstore);
+ zfile_fseek(configstore, 0, SEEK_SET);
return true;
}
-static char *cfg_fgets (char *line, int max, struct zfile *fh)
+static char *cfg_fgets(char *line, int max, struct zfile *fh)
{
- if (fh)
- return zfile_fgetsa (line, max, fh);
- return 0;
+#ifdef SINGLEFILE
+ extern TCHAR singlefile_config[];
+ static TCHAR *sfile_ptr;
+ TCHAR *p;
+#endif
+
+ if (fh)
+ return zfile_fgetsa(line, max, fh);
+#ifdef SINGLEFILE
+ if (sfile_ptr == 0) {
+ sfile_ptr = singlefile_config;
+ if (*sfile_ptr) {
+ write_log(_T("singlefile config found\n"));
+ while (*sfile_ptr++);
+ }
+ }
+ if (*sfile_ptr == 0) {
+ sfile_ptr = singlefile_config;
+ return 0;
+ }
+ p = sfile_ptr;
+ while (*p != 13 && *p != 10 && *p != 0) p++;
+ memset(line, 0, max);
+ memcpy(line, sfile_ptr, (p - sfile_ptr) * sizeof(TCHAR));
+ sfile_ptr = p + 1;
+ if (*sfile_ptr == 13)
+ sfile_ptr++;
+ if (*sfile_ptr == 10)
+ sfile_ptr++;
+ return line;
+#endif
+ return 0;
}
-static int cfgfile_load_2 (struct uae_prefs *p, const TCHAR *filename, bool real, int *type)
+static int cfgfile_load_2(struct uae_prefs *p, const TCHAR *filename, bool real, int *type)
{
- int i;
- struct zfile *fh;
- char linea[CONFIG_BLEN];
- TCHAR line[CONFIG_BLEN], line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
- struct strlist *sl;
- bool type1 = false, type2 = false;
- int askedtype = 0;
+ int i;
+ struct zfile *fh;
+ char linea[CONFIG_BLEN];
+ TCHAR line[CONFIG_BLEN], line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
+ struct strlist *sl;
+ bool type1 = false, type2 = false;
+ int askedtype = 0;
- if (type) {
- askedtype = *type;
- *type = 0;
- }
- if (real) {
- p->config_version = 0;
- config_newfilesystem = 0;
- //reset_inputdevice_config (p);
- }
+ if (type) {
+ askedtype = *type;
+ *type = 0;
+ }
+ if (real) {
+ p->config_version = 0;
+ config_newfilesystem = 0;
+ //reset_inputdevice_config (p);
+ }
- fh = zfile_fopen (filename, _T("r"), ZFD_NORMAL);
- if (! fh)
- return 0;
+ fh = zfile_fopen(filename, _T("r"), ZFD_NORMAL);
+#ifndef SINGLEFILE
+ if (!fh)
+ return 0;
+#endif
- while (cfg_fgets (linea, sizeof (linea), fh) != 0) {
- trimwsa (linea);
- if (strlen (linea) > 0) {
+ while (cfg_fgets(linea, sizeof(linea), fh) != 0) {
+ trimwsa(linea);
+ if (strlen(linea) > 0) {
if (linea[0] == '#' || linea[0] == ';') {
- struct strlist *u = xcalloc (struct strlist, 1);
+ struct strlist *u = xcalloc(struct strlist, 1);
u->option = NULL;
- TCHAR *com = au (linea);
- u->value = my_strdup (com);
- xfree (com);
+ TCHAR *com = au(linea);
+ u->value = my_strdup(com);
+ xfree(com);
u->unknown = 1;
u->next = p->all_lines;
p->all_lines = u;
- continue;
+ continue;
+ }
+ if (!cfgfile_separate_linea(filename, linea, line1b, line2b))
+ continue;
+ type1 = type2 = 0;
+ if (cfgfile_yesno(line1b, line2b, _T("config_hardware"), &type1) ||
+ cfgfile_yesno(line1b, line2b, _T("config_host"), &type2)) {
+ if (type1 && type)
+ *type |= CONFIG_TYPE_HARDWARE;
+ if (type2 && type)
+ *type |= CONFIG_TYPE_HOST;
+ continue;
+ }
+ if (real) {
+ cfgfile_parse_separated_line(p, line1b, line2b, askedtype);
+ }
+ else {
+ cfgfile_string(line1b, line2b, _T("config_description"), p->description, sizeof p->description / sizeof(TCHAR));
+ cfgfile_path(line1b, line2b, _T("config_hardware_path"), p->config_hardware_path, sizeof p->config_hardware_path / sizeof(TCHAR));
+ cfgfile_path(line1b, line2b, _T("config_host_path"), p->config_host_path, sizeof p->config_host_path / sizeof(TCHAR));
+ cfgfile_path(line1b, line2b, _T("config_all_path"), p->config_all_path, sizeof p->config_all_path / sizeof(TCHAR));
+ cfgfile_string(line1b, line2b, _T("config_window_title"), p->config_window_title, sizeof p->config_window_title / sizeof(TCHAR));
}
- if (!cfgfile_separate_linea (filename, linea, line1b, line2b))
- continue;
- type1 = type2 = 0;
- if (cfgfile_yesno (line1b, line2b, _T("config_hardware"), &type1) ||
- cfgfile_yesno (line1b, line2b, _T("config_host"), &type2)) {
- if (type1 && type)
- *type |= CONFIG_TYPE_HARDWARE;
- if (type2 && type)
- *type |= CONFIG_TYPE_HOST;
- continue;
- }
- if (real) {
- cfgfile_parse_separated_line (p, line1b, line2b, askedtype);
- } else {
- cfgfile_string (line1b, line2b, _T("config_description"), p->description, sizeof p->description / sizeof (TCHAR));
- }
- }
- }
-
- if (type && *type == 0)
- *type = CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST;
- zfile_fclose (fh);
-
- if (!real)
- return 1;
-
- for (sl = temp_lines; sl; sl = sl->next) {
- _stprintf (line, _T("%s=%s"), sl->option, sl->value);
- cfgfile_parse_line (p, line, 0);
- }
-
- for (i = 0; i < 4; i++) {
- subst (p->path_floppy, p->floppyslots[i].df, sizeof p->floppyslots[i].df / sizeof (TCHAR));
- if(i >= p->nr_floppies)
- p->floppyslots[i].dfxtype = DRV_NONE;
- }
- subst (p->path_rom, p->romfile, sizeof p->romfile / sizeof (TCHAR));
- subst (p->path_rom, p->romextfile, sizeof p->romextfile / sizeof (TCHAR));
-
- for (i = 0; i < MAX_EXPANSION_BOARDS; i++) {
- for (int j = 0; j < MAX_BOARD_ROMS; j++) {
- subst(p->path_rom, p->expansionboard[i].roms[j].romfile, MAX_DPATH / sizeof(TCHAR));
}
}
- return 1;
+ if (type && *type == 0)
+ *type = CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST;
+ zfile_fclose(fh);
+
+ if (!real)
+ return 1;
+
+ for (sl = temp_lines; sl; sl = sl->next) {
+ _stprintf(line, _T("%s=%s"), sl->option, sl->value);
+ cfgfile_parse_line(p, line, 0);
+ }
+
+ for (i = 0; i < 4; i++)
+ subst(p->path_floppy.path[0], p->floppyslots[i].df, sizeof p->floppyslots[i].df / sizeof(TCHAR));
+ subst(p->path_rom.path[0], p->romfile, sizeof p->romfile / sizeof(TCHAR));
+ subst(p->path_rom.path[0], p->romextfile, sizeof p->romextfile / sizeof(TCHAR));
+ subst(p->path_rom.path[0], p->romextfile2, sizeof p->romextfile2 / sizeof(TCHAR));
+
+ for (i = 0; i < MAX_EXPANSION_BOARDS; i++) {
+ for (int j = 0; j < MAX_BOARD_ROMS; j++) {
+ subst(p->path_rom.path[0], p->expansionboard[i].roms[j].romfile, MAX_DPATH / sizeof(TCHAR));
+ }
+ }
+
+ return 1;
}
-int cfgfile_load (struct uae_prefs *p, const TCHAR *filename, int *type, int ignorelink, int userconfig)
+int cfgfile_load(struct uae_prefs *p, const TCHAR *filename, int *type, int ignorelink, int userconfig)
{
- int v;
- static int recursive;
+ int v;
+ TCHAR tmp[MAX_DPATH];
+ int type2;
+ static int recursive;
- if (recursive > 1)
- return 0;
- recursive++;
- write_log (_T("load config '%s':%d\n"), filename, type ? *type : -1);
- v = cfgfile_load_2 (p, filename, 1, type);
- if (!v) {
+ if (recursive > 1)
+ return 0;
+ recursive++;
+ write_log(_T("load config '%s':%d\n"), filename, type ? *type : -1);
+ v = cfgfile_load_2(p, filename, 1, type);
+ if (!v) {
cfgfile_warning(_T("cfgfile_load_2 failed\n"));
- goto end;
- }
- if (userconfig)
- target_addtorecent (filename, 0);
+ goto end;
+ }
+ //if (userconfig)
+ // target_addtorecent(filename, 0);
+ if (!ignorelink) {
+ if (p->config_all_path[0]) {
+ fetch_configurationpath(tmp, sizeof(tmp) / sizeof(TCHAR));
+ _tcsncat(tmp, p->config_all_path, sizeof(tmp) / sizeof(TCHAR) - _tcslen(tmp) - 1);
+ type2 = CONFIG_TYPE_HOST | CONFIG_TYPE_HARDWARE;
+ cfgfile_load(p, tmp, &type2, 1, 0);
+ }
+ if (p->config_hardware_path[0]) {
+ fetch_configurationpath(tmp, sizeof(tmp) / sizeof(TCHAR));
+ _tcsncat(tmp, p->config_hardware_path, sizeof(tmp) / sizeof(TCHAR) - _tcslen(tmp) - 1);
+ type2 = CONFIG_TYPE_HARDWARE;
+ cfgfile_load(p, tmp, &type2, 1, 0);
+ }
+ if (p->config_host_path[0]) {
+ fetch_configurationpath(tmp, sizeof(tmp) / sizeof(TCHAR));
+ _tcsncat(tmp, p->config_host_path, sizeof(tmp) / sizeof(TCHAR) - _tcslen(tmp) - 1);
+ type2 = CONFIG_TYPE_HOST;
+ cfgfile_load(p, tmp, &type2, 1, 0);
+ }
+ }
end:
- recursive--;
- fixup_prefs (p, userconfig != 0);
- return v;
+ recursive--;
+ fixup_prefs(p, userconfig != 0);
+ return v;
}
-int cfgfile_save (struct uae_prefs *p, const TCHAR *filename, int type)
+void cfgfile_backup(const TCHAR *path)
{
- struct zfile *fh;
+ TCHAR dpath[MAX_DPATH];
- fh = zfile_fopen (filename, _T("w"), ZFD_NORMAL);
- if (! fh)
- return 0;
-
- if (!type)
- type = CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST;
- cfgfile_save_options (fh, p, type);
- zfile_fclose (fh);
- return 1;
+ fetch_configurationpath(dpath, sizeof(dpath) / sizeof(TCHAR));
+ _tcscat(dpath, _T("configuration.backup"));
+ //bool hidden = my_isfilehidden(dpath);
+ my_unlink(dpath);
+ my_rename(path, dpath);
+ //if (hidden)
+ // my_setfilehidden(dpath, hidden);
}
-int cfgfile_get_description (const TCHAR *filename, TCHAR *description)
+int cfgfile_save(struct uae_prefs *p, const TCHAR *filename, int type)
{
- int result = 0;
- struct uae_prefs *p = xmalloc (struct uae_prefs, 1);
+ struct zfile *fh;
- p->description[0] = 0;
- if (cfgfile_load_2 (p, filename, 0, 0)) {
- result = 1;
- if (description)
- _tcscpy (description, p->description);
- }
- xfree (p);
- return result;
+ cfgfile_backup(filename);
+ fh = zfile_fopen(filename, unicode_config ? _T("w, ccs=UTF-8") : _T("w"), ZFD_NORMAL);
+ if (!fh)
+ return 0;
+
+ if (!type)
+ type = CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST;
+ cfgfile_save_options(fh, p, type);
+ zfile_fclose(fh);
+ return 1;
+}
+
+int cfgfile_get_description(const TCHAR *filename, TCHAR *description, TCHAR *hostlink, TCHAR *hardwarelink, int *type)
+{
+ int result = 0;
+ struct uae_prefs *p = xmalloc(struct uae_prefs, 1);
+
+ p->description[0] = 0;
+ p->config_host_path[0] = 0;
+ p->config_hardware_path[0] = 0;
+ if (cfgfile_load_2(p, filename, 0, type)) {
+ result = 1;
+ if (description)
+ _tcscpy(description, p->description);
+ if (hostlink)
+ _tcscpy(hostlink, p->config_host_path);
+ if (hardwarelink)
+ _tcscpy(hardwarelink, p->config_hardware_path);
+ }
+ xfree(p);
+ return result;
}
int cfgfile_configuration_change(int v)
{
- static int mode;
- if (v >= 0)
- mode = v;
- return mode;
+ static int mode;
+ if (v >= 0)
+ mode = v;
+ return mode;
}
-static void parse_sound_spec (struct uae_prefs *p, const TCHAR *spec)
+void cfgfile_show_usage(void)
{
- TCHAR *x0 = my_strdup (spec);
- TCHAR *x1, *x2 = NULL, *x3 = NULL, *x4 = NULL, *x5 = NULL;
-
- x1 = _tcschr (x0, ':');
- if (x1 != NULL) {
- *x1++ = '\0';
- x2 = _tcschr (x1 + 1, ':');
- if (x2 != NULL) {
- *x2++ = '\0';
- x3 = _tcschr (x2 + 1, ':');
- if (x3 != NULL) {
- *x3++ = '\0';
- x4 = _tcschr (x3 + 1, ':');
- if (x4 != NULL) {
- *x4++ = '\0';
- x5 = _tcschr (x4 + 1, ':');
- }
- }
- }
- }
- p->produce_sound = _tstoi (x0);
- if (x1) {
- p->sound_stereo_separation = 0;
- if (*x1 == 'S') {
- p->sound_stereo = SND_STEREO;
- p->sound_stereo_separation = 7;
- } else if (*x1 == 's')
- p->sound_stereo = SND_STEREO;
- else
- p->sound_stereo = SND_MONO;
- }
- if (x3)
- p->sound_freq = _tstoi (x3);
- free (x0);
+ int i;
+ write_log(_T("UAE Configuration Help:\n") \
+ _T("=======================\n"));
+ for (i = 0; i < sizeof opttable / sizeof *opttable; i++)
+ write_log(_T("%s: %s\n"), opttable[i].config_label, opttable[i].config_help);
}
-static void parse_joy_spec (struct uae_prefs *p, const TCHAR *spec)
+/* This implements the old commandline option parsing. I've re-added this
+because the new way of doing things is painful for me (it requires me
+to type a couple hundred characters when invoking UAE). The following
+is far less annoying to use. */
+static void parse_gfx_specs(struct uae_prefs *p, const TCHAR *spec)
+{
+ TCHAR *x0 = my_strdup(spec);
+ TCHAR *x1, *x2;
+
+ x1 = _tcschr(x0, ':');
+ if (x1 == 0)
+ goto argh;
+ x2 = _tcschr(x1 + 1, ':');
+ if (x2 == 0)
+ goto argh;
+ *x1++ = 0; *x2++ = 0;
+
+ p->gfx_size_win.width = p->gfx_size_fs.width = _tstoi(x0);
+ p->gfx_size_win.height = p->gfx_size_fs.height = _tstoi(x1);
+ p->gfx_resolution = _tcschr(x2, 'l') != 0 ? 1 : 0;
+ p->gfx_xcenter = _tcschr(x2, 'x') != 0 ? 1 : _tcschr(x2, 'X') != 0 ? 2 : 0;
+ p->gfx_ycenter = _tcschr(x2, 'y') != 0 ? 1 : _tcschr(x2, 'Y') != 0 ? 2 : 0;
+ p->gfx_vresolution = _tcschr(x2, 'd') != 0 ? VRES_DOUBLE : VRES_NONDOUBLE;
+ p->gfx_pscanlines = _tcschr(x2, 'D') != 0;
+ if (p->gfx_pscanlines)
+ p->gfx_vresolution = VRES_DOUBLE;
+ p->gfx_apmode[0].gfx_fullscreen = _tcschr(x2, 'a') != 0;
+ p->gfx_apmode[1].gfx_fullscreen = _tcschr(x2, 'p') != 0;
+
+ free(x0);
+ return;
+
+argh:
+ write_log(_T("Bad display mode specification.\n"));
+ write_log(_T("The format to use is: \"width:height:modifiers\"\n"));
+ write_log(_T("Type \"uae -h\" for detailed help.\n"));
+ free(x0);
+}
+
+static void parse_sound_spec(struct uae_prefs *p, const TCHAR *spec)
+{
+ TCHAR *x0 = my_strdup(spec);
+ TCHAR *x1, *x2 = NULL, *x3 = NULL, *x4 = NULL, *x5 = NULL;
+
+ x1 = _tcschr(x0, ':');
+ if (x1 != NULL) {
+ *x1++ = '\0';
+ x2 = _tcschr(x1 + 1, ':');
+ if (x2 != NULL) {
+ *x2++ = '\0';
+ x3 = _tcschr(x2 + 1, ':');
+ if (x3 != NULL) {
+ *x3++ = '\0';
+ x4 = _tcschr(x3 + 1, ':');
+ if (x4 != NULL) {
+ *x4++ = '\0';
+ x5 = _tcschr(x4 + 1, ':');
+ }
+ }
+ }
+ }
+ p->produce_sound = _tstoi(x0);
+ if (x1) {
+ p->sound_stereo_separation = 0;
+ if (*x1 == 'S') {
+ p->sound_stereo = SND_STEREO;
+ p->sound_stereo_separation = 7;
+ }
+ else if (*x1 == 's')
+ p->sound_stereo = SND_STEREO;
+ else
+ p->sound_stereo = SND_MONO;
+ }
+ if (x3)
+ p->sound_freq = _tstoi(x3);
+ if (x4)
+ p->sound_maxbsiz = _tstoi(x4);
+ free(x0);
+}
+
+static void parse_joy_spec(struct uae_prefs *p, const TCHAR *spec)
{
int v0 = 2, v1 = 0;
if (_tcslen(spec) != 2)
@@ -4057,8 +6096,8 @@ static void parse_joy_spec (struct uae_prefs *p, const TCHAR *spec)
goto bad;
/* Let's scare Pascal programmers */
if (0)
-bad:
- write_log (_T("Bad joystick mode specification. Use -J xy, where x and y\n")
+ bad:
+ write_log(_T("Bad joystick mode specification. Use -J xy, where x and y\n")
_T("can be 0 for joystick 0, 1 for joystick 1, M for mouse, and\n")
_T("a, b or c for different keyboard settings.\n"));
@@ -4066,236 +6105,263 @@ bad:
p->jports[1].id = v1;
}
-static void parse_filesys_spec (struct uae_prefs *p, bool readonly, const TCHAR *spec)
+static void parse_filesys_spec(struct uae_prefs *p, bool readonly, const TCHAR *spec)
{
struct uaedev_config_info uci;
- TCHAR buf[256];
- TCHAR *s2;
+ TCHAR buf[256];
+ TCHAR *s2;
- uci_set_defaults (&uci, false);
- _tcsncpy (buf, spec, 255); buf[255] = 0;
- s2 = _tcschr (buf, ':');
- if (s2) {
- *s2++ = '\0';
+ uci_set_defaults(&uci, false);
+ _tcsncpy(buf, spec, 255); buf[255] = 0;
+ s2 = _tcschr(buf, ':');
+ if (s2) {
+ *s2++ = '\0';
#ifdef __DOS__
- {
- TCHAR *tmp;
+ {
+ TCHAR *tmp;
- while ((tmp = _tcschr (s2, '\\')))
- *tmp = '/';
- }
+ while ((tmp = _tcschr(s2, '\\')))
+ *tmp = '/';
+ }
#endif
#ifdef FILESYS
- _tcscpy (uci.volname, buf);
- _tcscpy (uci.rootdir, s2);
+ _tcscpy(uci.volname, buf);
+ _tcscpy(uci.rootdir, s2);
uci.readonly = readonly;
uci.type = UAEDEV_DIR;
- add_filesys_config (p, -1, &uci);
+ add_filesys_config(p, -1, &uci);
#endif
- } else {
- write_log (_T("Usage: [-m | -M] VOLNAME:mount_point\n"));
- }
+ }
+ else {
+ write_log(_T("Usage: [-m | -M] VOLNAME:mount_point\n"));
+ }
}
-static void parse_hardfile_spec (struct uae_prefs *p, const TCHAR *spec)
+static void parse_hardfile_spec(struct uae_prefs *p, const TCHAR *spec)
{
struct uaedev_config_info uci;
- TCHAR *x0 = my_strdup (spec);
- TCHAR *x1, *x2, *x3, *x4;
+ TCHAR *x0 = my_strdup(spec);
+ TCHAR *x1, *x2, *x3, *x4;
- uci_set_defaults (&uci, false);
- x1 = _tcschr (x0, ':');
- if (x1 == NULL)
- goto argh;
- *x1++ = '\0';
- x2 = _tcschr (x1 + 1, ':');
- if (x2 == NULL)
- goto argh;
- *x2++ = '\0';
- x3 = _tcschr (x2 + 1, ':');
- if (x3 == NULL)
- goto argh;
- *x3++ = '\0';
- x4 = _tcschr (x3 + 1, ':');
- if (x4 == NULL)
- goto argh;
- *x4++ = '\0';
+ uci_set_defaults(&uci, false);
+ x1 = _tcschr(x0, ':');
+ if (x1 == NULL)
+ goto argh;
+ *x1++ = '\0';
+ x2 = _tcschr(x1 + 1, ':');
+ if (x2 == NULL)
+ goto argh;
+ *x2++ = '\0';
+ x3 = _tcschr(x2 + 1, ':');
+ if (x3 == NULL)
+ goto argh;
+ *x3++ = '\0';
+ x4 = _tcschr(x3 + 1, ':');
+ if (x4 == NULL)
+ goto argh;
+ *x4++ = '\0';
#ifdef FILESYS
- _tcscpy (uci.rootdir, x4);
+ _tcscpy(uci.rootdir, x4);
//add_filesys_config (p, -1, NULL, NULL, x4, 0, 0, _tstoi (x0), _tstoi (x1), _tstoi (x2), _tstoi (x3), 0, 0, 0, 0, 0, 0, 0);
#endif
- free (x0);
- return;
+ free(x0);
+ return;
- argh:
- free (x0);
- cfgfile_warning(_T("Bad hardfile parameter specified\n"));
- return;
+argh:
+ free(x0);
+ write_log(_T("Bad hardfile parameter specified - type \"uae -h\" for help.\n"));
+ return;
}
-static void parse_cpu_specs (struct uae_prefs *p, const TCHAR *spec)
+static void parse_cpu_specs(struct uae_prefs *p, const TCHAR *spec)
{
- if (*spec < '0' || *spec > '4') {
- cfgfile_warning(_T("CPU parameter string must begin with '0', '1', '2', '3' or '4'.\n"));
- return;
- }
+ if (*spec < '0' || *spec > '4') {
+ write_log(_T("CPU parameter string must begin with '0', '1', '2', '3' or '4'.\n"));
+ return;
+ }
- p->cpu_model = (*spec++) * 10 + 68000;
- p->address_space_24 = p->cpu_model < 68020;
- p->cpu_compatible = 0;
- while (*spec != '\0') {
- switch (*spec) {
- case 'a':
- if (p->cpu_model < 68020)
- cfgfile_warning(_T("In 68000/68010 emulation, the address space is always 24 bit.\n"));
- else if (p->cpu_model >= 68040)
- cfgfile_warning(_T("In 68040/060 emulation, the address space is always 32 bit.\n"));
- else
- p->address_space_24 = 1;
- break;
- case 'c':
- if (p->cpu_model != 68000)
- cfgfile_warning(_T("The more compatible CPU emulation is only available for 68000\n")
- _T("emulation, not for 68010 upwards.\n"));
- else
- p->cpu_compatible = 1;
- break;
- default:
- cfgfile_warning(_T("Bad CPU parameter specified.\n"));
- break;
- }
- spec++;
- }
+ p->cpu_model = (*spec++) * 10 + 68000;
+ p->address_space_24 = p->cpu_model < 68020;
+ p->cpu_compatible = 0;
+ while (*spec != '\0') {
+ switch (*spec) {
+ case 'a':
+ if (p->cpu_model < 68020)
+ write_log(_T("In 68000/68010 emulation, the address space is always 24 bit.\n"));
+ else if (p->cpu_model >= 68040)
+ write_log(_T("In 68040/060 emulation, the address space is always 32 bit.\n"));
+ else
+ p->address_space_24 = 1;
+ break;
+ case 'c':
+ if (p->cpu_model != 68000)
+ write_log(_T("The more compatible CPU emulation is only available for 68000\n")
+ _T("emulation, not for 68010 upwards.\n"));
+ else
+ p->cpu_compatible = 1;
+ break;
+ default:
+ write_log(_T("Bad CPU parameter specified - type \"uae -h\" for help.\n"));
+ break;
+ }
+ spec++;
+ }
}
-static void cmdpath (TCHAR *dst, const TCHAR *src, int maxsz)
+static void cmdpath(TCHAR *dst, const TCHAR *src, int maxsz)
{
- TCHAR *s = target_expand_environment (src, NULL, 0);
- _tcsncpy (dst, s, maxsz);
+ TCHAR *s = target_expand_environment(src);
+ _tcsncpy(dst, s, maxsz);
dst[maxsz] = 0;
- xfree (s);
+ xfree(s);
}
/* Returns the number of args used up (0 or 1). */
-int parse_cmdline_option (struct uae_prefs *p, TCHAR c, const TCHAR *arg)
+int parse_cmdline_option(struct uae_prefs *p, TCHAR c, const TCHAR *arg)
{
- struct strlist *u = xcalloc (struct strlist, 1);
+ struct strlist *u = xcalloc(struct strlist, 1);
const TCHAR arg_required[] = _T("0123rKpImWSAJwNCZUFcblOdHRv");
- if (_tcschr (arg_required, c) && ! arg) {
- write_log (_T("Missing argument for option `-%c'!\n"), c);
- return 0;
- }
+ if (_tcschr(arg_required, c) && !arg) {
+ write_log(_T("Missing argument for option `-%c'!\n"), c);
+ return 0;
+ }
- u->option = xmalloc (TCHAR, 2);
- u->option[0] = c;
- u->option[1] = 0;
- if (arg)
- u->value = my_strdup(arg);
- u->next = p->all_lines;
- p->all_lines = u;
+ u->option = xmalloc(TCHAR, 2);
+ u->option[0] = c;
+ u->option[1] = 0;
+ u->value = my_strdup(arg);
+ u->next = p->all_lines;
+ p->all_lines = u;
- switch (c) {
- case '0': cmdpath (p->floppyslots[0].df, arg, 255); break;
- case '1': cmdpath (p->floppyslots[1].df, arg, 255); break;
- case '2': cmdpath (p->floppyslots[2].df, arg, 255); break;
- case '3': cmdpath (p->floppyslots[3].df, arg, 255); break;
- case 'r': cmdpath (p->romfile, arg, 255); break;
- case 'K': cmdpath (p->romextfile, arg, 255); break;
- case 'm': case 'M': parse_filesys_spec (p, c == 'M', arg); break;
- case 'W': parse_hardfile_spec (p, arg); break;
- case 'S': parse_sound_spec (p, arg); break;
- case 'R': p->gfx_framerate = _tstoi (arg); break;
- case 'J': parse_joy_spec (p, arg); break;
+ switch (c) {
+ case 'h': usage(); exit(0);
- case 'w': p->m68k_speed = _tstoi (arg); break;
+ case '0': cmdpath(p->floppyslots[0].df, arg, 255); break;
+ case '1': cmdpath(p->floppyslots[1].df, arg, 255); break;
+ case '2': cmdpath(p->floppyslots[2].df, arg, 255); break;
+ case '3': cmdpath(p->floppyslots[3].df, arg, 255); break;
+ case 'r': cmdpath(p->romfile, arg, 255); break;
+ case 'K': cmdpath(p->romextfile, arg, 255); break;
+ case 'p': _tcsncpy(p->prtname, arg, 255); p->prtname[255] = 0; break;
+ /* case 'I': _tcsncpy (p->sername, arg, 255); p->sername[255] = 0; currprefs.use_serial = 1; break; */
+ case 'm': case 'M': parse_filesys_spec(p, c == 'M', arg); break;
+ case 'W': parse_hardfile_spec(p, arg); break;
+ case 'S': parse_sound_spec(p, arg); break;
+ case 'R': p->gfx_framerate = _tstoi(arg); break;
+ case 'i': p->illegal_mem = 1; break;
+ case 'J': parse_joy_spec(p, arg); break;
- case 'G': p->start_gui = 0; break;
+ case 'w': p->m68k_speed = _tstoi(arg); break;
- case 'n':
- if (_tcschr (arg, 'i') != 0)
- p->immediate_blits = 1;
- break;
+ /* case 'g': p->use_gfxlib = 1; break; */
+ case 'G': p->start_gui = 0; break;
+ case 'D': p->start_debugger = 1; break;
- case 'v':
- set_chipset_mask (p, _tstoi (arg));
- break;
+ case 'n':
+ if (_tcschr(arg, 'i') != 0)
+ p->immediate_blits = 1;
+ break;
- case 'C':
- parse_cpu_specs (p, arg);
- break;
+ case 'v':
+ set_chipset_mask(p, _tstoi(arg));
+ break;
- case 'Z':
- p->z3fastmem[0].size = _tstoi (arg) * 0x100000;
- break;
+ case 'C':
+ parse_cpu_specs(p, arg);
+ break;
- case 'U':
- p->rtgboards[0].rtgmem_size = _tstoi (arg) * 0x100000;
- break;
+ case 'Z':
+ p->z3fastmem[0].size = _tstoi(arg) * 0x100000;
+ break;
- case 'F':
- p->fastmem[0].size = _tstoi (arg) * 0x100000;
- break;
+ case 'U':
+ p->rtgboards[0].rtgmem_size = _tstoi(arg) * 0x100000;
+ break;
- case 'b':
- p->bogomem_size = _tstoi (arg) * 0x40000;
- break;
+ case 'F':
+ p->fastmem[0].size = _tstoi(arg) * 0x100000;
+ break;
- case 'c':
- p->chipmem_size = _tstoi (arg) * 0x80000;
- break;
+ case 'b':
+ p->bogomem_size = _tstoi(arg) * 0x40000;
+ break;
- case 'l':
- if (0 == _tcsicmp(arg, _T("de")))
- p->keyboard_lang = KBD_LANG_DE;
- else if (0 == _tcsicmp(arg, _T("dk")))
- p->keyboard_lang = KBD_LANG_DK;
- else if (0 == _tcsicmp(arg, _T("us")))
- p->keyboard_lang = KBD_LANG_US;
- else if (0 == _tcsicmp(arg, _T("se")))
- p->keyboard_lang = KBD_LANG_SE;
- else if (0 == _tcsicmp(arg, _T("fr")))
- p->keyboard_lang = KBD_LANG_FR;
- else if (0 == _tcsicmp(arg, _T("it")))
- p->keyboard_lang = KBD_LANG_IT;
- else if (0 == _tcsicmp(arg, _T("es")))
- p->keyboard_lang = KBD_LANG_ES;
- break;
+ case 'c':
+ p->chipmem_size = _tstoi(arg) * 0x80000;
+ break;
- default:
- write_log (_T("Unknown option `-%c'!\n"), c);
- break;
- }
- return !! _tcschr (arg_required, c);
+ //case 'l':
+ // if (0 == strcasecmp(arg, _T("de")))
+ // p->keyboard_lang = KBD_LANG_DE;
+ // else if (0 == strcasecmp(arg, _T("dk")))
+ // p->keyboard_lang = KBD_LANG_DK;
+ // else if (0 == strcasecmp(arg, _T("us")))
+ // p->keyboard_lang = KBD_LANG_US;
+ // else if (0 == strcasecmp(arg, _T("se")))
+ // p->keyboard_lang = KBD_LANG_SE;
+ // else if (0 == strcasecmp(arg, _T("fr")))
+ // p->keyboard_lang = KBD_LANG_FR;
+ // else if (0 == strcasecmp(arg, _T("it")))
+ // p->keyboard_lang = KBD_LANG_IT;
+ // else if (0 == strcasecmp(arg, _T("es")))
+ // p->keyboard_lang = KBD_LANG_ES;
+ // break;
+
+ case 'O': parse_gfx_specs(p, arg); break;
+ case 'd':
+ if (_tcschr(arg, 'S') != NULL || _tcschr(arg, 's')) {
+ write_log(_T(" Serial on demand.\n"));
+ p->serial_demand = 1;
+ }
+ if (_tcschr(arg, 'P') != NULL || _tcschr(arg, 'p')) {
+ write_log(_T(" Parallel on demand.\n"));
+ p->parallel_demand = 1;
+ }
+
+ break;
+
+ case 'H':
+ p->color_mode = _tstoi(arg);
+ if (p->color_mode < 0) {
+ write_log(_T("Bad color mode selected. Using default.\n"));
+ p->color_mode = 0;
+ }
+ break;
+ default:
+ write_log(_T("Unknown option `-%c'!\n"), c);
+ break;
+ }
+ return !!_tcschr(arg_required, c);
}
-void cfgfile_addcfgparam (TCHAR *line)
+void cfgfile_addcfgparam(TCHAR *line)
{
- struct strlist *u;
- TCHAR line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
+ struct strlist *u;
+ TCHAR line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
- if (!line) {
- struct strlist **ps = &temp_lines;
- while (*ps) {
- struct strlist *s = *ps;
- *ps = s->next;
- xfree (s->value);
- xfree (s->option);
- xfree (s);
- }
- temp_lines = 0;
- return;
- }
- if (!cfgfile_separate_line (line, line1b, line2b))
- return;
- u = xcalloc (struct strlist, 1);
- u->option = my_strdup(line1b);
- u->value = my_strdup(line2b);
- u->next = temp_lines;
- temp_lines = u;
+ if (!line) {
+ struct strlist **ps = &temp_lines;
+ while (*ps) {
+ struct strlist *s = *ps;
+ *ps = s->next;
+ xfree(s->value);
+ xfree(s->option);
+ xfree(s);
+ }
+ temp_lines = 0;
+ return;
+ }
+ if (!cfgfile_separate_line(line, line1b, line2b))
+ return;
+ u = xcalloc(struct strlist, 1);
+ u->option = my_strdup(line1b);
+ u->value = my_strdup(line2b);
+ u->next = temp_lines;
+ temp_lines = u;
}
-static int cmdlineparser (const TCHAR *s, TCHAR *outp[], int max)
+int cmdlineparser(const TCHAR *s, TCHAR *outp[], int max)
{
int j, cnt = 0;
int slash = 0;
@@ -4320,7 +6386,8 @@ static int cmdlineparser (const TCHAR *s, TCHAR *outp[], int max)
if (quote) {
quote = 0;
doout = 1;
- } else {
+ }
+ else {
quote = 1;
j = -1;
}
@@ -4335,8 +6402,8 @@ static int cmdlineparser (const TCHAR *s, TCHAR *outp[], int max)
j++;
}
if (doout) {
- if (_tcslen (tmp1) > 0) {
- outp[cnt++] = my_strdup (tmp1);
+ if (_tcslen(tmp1) > 0) {
+ outp[cnt++] = my_strdup(tmp1);
outp[cnt] = 0;
}
tmp1[0] = 0;
@@ -4346,7 +6413,7 @@ static int cmdlineparser (const TCHAR *s, TCHAR *outp[], int max)
slash = 0;
}
if (j > 0 && cnt < max) {
- outp[cnt++] = my_strdup (tmp1);
+ outp[cnt++] = my_strdup(tmp1);
outp[cnt] = 0;
}
return cnt;
@@ -4354,16 +6421,16 @@ static int cmdlineparser (const TCHAR *s, TCHAR *outp[], int max)
#define UAELIB_MAX_PARSE 100
-static bool cfgfile_parse_uaelib_option (struct uae_prefs *p, TCHAR *option, TCHAR *value, int type)
+static bool cfgfile_parse_uaelib_option(struct uae_prefs* p, TCHAR* option, TCHAR* value, int type)
{
return false;
}
-static int cfgfile_searchconfig(const TCHAR *in, int index, TCHAR *out, int outsize)
+int cfgfile_searchconfig(const TCHAR *in, int index, TCHAR *out, int outsize)
{
TCHAR tmp[CONFIG_BLEN];
int j = 0;
- int inlen = _tcslen (in);
+ int inlen = _tcslen(in);
int joker = 0;
uae_u32 err = 0;
bool configsearchfound = false;
@@ -4385,14 +6452,14 @@ static int cfgfile_searchconfig(const TCHAR *in, int index, TCHAR *out, int outs
for (;;) {
uae_u8 b = 0;
- if (zfile_fread (&b, 1, 1, configstore) != 1) {
+ if (zfile_fread(&b, 1, 1, configstore) != 1) {
err = 10;
if (configsearchfound)
err = 0;
goto end;
}
- if (j >= sizeof (tmp) / sizeof (TCHAR) - 1)
- j = sizeof (tmp) / sizeof (TCHAR) - 1;
+ if (j >= sizeof(tmp) / sizeof(TCHAR) - 1)
+ j = sizeof(tmp) / sizeof(TCHAR) - 1;
if (b == 0) {
err = 10;
if (configsearchfound)
@@ -4400,12 +6467,12 @@ static int cfgfile_searchconfig(const TCHAR *in, int index, TCHAR *out, int outs
goto end;
}
if (b == '\n') {
- if (!_tcsncmp (tmp, in, inlen) && ((inlen > 0 && _tcslen (tmp) > inlen && tmp[inlen] == '=') || (joker))) {
+ if (!_tcsncmp(tmp, in, inlen) && ((inlen > 0 && _tcslen(tmp) > inlen && tmp[inlen] == '=') || (joker))) {
TCHAR *p;
if (joker)
p = tmp - 1;
else
- p = _tcschr (tmp, '=');
+ p = _tcschr(tmp, '=');
if (p) {
for (int i = 0; out && i < outsize - 1; i++) {
TCHAR b = *++p;
@@ -4420,7 +6487,8 @@ static int cfgfile_searchconfig(const TCHAR *in, int index, TCHAR *out, int outs
goto end;
}
j = 0;
- } else {
+ }
+ else {
tmp[j++] = b;
tmp[j] = 0;
}
@@ -4429,12 +6497,13 @@ end:
return err;
}
-uae_u32 cfgfile_modify (uae_u32 index, const TCHAR *parms, uae_u32 size, TCHAR *out, uae_u32 outsize)
+uae_u32 cfgfile_modify(uae_u32 index, const TCHAR *parms, uae_u32 size, TCHAR *out, uae_u32 outsize)
{
TCHAR *p;
TCHAR *argc[UAELIB_MAX_PARSE];
int argv, i;
uae_u32 err;
+ TCHAR zero = 0;
static TCHAR *configsearch;
*out = 0;
@@ -4447,13 +6516,13 @@ uae_u32 cfgfile_modify (uae_u32 index, const TCHAR *parms, uae_u32 size, TCHAR *
goto end;
}
if (configsearch) {
- err = cfgfile_searchconfig(configsearch, index, out, outsize);
+ err = cfgfile_searchconfig(configsearch, index, out, outsize);
goto end;
}
err = 0xffffffff;
for (i = 0; out && i < outsize - 1; i++) {
uae_u8 b = 0;
- if (zfile_fread (&b, 1, 1, configstore) != 1)
+ if (zfile_fread(&b, 1, 1, configstore) != 1)
err = 0;
if (b == 0)
err = 0;
@@ -4469,41 +6538,44 @@ uae_u32 cfgfile_modify (uae_u32 index, const TCHAR *parms, uae_u32 size, TCHAR *
if (size > 10000)
return 10;
- argv = cmdlineparser (parms, argc, UAELIB_MAX_PARSE);
+ argv = cmdlineparser(parms, argc, UAELIB_MAX_PARSE);
if (argv <= 1 && index == 0xffffffff) {
- createconfigstore (&currprefs);
- xfree (configsearch);
+ createconfigstore(&currprefs);
+ xfree(configsearch);
configsearch = NULL;
if (!configstore) {
err = 20;
goto end;
}
- if (argv > 0 && _tcslen (argc[0]) > 0)
- configsearch = my_strdup (argc[0]);
+ if (argv > 0 && _tcslen(argc[0]) > 0)
+ configsearch = my_strdup(argc[0]);
err = 0xffffffff;
goto end;
}
for (i = 0; i < argv; i++) {
if (i + 2 <= argv) {
- if (!inputdevice_uaelib (argc[i], argc[i + 1])) {
- if (!cfgfile_parse_uaelib_option (&changed_prefs, argc[i], argc[i + 1], 0)) {
- if (!cfgfile_parse_option (&changed_prefs, argc[i], argc[i + 1], 0)) {
+ if (!_tcsicmp(argc[i], _T("dbg"))) {
+ //debug_parser(argc[i + 1], out, outsize);
+ }
+ else if (!inputdevice_uaelib(argc[i], argc[i + 1])) {
+ if (!cfgfile_parse_uaelib_option(&changed_prefs, argc[i], argc[i + 1], 0)) {
+ if (!cfgfile_parse_option(&changed_prefs, argc[i], argc[i + 1], 0)) {
err = 5;
break;
}
}
}
- set_config_changed ();
- set_special (SPCFLAG_MODE_CHANGE);
+ set_config_changed();
+ set_special(SPCFLAG_MODE_CHANGE);
i++;
}
}
end:
for (i = 0; i < argv; i++)
- xfree (argc[i]);
- xfree (p);
+ xfree(argc[i]);
+ xfree(p);
return err;
}
@@ -4514,18 +6586,18 @@ uae_u32 cfgfile_uaelib_modify(TrapContext *ctx, uae_u32 index, uae_u32 parms, ua
TCHAR *out_p = NULL, *parms_in = NULL;
if (out)
- trap_put_byte(ctx, out, 0);
+ put_byte(out, 0);
if (size == 0) {
- while (trap_get_byte(ctx, parms + size) != 0)
+ while (get_byte(parms + size) != 0)
size++;
}
- parms_p = xmalloc (uae_char, size + 1);
+ parms_p = xmalloc(uae_char, size + 1);
if (!parms_p) {
ret = 10;
goto end;
}
if (out) {
- out_p = xmalloc (TCHAR, outsize + 1);
+ out_p = xmalloc(TCHAR, outsize + 1);
if (!out_p) {
ret = 10;
goto end;
@@ -4534,30 +6606,39 @@ uae_u32 cfgfile_uaelib_modify(TrapContext *ctx, uae_u32 index, uae_u32 parms, ua
}
p = parms_p;
for (i = 0; i < size; i++) {
- p[i] = trap_get_byte(ctx, parms + i);
+ p[i] = get_byte(parms + i);
if (p[i] == 10 || p[i] == 13 || p[i] == 0)
break;
}
p[i] = 0;
- parms_in = au (parms_p);
- ret = cfgfile_modify (index, parms_in, size, out_p, outsize);
- xfree (parms_in);
+ parms_in = au(parms_p);
+ ret = cfgfile_modify(index, parms_in, size, out_p, outsize);
+ xfree(parms_in);
if (out) {
- parms_out = ua (out_p);
- trap_put_string(ctx, parms_out, out, outsize - 1);
+ parms_out = ua(out_p);
+ int len = 0;
+ uae_u8 *haddr = (uae_u8*)parms_out;
+ for (;;) {
+ uae_u8 v = *haddr++;
+ put_byte(out, v);
+ out++;
+ if (!v)
+ break;
+ len++;
+ }
}
- xfree (parms_out);
+ xfree(parms_out);
end:
- xfree (out_p);
- xfree (parms_p);
+ xfree(out_p);
+ xfree(parms_p);
return ret;
}
-static const TCHAR *cfgfile_read_config_value (const TCHAR *option)
+static const TCHAR *cfgfile_read_config_value(const TCHAR *option)
{
struct strlist *sl;
for (sl = currprefs.all_lines; sl; sl = sl->next) {
- if (sl->option && !_tcsicmp (sl->option, option))
+ if (sl->option && !strcasecmp(sl->option, option))
return sl->value;
}
return NULL;
@@ -4571,7 +6652,17 @@ uae_u32 cfgfile_uaelib(TrapContext *ctx, int mode, uae_u32 name, uae_u32 dst, ua
if (mode)
return 0;
- trap_get_string(ctx, tmpa, name, sizeof tmpa);
+ int len = 0;
+ uae_u8 *haddr = (uae_u8*)tmpa;
+ for (;;) {
+ uae_u8 v = *haddr++;
+ put_byte(name, v);
+ name++;
+ if (!v)
+ break;
+ len++;
+ }
+
str = au(tmpa);
if (str[0] == 0) {
xfree(str);
@@ -4580,30 +6671,121 @@ uae_u32 cfgfile_uaelib(TrapContext *ctx, int mode, uae_u32 name, uae_u32 dst, ua
const TCHAR *value = cfgfile_read_config_value(str);
xfree(str);
if (value) {
- char *s = ua (value);
- trap_put_string(ctx, s, dst, maxlen);
- xfree (s);
+ char *s = ua(value);
+
+ len = 0;
+ haddr = (uae_u8*)s;
+ for (;;) {
+ uae_u8 v = *haddr++;
+ put_byte(dst, v);
+ dst++;
+ if (!v)
+ break;
+ len++;
+ }
+
+ xfree(s);
return dst;
}
return 0;
}
+uae_u8 *restore_configuration(uae_u8 *src)
+{
+ TCHAR *s = au(reinterpret_cast(src));
+ //write_log (s);
+ xfree(s);
+ src += strlen(reinterpret_cast(src)) + 1;
+ return src;
+}
+
+uae_u8 *save_configuration(int *len, bool fullconfig)
+{
+ int tmpsize = 100000;
+ uae_u8 *dstbak, *dst, *p;
+ int index = -1;
+
+ dstbak = dst = xcalloc(uae_u8, tmpsize);
+ p = dst;
+ for (;;) {
+ TCHAR tmpout[1000];
+ int ret;
+ tmpout[0] = 0;
+ ret = cfgfile_modify(index, _T("*"), 1, tmpout, sizeof(tmpout) / sizeof(TCHAR));
+ index++;
+ if (_tcslen(tmpout) > 0) {
+ char *out;
+ if (!fullconfig && !_tcsncmp(tmpout, _T("input."), 6))
+ continue;
+ //write_log (_T("'%s'\n"), tmpout);
+ out = uutf8(tmpout);
+ strcpy((char*)p, out);
+ xfree(out);
+ strcat((char*)p, "\n");
+ p += strlen((char*)p);
+ if (p - dstbak >= tmpsize - sizeof(tmpout))
+ break;
+ }
+ if (ret >= 0)
+ break;
+ }
+ *len = p - dstbak + 1;
+ return dstbak;
+}
+
+#ifdef UAE_MINI
+static void default_prefs_mini(struct uae_prefs *p, int type)
+{
+ _tcscpy(p->description, _T("UAE default A500 configuration"));
+
+ p->nr_floppies = 1;
+ p->floppyslots[0].dfxtype = DRV_35_DD;
+ p->floppyslots[1].dfxtype = DRV_NONE;
+ p->cpu_model = 68000;
+ p->address_space_24 = 1;
+ p->chipmem_size = 0x00080000;
+ p->bogomem_size = 0x00080000;
+}
+#endif
+
#include "sounddep/sound.h"
-void default_prefs (struct uae_prefs *p, bool reset, int type)
+void default_prefs(struct uae_prefs *p, bool reset, int type)
{
- int i;
+ int i;
int roms[] = { 6, 7, 8, 9, 10, 14, 5, 4, 3, 2, 1, -1 };
- TCHAR zero = 0;
- struct zfile *f;
+ TCHAR zero = 0;
+ struct zfile *f;
- reset_inputdevice_config (p, reset);
- memset (p, 0, sizeof (struct uae_prefs));
- _tcscpy (p->description, _T("UAE default configuration"));
+ //reset_inputdevice_config(p, reset); //TODO
+ reset_inputdevice_config(p);
- p->start_gui = true;
+ memset(p, 0, sizeof(*p));
+ _tcscpy(p->description, _T("UAE default configuration"));
+ p->config_hardware_path[0] = 0;
+ p->config_host_path[0] = 0;
- p->all_lines = 0;
+ p->gfx_scandoubler = false;
+ p->start_gui = true;
+ p->start_debugger = false;
+
+ p->all_lines = 0;
+ /* Note to porters: please don't change any of these options! UAE is supposed
+ * to behave identically on all platforms if possible.
+ * (TW says: maybe it is time to update default config..) */
+ p->illegal_mem = 0;
+ p->use_serial = 0;
+ p->serial_demand = 0;
+ p->serial_hwctsrts = 1;
+ p->serial_stopbits = 0;
+ p->parallel_demand = 0;
+ p->parallel_matrix_emulation = 0;
+ p->parallel_postscript_emulation = 0;
+ p->parallel_postscript_detection = 0;
+ p->parallel_autoflush_time = 5;
+ p->ghostscript_parameters[0] = 0;
+ p->uae_hide = 0;
+ p->uae_hide_autoconfig = false;
p->z3_mapping_mode = Z3MAPPING_AUTO;
p->mountitems = 0;
@@ -4616,95 +6798,212 @@ void default_prefs (struct uae_prefs *p, bool reset, int type)
p->jports[1].id = -1;
p->jports[2].id = -1;
p->jports[3].id = -1;
- if (reset) {
- inputdevice_joyport_config_store(p, _T("mouse"), 0, -1, 0);
- inputdevice_joyport_config_store(p, _T("joy1"), 1, -1, 0);
- }
- p->keyboard_lang = KBD_LANG_US;
+ //if (reset) {
+ // inputdevice_joyport_config_store(p, _T("mouse"), 0, -1, 0);
+ // inputdevice_joyport_config_store(p, _T("kbd1"), 1, -1, 0);
+ //}
- p->produce_sound = 3;
- p->sound_stereo = SND_STEREO;
- p->sound_stereo_separation = 7;
- p->sound_mixed_stereo_delay = 0;
- p->sound_freq = DEFAULT_SOUND_FREQ;
- p->sound_interpol = 0;
- p->sound_filter = FILTER_SOUND_OFF;
- p->sound_filter_type = 0;
- p->sound_volume_cd = 20;
+ p->keyboard_connected = true;
- p->cachesize = 0;
+ p->produce_sound = 3;
+ p->sound_stereo = SND_STEREO;
+ p->sound_stereo_separation = 7;
+ p->sound_mixed_stereo_delay = 0;
+ p->sound_freq = DEFAULT_SOUND_FREQ;
+ p->sound_maxbsiz = DEFAULT_SOUND_MAXB;
+ p->sound_interpol = 1;
+ p->sound_filter = FILTER_SOUND_EMUL;
+ p->sound_filter_type = 0;
+ p->sound_auto = true;
+ p->sound_cdaudio = false;
+ p->sampler_stereo = false;
+ p->sampler_buffer = 0;
+ p->sampler_freq = 0;
- p->gfx_framerate = 0;
-
-#ifdef AMIBERRY
- p->gfx_size.width = 640;
- p->gfx_size.height = 262;
- p->gfx_resolution = RES_HIRES;
+ p->comptrustbyte = 0;
+ p->comptrustword = 0;
+ p->comptrustlong = 0;
+ p->comptrustnaddr = 0;
+ p->compnf = 1;
+ p->comp_hardflush = 0;
+ p->comp_constjump = 1;
+#ifdef USE_JIT_FPU
+ p->compfpu = 1;
#else
- p->gfx_size.width = 320;
- p->gfx_size.height = 240;
- p->gfx_resolution = RES_LORES;
+ p->compfpu = 0;
#endif
+ p->cachesize = DEFAULT_JIT_CACHE_SIZE;
- p->immediate_blits = 0;
+ p->gfx_framerate = 1;
+ p->gfx_autoframerate = 50;
+ p->gfx_size_fs.width = 800;
+ p->gfx_size_fs.height = 600;
+ p->gfx_size_win.width = 720;
+ p->gfx_size_win.height = 568;
+ for (i = 0; i < 4; i++) {
+ p->gfx_size_fs_xtra[i].width = 0;
+ p->gfx_size_fs_xtra[i].height = 0;
+ p->gfx_size_win_xtra[i].width = 0;
+ p->gfx_size_win_xtra[i].height = 0;
+ }
+ p->gfx_resolution = RES_HIRES;
+#ifndef AMIBERRY
+ p->gfx_vresolution = VRES_DOUBLE;
+ p->gfx_iscanlines = 1;
+#else
+ p->gfx_vresolution = VRES_NONDOUBLE;
+ p->gfx_iscanlines = 0;
+#endif
+ p->gfx_apmode[0].gfx_fullscreen = GFX_WINDOW;
+ p->gfx_apmode[1].gfx_fullscreen = GFX_WINDOW;
+ p->gfx_xcenter = 0; p->gfx_ycenter = 0;
+ p->gfx_xcenter_pos = -1;
+ p->gfx_ycenter_pos = -1;
+ p->gfx_xcenter_size = -1;
+ p->gfx_ycenter_size = -1;
+ p->gfx_max_horizontal = RES_HIRES;
+ p->gfx_max_vertical = VRES_DOUBLE;
+ p->gfx_autoresolution_minv = 0;
+ p->gfx_autoresolution_minh = 0;
+ p->color_mode = 2;
+ p->gfx_blackerthanblack = 0;
+ p->gfx_autoresolution_vga = true;
+ p->gfx_apmode[0].gfx_backbuffers = 2;
+ p->gfx_apmode[1].gfx_backbuffers = 1;
+
+ p->immediate_blits = false;
p->waiting_blits = 0;
- p->chipset_refreshrate = 50;
- p->collision_level = 2;
- p->leds_on_screen = 0;
+ p->collision_level = 2;
+ p->leds_on_screen = 0;
+ p->leds_on_screen_mask[0] = p->leds_on_screen_mask[1] = (1 << LED_MAX) - 1;
+ p->keyboard_leds_in_use = 0;
+ p->keyboard_leds[0] = p->keyboard_leds[1] = p->keyboard_leds[2] = 0;
+ p->scsi = 0;
+ p->uaeserial = false;
+ p->cpu_idle = 0;
+ p->turbo_emulation = 0;
+ p->turbo_emulation_limit = 0;
+ p->headless = 0;
+ p->catweasel = 0;
+ p->tod_hack = 0;
+ p->maprom = 0;
p->boot_rom = 0;
-
+ p->filesys_no_uaefsdb = 0;
+ p->filesys_custom_uaefsdb = 1;
+ p->picasso96_nocustom = 1;
p->cart_internal = 1;
+ p->sana2 = false;
+ p->clipboard_sharing = false;
+ p->native_code = false;
p->cs_compatible = CP_GENERIC;
p->cs_rtc = 2;
p->cs_df0idhw = 1;
+ p->cs_a1000ram = 0;
p->cs_fatgaryrev = -1;
p->cs_ramseyrev = -1;
+ p->cs_agnusrev = -1;
+ p->cs_deniserev = -1;
+ p->cs_mbdmac = 0;
p->cs_cd32c2p = p->cs_cd32cd = p->cs_cd32nvram = p->cs_cd32fmv = false;
p->cs_cd32nvram_size = 1024;
+ p->cs_cdtvcd = p->cs_cdtvram = false;
+ p->cs_cdtvcard = 0;
p->cs_pcmcia = 0;
p->cs_ksmirror_e0 = 1;
p->cs_ksmirror_a8 = 0;
p->cs_ciaoverlay = 1;
p->cs_ciaatod = 0;
p->cs_df0idhw = 1;
+ p->cs_slowmemisfast = 0;
+ p->cs_resetwarning = 1;
p->cs_ciatodbug = false;
+ p->cs_color_burst = false;
- _tcscpy (p->floppyslots[0].df, _T(""));
- _tcscpy (p->floppyslots[1].df, _T(""));
- _tcscpy (p->floppyslots[2].df, _T(""));
- _tcscpy (p->floppyslots[3].df, _T(""));
+ for (int i = APMODE_NATIVE; i <= APMODE_RTG; i++) {
+ struct gfx_filterdata *f = &p->gf[i];
+ f->gfx_filter = 0;
+ f->gfx_filter_scanlineratio = (1 << 4) | 1;
+ for (int j = 0; j <= 2 * MAX_FILTERSHADERS; j++) {
+ f->gfx_filtershader[i][0] = 0;
+ f->gfx_filtermask[i][0] = 0;
+ }
+ f->gfx_filter_horiz_zoom_mult = 1.0;
+ f->gfx_filter_vert_zoom_mult = 1.0;
+ f->gfx_filter_bilinear = 0;
+ f->gfx_filter_filtermode = 0;
+ f->gfx_filter_keep_aspect = 0;
+ f->gfx_filter_autoscale = AUTOSCALE_STATIC_AUTO;
+ f->gfx_filter_keep_autoscale_aspect = false;
+ f->gfx_filteroverlay_overscan = 0;
+ }
- configure_rom (p, roms, 0);
- _tcscpy (p->romextfile, _T(""));
- _tcscpy (p->flashfile, _T(""));
- _tcscpy (p->cartfile, _T(""));
+ p->rtg_horiz_zoom_mult = 1.0;
+ p->rtg_vert_zoom_mult = 1.0;
- sprintf (p->path_rom, _T("%s/kickstarts/"), start_path_data);
- sprintf (p->path_floppy, _T("%s/disks/"), start_path_data);
- sprintf (p->path_hardfile, _T("%s/"), start_path_data);
- sprintf (p->path_cd, _T("%s/cd32/"), start_path_data);
+ _tcscpy(p->floppyslots[0].df, _T("df0.adf"));
+ _tcscpy(p->floppyslots[1].df, _T("df1.adf"));
+ _tcscpy(p->floppyslots[2].df, _T("df2.adf"));
+ _tcscpy(p->floppyslots[3].df, _T("df3.adf"));
- p->fpu_model = 0;
- p->cpu_model = 68000;
+ for (int i = 0; i < MAX_LUA_STATES; i++) {
+ p->luafiles[i][0] = 0;
+ }
+
+ configure_rom(p, roms, 0);
+ _tcscpy(p->romextfile, _T(""));
+ _tcscpy(p->romextfile2, _T(""));
+ p->romextfile2addr = 0;
+ _tcscpy(p->flashfile, _T(""));
+ _tcscpy(p->cartfile, _T(""));
+ _tcscpy(p->rtcfile, _T(""));
+
+ _tcscpy(p->path_rom.path[0], _T("./"));
+ _tcscpy(p->path_floppy.path[0], _T("./"));
+ _tcscpy(p->path_hardfile.path[0], _T("./"));
+
+ p->prtname[0] = 0;
+ p->sername[0] = 0;
+
+ p->cpu_thread = false;
+
+ p->fpu_model = 0;
+ p->cpu_model = 68000;
+ p->m68k_speed_throttle = 0;
+ p->cpu_clock_multiplier = 0;
+ p->cpu_frequency = 0;
+ p->mmu_model = 0;
+ p->cpu060_revision = 6;
+ p->fpu_revision = 0;
p->fpu_no_unimplemented = false;
- p->fpu_strict = 0;
- p->fpu_softfloat = 0;
- p->m68k_speed = 0;
- p->cpu_compatible = 0;
- p->address_space_24 = 1;
- p->chipset_mask = CSMASK_ECS_AGNUS;
- p->ntscmode = 0;
+ p->int_no_unimplemented = false;
+ p->fpu_strict = false;
+ p->fpu_softfloat = false;
+ p->m68k_speed = 0;
+#ifndef AMIBERRY
+ p->cpu_compatible = true;
+#else
+ p->cpu_compatible = false;
+#endif
+ p->address_space_24 = true;
+ p->cpu_cycle_exact = false;
+ p->cpu_memory_cycle_exact = false;
+ p->blitter_cycle_exact = false;
+ p->chipset_mask = CSMASK_ECS_AGNUS;
+ p->genlock = false;
+ p->genlock_image = 0;
+ p->genlock_mix = 0;
+ p->ntscmode = 0;
p->filesys_limit = 0;
p->filesys_max_name = 107;
+ p->filesys_max_file_size = 0x7fffffff;
- p->fastmem[0].size = 0x00000000;
- p->mbresmem_low_size = 0x00000000;
- p->mbresmem_high_size = 0x00000000;
- p->z3fastmem[0].size = 0x00000000;
- p->z3autoconfig_start = 0x10000000;
- p->chipmem_size = 0x00080000;
- p->bogomem_size = 0x00080000;
+ p->z3autoconfig_start = 0x10000000;
+ p->chipmem_size = 0x00080000;
+ p->bogomem_size = 0x00080000;
+ for (int i = 0; i < MAX_RTG_BOARDS; i++) {
+ p->rtgboards[i].rtg_index = i;
+ }
p->rtgboards[0].rtgmem_size = 0x00000000;
p->rtgboards[0].rtgmem_type = GFXBOARD_UAE_Z3;
p->custom_memory_addrs[0] = 0;
@@ -4712,22 +7011,43 @@ void default_prefs (struct uae_prefs *p, bool reset, int type)
p->custom_memory_addrs[1] = 0;
p->custom_memory_sizes[1] = 0;
- p->nr_floppies = 2;
+ p->nr_floppies = 2;
p->floppy_read_only = false;
- p->floppyslots[0].dfxtype = DRV_35_DD;
- p->floppyslots[1].dfxtype = DRV_35_DD;
- p->floppyslots[2].dfxtype = DRV_NONE;
- p->floppyslots[3].dfxtype = DRV_NONE;
- p->floppy_speed = 100;
- p->floppy_write_length = 0;
+ p->floppyslots[0].dfxtype = DRV_35_DD;
+ p->floppyslots[1].dfxtype = DRV_35_DD;
+ p->floppyslots[2].dfxtype = DRV_NONE;
+ p->floppyslots[3].dfxtype = DRV_NONE;
+ p->floppy_speed = 100;
+ p->floppy_write_length = 0;
+ p->floppy_random_bits_min = 1;
+ p->floppy_random_bits_max = 3;
+ p->dfxclickvolume_disk[0] = 33;
+ p->dfxclickvolume_disk[1] = 33;
+ p->dfxclickvolume_disk[2] = 33;
+ p->dfxclickvolume_disk[3] = 33;
+ p->dfxclickvolume_empty[0] = 33;
+ p->dfxclickvolume_empty[1] = 33;
+ p->dfxclickvolume_empty[2] = 33;
+ p->dfxclickvolume_empty[3] = 33;
+ p->dfxclickchannelmask = 0xffff;
p->cd_speed = 100;
-
- p->socket_emu = 0;
- p->input_tablet = TABLET_OFF;
-
- inputdevice_default_prefs (p);
- blkdev_default_prefs (p);
+ p->statecapturebuffersize = 100;
+ p->statecapturerate = 5 * 50;
+ p->inprec_autoplay = true;
+
+#ifdef UAE_MINI
+ default_prefs_mini(p, 0);
+#endif
+
+ p->input_tablet = TABLET_OFF;
+ p->tablet_library = false;
+ p->input_mouse_untrap = MOUSEUNTRAP_NONE;
+ p->input_magic_mouse_cursor = 0;
+
+ inputdevice_default_prefs(p);
+
+ blkdev_default_prefs(p);
p->cr_selected = -1;
struct chipset_refresh *cr;
@@ -4741,53 +7061,64 @@ void default_prefs (struct uae_prefs *p, bool reset, int type)
cr->horiz = -1;
cr->vert = -1;
cr->lace = -1;
- cr->vsync = - 1;
+ cr->vsync = -1;
+ cr->framelength = -1;
cr->rate = 50.0;
cr->ntsc = 0;
cr->locked = false;
cr->inuse = true;
- _tcscpy (cr->label, _T("PAL"));
+ _tcscpy(cr->label, _T("PAL"));
cr = &p->cr[CHIPSET_REFRESH_NTSC];
cr->index = CHIPSET_REFRESH_NTSC;
cr->horiz = -1;
cr->vert = -1;
cr->lace = -1;
- cr->vsync = - 1;
+ cr->vsync = -1;
+ cr->framelength = -1;
cr->rate = 60.0;
cr->ntsc = 1;
cr->locked = false;
cr->inuse = true;
- _tcscpy (cr->label, _T("NTSC"));
+ _tcscpy(cr->label, _T("NTSC"));
+
+ p->lightboost_strobo = false;
+ p->lightboost_strobo_ratio = 50;
savestate_state = 0;
- target_default_options (p, type);
+ target_default_options(p, type);
- zfile_fclose (default_file);
+ zfile_fclose(default_file);
default_file = NULL;
- f = zfile_fopen_empty (NULL, _T("configstore"));
+ f = zfile_fopen_empty(NULL, _T("configstore"));
if (f) {
uaeconfig++;
- cfgfile_save_options (f, p, 0);
+ cfgfile_save_options(f, p, 0);
uaeconfig--;
- cfg_write (&zero, f);
+ cfg_write(&zero, f);
default_file = f;
}
}
-static void buildin_default_prefs_68020 (struct uae_prefs *p)
+static void buildin_default_prefs_68020(struct uae_prefs *p)
{
p->cpu_model = 68020;
p->address_space_24 = 1;
- p->cpu_compatible = 0;
+ p->cpu_compatible = 1;
p->chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE | CSMASK_AGA;
p->chipmem_size = 0x200000;
p->bogomem_size = 0;
p->m68k_speed = -1;
}
-static void buildin_default_prefs (struct uae_prefs *p)
+static void buildin_default_host_prefs(struct uae_prefs *p)
{
+}
+
+static void buildin_default_prefs(struct uae_prefs *p)
+{
+ buildin_default_host_prefs(p);
+
p->floppyslots[0].dfxtype = DRV_35_DD;
if (p->nr_floppies != 1 && p->nr_floppies != 2)
p->nr_floppies = 2;
@@ -4798,26 +7129,45 @@ static void buildin_default_prefs (struct uae_prefs *p)
p->fpu_model = 0;
p->cpu_model = 68000;
+ p->cpu_clock_multiplier = 0;
+ p->cpu_frequency = 0;
+ p->cpu060_revision = 1;
+ p->fpu_revision = -1;
p->m68k_speed = 0;
p->cpu_compatible = 1;
p->address_space_24 = 1;
+ p->cpu_cycle_exact = false;
+ p->cpu_memory_cycle_exact = false;
+ p->blitter_cycle_exact = false;
p->chipset_mask = CSMASK_ECS_AGNUS;
p->immediate_blits = 0;
p->waiting_blits = 0;
p->collision_level = 2;
if (p->produce_sound < 1)
p->produce_sound = 1;
+ p->scsi = 0;
+ p->uaeserial = 0;
+ p->cpu_idle = 0;
+ p->turbo_emulation = 0;
+ p->turbo_emulation_limit = 0;
+ p->catweasel = 0;
+ p->tod_hack = 0;
+ p->maprom = 0;
+ p->cachesize = 0;
p->socket_emu = 0;
- p->sound_volume_cd = 0;
+ p->clipboard_sharing = false;
+ p->ppc_mode = 0;
+ p->ppc_model[0] = 0;
+ p->cpuboard_type = 0;
+ p->cpuboard_subtype = 0;
p->chipmem_size = 0x00080000;
p->bogomem_size = 0x00080000;
+ p->z3chipmem_size = 0;
for (int i = 0; i < MAX_RAM_BOARDS; i++) {
memset(p->fastmem, 0, sizeof(struct ramboard));
memset(p->z3fastmem, 0, sizeof(struct ramboard));
}
- p->mbresmem_low_size = 0x00000000;
- p->mbresmem_high_size = 0x00000000;
for (int i = 0; i < MAX_RTG_BOARDS; i++) {
p->rtgboards[i].rtgmem_size = 0x00000000;
p->rtgboards[i].rtgmem_type = GFXBOARD_UAE_Z3;
@@ -4827,9 +7177,14 @@ static void buildin_default_prefs (struct uae_prefs *p)
}
p->cs_rtc = 0;
+ p->cs_a1000ram = false;
p->cs_fatgaryrev = -1;
p->cs_ramseyrev = -1;
+ p->cs_agnusrev = -1;
+ p->cs_deniserev = -1;
+ p->cs_mbdmac = 0;
p->cs_cd32c2p = p->cs_cd32cd = p->cs_cd32nvram = p->cs_cd32fmv = false;
+ p->cs_cdtvcd = p->cs_cdtvram = p->cs_cdtvcard = false;
p->cs_ide = 0;
p->cs_pcmcia = 0;
p->cs_ksmirror_e0 = 1;
@@ -4837,39 +7192,67 @@ static void buildin_default_prefs (struct uae_prefs *p)
p->cs_ciaoverlay = 1;
p->cs_ciaatod = 0;
p->cs_df0idhw = 1;
+ p->cs_resetwarning = 0;
p->cs_ciatodbug = false;
+ p->cs_1mchipjumper = false;
- _tcscpy (p->romextfile, _T(""));
+ _tcscpy(p->romextfile, _T(""));
+ _tcscpy(p->romextfile2, _T(""));
+
+ p->ne2000pciname[0] = 0;
+ p->ne2000pcmcianame[0] = 0;
+ p->a2065name[0] = 0;
+
+ p->prtname[0] = 0;
+ p->sername[0] = 0;
p->mountitems = 0;
- p->leds_on_screen = 0;
- target_default_options (p, 1);
+ target_default_options(p, 1);
cfgfile_compatibility_romtype(p);
}
-static void set_68020_compa (struct uae_prefs *p, int compa, int cd32)
+static void set_68020_compa(struct uae_prefs *p, int compa, int cd32)
{
switch (compa)
{
- case 0:
- p->cpu_compatible = 0;
- p->m68k_speed = 0;
- break;
- case 1:
- p->cpu_compatible = 0;
- p->m68k_speed = 0;
- break;
- case 2:
- p->cpu_compatible = 0;
- p->m68k_speed = -1;
- p->address_space_24 = 0;
- break;
- case 3:
- p->cpu_compatible = 0;
- p->address_space_24 = 0;
- p->cachesize = MAX_JIT_CACHE;
- break;
+ case 0:
+ p->blitter_cycle_exact = 1;
+ p->m68k_speed = 0;
+ if ((p->cpu_model == 68020 || p->cpu_model == 68030) && p->cachesize == 0) {
+ p->cpu_cycle_exact = 1;
+ p->cpu_memory_cycle_exact = true;
+ if (p->cpu_model == 68020)
+ p->cpu_clock_multiplier = 4 << 8;
+ else
+ p->cpu_clock_multiplier = 5 << 8;
+ }
+ break;
+ case 1:
+ p->blitter_cycle_exact = true;
+ p->m68k_speed = 0;
+ if ((p->cpu_model == 68020 || p->cpu_model == 68030) && p->cachesize == 0) {
+ p->cpu_memory_cycle_exact = true;
+ if (p->cpu_model == 68020)
+ p->cpu_clock_multiplier = 4 << 8;
+ else
+ p->cpu_clock_multiplier = 5 << 8;
+ }
+ break;
+ case 2:
+ p->cpu_compatible = true;
+ p->m68k_speed = 0;
+ break;
+ case 3:
+ p->cpu_compatible = 0;
+ p->m68k_speed = -1;
+ p->address_space_24 = 0;
+ break;
+ case 4:
+ p->cpu_compatible = 0;
+ p->address_space_24 = 0;
+ p->cachesize = MAX_JIT_CACHE;
+ break;
}
if (p->cpu_model >= 68030)
p->address_space_24 = 0;
@@ -4881,25 +7264,62 @@ static void set_68020_compa (struct uae_prefs *p, int compa, int cd32)
* 3: no more compatible, waiting blits, no 100% sound
*/
-static void set_68000_compa (struct uae_prefs *p, int compa)
+static void set_68000_compa(struct uae_prefs *p, int compa)
{
+ p->cpu_clock_multiplier = 2 << 8;
switch (compa)
{
- case 0:
- break;
- case 1:
- break;
- case 2:
- p->cpu_compatible = 0;
- break;
- case 3:
- p->produce_sound = 2;
- p->cpu_compatible = 0;
- break;
+ case 0:
+ p->cpu_cycle_exact = p->cpu_memory_cycle_exact = p->blitter_cycle_exact = true;
+ break;
+ case 1:
+ break;
+ case 2:
+ p->cpu_compatible = 0;
+ break;
+ case 3:
+ p->produce_sound = 2;
+ p->cpu_compatible = 0;
+ break;
}
}
-static int bip_a4000 (struct uae_prefs *p, int config, int compa, int romcheck)
+static int bip_a3000(struct uae_prefs *p, int config, int compa, int romcheck)
+{
+ int roms[2];
+
+ if (config == 2)
+ roms[0] = 61;
+ else if (config == 1)
+ roms[0] = 71;
+ else
+ roms[0] = 59;
+ roms[1] = -1;
+ p->bogomem_size = 0;
+ p->chipmem_size = 0x200000;
+ p->cpu_model = 68030;
+ p->fpu_model = 68882;
+ p->fpu_no_unimplemented = true;
+ if (compa == 0)
+ p->mmu_model = 68030;
+ else
+ p->cachesize = MAX_JIT_CACHE;
+ p->chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE;
+ p->cpu_compatible = p->address_space_24 = 0;
+ p->m68k_speed = -1;
+ p->immediate_blits = 0;
+ p->produce_sound = 2;
+ p->floppyslots[0].dfxtype = DRV_35_HD;
+ p->floppy_speed = 0;
+ p->cpu_idle = 150;
+ p->cs_compatible = CP_A3000;
+ p->mbresmem_low_size = 8 * 1024 * 1024;
+ built_in_chipset_prefs(p);
+ p->cs_ciaatod = p->ntscmode ? 2 : 1;
+ return configure_rom(p, roms, romcheck);
+}
+
+static int bip_a4000(struct uae_prefs *p, int config, int compa, int romcheck)
{
int roms[8];
@@ -4916,52 +7336,210 @@ static int bip_a4000 (struct uae_prefs *p, int config, int compa, int romcheck)
p->fpu_model = 68882;
switch (config)
{
- case 1:
- p->cpu_model = 68040;
- p->fpu_model = 68040;
- break;
+ case 1:
+ p->cpu_model = 68040;
+ p->fpu_model = 68040;
+ break;
+ case 2:
+ p->cpu_model = 68060;
+ p->fpu_model = 68060;
+ p->ppc_mode = 1;
+ //cpuboard_setboard(p, BOARD_CYBERSTORM, BOARD_CYBERSTORM_SUB_PPC);
+ p->cpuboardmem1_size = 128 * 1024 * 1024;
+ int roms_ppc[] = { 98, -1 };
+ configure_rom(p, roms_ppc, romcheck);
+ break;
}
p->chipset_mask = CSMASK_AGA | CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE;
- p->cpu_compatible = p->address_space_24 = 0;
+ p->cpu_compatible = p->address_space_24 = 0;
p->m68k_speed = -1;
p->immediate_blits = 0;
p->produce_sound = 2;
p->cachesize = MAX_JIT_CACHE;
-
- p->nr_floppies = 2;
p->floppyslots[0].dfxtype = DRV_35_HD;
p->floppyslots[1].dfxtype = DRV_35_HD;
p->floppy_speed = 0;
+ p->cpu_idle = 150;
p->cs_compatible = CP_A4000;
- built_in_chipset_prefs (p);
+ built_in_chipset_prefs(p);
p->cs_ciaatod = p->ntscmode ? 2 : 1;
- return configure_rom (p, roms, romcheck);
+ return configure_rom(p, roms, romcheck);
}
-static int bip_cd32 (struct uae_prefs *p, int config, int compa, int romcheck)
+static int bip_a4000t(struct uae_prefs *p, int config, int compa, int romcheck)
+{
+
+ int roms[8];
+
+ roms[0] = 16;
+ roms[1] = 31;
+ roms[2] = 13;
+ roms[3] = -1;
+
+ p->bogomem_size = 0;
+ p->chipmem_size = 0x200000;
+ p->mbresmem_low_size = 8 * 1024 * 1024;
+ p->cpu_model = 68030;
+ p->fpu_model = 68882;
+ if (config > 0) {
+ p->cpu_model = 68040;
+ p->fpu_model = 68040;
+ }
+ p->chipset_mask = CSMASK_AGA | CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE;
+ p->cpu_compatible = p->address_space_24 = 0;
+ p->m68k_speed = -1;
+ p->immediate_blits = 0;
+ p->produce_sound = 2;
+ p->cachesize = MAX_JIT_CACHE;
+ p->floppyslots[0].dfxtype = DRV_35_HD;
+ p->floppyslots[1].dfxtype = DRV_35_HD;
+ p->floppy_speed = 0;
+ p->cpu_idle = 150;
+ p->cs_compatible = CP_A4000T;
+ built_in_chipset_prefs(p);
+ p->cs_ciaatod = p->ntscmode ? 2 : 1;
+ return configure_rom(p, roms, romcheck);
+}
+
+static void bip_velvet(struct uae_prefs *p, int config, int compa, int romcheck)
+{
+ p->chipset_mask = 0;
+ p->bogomem_size = 0;
+ p->sound_filter = FILTER_SOUND_ON;
+ set_68000_compa(p, compa);
+ p->floppyslots[1].dfxtype = DRV_NONE;
+ p->cs_compatible = CP_VELVET;
+ p->cs_slowmemisfast = 1;
+ p->cs_dipagnus = 1;
+ p->cs_agnusbltbusybug = 1;
+ built_in_chipset_prefs(p);
+ p->cs_denisenoehb = 1;
+ p->cs_cia6526 = 1;
+ p->chipmem_size = 0x40000;
+}
+
+static int bip_a1000(struct uae_prefs *p, int config, int compa, int romcheck)
+{
+ int roms[2];
+
+ roms[0] = 24;
+ roms[1] = -1;
+ p->chipset_mask = 0;
+ p->bogomem_size = 0;
+ p->sound_filter = FILTER_SOUND_ON;
+ set_68000_compa(p, compa);
+ p->floppyslots[1].dfxtype = DRV_NONE;
+ p->cs_compatible = CP_A1000;
+ p->cs_slowmemisfast = 1;
+ p->cs_dipagnus = 1;
+ p->cs_agnusbltbusybug = 1;
+ built_in_chipset_prefs(p);
+ if (config > 0)
+ p->cs_denisenoehb = 1;
+ if (config > 1)
+ p->chipmem_size = 0x40000;
+ if (config > 2) {
+ roms[0] = 125;
+ roms[1] = -1;
+ bip_velvet(p, config, compa, romcheck);
+ }
+ return configure_rom(p, roms, romcheck);
+}
+
+static int bip_cdtvcr(struct uae_prefs *p, int config, int compa, int romcheck)
+{
+ int roms[4];
+
+ p->bogomem_size = 0;
+ p->chipmem_size = 0x100000;
+ p->chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE;
+ p->cs_cdtvcd = p->cs_cdtvram = true;
+ p->cs_cdtvcr = true;
+ p->cs_rtc = 1;
+ p->nr_floppies = 0;
+ p->floppyslots[0].dfxtype = DRV_NONE;
+ if (config > 0)
+ p->floppyslots[0].dfxtype = DRV_35_DD;
+ p->floppyslots[1].dfxtype = DRV_NONE;
+ set_68000_compa(p, compa);
+ p->cs_compatible = CP_CDTVCR;
+ built_in_chipset_prefs(p);
+ fetch_datapath(p->flashfile, sizeof(p->flashfile) / sizeof(TCHAR));
+ _tcscat(p->flashfile, _T("cdtv-cr.nvr"));
+ roms[0] = 9;
+ roms[1] = 10;
+ roms[2] = -1;
+ if (!configure_rom(p, roms, romcheck))
+ return 0;
+ roms[0] = 108;
+ roms[1] = 107;
+ roms[2] = -1;
+ if (!configure_rom(p, roms, romcheck))
+ return 0;
+ return 1;
+}
+
+static int bip_cdtv(struct uae_prefs *p, int config, int compa, int romcheck)
+{
+ int roms[4];
+
+ if (config >= 2)
+ return bip_cdtvcr(p, config - 2, compa, romcheck);
+
+ p->bogomem_size = 0;
+ p->chipmem_size = 0x100000;
+ p->chipset_mask = CSMASK_ECS_AGNUS;
+ p->cs_cdtvcd = p->cs_cdtvram = 1;
+ if (config > 0)
+ p->cs_cdtvcard = 64;
+ p->cs_rtc = 1;
+ p->nr_floppies = 0;
+ p->floppyslots[0].dfxtype = DRV_NONE;
+ if (config > 0)
+ p->floppyslots[0].dfxtype = DRV_35_DD;
+ p->floppyslots[1].dfxtype = DRV_NONE;
+ set_68000_compa(p, compa);
+ p->cs_compatible = CP_CDTV;
+ built_in_chipset_prefs(p);
+ fetch_datapath(p->flashfile, sizeof(p->flashfile) / sizeof(TCHAR));
+ _tcscat(p->flashfile, _T("cdtv.nvr"));
+ roms[0] = 6;
+ roms[1] = 32;
+ roms[2] = -1;
+ if (!configure_rom(p, roms, romcheck))
+ return 0;
+ roms[0] = 20;
+ roms[1] = 21;
+ roms[2] = 22;
+ roms[3] = -1;
+ if (!configure_rom(p, roms, romcheck))
+ return 0;
+ return 1;
+}
+
+static int bip_cd32(struct uae_prefs *p, int config, int compa, int romcheck)
{
int roms[3];
- buildin_default_prefs_68020 (p);
+ buildin_default_prefs_68020(p);
p->cs_cd32c2p = p->cs_cd32cd = p->cs_cd32nvram = true;
p->nr_floppies = 0;
p->floppyslots[0].dfxtype = DRV_NONE;
p->floppyslots[1].dfxtype = DRV_NONE;
- set_68020_compa (p, compa, 1);
+ set_68020_compa(p, compa, 1);
p->cs_compatible = CP_CD32;
- built_in_chipset_prefs (p);
- fetch_datapath (p->flashfile, sizeof (p->flashfile) / sizeof (TCHAR));
- _tcscat (p->flashfile, _T("cd32.nvr"));
-
+ built_in_chipset_prefs(p);
+ fetch_datapath(p->flashfile, sizeof(p->flashfile) / sizeof(TCHAR));
+ _tcscat(p->flashfile, _T("cd32.nvr"));
roms[0] = 64;
roms[1] = -1;
- if (!configure_rom (p, roms, 0)) {
+ if (!configure_rom(p, roms, 0)) {
roms[0] = 18;
roms[1] = -1;
- if (!configure_rom (p, roms, romcheck))
+ if (!configure_rom(p, roms, romcheck))
return 0;
roms[0] = 19;
- if (!configure_rom (p, roms, romcheck))
+ if (!configure_rom(p, roms, romcheck))
return 0;
}
if (config > 0) {
@@ -4969,54 +7547,78 @@ static int bip_cd32 (struct uae_prefs *p, int config, int compa, int romcheck)
roms[0] = 74;
roms[1] = 23;
roms[2] = -1;
- if (!configure_rom (p, roms, romcheck))
+ if (!configure_rom(p, roms, romcheck))
return 0;
}
-
- p->cdslots[0].inuse = true;
- p->cdslots[0].type = SCSI_UNIT_IMAGE;
-
-#ifdef PANDORA
- p->gfx_size.width = 384;
- p->gfx_size.height = 256;
-#endif
-
- p->m68k_speed = M68K_SPEED_14MHZ_CYCLES;
-
return 1;
}
-static int bip_a1200 (struct uae_prefs *p, int config, int compa, int romcheck)
+static int bip_a1200(struct uae_prefs *p, int config, int compa, int romcheck)
{
int roms[4];
+ int roms_bliz[2];
- buildin_default_prefs_68020 (p);
+ buildin_default_prefs_68020(p);
roms[0] = 11;
roms[1] = 15;
roms[2] = 31;
roms[3] = -1;
-
+ roms_bliz[0] = -1;
+ roms_bliz[1] = -1;
p->cs_rtc = 0;
p->cs_compatible = CP_A1200;
- built_in_chipset_prefs (p);
+ built_in_chipset_prefs(p);
switch (config)
{
- case 1:
- p->fastmem[0].size = 0x400000;
- p->cs_rtc = 1;
- break;
+ case 1:
+ p->fastmem[0].size = 0x400000;
+ p->cs_rtc = 1;
+ break;
+ case 2:
+ //cpuboard_setboard(p, BOARD_BLIZZARD, BOARD_BLIZZARD_SUB_1230IV);
+ p->cpuboardmem1_size = 32 * 1024 * 1024;
+ p->cpu_model = 68030;
+ p->cs_rtc = 1;
+ roms_bliz[0] = 89;
+ configure_rom(p, roms_bliz, romcheck);
+ break;
+ case 3:
+ //cpuboard_setboard(p, BOARD_BLIZZARD, BOARD_BLIZZARD_SUB_1260);
+ p->cpuboardmem1_size = 32 * 1024 * 1024;
+ p->cpu_model = 68040;
+ p->fpu_model = 68040;
+ p->cs_rtc = 1;
+ roms_bliz[0] = 90;
+ configure_rom(p, roms_bliz, romcheck);
+ break;
+ case 4:
+ //cpuboard_setboard(p, BOARD_BLIZZARD, BOARD_BLIZZARD_SUB_1260);
+ p->cpuboardmem1_size = 32 * 1024 * 1024;
+ p->cpu_model = 68060;
+ p->fpu_model = 68060;
+ p->cs_rtc = 1;
+ roms_bliz[0] = 90;
+ configure_rom(p, roms_bliz, romcheck);
+ break;
+ case 5:
+ //cpuboard_setboard(p, BOARD_BLIZZARD, BOARD_BLIZZARD_SUB_PPC);
+ p->cpuboardmem1_size = 256 * 1024 * 1024;
+ p->cpu_model = 68060;
+ p->fpu_model = 68060;
+ p->ppc_mode = 1;
+ p->cs_rtc = 1;
+ roms[0] = 15;
+ roms[1] = 11;
+ roms[2] = -1;
+ roms_bliz[0] = 100;
+ configure_rom(p, roms_bliz, romcheck);
+ break;
}
- set_68020_compa (p, compa, 0);
-
- p->m68k_speed = M68K_SPEED_14MHZ_CYCLES;
-
- p->nr_floppies = 1;
- p->floppyslots[1].dfxtype = DRV_NONE;
-
- return configure_rom (p, roms, romcheck);
+ set_68020_compa(p, compa, 0);
+ return configure_rom(p, roms, romcheck);
}
-static int bip_a600 (struct uae_prefs *p, int config, int compa, int romcheck)
+static int bip_a600(struct uae_prefs *p, int config, int compa, int romcheck)
{
int roms[4];
@@ -5024,9 +7626,9 @@ static int bip_a600 (struct uae_prefs *p, int config, int compa, int romcheck)
roms[1] = 9;
roms[2] = 8;
roms[3] = -1;
- set_68000_compa (p, compa);
+ set_68000_compa(p, compa);
p->cs_compatible = CP_A600;
- built_in_chipset_prefs (p);
+ built_in_chipset_prefs(p);
p->bogomem_size = 0;
p->chipmem_size = 0x100000;
if (config > 0)
@@ -5036,20 +7638,20 @@ static int bip_a600 (struct uae_prefs *p, int config, int compa, int romcheck)
if (config == 2)
p->fastmem[0].size = 0x400000;
p->chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE;
- return configure_rom (p, roms, romcheck);
+ return configure_rom(p, roms, romcheck);
}
-static int bip_a500p (struct uae_prefs *p, int config, int compa, int romcheck)
+static int bip_a500p(struct uae_prefs *p, int config, int compa, int romcheck)
{
- int roms[2];
+ int roms[2];
roms[0] = 7;
- roms[1] = -1;
- set_68000_compa (p, compa);
+ roms[1] = -1;
+ set_68000_compa(p, compa);
p->cs_compatible = CP_A500P;
- built_in_chipset_prefs (p);
+ built_in_chipset_prefs(p);
p->bogomem_size = 0;
- p->chipmem_size = 0x100000;
+ p->chipmem_size = 0x100000;
if (config > 0)
p->cs_rtc = 1;
if (config == 1)
@@ -5057,89 +7659,185 @@ static int bip_a500p (struct uae_prefs *p, int config, int compa, int romcheck)
if (config == 2)
p->fastmem[0].size = 0x400000;
p->chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE;
- return configure_rom (p, roms, romcheck);
+ return configure_rom(p, roms, romcheck);
}
-static int bip_a500 (struct uae_prefs *p, int config, int compa, int romcheck)
+static int bip_a500(struct uae_prefs *p, int config, int compa, int romcheck)
{
- int roms[4];
+ int roms[4];
roms[0] = roms[1] = roms[2] = roms[3] = -1;
switch (config)
- {
- case 0: // KS 1.3, OCS Agnus, 0.5M Chip + 0.5M Slow
- roms[0] = 6;
- roms[1] = 32;
- p->chipset_mask = 0;
- break;
- case 1: // KS 1.3, ECS Agnus, 0.5M Chip + 0.5M Slow
- roms[0] = 6;
- roms[1] = 32;
- break;
- case 2: // KS 1.3, ECS Agnus, 1.0M Chip
- roms[0] = 6;
- roms[1] = 32;
- p->bogomem_size = 0;
- p->chipmem_size = 0x100000;
- break;
- case 3: // KS 1.3, OCS Agnus, 0.5M Chip
- roms[0] = 6;
- roms[1] = 32;
- p->bogomem_size = 0;
- p->chipset_mask = 0;
- p->cs_rtc = 0;
- p->floppyslots[1].dfxtype = DRV_NONE;
- break;
- case 4: // KS 1.2, OCS Agnus, 0.5M Chip
- roms[0] = 5;
- roms[1] = 4;
- roms[2] = 3;
- p->bogomem_size = 0;
- p->chipset_mask = 0;
- p->cs_rtc = 0;
- p->floppyslots[1].dfxtype = DRV_NONE;
- break;
- case 5: // KS 1.2, OCS Agnus, 0.5M Chip + 0.5M Slow
- roms[0] = 5;
- roms[1] = 4;
- roms[2] = 3;
- p->chipset_mask = 0;
- break;
+ {
+ case 0: // KS 1.3, OCS Agnus, 0.5M Chip + 0.5M Slow
+ roms[0] = 6;
+ roms[1] = 32;
+ p->chipset_mask = 0;
+ break;
+ case 1: // KS 1.3, ECS Agnus, 0.5M Chip + 0.5M Slow
+ roms[0] = 6;
+ roms[1] = 32;
+ break;
+ case 2: // KS 1.3, ECS Agnus, 1.0M Chip
+ roms[0] = 6;
+ roms[1] = 32;
+ p->bogomem_size = 0;
+ p->chipmem_size = 0x100000;
+ break;
+ case 3: // KS 1.3, OCS Agnus, 0.5M Chip
+ roms[0] = 6;
+ roms[1] = 32;
+ p->bogomem_size = 0;
+ p->chipset_mask = 0;
+ p->cs_rtc = 0;
+ p->floppyslots[1].dfxtype = DRV_NONE;
+ break;
+ case 4: // KS 1.2, OCS Agnus, 0.5M Chip
+ roms[0] = 5;
+ roms[1] = 4;
+ roms[2] = 3;
+ p->bogomem_size = 0;
+ p->chipset_mask = 0;
+ p->cs_rtc = 0;
+ p->floppyslots[1].dfxtype = DRV_NONE;
+ break;
+ case 5: // KS 1.2, OCS Agnus, 0.5M Chip + 0.5M Slow
+ roms[0] = 5;
+ roms[1] = 4;
+ roms[2] = 3;
+ p->chipset_mask = 0;
+ break;
}
- p->fast_copper = 0;
- set_68000_compa (p, compa);
+ set_68000_compa(p, compa);
p->cs_compatible = CP_A500;
- built_in_chipset_prefs (p);
- return configure_rom (p, roms, romcheck);
+ built_in_chipset_prefs(p);
+ return configure_rom(p, roms, romcheck);
}
-int built_in_prefs (struct uae_prefs *p, int model, int config, int compa, int romcheck)
+static int bip_super(struct uae_prefs *p, int config, int compa, int romcheck)
+{
+ int roms[7];
+
+ roms[0] = 16;
+ roms[1] = 31;
+ roms[2] = 15;
+ roms[3] = 14;
+ roms[4] = 12;
+ roms[5] = 11;
+ roms[6] = -1;
+ p->bogomem_size = 0;
+ p->chipmem_size = 0x400000;
+ p->z3fastmem[0].size = 8 * 1024 * 1024;
+ p->rtgboards[0].rtgmem_size = 16 * 1024 * 1024;
+ p->cpu_model = 68040;
+ p->fpu_model = 68040;
+ p->chipset_mask = CSMASK_AGA | CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE;
+ p->cpu_compatible = p->address_space_24 = 0;
+ p->m68k_speed = -1;
+ p->immediate_blits = 1;
+ p->produce_sound = 2;
+ p->cachesize = MAX_JIT_CACHE;
+ p->floppyslots[0].dfxtype = DRV_35_HD;
+ p->floppyslots[1].dfxtype = DRV_35_HD;
+ p->floppy_speed = 0;
+ p->cpu_idle = 150;
+ p->scsi = 1;
+ p->uaeserial = 1;
+ p->socket_emu = 1;
+ p->cart_internal = 0;
+ p->picasso96_nocustom = 1;
+ p->cs_compatible = 1;
+ built_in_chipset_prefs(p);
+ p->cs_ide = -1;
+ p->cs_ciaatod = p->ntscmode ? 2 : 1;
+ //_tcscat(p->flashfile, _T("battclock.nvr"));
+ return configure_rom(p, roms, romcheck);
+}
+
+static int bip_arcadia(struct uae_prefs *p, int config, int compa, int romcheck)
+{
+ int roms[4], i;
+ struct romlist **rl;
+
+ p->bogomem_size = 0;
+ p->chipset_mask = 0;
+ p->cs_rtc = 0;
+ p->nr_floppies = 0;
+ p->floppyslots[0].dfxtype = DRV_NONE;
+ p->floppyslots[1].dfxtype = DRV_NONE;
+ set_68000_compa(p, compa);
+ p->cs_compatible = CP_A500;
+ built_in_chipset_prefs(p);
+ fetch_datapath(p->flashfile, sizeof(p->flashfile) / sizeof(TCHAR));
+ _tcscat(p->flashfile, _T("arcadia.nvr"));
+ roms[0] = 5;
+ roms[1] = 4;
+ roms[2] = -1;
+ if (!configure_rom(p, roms, romcheck))
+ return 0;
+ roms[0] = 51;
+ roms[1] = 49;
+ roms[2] = -1;
+ if (!configure_rom(p, roms, romcheck))
+ return 0;
+ rl = getarcadiaroms();
+ for (i = 0; rl[i]; i++) {
+ if (config-- == 0) {
+ roms[0] = rl[i]->rd->id;
+ roms[1] = -1;
+ configure_rom(p, roms, 0);
+ break;
+ }
+ }
+ xfree(rl);
+ return 1;
+}
+
+int built_in_prefs(struct uae_prefs *p, int model, int config, int compa, int romcheck)
{
int v = 0;
- buildin_default_prefs (p);
+ buildin_default_prefs(p);
switch (model)
- {
- case 0:
- v = bip_a500 (p, config, compa, romcheck);
- break;
- case 1:
- v = bip_a500p (p, config, compa, romcheck);
- break;
- case 2:
- v = bip_a600 (p, config, compa, romcheck);
- break;
- case 3:
- v = bip_a1200 (p, config, compa, romcheck);
- break;
- case 4:
- v = bip_a4000 (p, config, compa, romcheck);
- break;
- case 5:
- v = bip_cd32 (p, config, compa, romcheck);
- break;
- }
- if (!p->immediate_blits)
+ {
+ case 0:
+ v = bip_a500(p, config, compa, romcheck);
+ break;
+ case 1:
+ v = bip_a500p(p, config, compa, romcheck);
+ break;
+ case 2:
+ v = bip_a600(p, config, compa, romcheck);
+ break;
+ case 3:
+ v = bip_a1000(p, config, compa, romcheck);
+ break;
+ case 4:
+ v = bip_a1200(p, config, compa, romcheck);
+ break;
+ case 5:
+ v = bip_a3000(p, config, compa, romcheck);
+ break;
+ case 6:
+ v = bip_a4000(p, config, compa, romcheck);
+ break;
+ case 7:
+ v = bip_a4000t(p, config, compa, romcheck);
+ break;
+ case 8:
+ v = bip_cd32(p, config, compa, romcheck);
+ break;
+ case 9:
+ v = bip_cdtv(p, config, compa, romcheck);
+ break;
+ case 10:
+ v = bip_arcadia(p, config, compa, romcheck);
+ break;
+ case 11:
+ v = bip_super(p, config, compa, romcheck);
+ break;
+ }
+ if ((p->cpu_model >= 68020 || !p->cpu_cycle_exact || !p->cpu_memory_cycle_exact) && !p->immediate_blits)
p->waiting_blits = 1;
if (p->sound_filter_type == FILTER_SOUND_TYPE_A500 && (p->chipset_mask & CSMASK_AGA))
p->sound_filter_type = FILTER_SOUND_TYPE_A1200;
@@ -5151,134 +7849,286 @@ int built_in_prefs (struct uae_prefs *p, int model, int config, int compa, int r
return v;
}
-int built_in_chipset_prefs (struct uae_prefs *p)
+int built_in_chipset_prefs(struct uae_prefs *p)
{
if (!p->cs_compatible)
return 1;
+ p->cs_a1000ram = 0;
p->cs_cd32c2p = p->cs_cd32cd = p->cs_cd32nvram = 0;
+ p->cs_cdtvcd = p->cs_cdtvram = p->cs_cdtvscsi = p->cs_cdtvcr = 0;
p->cs_fatgaryrev = -1;
p->cs_ide = 0;
p->cs_ramseyrev = -1;
+ p->cs_deniserev = -1;
+ p->cs_agnusrev = -1;
+ p->cs_denisenoehb = 0;
+ p->cs_dipagnus = 0;
+ p->cs_agnusbltbusybug = 0;
+ p->cs_mbdmac = 0;
p->cs_pcmcia = 0;
p->cs_ksmirror_e0 = 1;
p->cs_ksmirror_a8 = 0;
p->cs_ciaoverlay = 1;
p->cs_ciaatod = 0;
p->cs_rtc = 0;
+ p->cs_rtc_adjust_mode = p->cs_rtc_adjust = 0;
p->cs_df0idhw = 1;
+ p->cs_resetwarning = 1;
+ p->cs_slowmemisfast = 0;
p->cs_ciatodbug = false;
p->cs_z3autoconfig = false;
p->cs_bytecustomwritebug = false;
+ p->cs_1mchipjumper = false;
switch (p->cs_compatible)
{
- case CP_GENERIC: // generic
- if (p->cpu_model >= 68020) {
- // big box-like
- p->cs_rtc = 2;
- p->cs_fatgaryrev = 0;
- p->cs_ide = -1;
- p->cs_ramseyrev = 0x0f;
- } else if (p->cpu_compatible) {
- // very A500-like
- p->cs_df0idhw = 0;
- if (p->bogomem_size || p->chipmem_size > 0x80000 || p->fastmem[0].size)
- p->cs_rtc = 1;
- p->cs_ciatodbug = true;
- } else {
- // sort of A500-like
- p->cs_ide = -1;
- p->cs_rtc = 1;
- }
- break;
- case CP_CD32: // CD32
- p->cs_cd32c2p = p->cs_cd32cd = p->cs_cd32nvram = true;
- p->cs_ksmirror_e0 = 0;
- p->cs_ksmirror_a8 = 1;
- p->cs_ciaoverlay = 0;
- break;
- case CP_A500: // A500
- p->cs_df0idhw = 0;
- if (p->bogomem_size || p->chipmem_size > 0x80000 || p->fastmem[0].size)
- p->cs_rtc = 1;
+ case CP_GENERIC: // generic
+ if (p->cpu_model >= 68020) {
+ // big box-like
+ p->cs_rtc = 2;
+ p->cs_fatgaryrev = 0;
+ p->cs_ide = -1;
+ p->cs_mbdmac = 0;
+ p->cs_ramseyrev = 0x0f;
+ }
+ else if (p->cpu_compatible) {
+ // very A500-like
+ p->cs_df0idhw = 0;
+ p->cs_resetwarning = 0;
+ if (p->bogomem_size || p->chipmem_size > 0x80000 || p->fastmem[0].size)
+ p->cs_rtc = 1;
p->cs_ciatodbug = true;
- break;
- case CP_A500P: // A500+
- p->cs_rtc = 1;
- p->cs_ciatodbug = true;
- break;
- case CP_A600: // A600
- p->cs_ide = IDE_A600A1200;
- p->cs_pcmcia = 1;
- p->cs_ksmirror_a8 = 1;
- p->cs_ciaoverlay = 0;
- p->cs_ciatodbug = true;
- break;
- case CP_A1200: // A1200
- p->cs_ide = IDE_A600A1200;
- p->cs_pcmcia = 1;
- p->cs_ksmirror_a8 = 1;
- p->cs_ciaoverlay = 0;
- if (p->fastmem[0].size || p->z3fastmem[0].size)
- p->cs_rtc = 1;
- break;
- case CP_A2000: // A2000
- p->cs_rtc = 1;
+ }
+ else {
+ // sort of A500-like
+ p->cs_ide = -1;
+ p->cs_rtc = 1;
+ }
+ break;
+ case CP_CDTV: // CDTV
+ p->cs_rtc = 1;
+ p->cs_cdtvcd = p->cs_cdtvram = 1;
+ p->cs_df0idhw = 1;
+ p->cs_ksmirror_e0 = 0;
+ break;
+ case CP_CDTVCR: // CDTV-CR
+ p->cs_rtc = 1;
+ p->cs_cdtvcd = p->cs_cdtvram = 1;
+ p->cs_cdtvcr = true;
+ p->cs_df0idhw = 1;
+ p->cs_ksmirror_e0 = 0;
+ p->cs_ide = IDE_A600A1200;
+ p->cs_pcmcia = 1;
+ p->cs_ksmirror_a8 = 1;
+ p->cs_ciaoverlay = 0;
+ p->cs_resetwarning = 0;
+ p->cs_ciatodbug = true;
+ break;
+ case CP_CD32: // CD32
+ p->cs_cd32c2p = p->cs_cd32cd = p->cs_cd32nvram = true;
+ p->cs_ksmirror_e0 = 0;
+ p->cs_ksmirror_a8 = 1;
+ p->cs_ciaoverlay = 0;
+ p->cs_resetwarning = 0;
+ break;
+ case CP_A500: // A500
+ p->cs_df0idhw = 0;
+ p->cs_resetwarning = 0;
+ if (p->bogomem_size || p->chipmem_size > 0x80000 || p->fastmem[0].size)
+ p->cs_rtc = 1;
+ p->cs_ciatodbug = true;
+ break;
+ case CP_A500P: // A500+
+ p->cs_rtc = 1;
+ p->cs_resetwarning = 0;
+ p->cs_ciatodbug = true;
+ break;
+ case CP_A600: // A600
+ p->cs_ide = IDE_A600A1200;
+ p->cs_pcmcia = 1;
+ p->cs_ksmirror_a8 = 1;
+ p->cs_ciaoverlay = 0;
+ p->cs_resetwarning = 0;
+ p->cs_ciatodbug = true;
+ break;
+ case CP_A1000: // A1000
+ p->cs_a1000ram = 1;
p->cs_ciaatod = p->ntscmode ? 2 : 1;
- p->cs_ciatodbug = true;
- break;
- case CP_A4000: // A4000
- p->cs_rtc = 2;
- p->cs_fatgaryrev = 0;
- p->cs_ramseyrev = 0x0f;
- p->cs_ide = IDE_A4000;
- p->cs_ksmirror_a8 = 0;
- p->cs_ksmirror_e0 = 0;
- p->cs_ciaoverlay = 0;
- p->cs_z3autoconfig = true;
- break;
+ p->cs_ksmirror_e0 = 0;
+ p->cs_agnusbltbusybug = 1;
+ p->cs_dipagnus = 1;
+ p->cs_ciatodbug = true;
+ break;
+ case CP_VELVET: // A1000 Prototype
+ p->cs_ciaatod = p->ntscmode ? 2 : 1;
+ p->cs_ksmirror_e0 = 0;
+ p->cs_agnusbltbusybug = 1;
+ p->cs_dipagnus = 1;
+ p->cs_denisenoehb = 1;
+ break;
+ case CP_A1200: // A1200
+ p->cs_ide = IDE_A600A1200;
+ p->cs_pcmcia = 1;
+ p->cs_ksmirror_a8 = 1;
+ p->cs_ciaoverlay = 0;
+ if (p->fastmem[0].size || p->z3fastmem[0].size || p->cpuboard_type)
+ p->cs_rtc = 1;
+ break;
+ case CP_A2000: // A2000
+ p->cs_rtc = 1;
+ p->cs_ciaatod = p->ntscmode ? 2 : 1;
+ p->cs_ciatodbug = true;
+ break;
+ case CP_A3000: // A3000
+ p->cs_rtc = 2;
+ p->cs_fatgaryrev = 0;
+ p->cs_ramseyrev = 0x0d;
+ p->cs_mbdmac = 1;
+ p->cs_ksmirror_e0 = 0;
+ p->cs_ciaatod = p->ntscmode ? 2 : 1;
+ p->cs_z3autoconfig = true;
+ break;
+ case CP_A3000T: // A3000T
+ p->cs_rtc = 2;
+ p->cs_fatgaryrev = 0;
+ p->cs_ramseyrev = 0x0d;
+ p->cs_mbdmac = 1;
+ p->cs_ksmirror_e0 = 0;
+ p->cs_ciaatod = p->ntscmode ? 2 : 1;
+ p->cs_z3autoconfig = true;
+ break;
+ case CP_A4000: // A4000
+ p->cs_rtc = 2;
+ p->cs_fatgaryrev = 0;
+ p->cs_ramseyrev = 0x0f;
+ p->cs_ide = IDE_A4000;
+ p->cs_mbdmac = 0;
+ p->cs_ksmirror_a8 = 0;
+ p->cs_ksmirror_e0 = 0;
+ p->cs_ciaoverlay = 0;
+ p->cs_z3autoconfig = true;
+ break;
+ case CP_A4000T: // A4000T
+ p->cs_rtc = 2;
+ p->cs_fatgaryrev = 0;
+ p->cs_ramseyrev = 0x0f;
+ p->cs_ide = IDE_A4000;
+ p->cs_mbdmac = 2;
+ p->cs_ksmirror_a8 = 0;
+ p->cs_ksmirror_e0 = 0;
+ p->cs_ciaoverlay = 0;
+ p->cs_z3autoconfig = true;
+ break;
}
if (p->cpu_model >= 68040)
p->cs_bytecustomwritebug = true;
return 1;
}
-void set_config_changed (void)
+int built_in_cpuboard_prefs(struct uae_prefs *p)
+{
+ int roms[2], roms2[2];
+
+ roms[0] = -1;
+ roms[1] = -1;
+ roms2[0] = -1;
+ roms2[1] = -1;
+
+ //switch (cpuboards[p->cpuboard_type].id)
+ //{
+ //case BOARD_MACROSYSTEM:
+ // switch (p->cpuboard_subtype)
+ // {
+ // case BOARD_MACROSYSTEM_SUB_WARPENGINE_A4000:
+ // roms[0] = 93;
+ // break;
+ // }
+ // break;
+ //case BOARD_BLIZZARD:
+ // switch (p->cpuboard_subtype)
+ // {
+ // case BOARD_BLIZZARD_SUB_1230IV:
+ // roms[0] = 89;
+ // break;
+ // case BOARD_BLIZZARD_SUB_1260:
+ // roms[0] = 90;
+ // break;
+ // case BOARD_BLIZZARD_SUB_2060:
+ // roms[0] = 92;
+ // break;
+ // case BOARD_BLIZZARD_SUB_PPC:
+ // roms[0] = p->cpu_model == 68040 ? 99 : 100;
+ // break;
+ // }
+ // break;
+ //case BOARD_CYBERSTORM:
+ // switch (p->cpuboard_subtype)
+ // {
+ // case BOARD_CYBERSTORM_SUB_MK1:
+ // roms[0] = p->cpu_model == 68040 ? 95 : 101;
+ // break;
+ // case BOARD_CYBERSTORM_SUB_MK2:
+ // roms[0] = 96;
+ // break;
+ // case BOARD_CYBERSTORM_SUB_MK3:
+ // roms[0] = 97;
+ // break;
+ // case BOARD_CYBERSTORM_SUB_PPC:
+ // roms[0] = 98;
+ // break;
+ // }
+ // break;
+ //}
+ if (!configure_rom(p, roms, 0))
+ return 0;
+ if (!configure_rom(p, roms2, 0))
+ return 0;
+ return 1;
+}
+
+void set_config_changed(void)
{
config_changed = 1;
}
-void config_check_vsync (void)
+void config_check_vsync(void)
{
if (config_changed) {
+#ifdef WITH_LUA
+ if (config_changed == 1) {
+ createconfigstore(&currprefs);
+ uae_lua_run_handler("on_uae_config_changed");
+ }
+#endif
config_changed++;
if (config_changed >= 3)
config_changed = 0;
}
}
-bool is_error_log (void)
+bool is_error_log(void)
{
return error_lines != NULL;
}
-TCHAR *get_error_log (void)
+TCHAR *get_error_log(void)
{
strlist *sl;
int len = 0;
for (sl = error_lines; sl; sl = sl->next) {
- len += _tcslen (sl->option) + 1;
+ len += _tcslen(sl->option) + 1;
}
if (!len)
return NULL;
- TCHAR *s = xcalloc (TCHAR, len + 1);
+ TCHAR *s = xcalloc(TCHAR, len + 1);
for (sl = error_lines; sl; sl = sl->next) {
- _tcscat (s, sl->option);
- _tcscat (s, _T("\n"));
+ _tcscat(s, sl->option);
+ _tcscat(s, _T("\n"));
}
return s;
}
-void error_log (const TCHAR *format, ...)
+
+void error_log(const TCHAR *format, ...)
{
TCHAR buffer[256], *bufp;
int bufsize = 256;
@@ -5289,136 +8139,35 @@ void error_log (const TCHAR *format, ...)
while (*ps) {
struct strlist *s = *ps;
*ps = s->next;
- xfree (s->value);
- xfree (s->option);
- xfree (s);
+ xfree(s->value);
+ xfree(s->option);
+ xfree(s);
}
return;
}
- va_start (parms, format);
+ va_start(parms, format);
bufp = buffer;
for (;;) {
- int count = _vsntprintf (bufp, bufsize - 1, format, parms);
+ int count = _vsntprintf(bufp, bufsize - 1, format, parms);
if (count < 0) {
bufsize *= 10;
if (bufp != buffer)
- xfree (bufp);
- bufp = xmalloc (TCHAR, bufsize);
+ xfree(bufp);
+ bufp = xmalloc(TCHAR, bufsize);
continue;
}
break;
}
bufp[bufsize - 1] = 0;
- write_log (_T("%s\n"), bufp);
- va_end (parms);
+ write_log(_T("%s\n"), bufp);
+ va_end(parms);
- strlist *u = xcalloc (struct strlist, 1);
- u->option = my_strdup (bufp);
+ strlist *u = xcalloc(struct strlist, 1);
+ u->option = my_strdup(bufp);
u->next = error_lines;
error_lines = u;
if (bufp != buffer)
- xfree (bufp);
-}
-
-int bip_a4000 (struct uae_prefs *p, int rom)
-{
- return bip_a4000(p, 0, 0, 0);
-}
-
-int bip_cd32 (struct uae_prefs *p, int rom)
-{
- return bip_cd32(p, 0, 0, 0);
-}
-
-int bip_a1200 (struct uae_prefs *p, int rom)
-{
- int roms[4];
-
- int v = bip_a1200(p, 0, 0, 0);
- if(rom == 310)
- {
- roms[0] = 15;
- roms[1] = 11;
- roms[2] = 31;
- roms[3] = -1;
- v = configure_rom (p, roms, 0);
- }
-
- return v;
-}
-
-int bip_a500plus (struct uae_prefs *p, int rom)
-{
- int roms[4];
-
- int v = bip_a500p(p, 0, 0, 0);
- if(rom == 130)
- {
- roms[0] = 6;
- roms[1] = 5;
- roms[2] = 4;
- roms[3] = -1;
- }
- else
- {
- roms[0] = 7;
- roms[1] = 6;
- roms[2] = 5;
- roms[3] = -1;
- }
- return configure_rom (p, roms, 0);
-}
-
-int bip_a500 (struct uae_prefs *p, int rom)
-{
- int roms[4];
-
- int v = bip_a500(p, 0, 0, 0);
- if(rom == 130)
- {
- roms[0] = 6;
- roms[1] = 5;
- roms[2] = 4;
- roms[3] = -1;
- }
- else
- {
- roms[0] = 5;
- roms[1] = 4;
- roms[2] = 3;
- roms[3] = -1;
- }
- return configure_rom (p, roms, 0);
-}
-
-int bip_a2000 (struct uae_prefs *p, int rom)
-{
- int roms[4];
-
- if(rom == 130)
- {
- roms[0] = 6;
- roms[1] = 5;
- roms[2] = 4;
- roms[3] = -1;
- }
- else
- {
- roms[0] = 5;
- roms[1] = 4;
- roms[2] = 3;
- roms[3] = -1;
- }
- p->cs_compatible = CP_A2000;
- built_in_chipset_prefs (p);
- p->chipmem_size = 0x00080000;
- p->bogomem_size = 0x00080000;
- p->chipset_mask = 0;
- p->cpu_compatible = 0;
- p->fast_copper = 0;
- p->nr_floppies = 1;
- p->floppyslots[1].dfxtype = DRV_NONE;
- return configure_rom (p, roms, 0);
+ xfree(bufp);
}
diff --git a/src/cia.cpp b/src/cia.cpp
index 35823ead..bc30ffda 100644
--- a/src/cia.cpp
+++ b/src/cia.cpp
@@ -12,7 +12,7 @@
#include
#include "options.h"
-#include "memory.h"
+#include "include/memory.h"
#include "custom.h"
#include "newcpu.h"
#include "cia.h"
@@ -23,23 +23,36 @@
#include "savestate.h"
#include "inputdevice.h"
#include "zfile.h"
-#include "ar.h"
#include "akiko.h"
#include "audio.h"
#include "keyboard.h"
#include "uae.h"
#include "autoconf.h"
-#include "rtc.h"
+#include "drawing.h"
-/* Akiko internal CIA differences:
+#define CIAA_DEBUG_R 0
+#define CIAA_DEBUG_W 0
+#define CIAA_DEBUG_IRQ 0
-- BFE101 and BFD100: reads 3F if data direction is in.
+#define CIAB_DEBUG_R 0
+#define CIAB_DEBUG_W 0
+#define CIAB_DEBUG_IRQ 0
- */
+#define DONGLE_DEBUG 0
+#define KB_DEBUG 0
+#define CLOCK_DEBUG 0
-/* e-clock is 10 CPU cycles, 4 cycles high, 6 low
- * data transfer happens during 4 high cycles
- */
+#define TOD_HACK
+
+ /* Akiko internal CIA differences:
+
+ - BFE101 and BFD100: reads 3F if data direction is in.
+
+ */
+
+ /* e-clock is 10 CPU cycles, 4 cycles high, 6 low
+ * data transfer happens during 4 high cycles
+ */
#define ECLOCK_DATA_CYCLE 4
#define ECLOCK_WAIT_CYCLE 6
@@ -60,8 +73,10 @@ static unsigned long ciaatod, ciabtod, ciaatol, ciabtol, ciaaalarm, ciabalarm;
static int ciaatlatch, ciabtlatch;
static bool oldovl, oldcd32mute;
static bool led;
+static int led_old_brightness;
+static unsigned long led_cycles_on, led_cycles_off, led_cycle;
-static unsigned int ciabpra;
+unsigned int ciabpra;
static unsigned long ciaala, ciaalb, ciabla, ciablb;
static int ciaatodon, ciabtodon;
@@ -71,376 +86,660 @@ static int div10;
static int kbstate, kblostsynccnt;
static uae_u8 kbcode;
-static struct rtc_msm_data rtc_msm;
-static struct rtc_ricoh_data rtc_ricoh;
+static uae_u8 serbits;
+static int warned = 10;
+static int rtc_delayed_write;
-STATIC_INLINE void setclr (unsigned int *p, unsigned int val)
+static void setclr(unsigned int *p, unsigned int val)
{
- if (val & 0x80) {
- *p |= val & 0x7F;
- } else {
- *p &= ~val;
- }
+ if (val & 0x80) {
+ *p |= val & 0x7F;
+ }
+ else {
+ *p &= ~val;
+ }
}
-STATIC_INLINE void ICR (uae_u32 data)
+/* delay interrupt after current CIA register access if
+* interrupt would have triggered mid access
+*/
+static int cia_interrupt_disabled;
+static int cia_interrupt_delay;
+
+static void ICR(uae_u32 data)
{
- INTREQ_0 (0x8000 | data);
+ INTREQ_0(0x8000 | data);
}
-STATIC_INLINE void ICRA(uae_u32 data)
+static void ICRA(uae_u32 data)
{
ciaaicr |= 0x40;
+#if 1
+ if (currprefs.cpu_memory_cycle_exact && !(ciaaicr & 0x20) && (cia_interrupt_disabled & 1)) {
+ cia_interrupt_delay |= 1;
+#if CIAB_DEBUG_IRQ
+ write_log(_T("ciab interrupt disabled ICR=%02X PC=%x\n"), ciabicr, M68K_GETPC);
+#endif
+ return;
+ }
+#endif
ciaaicr |= 0x20;
- ICR (0x0008);
+ ICR(0x0008);
}
-STATIC_INLINE void ICRB(uae_u32 data)
+static void ICRB(uae_u32 data)
{
ciabicr |= 0x40;
+#if 1
+ if (currprefs.cpu_memory_cycle_exact && !(ciabicr & 0x20) && (cia_interrupt_disabled & 2)) {
+ cia_interrupt_delay |= 2;
+#if CIAB_DEBUG_IRQ
+ write_log(_T("ciab interrupt disabled ICR=%02X PC=%x\n"), ciabicr, M68K_GETPC);
+#endif
+ return;
+ }
+#endif
ciabicr |= 0x20;
- ICR (0x2000);
+ if (currprefs.cs_compatible == CP_VELVET) {
+ // Both CIAs in Velvet are connected to level 2.
+ ICR(0x0008);
+ }
+ else {
+ ICR(0x2000);
+ }
}
-STATIC_INLINE void RethinkICRA (void)
+static void RethinkICRA(void)
{
- if (ciaaicr & ciaaimask) {
+ if (ciaaicr & ciaaimask) {
+#if CIAA_DEBUG_IRQ
+ write_log(_T("CIAA IRQ %02X\n"), ciaaicr);
+#endif
if (!(ciaaicr & 0x80)) {
ciaaicr |= 0x80;
- ICRA (0x0008);
- }
- }
+ if (currprefs.cpu_memory_cycle_exact) {
+ event2_newevent_xx(-1, DIV10 + 2 * CYCLE_UNIT + CYCLE_UNIT / 2, 0, ICRA);
+ }
+ else {
+ ICRA(0x0008);
+ }
+ }
+ }
}
-STATIC_INLINE void RethinkICRB (void)
+static void RethinkICRB(void)
{
- if (ciabicr & ciabimask) {
+ if (ciabicr & ciabimask) {
+#if CIAB_DEBUG_IRQ
+ write_log(_T("CIAB IRQ %02X\n"), ciabicr);
+#endif
if (!(ciabicr & 0x80)) {
ciabicr |= 0x80;
- ICRB (0);
- }
- }
+ if (currprefs.cpu_memory_cycle_exact) {
+ event2_newevent_xx(-1, DIV10 + 2 * CYCLE_UNIT + CYCLE_UNIT / 2, 0, ICRB);
+ }
+ else {
+ ICRB(0);
+ }
+ }
+ }
}
-void rethink_cias (void)
+void rethink_cias(void)
{
if (ciaaicr & 0x40)
- ICRA (0);
+ ICRA(0);
if (ciabicr & 0x40)
- ICRB (0);
+ ICRB(0);
}
/* Figure out how many CIA timer cycles have passed for each timer since the
last call of CIA_calctimers. */
-static void compute_passed_time (void)
+static void compute_passed_time(void)
{
- unsigned long int ccount = (get_cycles () - eventtab[ev_cia].oldcycles + div10);
- unsigned long int ciaclocks = ccount / DIV10;
+ unsigned long int ccount = (get_cycles() - eventtab[ev_cia].oldcycles + div10);
+ unsigned long int ciaclocks = ccount / DIV10;
- ciaata_passed = ciaatb_passed = ciabta_passed = ciabtb_passed = 0;
+ ciaata_passed = ciaatb_passed = ciabta_passed = ciabtb_passed = 0;
- /* CIA A timers */
- if ((ciaacra & 0x21) == 0x01) {
+ /* CIA A timers */
+ if ((ciaacra & 0x21) == 0x01) {
unsigned long int cc = ciaclocks;
if (cc > ciaastarta)
cc -= ciaastarta;
else
cc = 0;
+ assert((ciaata + 1) >= cc);
ciaata_passed = cc;
- }
- if ((ciaacrb & 0x61) == 0x01) {
+ }
+ if ((ciaacrb & 0x61) == 0x01) {
unsigned long int cc = ciaclocks;
if (cc > ciaastartb)
cc -= ciaastartb;
else
cc = 0;
+ assert((ciaatb + 1) >= cc);
ciaatb_passed = cc;
- }
+ }
- /* CIA B timers */
- if ((ciabcra & 0x21) == 0x01) {
+ /* CIA B timers */
+ if ((ciabcra & 0x21) == 0x01) {
unsigned long int cc = ciaclocks;
if (cc > ciabstarta)
cc -= ciabstarta;
else
cc = 0;
+ assert((ciabta + 1) >= cc);
ciabta_passed = cc;
- }
- if ((ciabcrb & 0x61) == 0x01) {
+ }
+ if ((ciabcrb & 0x61) == 0x01) {
unsigned long int cc = ciaclocks;
if (cc > ciabstartb)
cc -= ciabstartb;
else
cc = 0;
+ assert((ciabtb + 1) >= cc);
ciabtb_passed = cc;
- }
+ }
}
/* Called to advance all CIA timers to the current time. This expects that
one of the timer values will be modified, and CIA_calctimers will be called
in the same cycle. */
-static int CIA_update_check (void)
+static int CIA_update_check(void)
{
- unsigned long int ccount = (get_cycles () - eventtab[ev_cia].oldcycles + div10);
- unsigned long int ciaclocks = ccount / DIV10;
+ unsigned long int ccount = (get_cycles() - eventtab[ev_cia].oldcycles + div10);
+ unsigned long int ciaclocks = ccount / DIV10;
- int aovfla = 0, aovflb = 0, asp = 0, bovfla = 0, bovflb = 0, bsp = 0;
+ int aovfla = 0, aovflb = 0, asp = 0, bovfla = 0, bovflb = 0, bsp = 0;
int icr = 0;
- div10 = ccount % DIV10;
+ div10 = ccount % DIV10;
- /* CIA A timers */
- if ((ciaacra & 0x21) == 0x01) {
+ /* CIA A timers */
+ if ((ciaacra & 0x21) == 0x01) {
bool check = true;
unsigned long int cc = ciaclocks;
if (ciaastarta > 0) {
if (cc > ciaastarta) {
cc -= ciaastarta;
ciaastarta = 0;
- } else {
+ }
+ else {
ciaastarta -= cc;
check = false;
}
}
if (check) {
+ assert((ciaata + 1) >= cc);
if ((ciaata + 1) == cc) {
- if ((ciaacra & 0x48) == 0x40 && ciaasdr_cnt > 0 && --ciaasdr_cnt == 0)
- asp = 1;
- aovfla = 1;
- if ((ciaacrb & 0x61) == 0x41 || (ciaacrb & 0x61) == 0x61) {
- if (ciaatb-- == 0)
- aovflb = 1;
- }
- }
+ if ((ciaacra & 0x48) == 0x40 && ciaasdr_cnt > 0 && --ciaasdr_cnt == 0)
+ asp = 1;
+ aovfla = 1;
+ if ((ciaacrb & 0x61) == 0x41 || (ciaacrb & 0x61) == 0x61) {
+ if (ciaatb-- == 0)
+ aovflb = 1;
+ }
+ }
ciaata -= cc;
}
- }
- if ((ciaacrb & 0x61) == 0x01) {
+ }
+ if ((ciaacrb & 0x61) == 0x01) {
bool check = true;
unsigned long int cc = ciaclocks;
if (ciaastartb > 0) {
if (cc > ciaastartb) {
cc -= ciaastartb;
ciaastartb = 0;
- } else {
+ }
+ else {
ciaastartb -= cc;
check = false;
}
}
if (check) {
+ assert((ciaatb + 1) >= cc);
if ((ciaatb + 1) == cc)
- aovflb = 1;
+ aovflb = 1;
ciaatb -= cc;
}
- }
+ }
- /* CIA B timers */
- if ((ciabcra & 0x21) == 0x01) {
+ /* CIA B timers */
+ if ((ciabcra & 0x21) == 0x01) {
bool check = true;
unsigned long int cc = ciaclocks;
if (ciabstarta > 0) {
if (cc > ciabstarta) {
cc -= ciabstarta;
ciabstarta = 0;
- } else {
+ }
+ else {
ciabstarta -= cc;
check = false;
}
}
if (check) {
+ assert((ciabta + 1) >= cc);
if ((ciabta + 1) == cc) {
- if ((ciabcra & 0x48) == 0x40 && ciabsdr_cnt > 0 && --ciabsdr_cnt == 0)
- bsp = 1;
- bovfla = 1;
- if ((ciabcrb & 0x61) == 0x41 || (ciabcrb & 0x61) == 0x61) {
- if (ciabtb-- == 0)
- bovflb = 1;
- }
- }
+ if ((ciabcra & 0x48) == 0x40 && ciabsdr_cnt > 0 && --ciabsdr_cnt == 0)
+ bsp = 1;
+ bovfla = 1;
+ if ((ciabcrb & 0x61) == 0x41 || (ciabcrb & 0x61) == 0x61) {
+ if (ciabtb-- == 0)
+ bovflb = 1;
+ }
+ }
ciabta -= cc;
}
- }
- if ((ciabcrb & 0x61) == 0x01) {
+ }
+ if ((ciabcrb & 0x61) == 0x01) {
bool check = true;
unsigned long int cc = ciaclocks;
if (ciabstartb > 0) {
if (cc > ciabstartb) {
cc -= ciabstartb;
ciabstartb = 0;
- } else {
+ }
+ else {
ciabstartb -= cc;
check = false;
}
}
if (check) {
+ assert((ciabtb + 1) >= cc);
if ((ciabtb + 1) == cc)
- bovflb = 1;
+ bovflb = 1;
ciabtb -= cc;
}
- }
+ }
- if (aovfla) {
+ if (aovfla) {
ciaaicr |= 1; icr = 1;
- ciaata = ciaala;
- if (ciaacra & 0x8) {
- ciaacra &= ~1;
- }
- }
- if (aovflb) {
+ ciaata = ciaala;
+ if (ciaacra & 0x8) {
+ ciaacra &= ~1;
+ }
+ }
+ if (aovflb) {
ciaaicr |= 2; icr = 1;
- ciaatb = ciaalb;
- if (ciaacrb & 0x8) {
- ciaacrb &= ~1;
- }
- }
- if (asp) {
+ ciaatb = ciaalb;
+ if (ciaacrb & 0x8) {
+ ciaacrb &= ~1;
+ }
+ }
+ if (asp) {
ciaaicr |= 8; icr = 1;
- }
- if (bovfla) {
+ }
+ if (bovfla) {
ciabicr |= 1; icr |= 2;
- ciabta = ciabla;
- if (ciabcra & 0x8) {
- ciabcra &= ~1;
- }
- }
- if (bovflb) {
+ ciabta = ciabla;
+ if (ciabcra & 0x8) {
+ ciabcra &= ~1;
+ }
+ }
+ if (bovflb) {
ciabicr |= 2; icr |= 2;
- ciabtb = ciablb;
- if (ciabcrb & 0x8) {
- ciabcrb &= ~1;
- }
- }
- if (bsp) {
+ ciabtb = ciablb;
+ if (ciabcrb & 0x8) {
+ ciabcrb &= ~1;
+ }
+ }
+ if (bsp) {
ciabicr |= 8; icr |= 2;
- }
+ }
return icr;
}
-static void CIA_update (void)
+static void CIA_update(void)
{
- int icr = CIA_update_check ();
+ int icr = CIA_update_check();
if (icr & 1)
- RethinkICRA ();
+ RethinkICRA();
if (icr & 2)
- RethinkICRB ();
+ RethinkICRB();
}
/* Call this only after CIA_update has been called in the same cycle. */
-static void CIA_calctimers (void)
+static void CIA_calctimers(void)
{
- long int ciaatimea = -1, ciaatimeb = -1, ciabtimea = -1, ciabtimeb = -1;
+ long int ciaatimea = -1, ciaatimeb = -1, ciabtimea = -1, ciabtimeb = -1;
int div10diff = DIV10 - div10;
- eventtab[ev_cia].oldcycles = get_cycles ();
+ eventtab[ev_cia].oldcycles = get_cycles();
- if ((ciaacra & 0x21) == 0x01) {
+ if ((ciaacra & 0x21) == 0x01) {
ciaatimea = div10diff + DIV10 * (ciaata + ciaastarta);
- }
- if ((ciaacrb & 0x61) == 0x01) {
+ }
+#if 0
+ if ((ciaacrb & 0x61) == 0x41) {
+ /* Timer B will not get any pulses if Timer A is off. */
+ if (ciaatimea >= 0) {
+ /* If Timer A is in one-shot mode, and Timer B needs more than
+ * one pulse, it will not underflow. */
+ if (ciaatb == 0 || (ciaacra & 0x8) == 0) {
+ /* Otherwise, we can determine the time of the underflow. */
+ /* This may overflow, however. So just ignore this timer and
+ use the fact that we'll call CIA_handler for the A timer. */
+ /* ciaatimeb = ciaatimea + ciaala * DIV10 * ciaatb; */
+ }
+ }
+ }
+#endif
+ if ((ciaacrb & 0x61) == 0x01) {
ciaatimeb = div10diff + DIV10 * (ciaatb + ciaastartb);
- }
+ }
- if ((ciabcra & 0x21) == 0x01) {
+ if ((ciabcra & 0x21) == 0x01) {
ciabtimea = div10diff + DIV10 * (ciabta + ciabstarta);
- }
- if ((ciabcrb & 0x61) == 0x01) {
+ }
+#if 0
+ if ((ciabcrb & 0x61) == 0x41) {
+ /* Timer B will not get any pulses if Timer A is off. */
+ if (ciabtimea >= 0) {
+ /* If Timer A is in one-shot mode, and Timer B needs more than
+ * one pulse, it will not underflow. */
+ if (ciabtb == 0 || (ciabcra & 0x8) == 0) {
+ /* Otherwise, we can determine the time of the underflow. */
+ /* ciabtimeb = ciabtimea + ciabla * DIV10 * ciabtb; */
+ }
+ }
+ }
+#endif
+ if ((ciabcrb & 0x61) == 0x01) {
ciabtimeb = div10diff + DIV10 * (ciabtb + ciabstartb);
- }
+ }
- eventtab[ev_cia].active = (ciaatimea != -1 || ciaatimeb != -1
- || ciabtimea != -1 || ciabtimeb != -1);
- if (eventtab[ev_cia].active) {
- unsigned long int ciatime = ~0L;
- if (ciaatimea != -1)
- ciatime = ciaatimea;
- if (ciaatimeb != -1 && ciaatimeb < ciatime)
- ciatime = ciaatimeb;
- if (ciabtimea != -1 && ciabtimea < ciatime)
- ciatime = ciabtimea;
- if (ciabtimeb != -1 && ciabtimeb < ciatime)
- ciatime = ciabtimeb;
- eventtab[ev_cia].evtime = ciatime + get_cycles ();
- }
- events_schedule();
+ eventtab[ev_cia].active = (ciaatimea != -1 || ciaatimeb != -1
+ || ciabtimea != -1 || ciabtimeb != -1);
+ if (eventtab[ev_cia].active) {
+ unsigned long int ciatime = ~0L;
+ if (ciaatimea != -1)
+ ciatime = ciaatimea;
+ if (ciaatimeb != -1 && ciaatimeb < ciatime)
+ ciatime = ciaatimeb;
+ if (ciabtimea != -1 && ciabtimea < ciatime)
+ ciatime = ciabtimea;
+ if (ciabtimeb != -1 && ciabtimeb < ciatime)
+ ciatime = ciabtimeb;
+ eventtab[ev_cia].evtime = ciatime + get_cycles();
+ }
+ events_schedule();
}
-void CIA_handler (void)
+void CIA_handler(void)
{
- CIA_update ();
- CIA_calctimers ();
+ CIA_update();
+ CIA_calctimers();
}
-void cia_diskindex (void)
+void cia_diskindex(void)
{
- ciabicr |= 0x10;
- RethinkICRB();
+ ciabicr |= 0x10;
+ RethinkICRB();
+}
+void cia_parallelack(void)
+{
+ ciaaicr |= 0x10;
+ RethinkICRA();
}
-static bool checkalarm (unsigned long tod, unsigned long alarm, bool inc)
+static bool checkalarm(unsigned long tod, unsigned long alarm, bool inc, int ab)
{
- if (tod == alarm)
- return true;
+ if (tod == alarm)
+ return true;
+ // if (!ab)
+ // return false;
if (!currprefs.cs_ciatodbug)
return false;
- if (!inc)
- return false;
- /* emulate buggy TODMED counter.
- * it counts: .. 29 2A 2B 2C 2D 2E 2F 20 30 31 32 ..
- * (2F->20->30 only takes couple of cycles but it will trigger alarm..
- */
- if (tod & 0x000fff)
- return false;
- if (((tod - 1) & 0xfff000) == alarm)
- return true;
- return false;
+ if (!inc)
+ return false;
+ /* emulate buggy TODMED counter.
+ * it counts: .. 29 2A 2B 2C 2D 2E 2F 20 30 31 32 ..
+ * (2F->20->30 only takes couple of cycles but it will trigger alarm..
+ */
+ if (tod & 0x000fff)
+ return false;
+ if (((tod - 1) & 0xfff000) == alarm)
+ return true;
+ return false;
}
-STATIC_INLINE void ciab_checkalarm (bool inc, bool irq)
+STATIC_INLINE bool ciab_checkalarm(bool inc, bool irq)
{
// hack: do not trigger alarm interrupt if KS code and both
// tod and alarm == 0. This incorrectly triggers on non-cycle exact
// modes. Real hardware value written to ciabtod by KS is always
// at least 1 or larger due to bus cycle delays when reading
// old value.
- if ((munge24 (m68k_getpc ()) & 0xFFF80000) != 0xF80000) {
+#if 1
+ if ((munge24(m68k_getpc()) & 0xFFF80000) != 0xF80000) {
if (ciabtod == 0 && ciabalarm == 0)
- return;
+ return false;
}
- if (checkalarm (ciabtod, ciabalarm, inc)) {
+#endif
+ if (checkalarm(ciabtod, ciabalarm, inc, 1)) {
+#if CIAB_DEBUG_IRQ
+ write_log(_T("CIAB tod %08x %08x\n"), ciabtod, ciabalarm);
+#endif
if (irq) {
- ciabicr |= 4;
- RethinkICRB ();
- }
- }
+ ciabicr |= 4;
+ RethinkICRB();
+ }
+ return true;
+ }
+ return false;
}
-STATIC_INLINE void ciaa_checkalarm (bool inc)
+STATIC_INLINE void ciaa_checkalarm(bool inc)
{
- if (checkalarm (ciaatod, ciaaalarm, inc)) {
- ciaaicr |= 4;
- RethinkICRA ();
- }
+ if (checkalarm(ciaatod, ciaaalarm, inc, 0)) {
+#if CIAA_DEBUG_IRQ
+ write_log(_T("CIAA tod %08x %08x\n"), ciaatod, ciaaalarm);
+#endif
+ ciaaicr |= 4;
+ RethinkICRA();
+ }
}
-static void setcode (uae_u8 keycode)
+
+#ifdef TOD_HACK
+static uae_u64 tod_hack_tv, tod_hack_tod, tod_hack_tod_last;
+static int tod_hack_enabled;
+static int tod_hack_delay;
+static int tod_diff_cnt;
+#define TOD_HACK_DELAY 50
+#define TOD_HACK_TIME 312 * 50 * 10
+static void tod_hack_reset(void)
{
- kbcode = ~((keycode << 1) | (keycode >> 7));
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ tod_hack_tv = (uae_u64)tv.tv_sec * 1000000 + tv.tv_usec;
+ tod_hack_tod = ciaatod;
+ tod_hack_tod_last = tod_hack_tod;
+ tod_diff_cnt = 0;
+}
+#endif
+
+static int heartbeat_cnt;
+void cia_heartbeat(void)
+{
+ heartbeat_cnt = 10;
}
-static void keyreq (void)
+static void do_tod_hack(int dotod)
{
+ struct timeval tv;
+ static int oldrate;
+ uae_u64 t;
+ int rate;
+ int docount = 0;
+
+ if (tod_hack_enabled == 0)
+ return;
+ if (!heartbeat_cnt) {
+ if (tod_hack_enabled > 0)
+ tod_hack_enabled = -1;
+ return;
+ }
+ if (tod_hack_enabled < 0) {
+ tod_hack_enabled = TOD_HACK_TIME;
+ return;
+ }
+ if (tod_hack_enabled > 1) {
+ tod_hack_enabled--;
+ if (tod_hack_enabled == 1) {
+ //write_log (_T("TOD HACK enabled\n"));
+ tod_hack_reset();
+ }
+ return;
+ }
+
+ if (currprefs.cs_ciaatod == 0) {
+ rate = (int)(vblank_hz + 0.5);
+ if (rate >= 59 && rate <= 61)
+ rate = 60;
+ if (rate >= 49 && rate <= 51)
+ rate = 50;
+ }
+ else if (currprefs.cs_ciaatod == 1) {
+ rate = 50;
+ }
+ else {
+ rate = 60;
+ }
+ if (rate <= 0)
+ return;
+ if (rate != oldrate || (ciaatod & 0xfff) != (tod_hack_tod_last & 0xfff)) {
+ write_log(_T("TOD HACK reset %d,%d %ld,%lld\n"), rate, oldrate, ciaatod, tod_hack_tod_last);
+ tod_hack_reset();
+ oldrate = rate;
+ docount = 1;
+ }
+
+ if (!dotod && currprefs.cs_ciaatod == 0)
+ return;
+
+ if (tod_hack_delay > 0) {
+ tod_hack_delay--;
+ if (tod_hack_delay > 0)
+ return;
+ tod_hack_delay = TOD_HACK_DELAY;
+ }
+
+ gettimeofday(&tv, NULL);
+ t = (uae_u64)tv.tv_sec * 1000000 + tv.tv_usec;
+ if (t - tod_hack_tv >= 1000000 / rate) {
+ tod_hack_tv += 1000000 / rate;
+ tod_diff_cnt += 1000000 - (1000000 / rate) * rate;
+ tod_hack_tv += tod_diff_cnt / rate;
+ tod_diff_cnt %= rate;
+ docount = 1;
+ }
+ if (docount) {
+ ciaatod++;
+ ciaatod &= 0x00ffffff;
+ tod_hack_tod_last = ciaatod;
+ ciaa_checkalarm(false);
+ }
+}
+
+static int resetwarning_phase, resetwarning_timer;
+
+static void setcode(uae_u8 keycode)
+{
+ kbcode = ~((keycode << 1) | (keycode >> 7));
+}
+
+static void sendrw(void)
+{
+ setcode(AK_RESETWARNING);
ciaasdr = kbcode;
kblostsynccnt = 8 * maxvpos * 8; // 8 frames * 8 bits.
ciaaicr |= 8;
- RethinkICRA ();
+ RethinkICRA();
+ write_log(_T("KB: sent reset warning code (phase=%d)\n"), resetwarning_phase);
+}
+
+int resetwarning_do(int canreset)
+{
+ if (!currprefs.keyboard_connected)
+ return 0;
+ if (resetwarning_phase || regs.halted > 0) {
+ /* just force reset if second reset happens during resetwarning */
+ if (canreset) {
+ resetwarning_phase = 0;
+ resetwarning_timer = 0;
+ }
+ return 0;
+ }
+ resetwarning_phase = 1;
+ resetwarning_timer = maxvpos_nom * 5;
+ write_log(_T("KB: reset warning triggered\n"));
+ sendrw();
+ return 1;
+}
+
+static void resetwarning_check(void)
+{
+ if (resetwarning_timer > 0) {
+ resetwarning_timer--;
+ if (resetwarning_timer <= 0) {
+ write_log(_T("KB: reset warning forced reset. Phase=%d\n"), resetwarning_phase);
+ resetwarning_phase = -1;
+ kblostsynccnt = 0;
+ //send_internalevent(INTERNALEVENT_KBRESET);
+ uae_reset(0, 1);
+ }
+ }
+ if (resetwarning_phase == 1) {
+ if (!kblostsynccnt) { /* first AK_RESETWARNING handshake received */
+ write_log(_T("KB: reset warning second phase..\n"));
+ resetwarning_phase = 2;
+ resetwarning_timer = maxvpos_nom * 5;
+ sendrw();
+ }
+ }
+ else if (resetwarning_phase == 2) {
+ if (ciaacra & 0x40) { /* second AK_RESETWARNING handshake active */
+ resetwarning_phase = 3;
+ write_log(_T("KB: reset warning SP = output\n"));
+ /* System won't reset until handshake signal becomes inactive or 10s has passed */
+ resetwarning_timer = 10 * maxvpos_nom * vblank_hz;
+ }
+ }
+ else if (resetwarning_phase == 3) {
+ if (!(ciaacra & 0x40)) { /* second AK_RESETWARNING handshake disabled */
+ write_log(_T("KB: reset warning end by software. reset.\n"));
+ resetwarning_phase = -1;
+ kblostsynccnt = 0;
+ //send_internalevent(INTERNALEVENT_KBRESET);
+ uae_reset(0, 1);
+ }
+ }
+}
+
+void CIA_hsync_prehandler(void)
+{
+}
+
+static void keyreq(void)
+{
+#if KB_DEBUG
+ write_log(_T("code=%02x (%02x)\n"), kbcode, (uae_u8)(~((kbcode >> 1) | (kbcode << 7))));
+#endif
+ ciaasdr = kbcode;
+ kblostsynccnt = 8 * maxvpos * 8; // 8 frames * 8 bits.
+ ciaaicr |= 8;
+ RethinkICRA();
}
/* All this complexity to lazy evaluate TOD increase.
- * Only increase it cycle-exactly if it is visible to running program:
- * causes interrupt or program is reading or writing TOD registers
- */
+* Only increase it cycle-exactly if it is visible to running program:
+* causes interrupt or program is reading or writing TOD registers
+*/
static int ciab_tod_hoffset;
static int ciab_tod_event_state;
@@ -448,152 +747,279 @@ static int ciab_tod_event_state;
// Possibly TICK input pin has built-in debounce circuit
#define TOD_INC_DELAY (14 * (ECLOCK_DATA_CYCLE + ECLOCK_WAIT_CYCLE) / 2)
-static void CIAB_tod_inc (bool irq)
+static void CIAB_tod_inc(bool irq)
{
ciab_tod_event_state = 3; // done
if (!ciabtodon)
return;
ciabtod++;
ciabtod &= 0xFFFFFF;
- ciab_checkalarm (true, irq);
+ ciab_checkalarm(true, irq);
}
-void CIAB_tod_inc_event (uae_u32 v)
+static void CIAB_tod_inc_event(uae_u32 v)
{
if (ciab_tod_event_state != 2)
return;
- CIAB_tod_inc (true);
+ CIAB_tod_inc(true);
}
// Someone reads or writes TOD registers, sync TOD increase
-static void CIAB_tod_check (void)
+static void CIAB_tod_check(void)
{
if (ciab_tod_event_state != 1 || !ciabtodon)
return;
- int hpos = current_hpos ();
+ int hpos = current_hpos();
hpos -= ciab_tod_hoffset;
if (hpos >= 0 || currprefs.m68k_speed < 0) {
// Program should see the changed TOD
- CIAB_tod_inc (true);
+ CIAB_tod_inc(true);
return;
}
// Not yet, add event to guarantee exact TOD inc position
ciab_tod_event_state = 2; // event active
- event2_newevent(ev2_ciab_tod, -hpos, 0);
+ event2_newevent_xx(-1, -hpos, 0, CIAB_tod_inc_event);
}
-void CIAB_tod_handler (int hoffset)
+void CIAB_tod_handler(int hoffset)
{
if (!ciabtodon)
return;
ciab_tod_hoffset = hoffset + TOD_INC_DELAY;
ciab_tod_event_state = 1; // TOD inc needed
- if (checkalarm ((ciabtod + 1) & 0xffffff, ciabalarm, true)) {
+ if (checkalarm((ciabtod + 1) & 0xffffff, ciabalarm, true, 1)) {
// causes interrupt on this line, add event
ciab_tod_event_state = 2; // event active
- event2_newevent(ev2_ciab_tod, ciab_tod_hoffset, 0);
+ event2_newevent_xx(-1, ciab_tod_hoffset, 0, CIAB_tod_inc_event);
}
}
-STATIC_INLINE void check_keyboard(void)
+void keyboard_connected(bool connect)
{
- if ((keys_available() || kbstate < 3) && !kblostsynccnt) {
- switch (kbstate)
- {
- case 0:
- kbcode = 0; /* powerup resync */
- kbstate++;
- break;
- case 1:
- setcode (AK_INIT_POWERUP);
- kbstate++;
- break;
- case 2:
- setcode (AK_TERM_POWERUP);
- kbstate++;
- break;
- case 3:
- kbcode = ~get_next_key ();
- break;
- }
- keyreq ();
+ if (connect) {
+ write_log(_T("Keyboard connected\n"));
+ }
+ else {
+ write_log(_T("Keyboard disconnected\n"));
+ }
+ kbstate = 0;
+ kblostsynccnt = 0;
+ resetwarning_phase = 0;
+}
+
+static void check_keyboard(void)
+{
+ if (currprefs.keyboard_connected) {
+ if ((keys_available() || kbstate < 3) && !kblostsynccnt) {
+ switch (kbstate)
+ {
+ case 0:
+ kbcode = 0; /* powerup resync */
+ kbstate++;
+ break;
+ case 1:
+ setcode(AK_INIT_POWERUP);
+ kbstate++;
+ break;
+ case 2:
+ setcode(AK_TERM_POWERUP);
+ kbstate++;
+ break;
+ case 3:
+ kbcode = ~get_next_key();
+ break;
+ }
+ keyreq();
+ }
+ }
+ else {
+ while (keys_available()) {
+ get_next_key();
+ }
}
}
-void CIA_hsync_posthandler (bool ciahsync)
+void CIA_hsync_posthandler(bool ciahsync, bool dotod)
{
if (ciahsync) {
// cia hysnc
// Previous line was supposed to increase TOD but
// no one cared. Do it now.
if (ciab_tod_event_state == 1)
- CIAB_tod_inc (false);
+ CIAB_tod_inc(false);
ciab_tod_event_state = 0;
- } else {
- // custom hsync
- if ((hsync_counter & 15) == 0)
- check_keyboard();
- }
-}
-void CIA_vsync_prehandler (void)
-{
- CIA_handler ();
- if (kblostsynccnt > 0) {
- kblostsynccnt -= maxvpos;
- if (kblostsynccnt <= 0) {
- kblostsynccnt = 0;
- keyreq ();
+ if (currprefs.tod_hack && ciaatodon)
+ do_tod_hack(dotod);
+ }
+ else if (currprefs.keyboard_connected) {
+ // custom hsync
+ if (resetwarning_phase) {
+ resetwarning_check();
+ while (keys_available())
+ get_next_key();
+ }
+ else {
+ if ((hsync_counter & 15) == 0)
+ check_keyboard();
+ }
+ }
+ else {
+ while (keys_available()) {
+ get_next_key();
}
}
}
-void CIAA_tod_handler (uae_u32 v)
+static void calc_led(int old_led)
+{
+ unsigned long c = get_cycles();
+ unsigned long t = (c - led_cycle) / CYCLE_UNIT;
+ if (old_led)
+ led_cycles_on += t;
+ else
+ led_cycles_off += t;
+ led_cycle = c;
+}
+
+static void led_vsync(void)
+{
+ int v;
+
+ calc_led(led);
+ if (led_cycles_on && !led_cycles_off)
+ v = 255;
+ else if (led_cycles_off && !led_cycles_on)
+ v = 0;
+ else if (led_cycles_off)
+ v = led_cycles_on * 255 / (led_cycles_on + led_cycles_off);
+ else
+ v = 255;
+ if (v < 0)
+ v = 0;
+ if (v > 255)
+ v = 255;
+ gui_data.powerled_brightness = v;
+ led_cycles_on = 0;
+ led_cycles_off = 0;
+ if (led_old_brightness != gui_data.powerled_brightness) {
+ gui_data.powerled = gui_data.powerled_brightness > 127;
+ //gui_led(LED_POWER, gui_data.powerled, gui_data.powerled_brightness);
+ gui_led(LED_POWER, gui_data.powerled);
+ led_filter_audio();
+ }
+ led_old_brightness = gui_data.powerled_brightness;
+ led_cycle = get_cycles();
+}
+
+static void write_battclock(void);
+void CIA_vsync_prehandler(void)
+{
+ if (heartbeat_cnt > 0)
+ heartbeat_cnt--;
+ if (rtc_delayed_write < 0) {
+ rtc_delayed_write = 50;
+ }
+ else if (rtc_delayed_write > 0) {
+ rtc_delayed_write--;
+ if (rtc_delayed_write == 0)
+ write_battclock();
+ }
+ led_vsync();
+ CIA_handler();
+ if (kblostsynccnt > 0) {
+ kblostsynccnt -= maxvpos;
+ if (kblostsynccnt <= 0) {
+ kblostsynccnt = 0;
+ keyreq();
+#if KB_DEBUG
+ write_log(_T("lostsync\n"));
+#endif
+ }
+ }
+}
+
+static void CIAA_tod_handler(uae_u32 v)
{
ciaatod++;
- ciaatod &= 0xFFFFFF;
- ciaa_checkalarm (true);
+ ciaatod &= 0xFFFFFF;
+ ciaa_checkalarm(true);
}
-void CIAA_tod_inc (int cycles)
+void CIAA_tod_inc(int cycles)
{
+#ifdef TOD_HACK
+ if (currprefs.tod_hack && tod_hack_enabled == 1)
+ return;
+#endif
if (!ciaatodon)
return;
- event2_newevent(ev2_ciaa_tod, cycles + TOD_INC_DELAY, 0);
+ event2_newevent_xx(-1, cycles + TOD_INC_DELAY, 0, CIAA_tod_handler);
}
-STATIC_INLINE void check_led (void)
+static void check_led(void)
{
- uae_u8 v = ciaapra;
- bool led2;
+ uae_u8 v = ciaapra;
+ bool led2;
- v |= ~ciaadra; /* output is high when pin's direction is input */
- led2 = (v & 2) ? 0 : 1;
- if (led2 != led) {
- led = led2;
- gui_data.powerled = led2;
- led_filter_audio();
- }
+ v |= ~ciaadra; /* output is high when pin's direction is input */
+ led2 = (v & 2) ? 0 : 1;
+ if (led2 != led) {
+ calc_led(led);
+ led = led2;
+ led_old_brightness = -1;
+ }
}
-static void bfe001_change (void)
+static void bfe001_change(void)
{
- uae_u8 v = ciaapra;
- check_led ();
- if (currprefs.cs_ciaoverlay && (v & 1) != oldovl) {
- oldovl = v & 1;
- if (!oldovl) {
- map_overlay (1);
- } else {
- map_overlay (0);
- }
- }
+ uae_u8 v = ciaapra;
+ check_led();
+ if (currprefs.cs_ciaoverlay && (v & 1) != oldovl) {
+ oldovl = v & 1;
+ if (!oldovl) {
+ map_overlay(1);
+ }
+ else {
+ //activate_debugger ();
+ map_overlay(0);
+ }
+ }
if (currprefs.cs_cd32cd && (v & 1) != oldcd32mute) {
oldcd32mute = v & 1;
- akiko_mute (oldcd32mute ? 0 : 1);
+ akiko_mute(oldcd32mute ? 0 : 1);
}
}
+static uae_u32 getciatod(uae_u32 tod)
+{
+ if (!currprefs.cs_cia6526)
+ return tod;
+ uae_u32 bcdtod = 0;
+ for (int i = 0; i < 4; i++) {
+ int val = tod % 10;
+ bcdtod *= 16;
+ bcdtod += val;
+ tod /= 10;
+ }
+ return bcdtod;
+}
+static void setciatod(unsigned long *tod, uae_u32 v)
+{
+ if (!currprefs.cs_cia6526) {
+ *tod = v;
+ return;
+ }
+ uae_u32 bintod = 0;
+ for (int i = 0; i < 4; i++) {
+ int val = v / 16;
+ bintod *= 10;
+ bintod += val;
+ v /= 16;
+ }
+ *tod = bintod;
+}
+
static uae_u8 ReadCIAA (unsigned int addr)
{
unsigned int tmp;
@@ -603,17 +1029,12 @@ static uae_u8 ReadCIAA (unsigned int addr)
switch (reg) {
case 0:
- {
-#ifdef ACTION_REPLAY
- action_replay_cia_access(false);
-#endif
- uae_u8 v = DISK_status_ciaa() & 0x3c;
- v |= handle_joystick_buttons (ciaapra, ciaadra);
- v |= (ciaapra | (ciaadra ^ 3)) & 0x03;
- return v;
- }
+ tmp = DISK_status() & 0x3c;
+ tmp |= handle_joystick_buttons (ciaapra, ciaadra);
+ tmp |= (ciaapra | (ciaadra ^ 3)) & 0x03;
+ return tmp;
case 1:
-#if defined(INPUTDEVICE_SIMPLE) && !defined(AMIBERRY)
+#ifdef INPUTDEVICE_SIMPLE
tmp = (ciaaprb & ciaadrb) | (ciaadrb ^ 0xff);
#else
tmp = handle_parport_joystick (0, ciaaprb, ciaadrb);
@@ -657,16 +1078,13 @@ static uae_u8 ReadCIAA (unsigned int addr)
else
return (uae_u8)(ciaatod >> 8);
case 10:
- /* only if not already latched. A1200 confirmed. (TW) */
- if (!ciaatlatch) {
+ if (!ciaatlatch) { /* only if not already latched. A1200 confirmed. (TW) */
/* no latching if ALARM is set */
if (!(ciaacrb & 0x80))
ciaatlatch = 1;
ciaatol = ciaatod;
}
return (uae_u8)(ciaatol >> 16);
- case 11:
- break;
case 12:
return ciaasdr;
case 13:
@@ -691,7 +1109,7 @@ static uae_u8 ReadCIAB (unsigned int addr)
switch (reg) {
case 0:
tmp = 0;
-#if defined(INPUTDEVICE_SIMPLE) && !defined(AMIBERRY)
+#ifdef INPUTDEVICE_SIMPLE
tmp = ((ciabpra & ciabdra) | (ciabdra ^ 0xff)) & 0x7;
#else
tmp |= handle_parport_joystick (1, ciabpra, ciabdra);
@@ -727,20 +1145,17 @@ static uae_u8 ReadCIAB (unsigned int addr)
case 7:
return (uae_u8)((ciabtb - ciabtb_passed) >> 8);
case 8:
- CIAB_tod_check ();
if (ciabtlatch) {
ciabtlatch = 0;
return (uae_u8)ciabtol;
} else
return (uae_u8)ciabtod;
case 9:
- CIAB_tod_check ();
if (ciabtlatch)
return (uae_u8)(ciabtol >> 8);
else
return (uae_u8)(ciabtod >> 8);
case 10:
- CIAB_tod_check ();
if (!ciabtlatch) {
/* no latching if ALARM is set */
if (!(ciabcrb & 0x80))
@@ -748,8 +1163,6 @@ static uae_u8 ReadCIAB (unsigned int addr)
ciabtol = ciabtod;
}
return (uae_u8)(ciabtol >> 16);
- case 11:
- break;
case 12:
return ciabsdr;
case 13:
@@ -764,258 +1177,385 @@ static uae_u8 ReadCIAB (unsigned int addr)
return 0;
}
-static void WriteCIAA (uae_u16 addr,uae_u8 val)
+static void WriteCIAA(uae_u16 addr, uae_u8 val)
{
int reg = addr & 15;
+#if CIAA_DEBUG_W > 0
+ write_log(_T("W_CIAA: bfe%x01 %02X %08X\n"), reg, val, M68K_GETPC);
+#endif
#ifdef ACTION_REPLAY
ar_ciaa[reg] = val;
#endif
- if (!currprefs.cs_ciaoverlay && oldovl) {
- map_overlay (1);
- oldovl = 0;
- }
- switch (reg) {
- case 0:
- ciaapra = (ciaapra & ~0xc3) | (val & 0xc3);
- bfe001_change ();
- handle_cd32_joystick_cia (ciaapra, ciaadra);
- break;
- case 1:
- ciaaprb = val;
- break;
- case 2:
- ciaadra = val;
- bfe001_change ();
- break;
- case 3:
- ciaadrb = val;
- break;
- case 4:
- CIA_update ();
- ciaala = (ciaala & 0xff00) | val;
- CIA_calctimers ();
- break;
- case 5:
- CIA_update ();
- ciaala = (ciaala & 0xff) | (val << 8);
- if ((ciaacra & 1) == 0)
- ciaata = ciaala;
- if (ciaacra & 8) {
- ciaata = ciaala;
- ciaacra |= 1;
- ciaastarta = CIASTARTCYCLESHI;
- }
- CIA_calctimers ();
- break;
- case 6:
- CIA_update ();
- ciaalb = (ciaalb & 0xff00) | val;
- CIA_calctimers ();
- break;
- case 7:
- CIA_update ();
- ciaalb = (ciaalb & 0xff) | (val << 8);
- if ((ciaacrb & 1) == 0)
- ciaatb = ciaalb;
- if (ciaacrb & 8) {
- ciaatb = ciaalb;
- ciaacrb |= 1;
- ciaastartb = CIASTARTCYCLESHI;
- }
- CIA_calctimers ();
- break;
- case 8:
- if (ciaacrb & 0x80) {
- ciaaalarm = (ciaaalarm & ~0xff) | val;
- } else {
- ciaatod = (ciaatod & ~0xff) | val;
- ciaatodon = 1;
- ciaa_checkalarm (false);
- }
- break;
- case 9:
- if (ciaacrb & 0x80) {
- ciaaalarm = (ciaaalarm & ~0xff00) | (val << 8);
- } else {
- ciaatod = (ciaatod & ~0xff00) | (val << 8);
- }
- break;
- case 10:
- if (ciaacrb & 0x80) {
- ciaaalarm = (ciaaalarm & ~0xff0000) | (val << 16);
- } else {
- ciaatod = (ciaatod & ~0xff0000) | (val << 16);
- ciaatodon = 0;
- }
- break;
- case 11:
+ if (!currprefs.cs_ciaoverlay && oldovl) {
+ map_overlay(1);
+ oldovl = 0;
+ }
+ switch (reg) {
+ case 0:
+#if DONGLE_DEBUG > 0
+ if (notinrom())
+ write_log(_T("BFE001 W %02X %s\n"), val, debuginfo(0));
+#endif
+ ciaapra = (ciaapra & ~0xc3) | (val & 0xc3);
+ bfe001_change();
+ handle_cd32_joystick_cia(ciaapra, ciaadra);
+ //dongle_cia_write(0, reg, val);
+#ifdef AMAX
+ if (is_device_rom(&currprefs, ROMTYPE_AMAX, 0) > 0)
+ amax_bfe001_write(val, ciaadra);
+#endif
break;
- case 12:
- CIA_update ();
- ciaasdr = val;
- if ((ciaacra & 0x41) == 0x41 && ciaasdr_cnt == 0)
- ciaasdr_cnt = 8 * 2;
- CIA_calctimers ();
- break;
- case 13:
- setclr(&ciaaimask,val);
- RethinkICRA ();
- break;
- case 14:
- CIA_update ();
- val &= 0x7f; /* bit 7 is unused */
- if ((val & 1) && !(ciaacra & 1))
- ciaastarta = CIASTARTCYCLESCRA;
- if ((val & 0x40) == 0 && (ciaacra & 0x40) != 0) {
- /* todo: check if low to high or high to low only */
- kblostsynccnt = 0;
- }
- ciaacra = val;
- if (ciaacra & 0x10) {
- ciaacra &= ~0x10;
- ciaata = ciaala;
- }
- CIA_calctimers ();
- break;
- case 15:
- CIA_update ();
- if ((val & 1) && !(ciaacrb & 1))
- ciaastartb = CIASTARTCYCLESCRA;
- ciaacrb = val;
- if (ciaacrb & 0x10) {
- ciaacrb &= ~0x10;
- ciaatb = ciaalb;
- }
- CIA_calctimers ();
- break;
- }
+ case 1:
+#if DONGLE_DEBUG > 0
+ if (notinrom())
+ write_log(_T("BFE101 W %02X %s\n"), val, debuginfo(0));
+#endif
+ ciaaprb = val;
+ //dongle_cia_write(0, reg, val);
+#ifdef PARALLEL_PORT
+ if (isprinter() > 0) {
+ doprinter(val);
+ cia_parallelack();
+ }
+ else if (isprinter() < 0) {
+ parallel_direct_write_data(val, ciaadrb);
+ cia_parallelack();
+#ifdef ARCADIA
+ }
+ else if (arcadia_bios) {
+ arcadia_parport(1, ciaaprb, ciaadrb);
+#endif
+ }
+ else if (parallel_port_scsi) {
+ parallel_port_scsi_write(0, ciaaprb, ciaadrb);
+ }
+#endif
+ break;
+ case 2:
+#if DONGLE_DEBUG > 0
+ if (notinrom())
+ write_log(_T("BFE201 W %02X %s\n"), val, debuginfo(0));
+#endif
+ ciaadra = val;
+ //dongle_cia_write(0, reg, val);
+ bfe001_change();
+ break;
+ case 3:
+ ciaadrb = val;
+ //dongle_cia_write(0, reg, val);
+#if DONGLE_DEBUG > 0
+ if (notinrom())
+ write_log(_T("BFE301 W %02X %s\n"), val, debuginfo(0));
+#endif
+#ifdef ARCADIA
+ if (arcadia_bios)
+ arcadia_parport(1, ciaaprb, ciaadrb);
+#endif
+ break;
+ case 4:
+ CIA_update();
+ ciaala = (ciaala & 0xff00) | val;
+ CIA_calctimers();
+ break;
+ case 5:
+ CIA_update();
+ ciaala = (ciaala & 0xff) | (val << 8);
+ if ((ciaacra & 1) == 0)
+ ciaata = ciaala;
+ if (ciaacra & 8) {
+ ciaata = ciaala;
+ ciaacra |= 1;
+ ciaastarta = CIASTARTCYCLESHI;
+ }
+ CIA_calctimers();
+ break;
+ case 6:
+ CIA_update();
+ ciaalb = (ciaalb & 0xff00) | val;
+ CIA_calctimers();
+ break;
+ case 7:
+ CIA_update();
+ ciaalb = (ciaalb & 0xff) | (val << 8);
+ if ((ciaacrb & 1) == 0)
+ ciaatb = ciaalb;
+ if (ciaacrb & 8) {
+ ciaatb = ciaalb;
+ ciaacrb |= 1;
+ ciaastartb = CIASTARTCYCLESHI;
+ }
+ CIA_calctimers();
+ break;
+ case 8:
+ if (ciaacrb & 0x80) {
+ setciatod(&ciaaalarm, (getciatod(ciaaalarm) & ~0xff) | val);
+ }
+ else {
+ setciatod(&ciaatod, (getciatod(ciaatod) & ~0xff) | val);
+ ciaatodon = 1;
+ ciaa_checkalarm(false);
+ }
+ break;
+ case 9:
+ if (ciaacrb & 0x80) {
+ setciatod(&ciaaalarm, (getciatod(ciaaalarm) & ~0xff00) | (val << 8));
+ }
+ else {
+ setciatod(&ciaatod, (getciatod(ciaatod) & ~0xff00) | (val << 8));
+ }
+ break;
+ case 10:
+ if (ciaacrb & 0x80) {
+ setciatod(&ciaaalarm, (getciatod(ciaaalarm) & ~0xff0000) | (val << 16));
+ }
+ else {
+ setciatod(&ciaatod, (getciatod(ciaatod) & ~0xff0000) | (val << 16));
+ if (!currprefs.cs_cia6526)
+ ciaatodon = 0;
+ }
+ break;
+ case 11:
+ if (currprefs.cs_cia6526) {
+ if (ciaacrb & 0x80) {
+ setciatod(&ciaaalarm, (getciatod(ciaaalarm) & ~0xff000000) | (val << 24));
+ }
+ else {
+ setciatod(&ciaatod, (getciatod(ciaatod) & ~0xff000000) | (val << 24));
+ ciaatodon = 0;
+ }
+ }
+ break;
+ case 12:
+ CIA_update();
+ ciaasdr = val;
+ if ((ciaacra & 0x41) == 0x41 && ciaasdr_cnt == 0)
+ ciaasdr_cnt = 8 * 2;
+#if KB_DEBUG
+ write_log(_T("CIAA serial port write: %02x cnt=%d PC=%08x\n"), ciaasdr, ciaasdr_cnt, M68K_GETPC);
+#endif
+ CIA_calctimers();
+ break;
+ case 13:
+ setclr(&ciaaimask, val);
+ RethinkICRA();
+ break;
+ case 14:
+ CIA_update();
+ val &= 0x7f; /* bit 7 is unused */
+ if ((val & 1) && !(ciaacra & 1))
+ ciaastarta = CIASTARTCYCLESCRA;
+ //if (currprefs.cpuboard_type != 0 && (val & 0x40) != (ciaacra & 0x40)) {
+ // /* bleh, Phase5 CPU timed early boot key check fix.. */
+ // if (m68k_getpc() >= 0xf00000 && m68k_getpc() < 0xf80000)
+ // check_keyboard();
+ //}
+ if ((val & 0x40) == 0 && (ciaacra & 0x40) != 0) {
+ /* todo: check if low to high or high to low only */
+ kblostsynccnt = 0;
+#if KB_DEBUG
+ write_log(_T("KB_ACK %02x->%02x %08x\n"), ciaacra, val, M68K_GETPC);
+#endif
+ }
+ ciaacra = val;
+ if (ciaacra & 0x10) {
+ ciaacra &= ~0x10;
+ ciaata = ciaala;
+ }
+ CIA_calctimers();
+ break;
+ case 15:
+ CIA_update();
+ if ((val & 1) && !(ciaacrb & 1))
+ ciaastartb = CIASTARTCYCLESCRA;
+ ciaacrb = val;
+ if (ciaacrb & 0x10) {
+ ciaacrb &= ~0x10;
+ ciaatb = ciaalb;
+ }
+ CIA_calctimers();
+ break;
+ }
}
-static void WriteCIAB (uae_u16 addr,uae_u8 val)
+static void WriteCIAB(uae_u16 addr, uae_u8 val)
{
int reg = addr & 15;
+#if CIAB_DEBUG_W > 0
+ if (((addr >= 8 && addr <= 10) || addr == 15) || CIAB_DEBUG_W > 1)
+ write_log(_T("W_CIAB: bfd%x00 %02X %08X\n"), reg, val, M68K_GETPC);
+#endif
#ifdef ACTION_REPLAY
ar_ciab[reg] = val;
#endif
- switch (reg) {
- case 0:
- ciabpra = val;
- break;
- case 1:
+ switch (reg) {
+ case 0:
+#if DONGLE_DEBUG > 0
+ if (notinrom())
+ write_log(_T("BFD000 W %02X %s\n"), val, debuginfo(0));
+#endif
+ //dongle_cia_write(1, reg, val);
+ ciabpra = val;
+#ifdef SERIAL_PORT
+ if (currprefs.use_serial)
+ serial_writestatus(ciabpra, ciabdra);
+#endif
+#ifdef PARALLEL_PORT
+ if (isprinter() < 0) {
+ parallel_direct_write_status(val, ciabdra);
+ }
+ else if (parallel_port_scsi) {
+ parallel_port_scsi_write(1, ciabpra, ciabdra);
+ }
+#endif
+ break;
+ case 1:
#ifdef ACTION_REPLAY
action_replay_cia_access(true);
#endif
- ciabprb = val;
- DISK_select(val);
- break;
- case 2:
- ciabdra = val;
- break;
- case 3:
- ciabdrb = val;
- break;
- case 4:
- CIA_update ();
- ciabla = (ciabla & 0xff00) | val;
- CIA_calctimers ();
- break;
- case 5:
- CIA_update ();
- ciabla = (ciabla & 0xff) | (val << 8);
- if ((ciabcra & 1) == 0)
- ciabta = ciabla;
- if (ciabcra & 8) {
- ciabta = ciabla;
- ciabcra |= 1;
- ciabstarta = CIASTARTCYCLESHI;
- }
- CIA_calctimers ();
- break;
- case 6:
- CIA_update ();
- ciablb = (ciablb & 0xff00) | val;
- CIA_calctimers ();
- break;
- case 7:
- CIA_update ();
- ciablb = (ciablb & 0xff) | (val << 8);
- if ((ciabcrb & 1) == 0)
- ciabtb = ciablb;
- if (ciabcrb & 8) {
- ciabtb = ciablb;
- ciabcrb |= 1;
- ciabstartb = CIASTARTCYCLESHI;
- }
- CIA_calctimers ();
- break;
- case 8:
- CIAB_tod_check ();
- if (ciabcrb & 0x80) {
- ciabalarm = (ciabalarm & ~0xff) | val;
- } else {
- ciabtod = (ciabtod & ~0xff) | val;
- ciabtodon = 1;
- ciab_checkalarm (false, true);
- }
- break;
- case 9:
- CIAB_tod_check ();
- if (ciabcrb & 0x80) {
- ciabalarm = (ciabalarm & ~0xff00) | (val << 8);
- } else {
- ciabtod = (ciabtod & ~0xff00) | (val << 8);
- }
- break;
- case 10:
- CIAB_tod_check ();
- if (ciabcrb & 0x80) {
- ciabalarm = (ciabalarm & ~0xff0000) | (val << 16);
- } else {
- ciabtod = (ciabtod & ~0xff0000) | (val << 16);
- ciabtodon = 0;
- }
- break;
- case 11:
+#if DONGLE_DEBUG > 0
+ if (notinrom())
+ write_log(_T("BFD100 W %02X %s\n"), val, debuginfo(0));
+#endif
+ //dongle_cia_write(1, reg, val);
+ ciabprb = val;
+ DISK_select(val);
break;
- case 12:
- CIA_update ();
- ciabsdr = val;
- if ((ciabcra & 0x40) == 0)
- ciabsdr_cnt = 0;
- if ((ciabcra & 0x41) == 0x41 && ciabsdr_cnt == 0)
- ciabsdr_cnt = 8 * 2;
- CIA_calctimers ();
- break;
- case 13:
- setclr(&ciabimask,val);
- RethinkICRB ();
- break;
- case 14:
- CIA_update ();
- val &= 0x7f; /* bit 7 is unused */
- if ((val & 1) && !(ciabcra & 1))
- ciabstarta = CIASTARTCYCLESCRA;
- ciabcra = val;
- if (ciabcra & 0x10) {
- ciabcra &= ~0x10;
- ciabta = ciabla;
- }
- CIA_calctimers ();
- break;
- case 15:
- CIA_update ();
- if ((val & 1) && !(ciabcrb & 1))
- ciabstartb = CIASTARTCYCLESCRA;
- ciabcrb = val;
- if (ciabcrb & 0x10) {
- ciabcrb &= ~0x10;
- ciabtb = ciablb;
- }
- CIA_calctimers ();
- break;
- }
+ case 2:
+#if DONGLE_DEBUG > 0
+ if (notinrom())
+ write_log(_T("BFD200 W %02X %s\n"), val, debuginfo(0));
+#endif
+ //dongle_cia_write(1, reg, val);
+ ciabdra = val;
+#ifdef SERIAL_PORT
+ if (currprefs.use_serial)
+ serial_writestatus(ciabpra, ciabdra);
+#endif
+ break;
+ case 3:
+#if DONGLE_DEBUG > 0
+ if (notinrom())
+ write_log(_T("BFD300 W %02X %s\n"), val, debuginfo(0));
+#endif
+ //dongle_cia_write(1, reg, val);
+ ciabdrb = val;
+ break;
+ case 4:
+ CIA_update();
+ ciabla = (ciabla & 0xff00) | val;
+ CIA_calctimers();
+ break;
+ case 5:
+ CIA_update();
+ ciabla = (ciabla & 0xff) | (val << 8);
+ if ((ciabcra & 1) == 0)
+ ciabta = ciabla;
+ if (ciabcra & 8) {
+ ciabta = ciabla;
+ ciabcra |= 1;
+ ciabstarta = CIASTARTCYCLESHI;
+ }
+ CIA_calctimers();
+ break;
+ case 6:
+ CIA_update();
+ ciablb = (ciablb & 0xff00) | val;
+ CIA_calctimers();
+ break;
+ case 7:
+ CIA_update();
+ ciablb = (ciablb & 0xff) | (val << 8);
+ if ((ciabcrb & 1) == 0)
+ ciabtb = ciablb;
+ if (ciabcrb & 8) {
+ ciabtb = ciablb;
+ ciabcrb |= 1;
+ ciabstartb = CIASTARTCYCLESHI;
+ }
+ CIA_calctimers();
+ break;
+ case 8:
+ CIAB_tod_check();
+ if (ciabcrb & 0x80) {
+ setciatod(&ciabalarm, (getciatod(ciabalarm) & ~0xff) | val);
+ }
+ else {
+ setciatod(&ciabtod, (getciatod(ciabtod) & ~0xff) | val);
+ ciabtodon = 1;
+ ciab_checkalarm(false, true);
+ }
+ break;
+ case 9:
+ CIAB_tod_check();
+ if (ciabcrb & 0x80) {
+ setciatod(&ciabalarm, (getciatod(ciabalarm) & ~0xff00) | (val << 8));
+ }
+ else {
+ setciatod(&ciabtod, (getciatod(ciabtod) & ~0xff00) | (val << 8));
+ }
+ break;
+ case 10:
+ CIAB_tod_check();
+ if (ciabcrb & 0x80) {
+ setciatod(&ciabalarm, (getciatod(ciabalarm) & ~0xff0000) | (val << 16));
+ }
+ else {
+ setciatod(&ciabtod, (getciatod(ciabtod) & ~0xff0000) | (val << 16));
+ if (!currprefs.cs_cia6526)
+ ciabtodon = 0;
+ }
+ break;
+ case 11:
+ if (currprefs.cs_cia6526) {
+ CIAB_tod_check();
+ if (ciabcrb & 0x80) {
+ setciatod(&ciabalarm, (getciatod(ciabalarm) & ~0xff000000) | (val << 24));
+ }
+ else {
+ setciatod(&ciabtod, (getciatod(ciabtod) & ~0xff000000) | (val << 24));
+ ciabtodon = 0;
+ }
+ }
+ break;
+ case 12:
+ CIA_update();
+ ciabsdr = val;
+ if ((ciabcra & 0x40) == 0)
+ ciabsdr_cnt = 0;
+ if ((ciabcra & 0x41) == 0x41 && ciabsdr_cnt == 0)
+ ciabsdr_cnt = 8 * 2;
+ CIA_calctimers();
+ break;
+ case 13:
+ setclr(&ciabimask, val);
+ RethinkICRB();
+ break;
+ case 14:
+ CIA_update();
+ val &= 0x7f; /* bit 7 is unused */
+ if ((val & 1) && !(ciabcra & 1))
+ ciabstarta = CIASTARTCYCLESCRA;
+ ciabcra = val;
+ if (ciabcra & 0x10) {
+ ciabcra &= ~0x10;
+ ciabta = ciabla;
+ }
+ CIA_calctimers();
+ break;
+ case 15:
+ CIA_update();
+ if ((val & 1) && !(ciabcrb & 1))
+ ciabstartb = CIASTARTCYCLESCRA;
+ ciabcrb = val;
+ if (ciabcrb & 0x10) {
+ ciabcrb &= ~0x10;
+ ciabtb = ciablb;
+ }
+ CIA_calctimers();
+ break;
+ }
}
void cia_set_overlay (bool overlay)
@@ -1023,69 +1563,89 @@ void cia_set_overlay (bool overlay)
oldovl = overlay;
}
-/* CIA memory access */
-
-DECLARE_MEMORY_FUNCTIONS(cia);
-static uae_u32 REGPARAM3 cia_bget_compatible (uaecptr) REGPARAM;
-addrbank cia_bank = {
- cia_lget, cia_wget, cia_bget,
- cia_lput, cia_wput, cia_bput,
- default_xlate, default_check, NULL, NULL, _T("CIA"),
- cia_lgeti, cia_wgeti,
- ABFLAG_IO | ABFLAG_CIA, S_READ, S_WRITE, NULL, 0x3f01, 0xbfc000
-};
-
-void CIA_reset (void)
+void CIA_reset(void)
{
- if (currprefs.cpu_model == 68000 && currprefs.cpu_compatible)
- cia_bank.bget = cia_bget_compatible;
- else
- cia_bank.bget = cia_bget;
+#ifdef TOD_HACK
+ tod_hack_tv = 0;
+ tod_hack_tod = 0;
+ tod_hack_enabled = 0;
+ if (currprefs.tod_hack)
+ tod_hack_enabled = TOD_HACK_TIME;
+#endif
- kblostsynccnt = 0;
+ kblostsynccnt = 0;
+ serbits = 0;
oldcd32mute = 1;
+ resetwarning_phase = resetwarning_timer = 0;
+ heartbeat_cnt = 0;
ciab_tod_event_state = 0;
- if (!savestate_state) {
+ if (!savestate_state) {
oldovl = true;
- kbstate = 0;
- ciaatlatch = ciabtlatch = 0;
- ciaapra = 0; ciaadra = 0;
- ciaatod = ciabtod = 0; ciaatodon = ciabtodon = 0;
- ciaaicr = ciabicr = ciaaimask = ciabimask = 0;
- ciaacra = ciaacrb = ciabcra = ciabcrb = 0x4; /* outmode = toggle; */
- ciaala = ciaalb = ciabla = ciablb = ciaata = ciaatb = ciabta = ciabtb = 0xFFFF;
- ciaaalarm = ciabalarm = 0;
- ciabpra = 0x8C; ciabdra = 0;
- div10 = 0;
- ciaasdr_cnt = 0; ciaasdr = 0;
- ciabsdr_cnt = 0; ciabsdr = 0;
- ciaata_passed = ciaatb_passed = ciabta_passed = ciabtb_passed = 0;
- ciaatol = ciabtol = ciaaprb = ciaadrb = ciabprb = ciabdrb = 0;
- CIA_calctimers ();
- DISK_select_set (ciabprb);
- }
- map_overlay (0);
- check_led ();
- if (savestate_state) {
+ kbstate = 0;
+ ciaatlatch = ciabtlatch = 0;
+ ciaapra = 0; ciaadra = 0;
+ ciaatod = ciabtod = 0; ciaatodon = ciabtodon = 0;
+ ciaaicr = ciabicr = ciaaimask = ciabimask = 0;
+ ciaacra = ciaacrb = ciabcra = ciabcrb = 0x4; /* outmode = toggle; */
+ ciaala = ciaalb = ciabla = ciablb = ciaata = ciaatb = ciabta = ciabtb = 0xFFFF;
+ ciaaalarm = ciabalarm = 0;
+ ciabpra = 0x8C; ciabdra = 0;
+ div10 = 0;
+ ciaasdr_cnt = 0; ciaasdr = 0;
+ ciabsdr_cnt = 0; ciabsdr = 0;
+ ciaata_passed = ciaatb_passed = ciabta_passed = ciabtb_passed = 0;
+ CIA_calctimers();
+ DISK_select_set(ciabprb);
+ }
+ map_overlay(0);
+ check_led();
+#ifdef SERIAL_PORT
+ if (currprefs.use_serial && !savestate_state)
+ serial_dtr_off(); /* Drop DTR at reset */
+#endif
+ if (savestate_state) {
if (currprefs.cs_ciaoverlay) {
oldovl = true;
}
- bfe001_change ();
+ bfe001_change();
if (!currprefs.cs_ciaoverlay) {
- map_overlay (oldovl ? 0 : 1);
+ map_overlay(oldovl ? 0 : 1);
}
- }
+ }
#ifdef CD32
- if (!isrestore ()) {
- akiko_reset ();
- if (!akiko_init ())
+ if (!isrestore()) {
+ akiko_reset();
+ if (!akiko_init())
currprefs.cs_cd32cd = changed_prefs.cs_cd32cd = 0;
}
#endif
}
-static void cia_wait_pre (void)
+void dumpcia(void)
+{
+ write_log(_T("A: CRA %02x CRB %02x ICR %02x IM %02x TA %04x (%04x) TB %04x (%04x)\n"),
+ ciaacra, ciaacrb, ciaaicr, ciaaimask, ciaata, ciaala, ciaatb, ciaalb);
+ write_log(_T("TOD %06x (%06x) ALARM %06x %c%c CYC=%08X\n"),
+ ciaatod, ciaatol, ciaaalarm, ciaatlatch ? 'L' : ' ', ciaatodon ? ' ' : 'S', get_cycles());
+ write_log(_T("B: CRA %02x CRB %02x ICR %02x IM %02x TA %04x (%04x) TB %04x (%04x)\n"),
+ ciabcra, ciabcrb, ciabicr, ciabimask, ciabta, ciabla, ciabtb, ciablb);
+ write_log(_T("TOD %06x (%06x) ALARM %06x %c%c CLK=%d\n"),
+ ciabtod, ciabtol, ciabalarm, ciabtlatch ? 'L' : ' ', ciabtodon ? ' ' : 'S', div10 / CYCLE_UNIT);
+}
+
+/* CIA memory access */
+
+DECLARE_MEMORY_FUNCTIONS(cia);
+addrbank cia_bank = {
+ cia_lget, cia_wget, cia_bget,
+ cia_lput, cia_wput, cia_bput,
+ default_xlate, default_check, NULL, NULL, _T("CIA"),
+ cia_lgeti, cia_wgeti,
+ ABFLAG_IO | ABFLAG_CIA, S_READ, S_WRITE, NULL, 0x3f01, 0xbfc000
+};
+
+static void cia_wait_pre(int cianummask)
{
if (currprefs.cachesize)
return;
@@ -1094,20 +1654,21 @@ static void cia_wait_pre (void)
int cycles;
if (div >= DIV10 * ECLOCK_DATA_CYCLE / 10) {
- cycles = DIV10 - div;
+ cycles = DIV10 - div;
cycles += DIV10 * ECLOCK_DATA_CYCLE / 10;
- } else if (div) {
- cycles = DIV10 + DIV10 * ECLOCK_DATA_CYCLE / 10 - div;
- } else {
+ }
+ else if (div) {
+ cycles = DIV10 + DIV10 * ECLOCK_DATA_CYCLE / 10 - div;
+ }
+ else {
cycles = DIV10 * ECLOCK_DATA_CYCLE / 10 - div;
}
-
- if (cycles) {
- do_cycles (cycles);
+ if (cycles) {
+ do_cycles(cycles);
}
}
-static void cia_wait_post (uae_u32 value)
+static void cia_wait_post(int cianummask, uae_u32 value)
{
if (currprefs.cachesize) {
do_cycles (8 * CYCLE_UNIT / 2);
@@ -1122,7 +1683,7 @@ static void cia_wait_post (uae_u32 value)
STATIC_INLINE bool issinglecia(void)
{
- return currprefs.cs_ide || currprefs.cs_pcmcia || currprefs.cs_cd32cd;
+ return currprefs.cs_ide || currprefs.cs_pcmcia || currprefs.cs_mbdmac || currprefs.cs_cd32cd;
}
STATIC_INLINE bool isgayle(void)
{
@@ -1138,7 +1699,7 @@ STATIC_INLINE bool iscia(uaecptr addr)
static bool isgaylenocia(uaecptr addr)
{
- if (!isgayle ())
+ if (!isgayle())
return true;
// gayle CIA region is only 4096 bytes at 0xbfd000 and 0xbfe000
return iscia(addr);
@@ -1164,46 +1725,7 @@ static int cia_chipselect(uaecptr addr)
return cs;
}
-static uae_u32 REGPARAM2 cia_bget_compatible (uaecptr addr)
-{
- int r = (addr & 0xf00) >> 8;
- uae_u8 v = 0;
-
- if (isgarynocia(addr))
- return dummy_get(addr, 1, false, 0);
-
- if (!isgaylenocia (addr))
- return dummy_get(addr, 1, false, 0);
-
- switch (cia_chipselect(addr)) {
- case 0:
- if (!issinglecia ()) {
- cia_wait_pre ();
- v = (addr & 1) ? ReadCIAA (r) : ReadCIAB (r);
- cia_wait_post (v);
- }
- break;
- case 1:
- cia_wait_pre ();
- v = (addr & 1) ? regs.irc : ReadCIAB (r);
- cia_wait_post (v);
- break;
- case 2:
- cia_wait_pre ();
- v = (addr & 1) ? ReadCIAA (r) : regs.irc >> 8;
- cia_wait_post (v);
- break;
- case 3:
- cia_wait_pre ();
- v = (addr & 1) ? regs.irc : regs.irc >> 8;
- cia_wait_post (v);
- break;
- }
-
- return v;
-}
-
-static uae_u32 REGPARAM2 cia_bget (uaecptr addr)
+static uae_u32 REGPARAM2 cia_bget(uaecptr addr)
{
int r = (addr & 0xf00) >> 8;
uae_u8 v = 0;
@@ -1211,36 +1733,53 @@ static uae_u32 REGPARAM2 cia_bget (uaecptr addr)
if (isgarynocia(addr))
return dummy_get(addr, 1, false, 0);
- if (!isgaylenocia (addr))
+ if (!isgaylenocia(addr))
return dummy_get(addr, 1, false, 0);
- switch (cia_chipselect(addr)) {
- case 0:
- if (!issinglecia ()) {
- cia_wait_pre ();
- v = (addr & 1) ? ReadCIAA (r) : ReadCIAB (r);
- cia_wait_post (v);
- }
- break;
- case 1:
- cia_wait_pre ();
- v = (addr & 1) ? dummy_get_safe(addr, 1, false, 0) : ReadCIAB (r);
- cia_wait_post (v);
- break;
- case 2:
- cia_wait_pre ();
- v = (addr & 1) ? ReadCIAA (r) : dummy_get_safe(addr, 1, false, 0);
- cia_wait_post (v);
- break;
+ switch (cia_chipselect(addr))
+ {
+ case 0:
+ if (!issinglecia()) {
+ cia_wait_pre(1 | 2);
+ v = (addr & 1) ? ReadCIAA(r) : ReadCIAB(r);
+ cia_wait_post(1 | 2, v);
+ }
+ break;
+ case 1:
+ cia_wait_pre(2);
+ if (currprefs.cpu_model == 68000 && currprefs.cpu_compatible) {
+ v = (addr & 1) ? regs.irc : ReadCIAB(r);
+ }
+ else {
+ v = (addr & 1) ? dummy_get(addr, 1, false, 0) : ReadCIAB(r);
+ }
+ cia_wait_post(2, v);
+ break;
+ case 2:
+ cia_wait_pre(1);
+ if (currprefs.cpu_model == 68000 && currprefs.cpu_compatible)
+ v = (addr & 1) ? ReadCIAA(r) : regs.irc >> 8;
+ else
+ v = (addr & 1) ? ReadCIAA(r) : dummy_get(addr, 1, false, 0);
+ cia_wait_post(1, v);
+ break;
case 3:
- v = 0xff;
- break;
- }
+ if (currprefs.cpu_model == 68000 && currprefs.cpu_compatible) {
+ cia_wait_pre(0);
+ v = (addr & 1) ? regs.irc : regs.irc >> 8;
+ cia_wait_post(0, v);
+ }
+ if (warned > 0 || currprefs.illegal_mem) {
+ write_log(_T("cia_bget: unknown CIA address %08X=%02X PC=%08X\n"), addr, v & 0xff, M68K_GETPC);
+ warned--;
+ }
+ break;
+ }
- return v;
+ return v;
}
-static uae_u32 REGPARAM2 cia_wget (uaecptr addr)
+static uae_u32 REGPARAM2 cia_wget(uaecptr addr)
{
int r = (addr & 0xf00) >> 8;
uae_u16 v = 0;
@@ -1248,435 +1787,632 @@ static uae_u32 REGPARAM2 cia_wget (uaecptr addr)
if (isgarynocia(addr))
return dummy_get(addr, 2, false, 0);
- if (!isgaylenocia (addr))
- return dummy_get_safe(addr, 2, false, 0);
+ if (!isgaylenocia(addr))
+ return dummy_get(addr, 2, false, 0);
- switch (cia_chipselect(addr))
- {
- case 0:
- if (!issinglecia ())
+ switch (cia_chipselect(addr))
+ {
+ case 0:
+ if (!issinglecia())
{
- cia_wait_pre ();
- v = (ReadCIAB (r) << 8) | ReadCIAA (r);
- cia_wait_post (v);
+ cia_wait_pre(1 | 2);
+ v = (ReadCIAB(r) << 8) | ReadCIAA(r);
+ cia_wait_post(1 | 2, v);
}
- break;
- case 1:
- cia_wait_pre ();
- v = (ReadCIAB (r) << 8) | dummy_get_safe(addr, 1, false, 0);
- cia_wait_post (v);
- break;
- case 2:
- cia_wait_pre ();
- v = (dummy_get_safe(addr, 1, false, 0) << 8) | ReadCIAA (r);
- cia_wait_post (v);
- break;
+ break;
+ case 1:
+ cia_wait_pre(2);
+ v = (ReadCIAB(r) << 8) | dummy_get(addr, 1, false, 0);
+ cia_wait_post(2, v);
+ break;
+ case 2:
+ cia_wait_pre(1);
+ v = (dummy_get(addr, 1, false, 0) << 8) | ReadCIAA(r);
+ cia_wait_post(1, v);
+ break;
case 3:
- if (currprefs.cpu_model == 68000 && currprefs.cpu_compatible) {
- cia_wait_pre ();
- v = regs.irc;
- cia_wait_post (v);
- }
- break;
- }
- return v;
+ if (currprefs.cpu_model == 68000 && currprefs.cpu_compatible) {
+ cia_wait_pre(0);
+ v = regs.irc;
+ cia_wait_post(0, v);
+ }
+ if (warned > 0 || currprefs.illegal_mem) {
+ write_log(_T("cia_wget: unknown CIA address %08X=%04X PC=%08X\n"), addr, v & 0xffff, M68K_GETPC);
+ warned--;
+ }
+ break;
+ }
+ return v;
}
-static uae_u32 REGPARAM2 cia_lget (uaecptr addr)
+static uae_u32 REGPARAM2 cia_lget(uaecptr addr)
{
- uae_u32 v;
- v = cia_wget (addr) << 16;
- v |= cia_wget (addr + 2);
- return v;
+ uae_u32 v;
+ v = cia_wget(addr) << 16;
+ v |= cia_wget(addr + 2);
+ return v;
}
-static uae_u32 REGPARAM2 cia_wgeti (uaecptr addr)
+static uae_u32 REGPARAM2 cia_wgeti(uaecptr addr)
{
- if (currprefs.cpu_model >= 68020)
- return dummy_wgeti(addr);
- return cia_wget(addr);
+ if (currprefs.cpu_model >= 68020)
+ return dummy_wgeti(addr);
+ return cia_wget(addr);
}
-static uae_u32 REGPARAM2 cia_lgeti (uaecptr addr)
+static uae_u32 REGPARAM2 cia_lgeti(uae_u32 addr)
{
- if (currprefs.cpu_model >= 68020)
- return dummy_lgeti(addr);
- return cia_lget(addr);
+ if (currprefs.cpu_model >= 68020)
+ return dummy_lgeti(addr);
+ return cia_lget(addr);
}
-static void REGPARAM2 cia_bput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 cia_bput(uaecptr addr, uae_u32 value)
{
- int r = (addr & 0xf00) >> 8;
+ int r = (addr & 0xf00) >> 8;
if (isgarynocia(addr)) {
+ dummy_put(addr, 1, false);
return;
}
- if (!isgaylenocia (addr))
+ if (!isgaylenocia(addr))
return;
int cs = cia_chipselect(addr);
- if (!issinglecia () || (cs & 3) != 0) {
- cia_wait_pre ();
- if ((cs & 2) == 0)
- WriteCIAB (r, value);
- if ((cs & 1) == 0)
- WriteCIAA (r, value);
- cia_wait_post (value);
- }
+ if (!issinglecia() || (cs & 3) != 0) {
+ cia_wait_pre(((cs & 2) == 0 ? 1 : 0) | ((cs & 1) == 0 ? 2 : 0));
+ if ((cs & 2) == 0)
+ WriteCIAB(r, value);
+ if ((cs & 1) == 0)
+ WriteCIAA(r, value);
+ cia_wait_post(((cs & 2) == 0 ? 1 : 0) | ((cs & 1) == 0 ? 2 : 0), value);
+ if (((cs & 3) == 3) && (warned > 0 || currprefs.illegal_mem)) {
+ write_log(_T("cia_bput: unknown CIA address %08X=%02X PC=%08X\n"), addr, value & 0xff, M68K_GETPC);
+ warned--;
+ }
+ }
}
-static void REGPARAM2 cia_wput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 cia_wput(uaecptr addr, uae_u32 value)
{
- int r = (addr & 0xf00) >> 8;
+ int r = (addr & 0xf00) >> 8;
if (isgarynocia(addr)) {
+ dummy_put(addr, 2, false);
return;
}
- if (!isgaylenocia (addr))
+ if (!isgaylenocia(addr))
return;
int cs = cia_chipselect(addr);
- if (!issinglecia ()|| (cs & 3) != 0) {
- cia_wait_pre ();
- if ((cs & 2) == 0)
- WriteCIAB (r, value >> 8);
- if ((cs & 1) == 0)
- WriteCIAA (r, value & 0xff);
- cia_wait_post (value);
- }
+ if (!issinglecia() || (cs & 3) != 0) {
+ cia_wait_pre(((cs & 2) == 0 ? 1 : 0) | ((cs & 1) == 0 ? 2 : 0));
+ if ((cs & 2) == 0)
+ WriteCIAB(r, value >> 8);
+ if ((cs & 1) == 0)
+ WriteCIAA(r, value & 0xff);
+ cia_wait_post(((cs & 2) == 0 ? 1 : 0) | ((cs & 1) == 0 ? 2 : 0), value);
+ if (((cs & 3) == 3) && (warned > 0 || currprefs.illegal_mem)) {
+ write_log(_T("cia_wput: unknown CIA address %08X=%04X %08X\n"), addr, value & 0xffff, M68K_GETPC);
+ warned--;
+ }
+ }
}
-static void REGPARAM2 cia_lput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 cia_lput(uaecptr addr, uae_u32 value)
{
- cia_wput (addr, value >> 16);
- cia_wput (addr + 2, value & 0xffff);
+ cia_wput(addr, value >> 16);
+ cia_wput(addr + 2, value & 0xffff);
}
/* battclock memory access */
-static uae_u32 REGPARAM3 clock_lget (uaecptr) REGPARAM;
-static uae_u32 REGPARAM3 clock_wget (uaecptr) REGPARAM;
-static uae_u32 REGPARAM3 clock_bget (uaecptr) REGPARAM;
-static void REGPARAM3 clock_lput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 clock_wput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 clock_bput (uaecptr, uae_u32) REGPARAM;
+static uae_u32 REGPARAM3 clock_lget(uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 clock_wget(uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 clock_bget(uaecptr) REGPARAM;
+static void REGPARAM3 clock_lput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 clock_wput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 clock_bput(uaecptr, uae_u32) REGPARAM;
addrbank clock_bank = {
- clock_lget, clock_wget, clock_bget,
- clock_lput, clock_wput, clock_bput,
+ clock_lget, clock_wget, clock_bget,
+ clock_lput, clock_wput, clock_bput,
default_xlate, default_check, NULL, NULL, _T("Battery backed up clock (none)"),
dummy_lgeti, dummy_wgeti,
ABFLAG_IO, S_READ, S_WRITE, NULL, 0x3f, 0xd80000
};
-static uae_u8 getclockreg (int addr, struct tm *ct)
+static unsigned int clock_control_d;
+static unsigned int clock_control_e;
+static unsigned int clock_control_f;
+
+#define RF5C01A_RAM_SIZE 16
+static uae_u8 rtc_memory[RF5C01A_RAM_SIZE], rtc_alarm[RF5C01A_RAM_SIZE];
+
+static uae_u8 getclockreg(int addr, struct tm *ct)
{
uae_u8 v = 0;
if (currprefs.cs_rtc == 1 || currprefs.cs_rtc == 3) { /* MSM6242B */
- return get_clock_msm(&rtc_msm, addr, ct);
- } else if (currprefs.cs_rtc == 2) { /* RF5C01A */
- return get_clock_ricoh(&rtc_ricoh, addr, ct);
+ switch (addr) {
+ case 0x0: v = ct->tm_sec % 10; break;
+ case 0x1: v = ct->tm_sec / 10; break;
+ case 0x2: v = ct->tm_min % 10; break;
+ case 0x3: v = ct->tm_min / 10; break;
+ case 0x4: v = ct->tm_hour % 10; break;
+ case 0x5:
+ if (clock_control_f & 4) {
+ v = ct->tm_hour / 10; // 24h
+ }
+ else {
+ v = (ct->tm_hour % 12) / 10; // 12h
+ v |= ct->tm_hour >= 12 ? 4 : 0; // AM/PM bit
+ }
+ break;
+ case 0x6: v = ct->tm_mday % 10; break;
+ case 0x7: v = ct->tm_mday / 10; break;
+ case 0x8: v = (ct->tm_mon + 1) % 10; break;
+ case 0x9: v = (ct->tm_mon + 1) / 10; break;
+ case 0xA: v = ct->tm_year % 10; break;
+ case 0xB: v = (ct->tm_year / 10) & 0x0f; break;
+ case 0xC: v = ct->tm_wday; break;
+ case 0xD: v = clock_control_d; break;
+ case 0xE: v = clock_control_e; break;
+ case 0xF: v = clock_control_f; break;
+ }
}
+ else if (currprefs.cs_rtc == 2) { /* RF5C01A */
+ int bank = clock_control_d & 3;
+ /* memory access */
+ if (bank >= 2 && addr < 0x0d)
+ return (rtc_memory[addr] >> ((bank == 2) ? 0 : 4)) & 0x0f;
+ /* alarm */
+ if (bank == 1 && addr < 0x0d) {
+ v = rtc_alarm[addr];
+#if CLOCK_DEBUG
+ write_log(_T("CLOCK ALARM R %X: %X\n"), addr, v);
+#endif
+ return v;
+ }
+ switch (addr) {
+ case 0x0: v = ct->tm_sec % 10; break;
+ case 0x1: v = ct->tm_sec / 10; break;
+ case 0x2: v = ct->tm_min % 10; break;
+ case 0x3: v = ct->tm_min / 10; break;
+ case 0x4: v = ct->tm_hour % 10; break;
+ case 0x5:
+ if (rtc_alarm[10] & 1)
+ v = ct->tm_hour / 10; // 24h
+ else
+ v = ((ct->tm_hour % 12) / 10) | (ct->tm_hour >= 12 ? 2 : 0); // 12h
+ break;
+ case 0x6: v = ct->tm_wday; break;
+ case 0x7: v = ct->tm_mday % 10; break;
+ case 0x8: v = ct->tm_mday / 10; break;
+ case 0x9: v = (ct->tm_mon + 1) % 10; break;
+ case 0xA: v = (ct->tm_mon + 1) / 10; break;
+ case 0xB: v = (ct->tm_year % 100) % 10; break;
+ case 0xC: v = (ct->tm_year % 100) / 10; break;
+ case 0xD: v = clock_control_d; break;
+ /* E and F = write-only, reads as zero */
+ case 0xE: v = 0; break;
+ case 0xF: v = 0; break;
+ }
+ }
+#if CLOCK_DEBUG
+ write_log(_T("CLOCK R: %X = %X, PC=%08x\n"), addr, v, M68K_GETPC);
+#endif
return v;
}
+static void write_battclock(void)
+{
+ if (!currprefs.rtcfile[0] || currprefs.cs_rtc == 0)
+ return;
+ struct zfile *f = zfile_fopen(currprefs.rtcfile, _T("wb"));
+ if (f) {
+ struct tm *ct;
+ time_t t = time(0);
+ t += currprefs.cs_rtc_adjust;
+ ct = localtime(&t);
+ uae_u8 od = clock_control_d;
+ if (currprefs.cs_rtc == 2)
+ clock_control_d &= ~3;
+ for (int i = 0; i < 13; i++) {
+ uae_u8 v = getclockreg(i, ct);
+ zfile_fwrite(&v, 1, 1, f);
+ }
+ clock_control_d = od;
+ zfile_fwrite(&clock_control_d, 1, 1, f);
+ zfile_fwrite(&clock_control_e, 1, 1, f);
+ zfile_fwrite(&clock_control_f, 1, 1, f);
+ if (currprefs.cs_rtc == 2) {
+ zfile_fwrite(rtc_alarm, RF5C01A_RAM_SIZE, 1, f);
+ zfile_fwrite(rtc_memory, RF5C01A_RAM_SIZE, 1, f);
+ }
+ zfile_fclose(f);
+ }
+}
+
void rtc_hardreset(void)
{
+ rtc_delayed_write = 0;
if (currprefs.cs_rtc == 1 || currprefs.cs_rtc == 3) { /* MSM6242B */
clock_bank.name = currprefs.cs_rtc == 1 ? _T("Battery backed up clock (MSM6242B)") : _T("Battery backed up clock A2000 (MSM6242B)");
- rtc_msm.clock_control_d = 0x1;
- rtc_msm.clock_control_e = 0;
- rtc_msm.clock_control_f = 0x4; /* 24/12 */
- } else if (currprefs.cs_rtc == 2) { /* RF5C01A */
+ clock_control_d = 0x1;
+ clock_control_e = 0;
+ clock_control_f = 0x4; /* 24/12 */
+ }
+ else if (currprefs.cs_rtc == 2) { /* RF5C01A */
clock_bank.name = _T("Battery backed up clock (RF5C01A)");
- rtc_ricoh.clock_control_d = 0x8; /* Timer EN */
- rtc_ricoh.clock_control_e = 0;
- rtc_ricoh.clock_control_f = 0;
- memset (rtc_ricoh.rtc_memory, 0, RF5C01A_RAM_SIZE);
- memset (rtc_ricoh.rtc_alarm, 0, RF5C01A_RAM_SIZE);
- rtc_ricoh.rtc_alarm[10] = 1; /* 24H mode */
+ clock_control_d = 0x8; /* Timer EN */
+ clock_control_e = 0;
+ clock_control_f = 0;
+ memset(rtc_memory, 0, RF5C01A_RAM_SIZE);
+ memset(rtc_alarm, 0, RF5C01A_RAM_SIZE);
+ rtc_alarm[10] = 1; /* 24H mode */
+ }
+ if (currprefs.rtcfile[0]) {
+ struct zfile *f = zfile_fopen(currprefs.rtcfile, _T("rb"));
+ if (f) {
+ uae_u8 empty[13];
+ zfile_fread(empty, 13, 1, f);
+ zfile_fread(&clock_control_d, 1, 1, f);
+ zfile_fread(&clock_control_e, 1, 1, f);
+ zfile_fread(&clock_control_f, 1, 1, f);
+ zfile_fread(rtc_alarm, RF5C01A_RAM_SIZE, 1, f);
+ zfile_fread(rtc_memory, RF5C01A_RAM_SIZE, 1, f);
+ zfile_fclose(f);
+ }
}
}
-static uae_u32 REGPARAM2 clock_lget (uaecptr addr)
+static uae_u32 REGPARAM2 clock_lget(uaecptr addr)
{
if ((addr & 0xffff) >= 0x8000 && currprefs.cs_fatgaryrev >= 0)
return dummy_get(addr, 4, false, 0);
- return (clock_wget (addr) << 16) | clock_wget (addr + 2);
+ return (clock_wget(addr) << 16) | clock_wget(addr + 2);
}
-static uae_u32 REGPARAM2 clock_wget (uaecptr addr)
+static uae_u32 REGPARAM2 clock_wget(uaecptr addr)
{
if ((addr & 0xffff) >= 0x8000 && currprefs.cs_fatgaryrev >= 0)
return dummy_get(addr, 2, false, 0);
- return (clock_bget (addr) << 8) | clock_bget (addr + 1);
+ return (clock_bget(addr) << 8) | clock_bget(addr + 1);
}
-static uae_u32 REGPARAM2 clock_bget (uaecptr addr)
+static uae_u32 REGPARAM2 clock_bget(uaecptr addr)
{
- struct tm *ct;
+ struct tm *ct;
uae_u8 v = 0;
if ((addr & 0xffff) >= 0x8000 && currprefs.cs_fatgaryrev >= 0)
return dummy_get(addr, 1, false, 0);
- addr &= 0x3f;
+#ifdef CDTV
+ if (currprefs.cs_cdtvram && (addr & 0xffff) >= 0x8000)
+ return cdtv_battram_read(addr);
+#endif
+
+ addr &= 0x3f;
if ((addr & 3) == 2 || (addr & 3) == 0 || currprefs.cs_rtc == 0) {
- return dummy_get_safe(addr, 1, false, v);
- }
- time_t t = time(0);
- ct = localtime (&t);
- addr >>= 2;
- return getclockreg (addr, ct);
+ return dummy_get(addr, 1, false, v);
+ }
+ time_t t = time(0);
+ t += currprefs.cs_rtc_adjust;
+ ct = localtime(&t);
+ addr >>= 2;
+ return getclockreg(addr, ct);
}
-static void REGPARAM2 clock_lput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 clock_lput(uaecptr addr, uae_u32 value)
{
if ((addr & 0xffff) >= 0x8000 && currprefs.cs_fatgaryrev >= 0) {
+ dummy_put(addr, 4, value);
return;
}
- clock_wput (addr, value >> 16);
- clock_wput (addr + 2, value);
+ clock_wput(addr, value >> 16);
+ clock_wput(addr + 2, value);
}
-static void REGPARAM2 clock_wput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 clock_wput(uaecptr addr, uae_u32 value)
{
if ((addr & 0xffff) >= 0x8000 && currprefs.cs_fatgaryrev >= 0) {
+ dummy_put(addr, 2, value);
return;
}
- clock_bput (addr, value >> 8);
- clock_bput (addr + 1, value);
+ clock_bput(addr, value >> 8);
+ clock_bput(addr + 1, value);
}
-static void REGPARAM2 clock_bput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 clock_bput(uaecptr addr, uae_u32 value)
{
+ // write_log(_T("W: %x (%x): %x, PC=%08x\n"), addr, (addr & 0xff) >> 2, value & 0xff, M68K_GETPC);
+
if ((addr & 0xffff) >= 0x8000 && currprefs.cs_fatgaryrev >= 0) {
+ dummy_put(addr, 1, value);
return;
}
- addr &= 0x3f;
+#ifdef CDTV
+ if (currprefs.cs_cdtvram && (addr & 0xffff) >= 0x8000) {
+ cdtv_battram_write(addr, value);
+ return;
+ }
+#endif
+
+ addr &= 0x3f;
if ((addr & 1) != 1 || currprefs.cs_rtc == 0)
- return;
- addr >>= 2;
- value &= 0x0f;
+ return;
+ addr >>= 2;
+ value &= 0x0f;
if (currprefs.cs_rtc == 1 || currprefs.cs_rtc == 3) { /* MSM6242B */
- put_clock_msm(&rtc_msm, addr, value);
- } else if (currprefs.cs_rtc == 2) { /* RF5C01A */
- put_clock_ricoh(&rtc_ricoh, addr, value);
+#if CLOCK_DEBUG
+ write_log(_T("CLOCK W %X: %X\n"), addr, value);
+#endif
+ switch (addr)
+ {
+ case 0xD: clock_control_d = value & (1 | 8); break;
+ case 0xE: clock_control_e = value; break;
+ case 0xF: clock_control_f = value; break;
+ }
}
+ else if (currprefs.cs_rtc == 2) { /* RF5C01A */
+ int bank = clock_control_d & 3;
+ /* memory access */
+ if (bank >= 2 && addr < 0x0d) {
+ uae_u8 ov = rtc_memory[addr];
+ rtc_memory[addr] &= ((bank == 2) ? 0xf0 : 0x0f);
+ rtc_memory[addr] |= value << ((bank == 2) ? 0 : 4);
+ if (rtc_memory[addr] != ov)
+ rtc_delayed_write = -1;
+ return;
+ }
+ /* alarm */
+ if (bank == 1 && addr < 0x0d) {
+#if CLOCK_DEBUG
+ write_log(_T("CLOCK ALARM W %X: %X\n"), addr, value);
+#endif
+ uae_u8 ov = rtc_alarm[addr];
+ rtc_alarm[addr] = value;
+ rtc_alarm[0] = rtc_alarm[1] = rtc_alarm[9] = rtc_alarm[12] = 0;
+ rtc_alarm[3] &= ~0x8;
+ rtc_alarm[5] &= ~0xc;
+ rtc_alarm[6] &= ~0x8;
+ rtc_alarm[8] &= ~0xc;
+ rtc_alarm[10] &= ~0xe;
+ rtc_alarm[11] &= ~0xc;
+ if (rtc_alarm[addr] != ov)
+ rtc_delayed_write = -1;
+ return;
+ }
+#if CLOCK_DEBUG
+ write_log(_T("CLOCK W %X: %X\n"), addr, value);
+#endif
+ switch (addr)
+ {
+ case 0xD: clock_control_d = value; break;
+ case 0xE: clock_control_e = value; break;
+ case 0xF: clock_control_f = value; break;
+ }
+ }
+ rtc_delayed_write = -1;
}
#ifdef SAVESTATE
/* CIA-A and CIA-B save/restore code */
-static void save_cia_prepare (void)
+static void save_cia_prepare(void)
{
- CIA_update_check ();
- CIA_calctimers ();
- compute_passed_time ();
+ CIA_update_check();
+ CIA_calctimers();
+ compute_passed_time();
}
-void restore_cia_start (void)
+void restore_cia_start(void)
{
/* Fixes very old statefiles without keyboard state */
kbstate = 3;
+ setcapslockstate(0);
kblostsynccnt = 0;
}
-void restore_cia_finish (void)
+void restore_cia_finish(void)
{
- eventtab[ev_cia].oldcycles = get_cycles ();
- CIA_update ();
- CIA_calctimers ();
- compute_passed_time ();
+ eventtab[ev_cia].oldcycles = get_cycles();
+ CIA_update();
+ CIA_calctimers();
+ compute_passed_time();
eventtab[ev_cia].oldcycles -= div10;
- DISK_select_set (ciabprb);
+ //dumpcia ();
+ DISK_select_set(ciabprb);
}
-uae_u8 *restore_cia (int num, uae_u8 *src)
+uae_u8 *restore_cia(int num, uae_u8 *src)
{
- uae_u8 b;
- uae_u16 w;
- uae_u32 l;
+ uae_u8 b;
+ uae_u16 w;
+ uae_u32 l;
- /* CIA registers */
- b = restore_u8 (); /* 0 PRA */
- if (num) ciabpra = b; else ciaapra = b;
- b = restore_u8 (); /* 1 PRB */
- if (num) ciabprb = b; else ciaaprb = b;
- b = restore_u8 (); /* 2 DDRA */
- if (num) ciabdra = b; else ciaadra = b;
- b = restore_u8 (); /* 3 DDRB */
- if (num) ciabdrb = b; else ciaadrb = b;
- w = restore_u16 (); /* 4 TA */
- if (num) ciabta = w; else ciaata = w;
- w = restore_u16 (); /* 6 TB */
- if (num) ciabtb = w; else ciaatb = w;
- l = restore_u8 (); /* 8/9/A TOD */
- l |= restore_u8 () << 8;
- l |= restore_u8 () << 16;
- if (num) ciabtod = l; else ciaatod = l;
- restore_u8 (); /* B unused */
- b = restore_u8 (); /* C SDR */
- if (num) ciabsdr = b; else ciaasdr = b;
- b = restore_u8 (); /* D ICR INFORMATION (not mask!) */
- if (num) ciabicr = b; else ciaaicr = b;
- b = restore_u8 (); /* E CRA */
- if (num) ciabcra = b; else ciaacra = b;
- b = restore_u8 (); /* F CRB */
- if (num) ciabcrb = b; else ciaacrb = b;
+ /* CIA registers */
+ b = restore_u8(); /* 0 PRA */
+ if (num) ciabpra = b; else ciaapra = b;
+ b = restore_u8(); /* 1 PRB */
+ if (num) ciabprb = b; else ciaaprb = b;
+ b = restore_u8(); /* 2 DDRA */
+ if (num) ciabdra = b; else ciaadra = b;
+ b = restore_u8(); /* 3 DDRB */
+ if (num) ciabdrb = b; else ciaadrb = b;
+ w = restore_u16(); /* 4 TA */
+ if (num) ciabta = w; else ciaata = w;
+ w = restore_u16(); /* 6 TB */
+ if (num) ciabtb = w; else ciaatb = w;
+ l = restore_u8(); /* 8/9/A TOD */
+ l |= restore_u8() << 8;
+ l |= restore_u8() << 16;
+ if (num) ciabtod = l; else ciaatod = l;
+ restore_u8(); /* B unused */
+ b = restore_u8(); /* C SDR */
+ if (num) ciabsdr = b; else ciaasdr = b;
+ b = restore_u8(); /* D ICR INFORMATION (not mask!) */
+ if (num) ciabicr = b; else ciaaicr = b;
+ b = restore_u8(); /* E CRA */
+ if (num) ciabcra = b; else ciaacra = b;
+ b = restore_u8(); /* F CRB */
+ if (num) ciabcrb = b; else ciaacrb = b;
- /* CIA internal data */
+ /* CIA internal data */
- b = restore_u8 (); /* ICR MASK */
- if (num) ciabimask = b; else ciaaimask = b;
- w = restore_u8 (); /* timer A latch */
- w |= restore_u8 () << 8;
- if (num) ciabla = w; else ciaala = w;
- w = restore_u8 (); /* timer B latch */
- w |= restore_u8 () << 8;
- if (num) ciablb = w; else ciaalb = w;
- w = restore_u8 (); /* TOD latched value */
- w |= restore_u8 () << 8;
- w |= restore_u8 () << 16;
- if (num) ciabtol = w; else ciaatol = w;
- l = restore_u8 (); /* alarm */
- l |= restore_u8 () << 8;
- l |= restore_u8 () << 16;
- if (num) ciabalarm = l; else ciaaalarm = l;
- b = restore_u8 ();
- if (num) ciabtlatch = b & 1; else ciaatlatch = b & 1; /* is TOD latched? */
- if (num) ciabtodon = b & 2; else ciaatodon = b & 2; /* is TOD stopped? */
- b = restore_u8 ();
- if (num)
- div10 = CYCLE_UNIT * b;
- b = restore_u8 ();
- if (num) ciabsdr_cnt = b; else ciaasdr_cnt = b;
- return src;
+ b = restore_u8(); /* ICR MASK */
+ if (num) ciabimask = b; else ciaaimask = b;
+ w = restore_u8(); /* timer A latch */
+ w |= restore_u8() << 8;
+ if (num) ciabla = w; else ciaala = w;
+ w = restore_u8(); /* timer B latch */
+ w |= restore_u8() << 8;
+ if (num) ciablb = w; else ciaalb = w;
+ w = restore_u8(); /* TOD latched value */
+ w |= restore_u8() << 8;
+ w |= restore_u8() << 16;
+ if (num) ciabtol = w; else ciaatol = w;
+ l = restore_u8(); /* alarm */
+ l |= restore_u8() << 8;
+ l |= restore_u8() << 16;
+ if (num) ciabalarm = l; else ciaaalarm = l;
+ b = restore_u8();
+ if (num) ciabtlatch = b & 1; else ciaatlatch = b & 1; /* is TOD latched? */
+ if (num) ciabtodon = b & 2; else ciaatodon = b & 2; /* is TOD stopped? */
+ b = restore_u8();
+ if (num)
+ div10 = CYCLE_UNIT * b;
+ b = restore_u8();
+ if (num) ciabsdr_cnt = b; else ciaasdr_cnt = b;
+ return src;
}
-uae_u8 *save_cia (int num, int *len, uae_u8 *dstptr)
+uae_u8 *save_cia(int num, int *len, uae_u8 *dstptr)
{
- uae_u8 *dstbak,*dst, b;
- uae_u16 t;
+ uae_u8 *dstbak, *dst, b;
+ uae_u16 t;
- if (dstptr)
- dstbak = dst = dstptr;
- else
- dstbak = dst = xmalloc (uae_u8, 100);
+ if (dstptr)
+ dstbak = dst = dstptr;
+ else
+ dstbak = dst = xmalloc(uae_u8, 1000);
- save_cia_prepare ();
+ save_cia_prepare();
- /* CIA registers */
+ /* CIA registers */
- b = num ? ciabpra : ciaapra; /* 0 PRA */
- save_u8 (b);
- b = num ? ciabprb : ciaaprb; /* 1 PRB */
- save_u8 (b);
- b = num ? ciabdra : ciaadra; /* 2 DDRA */
- save_u8 (b);
- b = num ? ciabdrb : ciaadrb; /* 3 DDRB */
- save_u8 (b);
- t = (num ? ciabta - ciabta_passed : ciaata - ciaata_passed);/* 4 TA */
- save_u16 (t);
- t = (num ? ciabtb - ciabtb_passed : ciaatb - ciaatb_passed);/* 6 TB */
- save_u16 (t);
- b = (num ? ciabtod : ciaatod); /* 8 TODL */
- save_u8 (b);
- b = (num ? ciabtod >> 8 : ciaatod >> 8); /* 9 TODM */
- save_u8 (b);
- b = (num ? ciabtod >> 16 : ciaatod >> 16); /* A TODH */
- save_u8 (b);
- save_u8 (0); /* B unused */
- b = num ? ciabsdr : ciaasdr; /* C SDR */
- save_u8 (b);
- b = num ? ciabicr : ciaaicr; /* D ICR INFORMATION (not mask!) */
- save_u8 (b);
- b = num ? ciabcra : ciaacra; /* E CRA */
- save_u8 (b);
- b = num ? ciabcrb : ciaacrb; /* F CRB */
- save_u8 (b);
+ b = num ? ciabpra : ciaapra; /* 0 PRA */
+ save_u8(b);
+ b = num ? ciabprb : ciaaprb; /* 1 PRB */
+ save_u8(b);
+ b = num ? ciabdra : ciaadra; /* 2 DDRA */
+ save_u8(b);
+ b = num ? ciabdrb : ciaadrb; /* 3 DDRB */
+ save_u8(b);
+ t = (num ? ciabta - ciabta_passed : ciaata - ciaata_passed);/* 4 TA */
+ save_u16(t);
+ t = (num ? ciabtb - ciabtb_passed : ciaatb - ciaatb_passed);/* 6 TB */
+ save_u16(t);
+ b = (num ? ciabtod : ciaatod); /* 8 TODL */
+ save_u8(b);
+ b = (num ? ciabtod >> 8 : ciaatod >> 8); /* 9 TODM */
+ save_u8(b);
+ b = (num ? ciabtod >> 16 : ciaatod >> 16); /* A TODH */
+ save_u8(b);
+ save_u8(0); /* B unused */
+ b = num ? ciabsdr : ciaasdr; /* C SDR */
+ save_u8(b);
+ b = num ? ciabicr : ciaaicr; /* D ICR INFORMATION (not mask!) */
+ save_u8(b);
+ b = num ? ciabcra : ciaacra; /* E CRA */
+ save_u8(b);
+ b = num ? ciabcrb : ciaacrb; /* F CRB */
+ save_u8(b);
- /* CIA internal data */
+ /* CIA internal data */
- save_u8 (num ? ciabimask : ciaaimask); /* ICR */
- b = (num ? ciabla : ciaala); /* timer A latch LO */
- save_u8 (b);
- b = (num ? ciabla >> 8 : ciaala >> 8); /* timer A latch HI */
- save_u8 (b);
- b = (num ? ciablb : ciaalb); /* timer B latch LO */
- save_u8 (b);
- b = (num ? ciablb >> 8 : ciaalb >> 8); /* timer B latch HI */
- save_u8 (b);
- b = (num ? ciabtol : ciaatol); /* latched TOD LO */
- save_u8 (b);
- b = (num ? ciabtol >> 8 : ciaatol >> 8); /* latched TOD MED */
- save_u8 (b);
- b = (num ? ciabtol >> 16 : ciaatol >> 16); /* latched TOD HI */
- save_u8 (b);
- b = (num ? ciabalarm : ciaaalarm); /* alarm LO */
- save_u8 (b);
- b = (num ? ciabalarm >> 8 : ciaaalarm >>8 ); /* alarm MED */
- save_u8 (b);
- b = (num ? ciabalarm >> 16 : ciaaalarm >> 16); /* alarm HI */
- save_u8 (b);
- b = 0;
- if (num)
- b |= ciabtlatch ? 1 : 0;
- else
- b |= ciaatlatch ? 1 : 0; /* is TOD latched? */
- if (num)
- b |= ciabtodon ? 2 : 0;
- else
- b |= ciaatodon ? 2 : 0; /* TOD stopped? */
- save_u8 (b);
- save_u8 (num ? div10 / CYCLE_UNIT : 0);
- save_u8 (num ? ciabsdr_cnt : ciaasdr_cnt);
- *len = dst - dstbak;
- return dstbak;
+ save_u8(num ? ciabimask : ciaaimask); /* ICR */
+ b = (num ? ciabla : ciaala); /* timer A latch LO */
+ save_u8(b);
+ b = (num ? ciabla >> 8 : ciaala >> 8); /* timer A latch HI */
+ save_u8(b);
+ b = (num ? ciablb : ciaalb); /* timer B latch LO */
+ save_u8(b);
+ b = (num ? ciablb >> 8 : ciaalb >> 8); /* timer B latch HI */
+ save_u8(b);
+ b = (num ? ciabtol : ciaatol); /* latched TOD LO */
+ save_u8(b);
+ b = (num ? ciabtol >> 8 : ciaatol >> 8); /* latched TOD MED */
+ save_u8(b);
+ b = (num ? ciabtol >> 16 : ciaatol >> 16); /* latched TOD HI */
+ save_u8(b);
+ b = (num ? ciabalarm : ciaaalarm); /* alarm LO */
+ save_u8(b);
+ b = (num ? ciabalarm >> 8 : ciaaalarm >> 8);/* alarm MED */
+ save_u8(b);
+ b = (num ? ciabalarm >> 16 : ciaaalarm >> 16); /* alarm HI */
+ save_u8(b);
+ b = 0;
+ if (num)
+ b |= ciabtlatch ? 1 : 0;
+ else
+ b |= ciaatlatch ? 1 : 0; /* is TOD latched? */
+ if (num)
+ b |= ciabtodon ? 2 : 0;
+ else
+ b |= ciaatodon ? 2 : 0; /* TOD stopped? */
+ save_u8(b);
+ save_u8(num ? div10 / CYCLE_UNIT : 0);
+ save_u8(num ? ciabsdr_cnt : ciaasdr_cnt);
+ *len = dst - dstbak;
+ return dstbak;
}
-uae_u8 *save_keyboard (int *len, uae_u8 *dstptr)
+uae_u8 *save_keyboard(int *len, uae_u8 *dstptr)
{
uae_u8 *dst, *dstbak;
if (dstptr)
dstbak = dst = dstptr;
else
- dstbak = dst = xmalloc (uae_u8, 4 + 4 + 1 + 1 + 1 + 1 + 1 + 2);
- save_u32 (1);
- save_u8 (kbstate);
- save_u8 (0);
- save_u8 (0);
- save_u8 (0);
- save_u8 (kbcode);
- save_u16 (kblostsynccnt);
+ dstbak = dst = xmalloc(uae_u8, 4 + 4 + 1 + 1 + 1 + 1 + 1 + 2);
+ save_u32(getcapslockstate() ? 1 : 0);
+ save_u32(1);
+ save_u8(kbstate);
+ save_u8(0);
+ save_u8(0);
+ save_u8(0);
+ save_u8(kbcode);
+ save_u16(kblostsynccnt);
*len = dst - dstbak;
return dstbak;
}
-uae_u8 *restore_keyboard (uae_u8 *src)
+uae_u8 *restore_keyboard(uae_u8 *src)
{
- uae_u32 v = restore_u32 ();
- kbstate = restore_u8 ();
- restore_u8 ();
- restore_u8 ();
- restore_u8 ();
- kbcode = restore_u8 ();
- kblostsynccnt = restore_u16 ();
+ setcapslockstate(restore_u32() & 1);
+ uae_u32 v = restore_u32();
+ kbstate = restore_u8();
+ restore_u8();
+ restore_u8();
+ restore_u8();
+ kbcode = restore_u8();
+ kblostsynccnt = restore_u16();
if (!(v & 1)) {
kbstate = 3;
kblostsynccnt = 0;
}
- return src;
+ return src;
}
#endif /* SAVESTATE */
diff --git a/src/custom.cpp b/src/custom.cpp
index 979d7efb..c19bf2d7 100644
--- a/src/custom.cpp
+++ b/src/custom.cpp
@@ -1,19 +1,18 @@
- /*
-* UAE - The Un*x Amiga Emulator
-*
-* Custom chip emulation
-*
-* Copyright 1995-2002 Bernd Schmidt
-* Copyright 1995 Alessandro Bissacco
-* Copyright 2000-2015 Toni Wilen
-*/
+/*
+ * UAE - The Un*x Amiga Emulator
+ *
+ * Custom chip emulation
+ *
+ * Copyright 1995-2002 Bernd Schmidt
+ * Copyright 1995 Alessandro Bissacco
+ * Copyright 2000-2010 Toni Wilen
+ */
#include "sysconfig.h"
#include "sysdeps.h"
#include
#include
-#include
#include "options.h"
#include "uae.h"
@@ -29,162 +28,240 @@
#include "blitter.h"
#include "xwin.h"
#include "inputdevice.h"
+#include "keybuf.h"
#include "autoconf.h"
#include "traps.h"
#include "gui.h"
#include "picasso96.h"
#include "drawing.h"
-#include "ar.h"
#include "akiko.h"
-#include "devices.h"
+#include "gfxboard.h"
+#include "blkdev.h"
+#include "clipboard.h"
+#include "amiberry_gfx.h"
+#include "rommgr.h"
+#define CUSTOM_DEBUG 0
+#define SPRITE_DEBUG 0
+#define SPRITE_DEBUG_MINY 0
+#define SPRITE_DEBUG_MAXY 0x300
#define SPR0_HPOS 0x15
#define MAX_SPRITES 8
+#define SPRITE_COLLISIONS
+#define SPEEDUP 1
+#define AUTOSCALE_SPRITES 1
-#define nocustom() (picasso_on)
+#define SPRBORDER 0
-static void uae_abort (const TCHAR *format,...)
+STATIC_INLINE bool nocustom(void)
+{
+ if (picasso_on && currprefs.picasso96_nocustom)
+ return true;
+ return false;
+}
+
+static void uae_abort(const TCHAR *format, ...)
{
static int nomore;
va_list parms;
TCHAR buffer[1000];
- va_start (parms, format);
- _vsntprintf (buffer, sizeof (buffer) - 1, format, parms );
- va_end (parms);
+ va_start(parms, format);
+ _vsntprintf(buffer, sizeof(buffer) - 1, format, parms);
+ va_end(parms);
if (nomore) {
- write_log (_T("%s\n"), buffer);
+ write_log(_T("%s\n"), buffer);
return;
}
- gui_message (buffer);
+ gui_message(buffer);
nomore = 1;
}
-#define SPEEDUP_CYCLES_JIT 5000
-#define SPEEDUP_CYCLES_NONJIT 256
-#define SPEEDUP_TIMELIMIT_JIT -750
-#define SPEEDUP_TIMELIMIT_NONJIT -750
-int pissoff_value = SPEEDUP_CYCLES_JIT * CYCLE_UNIT;
-int speedup_timelimit = SPEEDUP_TIMELIMIT_JIT;
+static unsigned int n_consecutive_skipped = 0;
+static unsigned int total_skipped = 0;
+
+extern int cpu_last_stop_vpos, cpu_stopped_lines;
+static int cpu_sleepmode, cpu_sleepmode_cnt;
+
+STATIC_INLINE void sync_copper(int hpos);
/* Events */
+unsigned long int vsync_cycles;
+static int extra_cycle;
+
static int rpt_did_reset;
struct ev eventtab[ev_max];
struct ev2 eventtab2[ev2_max];
+int hpos_offset;
int vpos;
static int vpos_count, vpos_count_diff;
-static int lof_store; // real bit in custom registers
+int lof_store; // real bit in custom registers
static int lof_current; // what display device thinks
static bool lof_lastline, lof_prev_lastline;
+static int lol;
static int next_lineno, prev_lineno;
+static enum nln_how nextline_how;
static int lof_changed = 0, lof_changing = 0, interlace_changed = 0;
static int lof_changed_previous_field;
static int vposw_change;
static bool lof_lace;
+static bool bplcon0_interlace_seen;
+static int scandoubled_line;
static bool vsync_rendered, frame_rendered, frame_shown;
static int vsynctimeperline;
static int frameskiptime;
+static bool genlockhtoggle;
+static bool genlockvtoggle;
+static bool graphicsbuffer_retry;
+static int scanlinecount;
static int cia_hsync;
#define LOF_TOGGLES_NEEDED 3
+
static int lof_togglecnt_lace, lof_togglecnt_nlace;
+/* Stupid genlock-detection prevention hack.
+* We should stop calling vsync_handler() and
+* hstop_handler() completely but it is not
+* worth the trouble..
+*/
static int vpos_previous, hpos_previous;
+static int vpos_lpen, hpos_lpen, lightpen_triggered;
+int lightpen_x = -1, lightpen_y = -1, lightpen_cx, lightpen_cy, lightpen_active, lightpen_enabled;
-static uae_u32 sprtaba[256],sprtabb[256];
+static uae_u32 sprtaba[256], sprtabb[256];
static uae_u32 sprite_ab_merge[256];
-
/* Tables for collision detection. */
static uae_u32 sprclx[16], clxmask[16];
+/* T genlock bit in ECS Denise and AGA color registers */
+static uae_u8 color_regs_genlock[256];
+
/*
* Hardware registers of all sorts.
*/
-static int REGPARAM3 custom_wput_1 (int, uaecptr, uae_u32, int) REGPARAM;
+static int REGPARAM3 custom_wput_1(int, uaecptr, uae_u32, int) REGPARAM;
-static uae_u16 intena;
-uae_u16 intreq;
+static uae_u16 cregs[256];
+
+uae_u16 intena, intreq;
uae_u16 dmacon;
uae_u16 adkcon; /* used by audio code */
uae_u32 last_custom_value1;
-static uae_u32 cop1lc,cop2lc,copcon;
-
+static uae_u32 cop1lc, cop2lc, copcon;
+
int maxhpos = MAXHPOS_PAL;
+int maxhpos_short = MAXHPOS_PAL;
int maxvpos = MAXVPOS_PAL;
int maxvpos_nom = MAXVPOS_PAL; // nominal value (same as maxvpos but "faked" maxvpos in fake 60hz modes)
int maxvpos_display = MAXVPOS_PAL; // value used for display size
int hsyncendpos, hsyncstartpos;
static int maxvpos_total = 511;
int minfirstline = VBLANK_ENDLINE_PAL;
+int firstblankedline;
static int equ_vblank_endline = EQU_ENDLINE_PAL;
static bool equ_vblank_toggle = true;
-float vblank_hz = VBLANK_HZ_PAL, fake_vblank_hz, vblank_hz_nom;
-float hblank_hz;
+double vblank_hz = VBLANK_HZ_PAL, fake_vblank_hz, vblank_hz_stored, vblank_hz_nom;
+double hblank_hz;
static float vblank_hz_lof, vblank_hz_shf, vblank_hz_lace;
+static int vblank_hz_mult, vblank_hz_state;
static struct chipset_refresh *stored_chipset_refresh;
+int doublescan;
+bool programmedmode;
int syncbase;
static int fmode_saved, fmode;
-static uae_u16 beamcon0, new_beamcon0;
+uae_u16 beamcon0, new_beamcon0;
static bool varsync_changed;
-static uae_u16 vtotal = MAXVPOS_PAL, htotal = MAXHPOS_PAL;
+uae_u16 vtotal = MAXVPOS_PAL, htotal = MAXHPOS_PAL;
+static int maxvpos_stored, maxhpos_stored;
static uae_u16 hsstop, hbstrt, hbstop, vsstop, vbstrt, vbstop, hsstrt, vsstrt, hcenter;
+static int ciavsyncmode;
static int diw_hstrt, diw_hstop;
static int diw_hcounter;
+static uae_u16 refptr;
+static uae_u32 refptr_val;
#define HSYNCTIME (maxhpos * CYCLE_UNIT)
struct sprite {
- uaecptr pt;
- int xpos;
- int vstart;
- int vstop;
+ uaecptr pt;
+ int xpos;
+ int vstart;
+ int vstop;
int dblscan; /* AGA SSCAN2 */
- int armed;
- int dmastate;
- int dmacycle;
+ int armed;
+ int dmastate;
+ int dmacycle;
+ int ptxhpos;
+ int ptxhpos2, ptxvpos2;
+ bool ignoreverticaluntilnextline;
};
static struct sprite spr[MAX_SPRITES];
static int plfstrt_sprite;
+static bool sprite_ignoreverticaluntilnextline;
+
+uaecptr sprite_0;
+int sprite_0_width, sprite_0_height, sprite_0_doubled;
+uae_u32 sprite_0_colors[4];
+static uae_u8 magic_sprite_mask = 0xff;
static int sprite_vblank_endline = VBLANK_SPRITE_PAL;
static uae_u16 sprctl[MAX_SPRITES], sprpos[MAX_SPRITES];
+#ifdef AGA
static uae_u16 sprdata[MAX_SPRITES][4], sprdatb[MAX_SPRITES][4];
+#else
+static uae_u16 sprdata[MAX_SPRITES][1], sprdatb[MAX_SPRITES][1];
+#endif
+static int sprite_last_drawn_at[MAX_SPRITES];
static int last_sprite_point, nr_armed;
static int sprite_width, sprres;
+static int sprite_sprctlmask;
int sprite_buffer_res;
+#ifdef CPUEMU_13
+uae_u8 cycle_line[256 + 1];
+#endif
+
static bool bpl1dat_written, bpl1dat_written_at_least_once;
static bool bpldmawasactive;
static uae_s16 bpl1mod, bpl2mod, dbpl1mod, dbpl2mod;
static int dbpl1mod_on, dbpl2mod_on;
-static uaecptr bplpt[8];
+static uaecptr prevbpl[2][MAXVPOS][8];
+static uaecptr bplpt[8], bplptx[8];
+
+static int bitplane_line_crossing;
static struct color_entry current_colors;
-static unsigned int bplcon0;
+unsigned int bplcon0;
static unsigned int bplcon1, bplcon2, bplcon3, bplcon4;
static unsigned int bplcon0d, bplcon0dd, bplcon0_res, bplcon0_planes, bplcon0_planes_limit;
static unsigned int diwstrt, diwstop, diwhigh;
static int diwhigh_written;
static unsigned int ddfstrt, ddfstop;
-static int line_cyclebased, badmode;
+static int line_cyclebased, badmode, diw_change;
+static int bplcon1_fetch;
+static int hpos_is_zero_bplcon1_hack = -1;
#define SET_LINE_CYCLEBASED line_cyclebased = 2;
/* The display and data fetch windows */
-
enum diw_states
{
DIW_waiting_start, DIW_waiting_stop
};
static int plffirstline, plflastline;
+int plffirstline_total, plflastline_total;
+static int autoscale_bordercolors;
static int plfstrt, plfstop;
static int sprite_minx, sprite_maxx;
+static int first_bpl_vpos;
+static int last_ddf_pix_hpos;
static int last_decide_line_hpos;
static int last_fetch_hpos, last_sprite_hpos;
static int diwfirstword, diwlastword;
@@ -192,6 +269,16 @@ static int last_hdiw;
static enum diw_states diwstate, hdiwstate, ddfstate;
static int bpl_hstart;
+int first_planes_vpos, last_planes_vpos;
+static int first_bplcon0, first_bplcon0_old;
+static int first_planes_vpos_old, last_planes_vpos_old;
+int diwfirstword_total, diwlastword_total;
+int ddffirstword_total, ddflastword_total;
+static int diwfirstword_total_old, diwlastword_total_old;
+static int ddffirstword_total_old, ddflastword_total_old;
+bool vertical_changed, horizontal_changed;
+int firstword_bplcon1;
+
static int last_copper_hpos;
static int copper_access;
@@ -199,18 +286,18 @@ static int copper_access;
static unsigned int clxdat, clxcon, clxcon2, clxcon_bpl_enable, clxcon_bpl_match;
enum copper_states {
- COP_stop,
+ COP_stop,
COP_waitforever,
- COP_read1,
- COP_read2,
- COP_bltwait,
- COP_wait_in2,
- COP_skip_in2,
- COP_wait1,
- COP_wait,
- COP_skip1,
- COP_strobe_delay1,
- COP_strobe_delay2,
+ COP_read1,
+ COP_read2,
+ COP_bltwait,
+ COP_wait_in2,
+ COP_skip_in2,
+ COP_wait1,
+ COP_wait,
+ COP_skip1,
+ COP_strobe_delay1,
+ COP_strobe_delay2,
COP_strobe_delay1x,
COP_strobe_delay2x,
COP_strobe_extra, // just to skip current cycle when CPU wrote to COPJMP
@@ -218,71 +305,66 @@ enum copper_states {
};
struct copper {
- /* The current instruction words. */
- unsigned int i1, i2;
- enum copper_states state, state_prev;
- /* Instruction pointer. */
- uaecptr ip;
- int hpos;
- unsigned int ignore_next;
- int vcmp, hcmp;
+ /* The current instruction words. */
+ unsigned int i1, i2;
+ unsigned int saved_i1, saved_i2;
+ enum copper_states state, state_prev;
+ /* Instruction pointer. */
+ uaecptr ip, saved_ip;
+ int hpos, vpos;
+ unsigned int ignore_next;
+ int vcmp, hcmp;
- /* When we schedule a copper event, knowing a few things about the future
- of the copper list can reduce the number of sync_with_cpu calls
- dramatically. */
- unsigned int first_sync;
- unsigned int regtypes_modified;
-
- int strobe; /* COPJMP1 / COPJMP2 accessed */
- int moveaddr, movedata, movedelay;
+ int strobe; /* COPJMP1 / COPJMP2 accessed */
+ int moveaddr, movedata, movedelay;
};
-#define REGTYPE_NONE 0
-#define REGTYPE_COLOR 1
-#define REGTYPE_SPRITE 2
-#define REGTYPE_PLANE 4
-#define REGTYPE_BLITTER 8
-#define REGTYPE_JOYPORT 16
-#define REGTYPE_DISK 32
-#define REGTYPE_POS 64
-#define REGTYPE_AUDIO 128
-
-#define REGTYPE_ALL 255
-/* Always set in regtypes_modified, to enable a forced update when things like
- DMACON, BPLCON0, COPJMPx get written. */
-#define REGTYPE_FORCE 256
-
-static unsigned int regtypes[512];
-
static struct copper cop_state;
static int copper_enabled_thisline;
+static int cop_min_waittime;
/*
- * Statistics
- */
-static unsigned long lastframetime = 0;
-unsigned long timeframes = 0;
-unsigned long hsync_counter = 0;
+* Statistics
+*/
+unsigned long int frametime = 0, lastframetime = 0, timeframes = 0;
+unsigned long hsync_counter = 0, vsync_counter = 0;
unsigned long int idletime;
+int bogusframe;
/* Recording of custom chip register changes. */
-struct sprite_entry *curr_sprite_entries = 0;
-struct color_change *curr_color_changes = 0;
+static int current_change_set;
+static struct sprite_entry sprite_entries[2][MAX_SPR_PIXELS / 16];
+static struct color_change color_changes[2][MAX_REG_CHANGE];
struct decision line_decisions[2 * (MAXVPOS + 2) + 1];
-struct draw_info curr_drawinfo[2 * (MAXVPOS + 2) + 1];
+static struct draw_info line_drawinfo[2][2 * (MAXVPOS + 2) + 1];
#define COLOR_TABLE_SIZE (MAXVPOS + 2) * 2
-struct color_entry curr_color_tables[COLOR_TABLE_SIZE];
+static struct color_entry color_tables[2][COLOR_TABLE_SIZE];
static int next_sprite_entry = 0;
+static int prev_next_sprite_entry;
static int next_sprite_forced = 1;
+struct sprite_entry *curr_sprite_entries, *prev_sprite_entries;
+struct color_change *curr_color_changes, *prev_color_changes;
+struct draw_info *curr_drawinfo, *prev_drawinfo;
+struct color_entry *curr_color_tables, *prev_color_tables;
+
static int next_color_change;
static int next_color_entry, remembered_color_entry;
+static int color_src_match, color_dest_match, color_compare_result;
+
+static uae_u32 thisline_changed;
+
+#ifdef SMART_UPDATE
+#define MARK_LINE_CHANGED do { thisline_changed = 1; } while (0)
+#else
+#define MARK_LINE_CHANGED do { ; } while (0)
+#endif
static struct decision thisline_decision;
static int fetch_cycle, fetch_modulo_cycle;
-static int aga_plf_passed_stop2;
+static bool aga_plf_passed_stop2;
static int plf_start_hpos, plf_end_hpos;
static int ddfstop_written_hpos;
static int bitplane_off_delay;
@@ -290,10 +372,12 @@ static bool ocs_agnus_ddf_enable_toggle;
static int bpl_dma_off_when_active;
static int bitplane_maybe_start_hpos;
static bool ddfstop_matched;
+static int bitplane_overrun, bitplane_overrun_hpos;
+static int bitplane_overrun_fetch_cycle, bitplane_overrun_cycle_diagram_shift;
enum plfstate
{
- plf_idle,
+ plf_idle,
// enable passed
plf_passed_enable,
// ddfstrt match
@@ -320,10 +404,10 @@ enum plfrenderstate
} plfr_state;
enum fetchstate {
- fetch_not_started,
+ fetch_not_started,
fetch_started_first,
- fetch_started,
- fetch_was_plane0
+ fetch_started,
+ fetch_was_plane0
} fetch_state;
/*
@@ -335,119 +419,206 @@ STATIC_INLINE int ecsshres(void)
return bplcon0_res == RES_SUPERHIRES && (currprefs.chipset_mask & CSMASK_ECS_DENISE) && !(currprefs.chipset_mask & CSMASK_AGA);
}
-#define nodraw() (framecnt != 0)
-
-void set_speedup_values(void)
+STATIC_INLINE int nodraw(void)
{
- if(currprefs.m68k_speed < 0) {
- if (currprefs.cachesize) {
- pissoff_value = SPEEDUP_CYCLES_JIT * CYCLE_UNIT;
- speedup_timelimit = SPEEDUP_TIMELIMIT_JIT;
- } else {
- pissoff_value = SPEEDUP_CYCLES_NONJIT * CYCLE_UNIT;
- speedup_timelimit = SPEEDUP_TIMELIMIT_NONJIT;
- }
- } else {
- pissoff_value = 0;
- speedup_timelimit = 0;
- }
+ //return !currprefs.cpu_memory_cycle_exact && framecnt != 0;
+ return framecnt != 0;
}
-void reset_frame_rate_hack (void)
+static int doflickerfix(void)
{
- if (currprefs.m68k_speed >= 0)
- return;
+ return currprefs.gfx_vresolution && doublescan < 0 && vpos < MAXVPOS;
+}
- rpt_did_reset = 1;
+uae_u32 get_copper_address(int copno)
+{
+ switch (copno) {
+ case 1: return cop1lc;
+ case 2: return cop2lc;
+ case -1: return cop_state.ip;
+ default: return 0;
+ }
+}
+
+void reset_frame_rate_hack(void)
+{
+ if (currprefs.m68k_speed >= 0)
+ return;
+
+ rpt_did_reset = 1;
is_syncline = 0;
- vsyncmintime = read_processor_time() + vsynctimebase;
- write_log (_T("Resetting frame rate hack\n"));
+ vsyncmintime = read_processor_time() + vsynctimebase;
+ write_log(_T("Resetting frame rate hack\n"));
}
-STATIC_INLINE void setclr (uae_u16 *p, uae_u16 val)
+STATIC_INLINE void setclr(uae_u16 *p, uae_u16 val)
{
- if (val & 0x8000)
- *p |= val & 0x7FFF;
- else
- *p &= ~val;
+ if (val & 0x8000)
+ *p |= val & 0x7FFF;
+ else
+ *p &= ~val;
}
-STATIC_INLINE void set_chipset_mode(void)
+STATIC_INLINE void alloc_cycle(int hpos, int type)
+{
+#ifdef CPUEMU_13
+ cycle_line[hpos] = type;
+#endif
+}
+STATIC_INLINE void alloc_cycle_maybe(int hpos, int type)
+{
+#ifdef CPUEMU_13
+ if ((cycle_line[hpos] & CYCLE_MASK) == 0)
+ alloc_cycle(hpos, type);
+#endif
+}
+
+void alloc_cycle_ext(int hpos, int type)
+{
+ alloc_cycle(hpos, type);
+}
+
+void alloc_cycle_blitter(int hpos, uaecptr *ptr, int chnum)
+{
+#ifdef CPUEMU_13
+ if (cycle_line[hpos] & CYCLE_COPPER_SPECIAL) {
+ static int warned = 100;
+ uaecptr srcptr = cop_state.strobe == 1 ? cop1lc : cop2lc;
+ if (warned > 0) {
+ write_log(_T("buggy copper cycle conflict with blitter ch %c %08x <- %08x PC=%08x\n"), 'A' + (chnum - 1), *ptr, srcptr, m68k_getpc());
+ warned--;
+ //activate_debugger ();
+ }
+ if ((currprefs.cs_hacks & 1) && currprefs.cpu_model == 68000)
+ *ptr = srcptr;
+ }
+#endif
+ alloc_cycle(hpos, CYCLE_BLITTER);
+}
+
+static void set_chipset_mode(void)
{
if (currprefs.chipset_mask & CSMASK_AGA) {
fmode = fmode_saved;
- } else {
+ }
+ else {
fmode = 0;
}
- sprite_width = GET_SPRITEWIDTH (fmode);
+ sprite_width = GET_SPRITEWIDTH(fmode);
}
static void update_mirrors(void)
{
- aga_mode = (currprefs.chipset_mask & CSMASK_AGA) != 0;
+ aga_mode = (currprefs.chipset_mask & CSMASK_AGA) != 0;
+ direct_rgb = aga_mode;
+ if (currprefs.chipset_mask & CSMASK_AGA)
+ sprite_sprctlmask = 0x01 | 0x08 | 0x10;
+ else if (currprefs.chipset_mask & CSMASK_ECS_DENISE)
+ sprite_sprctlmask = 0x01 | 0x10;
+ else
+ sprite_sprctlmask = 0x01;
set_chipset_mode();
}
-STATIC_INLINE uae_u8 *pfield_xlateptr (uaecptr plpt, int bytecount)
+STATIC_INLINE uae_u8 *pfield_xlateptr(uaecptr plpt, int bytecount)
{
- plpt &= chipmem_bank.mask;
- if((plpt + bytecount) > chipmem_bank.allocated_size)
- return NULL;
- return chipmem_bank.baseaddr + plpt;
+ if (!chipmem_check_indirect(plpt, bytecount)) {
+ static int count = 0;
+ if (!count)
+ count++, write_log(_T("Warning: Bad playfield pointer %08x\n"), plpt);
+ return NULL;
+ }
+ return chipmem_xlate_indirect(plpt);
}
-static void docols (struct color_entry *colentry)
+static void docols(struct color_entry *colentry)
{
int i;
-
- if (aga_mode) {
+
+#ifdef AGA
+ if (currprefs.chipset_mask & CSMASK_AGA) {
for (i = 0; i < 256; i++) {
- int v = colentry->color_regs_aga[i];
- if (v < 0 || v > 16777215)
+ int v = color_reg_get(colentry, i);
+ if (v < 0 || v > 16777215)
continue;
- colentry->acolors[i] = CONVERT_RGB (v);
- }
- } else {
- for (i = 0; i < 32; i++) {
- int v = colentry->color_regs_ecs[i];
- if (v < 0 || v > 4095)
- continue;
- colentry->acolors[i] = xcolors[v];
+ colentry->acolors[i] = getxcolor(v);
}
}
+ else {
+#endif
+ for (i = 0; i < 32; i++) {
+ int v = color_reg_get(colentry, i);
+ if (v < 0 || v > 4095)
+ continue;
+ colentry->acolors[i] = getxcolor(v);
+ }
+#ifdef AGA
+ }
+#endif
}
extern struct color_entry colors_for_drawing;
-void notice_new_xcolors (void)
+void notice_new_xcolors(void)
{
int i;
-
- update_mirrors ();
+
+ update_mirrors();
docols(¤t_colors);
- docols(&colors_for_drawing);
- for (i = 0; i < (MAXVPOS + 1)*2; i++) {
- docols(curr_color_tables + i);
+ docols(&colors_for_drawing);
+ for (i = 0; i < (MAXVPOS + 1) * 2; i++) {
+ docols(color_tables[0] + i);
+ docols(color_tables[1] + i);
}
}
-static void do_sprites (int currhp);
+static void do_sprites(int currhp);
-static void remember_ctable (void)
+static void remember_ctable(void)
{
/* This can happen when program crashes very badly */
if (next_color_entry >= COLOR_TABLE_SIZE)
return;
if (remembered_color_entry < 0) {
/* The colors changed since we last recorded a color map. Record a
- * new one. */
- color_reg_cpy (curr_color_tables + next_color_entry, ¤t_colors);
+ * new one. */
+ color_reg_cpy(curr_color_tables + next_color_entry, ¤t_colors);
remembered_color_entry = next_color_entry++;
}
thisline_decision.ctable = remembered_color_entry;
+ if (color_src_match < 0 || color_dest_match != remembered_color_entry
+ || line_decisions[next_lineno].ctable != color_src_match)
+ {
+ /* The remembered comparison didn't help us - need to compare again. */
+ int oldctable = line_decisions[next_lineno].ctable;
+ int changed = 0;
+
+ if (oldctable < 0) {
+ changed = 1;
+ color_src_match = color_dest_match = -1;
+ }
+ else {
+ color_compare_result = color_reg_cmp(&prev_color_tables[oldctable], ¤t_colors) != 0;
+ if (color_compare_result)
+ changed = 1;
+ color_src_match = oldctable;
+ color_dest_match = remembered_color_entry;
+ }
+ thisline_changed |= changed;
+ }
+ else {
+ /* We know the result of the comparison */
+ if (color_compare_result)
+ thisline_changed = 1;
+ }
}
-STATIC_INLINE int get_equ_vblank_endline (void)
+static void remember_ctable_for_border(void)
+{
+ remember_ctable();
+}
+
+STATIC_INLINE int get_equ_vblank_endline(void)
{
return equ_vblank_endline + (equ_vblank_toggle ? (lof_current ? 1 : 0) : 0);
}
@@ -463,16 +634,16 @@ STATIC_INLINE int get_equ_vblank_endline (void)
/* Called to determine the state of the horizontal display window state
* machine at the current position. It might have changed since we last
* checked. */
-static void decide_diw (int hpos)
+static void decide_diw(int hpos)
{
/* Last hpos = hpos + 0.5, eg. normal PAL end hpos is 227.5 * 2 = 455
- OCS Denise: 9 bit hdiw counter does not reset during lines 0 to 9
- (PAL) or lines 0 to 10 (NTSC). A1000 PAL: 1 to 9, NTSC: 1 to 10.
- ECS Denise and AGA: no above "features"
+ OCS Denise: 9 bit hdiw counter does not reset during lines 0 to 9
+ (PAL) or lines 0 to 10 (NTSC). A1000 PAL: 1 to 9, NTSC: 1 to 10.
+ ECS Denise and AGA: no above "features"
*/
int hdiw = hpos >= maxhpos ? maxhpos * 2 + 1 : hpos * 2 + 2;
- if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE) && vpos <= get_equ_vblank_endline ())
+ if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE) && vpos <= get_equ_vblank_endline())
hdiw = diw_hcounter;
/* always mask, bad programs may have set maxhpos = 256 */
hdiw &= 511;
@@ -498,17 +669,19 @@ static void decide_diw (int hpos)
last_hdiw = hdiw;
}
-static int fetchmode, fetchmode_size, fetchmode_mask, fetchmode_bytes, fetchmode_fmode;
+static int fetchmode, fetchmode_size, fetchmode_mask, fetchmode_bytes;
static int real_bitplane_number[3][3][9];
/* Disable bitplane DMA if planes > available DMA slots. This is needed
- e.g. by the Sanity WOC demo (at the "Party Effect"). */
-STATIC_INLINE int GET_PLANES_LIMIT (void)
+e.g. by the Sanity WOC demo (at the "Party Effect"). */
+STATIC_INLINE int GET_PLANES_LIMIT(uae_u16 bc0)
{
- return real_bitplane_number[fetchmode][bplcon0_res][bplcon0_planes];
+ int res = GET_RES_AGNUS(bc0);
+ int planes = GET_PLANES(bc0);
+ return real_bitplane_number[fetchmode][res][planes];
}
-static void reset_moddelays (void)
+static void reset_moddelays(void)
{
if (dbpl1mod_on > 0) {
bpl1mod = dbpl1mod;
@@ -520,9 +693,9 @@ static void reset_moddelays (void)
}
}
-static void add_modulo (int hpos, int nr)
+static void add_modulo(int hpos, int nr)
{
- int mod;
+ int mod;
if (dbpl1mod_on != hpos && dbpl1mod_on) {
bpl1mod = dbpl1mod;
@@ -532,62 +705,90 @@ static void add_modulo (int hpos, int nr)
bpl2mod = dbpl2mod;
dbpl2mod_on = 0;
}
- if (fmode & 0x4000) {
- if (((diwstrt >> 8) ^ vpos) & 1)
- mod = bpl2mod;
- else
- mod = bpl1mod;
- } else if (nr & 1)
- mod = bpl2mod;
- else
- mod = bpl1mod;
- bplpt[nr] += mod;
- reset_moddelays ();
+ if (fmode & 0x4000) {
+ if (((diwstrt >> 8) ^ vpos) & 1)
+ mod = bpl2mod;
+ else
+ mod = bpl1mod;
+ }
+ else if (nr & 1)
+ mod = bpl2mod;
+ else
+ mod = bpl1mod;
+ bplpt[nr] += mod;
+ bplptx[nr] += mod;
+ reset_moddelays();
}
-STATIC_INLINE void add_modulos(void)
+static void add_modulos(void)
{
- int m1, m2;
-
- reset_moddelays ();
- if (fmode & 0x4000) {
- if (((diwstrt >> 8) ^ vpos) & 1)
- m1 = m2 = bpl2mod;
- else
- m1 = m2 = bpl1mod;
- } else {
- m1 = bpl1mod;
- m2 = bpl2mod;
- }
-
- switch (bplcon0_planes_limit) {
- case 8: bplpt[7] += m2;
- case 7: bplpt[6] += m1;
- case 6: bplpt[5] += m2;
- case 5: bplpt[4] += m1;
- case 4: bplpt[3] += m2;
- case 3: bplpt[2] += m1;
- case 2: bplpt[1] += m2;
- case 1: bplpt[0] += m1;
- }
+ int m1, m2;
+
+ reset_moddelays();
+ if (fmode & 0x4000) {
+ if (((diwstrt >> 8) ^ vpos) & 1)
+ m1 = m2 = bpl2mod;
+ else
+ m1 = m2 = bpl1mod;
+ }
+ else {
+ m1 = bpl1mod;
+ m2 = bpl2mod;
+ }
+
+ switch (bplcon0_planes_limit) {
+#ifdef AGA
+ case 8: bplpt[7] += m2; bplptx[7] += m2;
+ case 7: bplpt[6] += m1; bplptx[6] += m1;
+#endif
+ case 6: bplpt[5] += m2; bplptx[5] += m2;
+ case 5: bplpt[4] += m1; bplptx[4] += m1;
+ case 4: bplpt[3] += m2; bplptx[3] += m2;
+ case 3: bplpt[2] += m1; bplptx[2] += m1;
+ case 2: bplpt[1] += m2; bplptx[1] += m2;
+ case 1: bplpt[0] += m1; bplptx[0] += m1;
+ }
+}
+
+static void finish_playfield_line(void)
+{
+ /* The latter condition might be able to happen in interlaced frames. */
+ if (vpos >= minfirstline && (thisframe_first_drawn_line < 0 || vpos < thisframe_first_drawn_line))
+ thisframe_first_drawn_line = vpos;
+ thisframe_last_drawn_line = vpos;
+
+#ifdef SMART_UPDATE
+ if (line_decisions[next_lineno].plflinelen != thisline_decision.plflinelen
+ || line_decisions[next_lineno].plfleft != thisline_decision.plfleft
+ || line_decisions[next_lineno].bplcon0 != thisline_decision.bplcon0
+ || line_decisions[next_lineno].bplcon2 != thisline_decision.bplcon2
+#ifdef ECS_DENISE
+ || line_decisions[next_lineno].bplcon3 != thisline_decision.bplcon3
+#endif
+#ifdef AGA
+ || line_decisions[next_lineno].bplcon4 != thisline_decision.bplcon4
+#endif
+ )
+#endif /* SMART_UPDATE */
+ thisline_changed = 1;
}
/* The fetch unit mainly controls ddf stop. It's the number of cycles that
- are contained in an indivisible block during which ddf is active. E.g.
- if DDF starts at 0x30, and fetchunit is 8, then possible DDF stops are
- 0x30 + n * 8. */
+are contained in an indivisible block during which ddf is active. E.g.
+if DDF starts at 0x30, and fetchunit is 8, then possible DDF stops are
+0x30 + n * 8. */
static int fetchunit, fetchunit_mask;
/* The delay before fetching the same bitplane again. Can be larger than
- the number of bitplanes; in that case there are additional empty cycles
- with no data fetch (this happens for high fetchmodes and low
- resolutions). */
-static int fetchstart, fetchstart_mask;
+the number of bitplanes; in that case there are additional empty cycles
+with no data fetch (this happens for high fetchmodes and low
+resolutions). */
+static int fetchstart, fetchstart_shift, fetchstart_mask;
/* fm_maxplane holds the maximum number of planes possible with the current
- fetch mode. This selects the cycle diagram:
- 8 planes: 73516240
- 4 planes: 3120
- 2 planes: 10. */
-static int fm_maxplane;
+fetch mode. This selects the cycle diagram:
+8 planes: 73516240
+4 planes: 3120
+2 planes: 10. */
+static int fm_maxplane, fm_maxplane_shift;
/* The corresponding values, by fetchmode and display resolution. */
static const int fetchunits[] = { 8,8,8,0, 16,8,8,0, 32,16,8,0 };
@@ -602,74 +803,77 @@ static const int cycle_sequences[3 * 8] = { 2,1,2,1,2,1,2,1, 4,2,3,1,4,2,3,1, 8,
static void create_cycle_diagram_table(void)
{
- int fm, res, cycle, planes, rplanes, v;
- int fetch_start, max_planes, freecycles;
- const int *cycle_sequence;
-
- for (fm = 0; fm <= 2; fm++) {
- for (res = 0; res <= 2; res++) {
- max_planes = fm_maxplanes[fm * 4 + res];
- fetch_start = 1 << fetchstarts[fm * 4 + res];
- cycle_sequence = &cycle_sequences[(max_planes - 1) * 8];
- max_planes = 1 << max_planes;
- for (planes = 0; planes <= 8; planes++) {
- freecycles = 0;
- for (cycle = 0; cycle < 32; cycle++)
- cycle_diagram_table[fm][res][planes][cycle] = -1;
- if (planes <= max_planes) {
- for (cycle = 0; cycle < fetch_start; cycle++) {
- if (cycle < max_planes && planes >= cycle_sequence[cycle & 7]) {
- v = cycle_sequence[cycle & 7];
- } else {
- v = 0;
- freecycles++;
- }
- cycle_diagram_table[fm][res][planes][cycle] = v;
- }
- }
- cycle_diagram_free_cycles[fm][res][planes] = freecycles;
- cycle_diagram_total_cycles[fm][res][planes] = fetch_start;
- rplanes = planes;
- if (rplanes > max_planes)
- rplanes = 0;
- if (rplanes == 7 && fm == 0 && res == 0 && !(aga_mode))
- rplanes = 4;
- real_bitplane_number[fm][res][planes] = rplanes;
- }
- }
- }
-}
+ int fm, res, cycle, planes, rplanes, v;
+ int fetch_start, max_planes, freecycles;
+ const int *cycle_sequence;
+ for (fm = 0; fm <= 2; fm++) {
+ for (res = 0; res <= 2; res++) {
+ max_planes = fm_maxplanes[fm * 4 + res];
+ fetch_start = 1 << fetchstarts[fm * 4 + res];
+ cycle_sequence = &cycle_sequences[(max_planes - 1) * 8];
+ max_planes = 1 << max_planes;
+ for (planes = 0; planes <= 8; planes++) {
+ freecycles = 0;
+ for (cycle = 0; cycle < 32; cycle++)
+ cycle_diagram_table[fm][res][planes][cycle] = -1;
+ if (planes <= max_planes) {
+ for (cycle = 0; cycle < fetch_start; cycle++) {
+ if (cycle < max_planes && planes >= cycle_sequence[cycle & 7]) {
+ v = cycle_sequence[cycle & 7];
+ }
+ else {
+ v = 0;
+ freecycles++;
+ }
+ cycle_diagram_table[fm][res][planes][cycle] = v;
+ }
+ }
+ cycle_diagram_free_cycles[fm][res][planes] = freecycles;
+ cycle_diagram_total_cycles[fm][res][planes] = fetch_start;
+ rplanes = planes;
+ if (rplanes > max_planes)
+ rplanes = 0;
+ if (rplanes == 7 && fm == 0 && res == 0 && !(currprefs.chipset_mask & CSMASK_AGA))
+ rplanes = 4;
+ real_bitplane_number[fm][res][planes] = rplanes;
+ }
+ }
+ }
+}
/* Used by the copper. */
static int estimated_last_fetch_cycle;
static int cycle_diagram_shift;
-static void estimate_last_fetch_cycle (int hpos)
+static void estimate_last_fetch_cycle(int hpos)
{
+ int fetchunit = fetchunits[fetchmode * 4 + bplcon0_res];
// Last fetch is always max 8 even if fetchunit is larger.
int lastfetchunit = fetchunit >= 8 ? 8 : fetchunit;
if (plf_state < plf_passed_stop) {
- int stop;
-
+ int stop;
+
if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
// ECS: stop wins if start == stop
stop = plfstop + DDF_OFFSET < hpos || plfstop > HARD_DDF_STOP ? HARD_DDF_STOP : plfstop;
- } else {
+ }
+ else {
// OCS: start wins if start == stop
stop = plfstop + DDF_OFFSET <= hpos || plfstop > HARD_DDF_STOP ? HARD_DDF_STOP : plfstop;
}
/* We know that fetching is up-to-date up until hpos, so we can use fetch_cycle. */
int fetch_cycle_at_stop = fetch_cycle + (stop - hpos + DDF_OFFSET);
- int starting_last_block_at = (fetch_cycle_at_stop + fetchunit - 1) & ~fetchunit_mask;
-
+ int starting_last_block_at = (fetch_cycle_at_stop + fetchunit - 1) & ~(fetchunit - 1);
+
estimated_last_fetch_cycle = hpos + (starting_last_block_at - fetch_cycle) + lastfetchunit;
- } else {
- int starting_last_block_at = (fetch_cycle + fetchunit - 1) & ~fetchunit_mask;
+ }
+ else {
+ int starting_last_block_at = (fetch_cycle + fetchunit - 1) & ~(fetchunit - 1);
if (plf_state == plf_passed_stop2)
starting_last_block_at -= fetchunit;
-
+
estimated_last_fetch_cycle = hpos + (starting_last_block_at - fetch_cycle) + lastfetchunit;
}
}
@@ -679,16 +883,23 @@ static int out_nbits, out_offs;
static uae_u16 todisplay[MAX_PLANES], todisplay2[MAX_PLANES];
static uae_u16 fetched[MAX_PLANES];
static bool todisplay_fetched[2];
+#ifdef AGA
static uae_u64 todisplay_aga[MAX_PLANES], todisplay2_aga[MAX_PLANES];
static uae_u64 fetched_aga[MAX_PLANES];
+#endif
/* Expansions from bplcon0/bplcon1. */
static int toscr_res, toscr_res2p;
static int toscr_nr_planes, toscr_nr_planes2, toscr_nr_planes_agnus, toscr_nr_planes_shifter;
+static int fetchwidth;
static int toscr_delay[2], toscr_delay_adjusted[2], toscr_delay_sh[2];
-static int delay_cycles, delay_lastcycle[2];
+static bool shdelay_disabled;
+static int delay_cycles, delay_lastcycle[2], hack_delay_shift;
static bool bplcon1_written;
+#define PLANE_RESET_HPOS 8
+static int planesactiveatresetpoint;
+
/* The number of bits left from the last fetched words.
This is an optimization - conceptually, we have to make sure the result is
the same as if toscr is called in each clock cycle. However, to speed this
@@ -697,132 +908,179 @@ static bool bplcon1_written;
we can do more work at once. */
static int toscr_nbits;
-static void record_color_change2 (int hpos, int regno, uae_u32 value)
+static void record_color_change2(int hpos, int regno, unsigned long value)
{
- int pos = (hpos * 2) * 4;
- if (regno == 0x1000 + 0x10c) {
- pos += 4; // BPLCON4 change needs 1 lores pixel delay
- if (value & 0xff00)
- thisline_decision.xor_seen = true;
- }
+ int pos = hpos * 2;
+ if (regno == 0x1000 + 0x10c)
+ pos++; // BPLCON4 change needs 1 lores pixel delay
curr_color_changes[next_color_change].linepos = pos;
curr_color_changes[next_color_change].regno = regno;
curr_color_changes[next_color_change].value = value;
next_color_change++;
- curr_color_changes[next_color_change].regno = -1;
+ curr_color_changes[next_color_change].regno = -1;
+}
+
+static bool isehb(uae_u16 bplcon0, uae_u16 bplcon2)
+{
+ bool bplehb;
+ if (currprefs.chipset_mask & CSMASK_AGA)
+ bplehb = (bplcon0 & 0x7010) == 0x6000;
+ else if (currprefs.chipset_mask & CSMASK_ECS_DENISE)
+ bplehb = ((bplcon0 & 0xFC00) == 0x6000 || (bplcon0 & 0xFC00) == 0x7000);
+ else
+ bplehb = ((bplcon0 & 0xFC00) == 0x6000 || (bplcon0 & 0xFC00) == 0x7000) && !currprefs.cs_denisenoehb;
+ return bplehb;
}
// OCS/ECS, lores, 7 planes = 4 "real" planes + BPL5DAT and BPL6DAT as static 5th and 6th plane
-STATIC_INLINE int isocs7planes (void)
+STATIC_INLINE int isocs7planes(void)
{
- return !(aga_mode) && bplcon0_res == 0 && bplcon0_planes == 7;
+ return !(currprefs.chipset_mask & CSMASK_AGA) && bplcon0_res == 0 && bplcon0_planes == 7;
}
-STATIC_INLINE int is_bitplane_dma (int hpos)
+int is_bitplane_dma(int hpos)
{
- if (hpos < bpl_hstart || fetch_state == fetch_not_started || plf_state == plf_wait) {
- return 0;
- }
- if ((plf_state >= plf_end && hpos >= thisline_decision.plfright)
- || hpos >= estimated_last_fetch_cycle)
- return 0;
- return curr_diagram[(hpos - cycle_diagram_shift) & fetchstart_mask];
+ if (hpos < bpl_hstart || fetch_state == fetch_not_started || plf_state == plf_wait) {
+ if (bitplane_overrun && hpos < bitplane_overrun_hpos) {
+ return curr_diagram[(hpos - bitplane_overrun_cycle_diagram_shift) & fetchstart_mask];
+ }
+ return 0;
+ }
+ if ((plf_state >= plf_end && hpos >= thisline_decision.plfright)
+ || hpos >= estimated_last_fetch_cycle)
+ return 0;
+ return curr_diagram[(hpos - cycle_diagram_shift) & fetchstart_mask];
+}
+
+STATIC_INLINE int is_bitplane_dma_inline(int hpos)
+{
+ if (hpos < bpl_hstart || fetch_state == fetch_not_started || plf_state == plf_wait) {
+ if (bitplane_overrun && hpos < bitplane_overrun_hpos) {
+ return curr_diagram[(hpos - bitplane_overrun_cycle_diagram_shift) & fetchstart_mask];
+ }
+ return 0;
+ }
+ if ((plf_state >= plf_end && hpos >= thisline_decision.plfright)
+ || hpos >= estimated_last_fetch_cycle)
+ return 0;
+ return curr_diagram[(hpos - cycle_diagram_shift) & fetchstart_mask];
+}
+
+static int islinetoggle(void)
+{
+ int linetoggle = 0;
+ if (!(beamcon0 & 0x0800) && !(beamcon0 & 0x0020) && (currprefs.chipset_mask & CSMASK_ECS_AGNUS)) {
+ linetoggle = 1; // NTSC and !LOLDIS -> LOL toggles every line
+ }
+ else if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS) && currprefs.ntscmode) {
+ linetoggle = 1; // hardwired NTSC Agnus
+ }
+ return linetoggle;
}
/* Expand bplcon0/bplcon1 into the toscr_xxx variables. */
-STATIC_INLINE void compute_toscr_delay (int bplcon1)
+static void compute_toscr_delay(int bplcon1)
{
- int delay1 = (bplcon1 & 0x0f) | ((bplcon1 & 0x0c00) >> 6);
- int delay2 = ((bplcon1 >> 4) & 0x0f) | (((bplcon1 >> 4) & 0x0c00) >> 6);
- int shdelay1 = (bplcon1 >> 8) & 3;
- int shdelay2 = (bplcon1 >> 12) & 3;
+ int delay1 = (bplcon1 & 0x0f) | ((bplcon1 & 0x0c00) >> 6);
+ int delay2 = ((bplcon1 >> 4) & 0x0f) | (((bplcon1 >> 4) & 0x0c00) >> 6);
+ int shdelay1 = (bplcon1 >> 8) & 3;
+ int shdelay2 = (bplcon1 >> 12) & 3;
int delaymask = fetchmode_mask >> toscr_res;
-
- toscr_delay[0] = (delay1 & delaymask) << toscr_res;
- toscr_delay[0] |= shdelay1 >> (RES_MAX - toscr_res);
- toscr_delay[1] = (delay2 & delaymask) << toscr_res;
- toscr_delay[1] |= shdelay2 >> (RES_MAX - toscr_res);
+ toscr_delay[0] = (delay1 & delaymask) << toscr_res;
+ toscr_delay[0] |= shdelay1 >> (RES_MAX - toscr_res);
+ toscr_delay[1] = (delay2 & delaymask) << toscr_res;
+ toscr_delay[1] |= shdelay2 >> (RES_MAX - toscr_res);
+
+#if SPEEDUP
/* SPEEDUP code still needs this hack */
int delayoffset = fetchmode_size - (((bpl_hstart - (HARD_DDF_START_REAL + DDF_OFFSET)) & fetchstart_mask) << 1);
- delay1 += delayoffset;
- delay2 += delayoffset;
+ delay1 += delayoffset;
+ delay2 += delayoffset;
toscr_delay_adjusted[0] = (delay1 & delaymask) << toscr_res;
toscr_delay_adjusted[0] |= shdelay1 >> (RES_MAX - toscr_res);
toscr_delay_adjusted[1] = (delay2 & delaymask) << toscr_res;
toscr_delay_adjusted[1] |= shdelay2 >> (RES_MAX - toscr_res);
+#endif
}
-static void set_delay_lastcycle (void)
+static void set_delay_lastcycle(void)
{
if (HARD_DDF_LIMITS_DISABLED) {
delay_lastcycle[0] = (256 * 2) << bplcon0_res;
delay_lastcycle[1] = (256 * 2) << bplcon0_res;
- } else {
+ }
+ else {
delay_lastcycle[0] = ((maxhpos + 1) * 2 + 0) << bplcon0_res;
delay_lastcycle[1] = delay_lastcycle[0];
- if (currprefs.ntscmode)
+ if (islinetoggle())
delay_lastcycle[1]++;
}
}
static int bpldmasetuphpos, bpldmasetuphpos_diff;
static int bpldmasetupphase;
-static void update_toscr_planes (int fm);
+static void update_toscr_planes(int fm);
/* set currently active Agnus bitplane DMA sequence */
-static void setup_fmodes (int hpos)
+static void setup_fmodes(int hpos)
{
- switch (fmode & 3)
- {
- case 0:
- fetchmode = 0;
- break;
- case 1:
- case 2:
- fetchmode = 1;
- break;
- case 3:
- fetchmode = 2;
- break;
- }
- badmode = GET_RES_AGNUS (bplcon0) != GET_RES_DENISE (bplcon0);
- bplcon0_res = GET_RES_AGNUS (bplcon0);
- bplcon0_planes = GET_PLANES (bplcon0);
- bplcon0_planes_limit = GET_PLANES_LIMIT ();
- fetchunit = fetchunits[fetchmode * 4 + bplcon0_res];
- fetchunit_mask = fetchunit - 1;
- int fetchstart_shift = fetchstarts[fetchmode * 4 + bplcon0_res];
- fetchstart = 1 << fetchstart_shift;
- fetchstart_mask = fetchstart - 1;
- int fm_maxplane_shift = fm_maxplanes[fetchmode * 4 + bplcon0_res];
- fm_maxplane = 1 << fm_maxplane_shift;
- fetch_modulo_cycle = fetchunit - fetchstart;
+ switch (fmode & 3)
+ {
+ case 0:
+ fetchmode = 0;
+ break;
+ case 1:
+ case 2:
+ fetchmode = 1;
+ break;
+ case 3:
+ fetchmode = 2;
+ break;
+ }
+ badmode = GET_RES_AGNUS(bplcon0) != GET_RES_DENISE(bplcon0);
+ bplcon0_res = GET_RES_AGNUS(bplcon0);
+ bplcon0_planes = GET_PLANES(bplcon0);
+ bplcon0_planes_limit = GET_PLANES_LIMIT(bplcon0);
+ fetchunit = fetchunits[fetchmode * 4 + bplcon0_res];
+ fetchunit_mask = fetchunit - 1;
+ fetchstart_shift = fetchstarts[fetchmode * 4 + bplcon0_res];
+ fetchstart = 1 << fetchstart_shift;
+ fetchstart_mask = fetchstart - 1;
+ fm_maxplane_shift = fm_maxplanes[fetchmode * 4 + bplcon0_res];
+ fm_maxplane = 1 << fm_maxplane_shift;
+ fetch_modulo_cycle = fetchunit - fetchstart;
fetchmode_size = 16 << fetchmode;
fetchmode_bytes = 2 << fetchmode;
fetchmode_mask = fetchmode_size - 1;
- fetchmode_fmode = fmode;
- set_delay_lastcycle ();
- compute_toscr_delay (bplcon1);
+ set_delay_lastcycle();
+ compute_toscr_delay(bplcon1);
if (thisline_decision.plfleft < 0) {
thisline_decision.bplres = bplcon0_res;
thisline_decision.bplcon0 = bplcon0;
thisline_decision.nr_planes = bplcon0_planes;
}
-
- curr_diagram = cycle_diagram_table[fetchmode][bplcon0_res][bplcon0_planes_limit];
- estimate_last_fetch_cycle (hpos);
+#ifdef CPUEMU_13
+ if (is_bitplane_dma(hpos - 1))
+ cycle_line[hpos - 1] = 1;
+#endif
+ curr_diagram = cycle_diagram_table[fetchmode][bplcon0_res][bplcon0_planes_limit];
+ estimate_last_fetch_cycle(hpos);
+#ifdef DEBUGGER
+ if (bpldmasetuphpos >= 0 && debug_dma)
+ record_dma_event(DMA_EVENT_BPLFETCHUPDATE, hpos, vpos);
+#endif
bpldmasetuphpos = -1;
bpldmasetupphase = 0;
toscr_nr_planes_agnus = bplcon0_planes;
- if (isocs7planes ()) {
+ if (isocs7planes()) {
toscr_nr_planes_agnus = 6;
}
SET_LINE_CYCLEBASED;
}
-static void BPLCON0_Denise (int hpos, uae_u16 v, bool);
+static void BPLCON0_Denise(int hpos, uae_u16 v, bool);
// writing to BPLCON0 adds 4 cycle delay before Agnus bitplane DMA sequence changes
// (Note that Denise sees the change after 1 cycle)
@@ -831,33 +1089,33 @@ static void BPLCON0_Denise (int hpos, uae_u16 v, bool);
#define BPLCON_AGNUS_DELAY (3 + (copper_access ? 1 : 0) + (bplcon0_planes == 8 ? 1 : 0))
#define BPLCON_DENISE_DELAY (copper_access ? 1 : 0)
-STATIC_INLINE void maybe_setup_fmodes (int hpos)
+static void maybe_setup_fmodes(int hpos)
{
switch (bpldmasetupphase)
{
case 0:
- BPLCON0_Denise (hpos, bplcon0, false);
+ BPLCON0_Denise(hpos, bplcon0, false);
bpldmasetupphase++;
bpldmasetuphpos += bpldmasetuphpos_diff;
break;
case 1:
- setup_fmodes (hpos);
+ setup_fmodes(hpos);
break;
}
}
-STATIC_INLINE void maybe_check (int hpos)
+STATIC_INLINE void maybe_check(int hpos)
{
if (bpldmasetuphpos > 0 && hpos >= bpldmasetuphpos)
- maybe_setup_fmodes (hpos);
+ maybe_setup_fmodes(hpos);
}
-static void bpldmainitdelay (int hpos)
+static void bpldmainitdelay(int hpos)
{
SET_LINE_CYCLEBASED;
- if (hpos + BPLCON_AGNUS_DELAY < 0x14) {
- BPLCON0_Denise (hpos, bplcon0, false);
- setup_fmodes (hpos);
+ if (!bitplane_overrun && hpos + BPLCON_AGNUS_DELAY < 0x14) {
+ BPLCON0_Denise(hpos, bplcon0, false);
+ setup_fmodes(hpos);
return;
}
if (bpldmasetuphpos < 0) {
@@ -865,111 +1123,127 @@ static void bpldmainitdelay (int hpos)
bpldmasetuphpos_diff = BPLCON_AGNUS_DELAY - BPLCON_DENISE_DELAY;
bpldmasetupphase = 0;
if (BPLCON_DENISE_DELAY == 0) {
- maybe_setup_fmodes (hpos);
+ maybe_setup_fmodes(hpos);
}
}
}
-STATIC_INLINE void clear_fetchbuffer (uae_u32 *ptr, int nwords)
+STATIC_INLINE void clear_fetchbuffer(uae_u32 *ptr, int nwords)
{
- memset (ptr, 0, nwords * 4);
+ int i;
+
+ if (!thisline_changed) {
+ for (i = 0; i < nwords; i++) {
+ if (ptr[i]) {
+ thisline_changed = 1;
+ break;
+ }
+ }
+ }
+ memset(ptr, 0, nwords * 4);
}
-STATIC_INLINE void update_toscr_planes (int fm)
+static void update_toscr_planes(int fm)
{
// This must be called just before new bitplane block starts,
// not when depth value changes. Depth can change early and can leave
// 16+ pixel horizontal line of old data visible.
if (toscr_nr_planes_agnus > thisline_decision.nr_planes) {
- if(out_offs) {
- int j;
- for (j = thisline_decision.nr_planes; j < toscr_nr_planes_agnus; j++) {
- clear_fetchbuffer ((uae_u32 *)(line_data[next_lineno] + 2 * MAX_WORDS_PER_LINE * j), out_offs);
+ if (out_offs) {
+ int j;
+ for (j = thisline_decision.nr_planes; j < toscr_nr_planes_agnus; j++) {
+ clear_fetchbuffer(reinterpret_cast(line_data[next_lineno] + 2 * MAX_WORDS_PER_LINE * j), out_offs);
if (thisline_decision.plfleft >= 0) {
todisplay[j] = 0;
+#ifdef AGA
if (fm)
todisplay_aga[j] = 0;
- }
- }
- }
+#endif
+ }
+ }
+ }
thisline_decision.nr_planes = toscr_nr_planes_agnus;
- }
-}
-
-STATIC_INLINE void maybe_first_bpl1dat (int hpos)
-{
- if (thisline_decision.plfleft < 0) {
- thisline_decision.plfleft = hpos;
}
}
-STATIC_INLINE void fetch (int nr, int fm, bool modulo, int hpos)
+STATIC_INLINE void maybe_first_bpl1dat(int hpos)
+{
+ if (thisline_decision.plfleft < 0)
+ thisline_decision.plfleft = hpos;
+}
+
+static int fetch_warn(int nr, int hpos)
+{
+ static int warned1 = 30, warned2 = 30;
+ int add = fetchmode_bytes;
+ if (hpos == maxhpos - 1 || hpos == 1 || hpos == 3 || hpos == 5) {
+ if (warned1 >= 0) {
+ write_log(_T("WARNING: BPL fetch conflicts with strobe refresh slot %d!\n"), hpos);
+ warned1--;
+ }
+ add = refptr_val;
+ }
+ else {
+ if (warned2 >= 0) {
+ warned2--;
+ write_log(_T("WARNING: BPL fetch at hpos 0x%02X!\n"), hpos);
+ }
+ add = refptr_val;
+ }
+ bitplane_line_crossing = hpos;
+ return add;
+ }
+
+static void fetch(int nr, int fm, bool modulo, int hpos)
{
if (nr < bplcon0_planes_limit) {
- uaecptr p;
+ uaecptr p;
int add = fetchmode_bytes;
- p = bplpt[nr];
+ // refresh conflict?
+ if ((hpos > maxhpos - HPOS_SHIFT || hpos == 1 || hpos == 3 || hpos == 5) && !(beamcon0 & 0x80)) {
+ add = fetch_warn(nr, hpos);
+ }
+ p = bplpt[nr];
bplpt[nr] += add;
+ bplptx[nr] += add;
if (nr == 0)
bpl1dat_written = true;
- switch (fm)
- {
- case 0:
- fetched[nr] = chipmem_wget_indirect (p);
- last_custom_value1 = fetched[nr];
- break;
- case 1:
- {
- uaecptr pm = p & ~3;
- if (p & 2) {
- fetched_aga[nr] = chipmem_lget_indirect(pm) & 0x0000ffff;
- fetched_aga[nr] |= fetched_aga[nr] << 16;
- } else if (fetchmode_fmode & 2) { // optimized (fetchmode_fmode & 3) == 2
- fetched_aga[nr] = chipmem_lget_indirect(pm) & 0xffff0000;
- fetched_aga[nr] |= fetched_aga[nr] >> 16;
- } else {
- fetched_aga[nr] = chipmem_lget_indirect(pm);
- }
- last_custom_value1 = (uae_u32)fetched_aga[nr];
- fetched[nr] = (uae_u16)fetched_aga[nr];
- break;
- }
- case 2:
- {
- uaecptr pm = p & ~7;
- uaecptr pm1, pm2;
- if (p & 4) {
- pm1 = pm + 4;
- pm2 = pm + 4;
- } else {
- pm1 = pm;
- pm2 = pm + 4;
- }
- if (p & 2) {
- uae_u32 v1 = chipmem_lget_indirect(pm1) & 0x0000ffff;
- uae_u32 v2 = chipmem_lget_indirect(pm2) & 0x0000ffff;
- v1 |= v1 << 16;
- v2 |= v2 << 16;
- fetched_aga[nr] = (((uae_u64)v1) << 32) | v2;
- } else {
- fetched_aga[nr] = ((uae_u64)chipmem_lget_indirect(pm1)) << 32;
- fetched_aga[nr] |= chipmem_lget_indirect(pm2);
- }
- last_custom_value1 = (uae_u32)fetched_aga[nr];
- fetched[nr] = (uae_u16)fetched_aga[nr];
- break;
- }
- }
- if (modulo)
+#ifdef DEBUGGER
+ if (debug_dma)
+ record_dma(0x110 + nr * 2, chipmem_wget_indirect(p), p, hpos, vpos, DMARECORD_BITPLANE);
+ if (memwatch_enabled)
+ debug_wgetpeekdma_chipram(p, chipmem_wget_indirect(p), MW_MASK_BPL_0 << nr, 0x110 + nr * 2);
+#endif
+ switch (fm)
+ {
+ case 0:
+ fetched[nr] = chipmem_wget_indirect(p);
+ last_custom_value1 = fetched[nr];
+ break;
+#ifdef AGA
+ case 1:
+ fetched_aga[nr] = chipmem_lget_indirect(p);
+ last_custom_value1 = fetched_aga[nr];
+ fetched[nr] = uae_u16(fetched_aga[nr]);
+ break;
+ case 2:
+ fetched_aga[nr] = static_cast(chipmem_lget_indirect(p)) << 32;
+ fetched_aga[nr] |= chipmem_lget_indirect(p + 4);
+ last_custom_value1 = uae_u32(fetched_aga[nr]);
+ fetched[nr] = uae_u16(fetched_aga[nr]);
+ break;
+#endif
+ }
+ if (modulo)
add_modulo(hpos, nr);
}
}
-STATIC_INLINE void toscr_3_ecs (int oddeven, int step, int nbits)
+STATIC_INLINE void toscr_3_ecs(int oddeven, int step, int nbits)
{
int i;
int shift = 16 - nbits;
@@ -986,7 +1260,9 @@ STATIC_INLINE void toscr_3_ecs (int oddeven, int step, int nbits)
}
}
-STATIC_INLINE void toscr_3_aga (int oddeven, int step, int nbits, int fm)
+#ifdef AGA
+
+STATIC_INLINE void toscr_3_aga(int oddeven, int step, int nbits, int fm)
{
int i;
uae_u32 mask = 0xFFFF >> (16 - nbits);
@@ -1002,38 +1278,44 @@ STATIC_INLINE void toscr_3_aga (int oddeven, int step, int nbits, int fm)
}
}
-static void toscr_2_0 (int nbits) { toscr_3_ecs (0, 1, nbits); }
-static void toscr_2_0_oe (int oddeven, int step, int nbits) { toscr_3_ecs (oddeven, step, nbits); }
-static void toscr_2_1 (int nbits) { toscr_3_aga (0, 1, nbits, 1); }
-static void toscr_2_1_oe (int oddeven, int step, int nbits) { toscr_3_aga (oddeven, step, nbits, 1); }
-static void toscr_2_2 (int nbits) { toscr_3_aga (0, 1, nbits, 2); }
-static void toscr_2_2_oe (int oddeven, int step, int nbits) { toscr_3_aga (oddeven, step, nbits, 2); }
+#endif
-static void do_tosrc (int oddeven, int step, int nbits, int fm)
+static void toscr_2_0(int nbits) { toscr_3_ecs(0, 1, nbits); }
+static void toscr_2_0_oe(int oddeven, int step, int nbits) { toscr_3_ecs(oddeven, step, nbits); }
+#ifdef AGA
+static void toscr_2_1(int nbits) { toscr_3_aga(0, 1, nbits, 1); }
+static void toscr_2_1_oe(int oddeven, int step, int nbits) { toscr_3_aga(oddeven, step, nbits, 1); }
+static void toscr_2_2(int nbits) { toscr_3_aga(0, 1, nbits, 2); }
+static void toscr_2_2_oe(int oddeven, int step, int nbits) { toscr_3_aga(oddeven, step, nbits, 2); }
+#endif
+
+STATIC_INLINE void do_tosrc(int oddeven, int step, int nbits, int fm)
{
switch (fm) {
- case 0:
- if (step == 2)
- toscr_2_0_oe (oddeven, step, nbits);
- else
- toscr_2_0 (nbits);
- break;
- case 1:
- if (step == 2)
- toscr_2_1_oe (oddeven, step, nbits);
- else
- toscr_2_1 (nbits);
- break;
- case 2:
- if (step == 2)
- toscr_2_2_oe (oddeven, step, nbits);
- else
- toscr_2_2 (nbits);
- break;
+ case 0:
+ if (step == 2)
+ toscr_2_0_oe(oddeven, step, nbits);
+ else
+ toscr_2_0(nbits);
+ break;
+#ifdef AGA
+ case 1:
+ if (step == 2)
+ toscr_2_1_oe(oddeven, step, nbits);
+ else
+ toscr_2_1(nbits);
+ break;
+ case 2:
+ if (step == 2)
+ toscr_2_2_oe(oddeven, step, nbits);
+ else
+ toscr_2_2(nbits);
+ break;
+#endif
}
}
-STATIC_INLINE void do_delays_3_ecs (int nbits)
+STATIC_INLINE void do_delays_3_ecs(int nbits)
{
int delaypos = delay_cycles & fetchmode_mask;
for (int oddeven = 0; oddeven < 2; oddeven++) {
@@ -1043,7 +1325,7 @@ STATIC_INLINE void do_delays_3_ecs (int nbits)
int diff = delay - delaypos;
int nbits2 = nbits;
if (nbits2 > diff) {
- do_tosrc (oddeven, 2, diff, 0);
+ do_tosrc(oddeven, 2, diff, 0);
nbits2 -= diff;
if (todisplay_fetched[oddeven]) {
for (int i = oddeven; i < toscr_nr_planes_shifter; i += 2)
@@ -1052,11 +1334,11 @@ STATIC_INLINE void do_delays_3_ecs (int nbits)
}
}
if (nbits2)
- do_tosrc (oddeven, 2, nbits2, 0);
+ do_tosrc(oddeven, 2, nbits2, 0);
}
}
-STATIC_INLINE void do_delays_fast_3_ecs (int nbits)
+STATIC_INLINE void do_delays_fast_3_ecs(int nbits)
{
int delaypos = delay_cycles & fetchmode_mask;
int delay = toscr_delay[0];
@@ -1065,7 +1347,7 @@ STATIC_INLINE void do_delays_fast_3_ecs (int nbits)
int diff = delay - delaypos;
int nbits2 = nbits;
if (nbits2 > diff) {
- do_tosrc (0, 1, diff, 0);
+ do_tosrc(0, 1, diff, 0);
nbits2 -= diff;
if (todisplay_fetched[0]) {
for (int i = 0; i < toscr_nr_planes_shifter; i++)
@@ -1075,10 +1357,10 @@ STATIC_INLINE void do_delays_fast_3_ecs (int nbits)
}
}
if (nbits2)
- do_tosrc (0, 1, nbits2, 0);
+ do_tosrc(0, 1, nbits2, 0);
}
-STATIC_INLINE void do_delays_3_aga (int nbits, int fm)
+STATIC_INLINE void do_delays_3_aga(int nbits, int fm)
{
int delaypos = delay_cycles & fetchmode_mask;
for (int oddeven = 0; oddeven < 2; oddeven++) {
@@ -1088,7 +1370,7 @@ STATIC_INLINE void do_delays_3_aga (int nbits, int fm)
int diff = delay - delaypos;
int nbits2 = nbits;
if (nbits2 > diff) {
- do_tosrc (oddeven, 2, diff, fm);
+ do_tosrc(oddeven, 2, diff, fm);
nbits2 -= diff;
if (todisplay_fetched[oddeven]) {
for (int i = oddeven; i < toscr_nr_planes_shifter; i += 2)
@@ -1097,11 +1379,11 @@ STATIC_INLINE void do_delays_3_aga (int nbits, int fm)
}
}
if (nbits2)
- do_tosrc (oddeven, 2, nbits2, fm);
+ do_tosrc(oddeven, 2, nbits2, fm);
}
}
-STATIC_INLINE void do_delays_fast_3_aga (int nbits, int fm)
+STATIC_INLINE void do_delays_fast_3_aga(int nbits, int fm)
{
int delaypos = delay_cycles & fetchmode_mask;
int delay = toscr_delay[0];
@@ -1110,7 +1392,7 @@ STATIC_INLINE void do_delays_fast_3_aga (int nbits, int fm)
int diff = delay - delaypos;
int nbits2 = nbits;
if (nbits2 > diff) {
- do_tosrc (0, 1, diff, fm);
+ do_tosrc(0, 1, diff, fm);
nbits2 -= diff;
if (todisplay_fetched[0]) {
for (int i = 0; i < toscr_nr_planes_shifter; i++)
@@ -1120,79 +1402,94 @@ STATIC_INLINE void do_delays_fast_3_aga (int nbits, int fm)
}
}
if (nbits2)
- do_tosrc (0, 1, nbits2, fm);
+ do_tosrc(0, 1, nbits2, fm);
}
-static void do_delays_2_0 (int nbits) { do_delays_3_ecs (nbits); }
-static void do_delays_2_1 (int nbits) { do_delays_3_aga (nbits, 1); }
-static void do_delays_2_2 (int nbits) { do_delays_3_aga (nbits, 2); }
-static void do_delays_fast_2_0 (int nbits) { do_delays_fast_3_ecs (nbits); }
-static void do_delays_fast_2_1 (int nbits) { do_delays_fast_3_aga (nbits, 1); }
-static void do_delays_fast_2_2 (int nbits) { do_delays_fast_3_aga (nbits, 2); }
+static void do_delays_2_0(int nbits) { do_delays_3_ecs(nbits); }
+#ifdef AGA
+static void do_delays_2_1(int nbits) { do_delays_3_aga(nbits, 1); }
+static void do_delays_2_2(int nbits) { do_delays_3_aga(nbits, 2); }
+#endif
+static void do_delays_fast_2_0(int nbits) { do_delays_fast_3_ecs(nbits); }
+#ifdef AGA
+static void do_delays_fast_2_1(int nbits) { do_delays_fast_3_aga(nbits, 1); }
+static void do_delays_fast_2_2(int nbits) { do_delays_fast_3_aga(nbits, 2); }
+#endif
+
// slower version, odd and even delays are different or crosses maxhpos
-static void do_delays (int nbits, int fm)
+STATIC_INLINE void do_delays(int nbits, int fm)
{
switch (fm) {
case 0:
- do_delays_2_0 (nbits);
+ do_delays_2_0(nbits);
break;
+#ifdef AGA
case 1:
- do_delays_2_1 (nbits);
+ do_delays_2_1(nbits);
break;
case 2:
- do_delays_2_2 (nbits);
+ do_delays_2_2(nbits);
break;
+#endif
}
}
// common optimized case: odd delay == even delay
-static void do_delays_fast (int nbits, int fm)
+STATIC_INLINE void do_delays_fast(int nbits, int fm)
{
switch (fm) {
case 0:
- do_delays_fast_2_0 (nbits);
+ do_delays_fast_2_0(nbits);
break;
+#ifdef AGA
case 1:
- do_delays_fast_2_1 (nbits);
+ do_delays_fast_2_1(nbits);
break;
case 2:
- do_delays_fast_2_2 (nbits);
+ do_delays_fast_2_2(nbits);
break;
+#endif
}
}
-static void toscr_right_edge (int nbits, int fm)
+static void toscr_right_edge(int nbits, int fm)
{
// Emulate hpos counter (delay_cycles) reseting at the end of scanline.
// (Result is ugly shift in graphics in far right overscan)
- int diff = delay_lastcycle[0] - delay_cycles;
+ int diff = delay_lastcycle[lol] - delay_cycles;
int nbits2 = nbits;
if (nbits2 >= diff) {
- do_delays (diff, fm);
+ do_delays(diff, fm);
nbits2 -= diff;
delay_cycles = 0;
+ if (hpos_is_zero_bplcon1_hack >= 0) {
+ compute_toscr_delay(hpos_is_zero_bplcon1_hack);
+ hpos_is_zero_bplcon1_hack = -1;
+ }
toscr_delay[0] -= 2;
toscr_delay[0] &= fetchmode_mask;
toscr_delay[1] -= 2;
toscr_delay[1] &= fetchmode_mask;
}
if (nbits2) {
- do_delays (nbits2, fm);
+ do_delays(nbits2, fm);
delay_cycles += nbits2;
}
}
-STATIC_INLINE void toscr_1 (int nbits, int fm)
+STATIC_INLINE void toscr_1(int nbits, int fm)
{
- if (delay_cycles + nbits >= delay_lastcycle[0]) {
- toscr_right_edge (nbits, fm);
- } else if (toscr_delay[0] == toscr_delay[1]) {
+ if (delay_cycles + nbits >= delay_lastcycle[lol]) {
+ toscr_right_edge(nbits, fm);
+ }
+ else if (toscr_delay[0] == toscr_delay[1]) {
// Most common case.
- do_delays_fast (nbits, fm);
+ do_delays_fast(nbits, fm);
delay_cycles += nbits;
- } else {
- do_delays (nbits, fm);
+ }
+ else {
+ do_delays(nbits, fm);
delay_cycles += nbits;
}
@@ -1201,8 +1498,11 @@ STATIC_INLINE void toscr_1 (int nbits, int fm)
int i;
uae_u8 *dataptr = line_data[next_lineno] + out_offs * 4;
for (i = 0; i < thisline_decision.nr_planes; i++) {
- uae_u32 *dataptr32 = (uae_u32 *)dataptr;
- *dataptr32 = outword[i];
+ uae_u32 *dataptr32 = reinterpret_cast(dataptr);
+ if (*dataptr32 != outword[i]) {
+ thisline_changed = 1;
+ *dataptr32 = outword[i];
+ }
outword[i] = 0;
dataptr += MAX_WORDS_PER_LINE * 2;
}
@@ -1211,119 +1511,123 @@ STATIC_INLINE void toscr_1 (int nbits, int fm)
}
}
-static void toscr_1_hires (int nbits_nres, int fm)
-{
- int maxnbits = 16;
- while (nbits_nres >= 0) {
- int nbits = nbits_nres >= maxnbits ? maxnbits : nbits_nres;
- if (delay_cycles + nbits >= delay_lastcycle[0]) {
- toscr_right_edge(nbits, fm);
- } else {
- do_delays(nbits, fm);
- delay_cycles += nbits;
- }
+static void toscr_fm0(int);
+static void toscr_fm1(int);
+static void toscr_fm2(int);
- out_nbits += nbits;
- if (out_nbits == 32) {
- int i;
- uae_u8 *dataptr = line_data[next_lineno] + out_offs * 4;
- for (i = 0; i < thisline_decision.nr_planes; i++) {
- uae_u32 *dataptr32 = (uae_u32 *)dataptr;
- *dataptr32 = outword[i];
- outword[i] = 0;
- dataptr += MAX_WORDS_PER_LINE * 2;
- }
- out_offs++;
- out_nbits = 0;
- }
- nbits_nres -= nbits;
+STATIC_INLINE void toscr(int nbits, int fm)
+{
+ switch (fm) {
+ case 0: toscr_fm0(nbits); break;
+#ifdef AGA
+ case 1: toscr_fm1(nbits); break;
+ case 2: toscr_fm2(nbits); break;
+#endif
}
}
-static void toscr_fm0 (int);
-static void toscr_fm1 (int);
-static void toscr_fm2 (int);
-
-STATIC_INLINE void toscr (int nbits, int fm)
-{
- switch (fm) {
- case 0: toscr_fm0 (nbits); break;
- case 1: toscr_fm1 (nbits); break;
- case 2: toscr_fm2 (nbits); break;
- }
-}
-
-STATIC_INLINE void toscr_0 (int nbits, int fm)
+STATIC_INLINE void toscr_0(int nbits, int fm)
{
int t;
if (nbits > 16) {
- toscr (16, fm);
+ toscr(16, fm);
nbits -= 16;
}
t = 32 - out_nbits;
if (t < nbits) {
- toscr_1 (t, fm);
+ toscr_1(t, fm);
nbits -= t;
}
- toscr_1 (nbits, fm);
+ toscr_1(nbits, fm);
}
-static void toscr_fm0 (int nbits) { toscr_0 (nbits, 0); }
-static void toscr_fm1 (int nbits) { toscr_0 (nbits, 1); }
-static void toscr_fm2 (int nbits) { toscr_0 (nbits, 2); }
+static void toscr_fm0(int nbits) { toscr_0(nbits, 0); }
+static void toscr_fm1(int nbits) { toscr_0(nbits, 1); }
+static void toscr_fm2(int nbits) { toscr_0(nbits, 2); }
-STATIC_INLINE int flush_plane_data (int fm)
+static int flush_plane_data(int fm)
{
int i = 0;
if (out_nbits <= 16) {
i += 16;
- toscr_1 (16, fm);
+ toscr_1(16, fm);
}
if (out_nbits != 0) {
i += 32 - out_nbits;
- toscr_1 (32 - out_nbits, fm);
+ toscr_1(32 - out_nbits, fm);
}
i += 32;
- toscr_1 (16, fm);
- toscr_1 (16, fm);
+ toscr_1(16, fm);
+ toscr_1(16, fm);
- if (fm == 2) {
+ if (fm == 2) {
/* flush AGA full 64-bit shift register + possible data in todisplay */
- i += 32;
- toscr_1 (16, fm);
- toscr_1 (16, fm);
i += 32;
- toscr_1 (16, fm);
- toscr_1 (16, fm);
+ toscr_1(16, fm);
+ toscr_1(16, fm);
+ i += 32;
+ toscr_1(16, fm);
+ toscr_1(16, fm);
}
return i >> (1 + toscr_res);
}
-STATIC_INLINE void flush_display (int fm)
+STATIC_INLINE void flush_display(int fm)
{
- if (toscr_nbits > 0 && thisline_decision.plfleft >= 0)
- toscr (toscr_nbits, fm);
- toscr_nbits = 0;
+ if (toscr_nbits > 0 && thisline_decision.plfleft >= 0)
+ toscr(toscr_nbits, fm);
+ toscr_nbits = 0;
}
-static void update_denise_shifter_planes (int hpos)
+static void record_color_change(int hpos, int regno, unsigned long value);
+
+static void hack_shres_delay(int hpos)
{
- int np = GET_PLANES (bplcon0d);
+ if (!(currprefs.chipset_mask & CSMASK_AGA) && !toscr_delay_sh[0] && !toscr_delay_sh[1])
+ return;
+ int o0 = toscr_delay_sh[0];
+ int o1 = toscr_delay_sh[1];
+ int shdelay1 = (bplcon1 >> 8) & 3;
+ int shdelay2 = (bplcon1 >> 12) & 3;
+ if (shdelay1 != shdelay2) {
+ shdelay_disabled = true;
+ }
+ if (shdelay_disabled) {
+ toscr_delay_sh[0] = 0;
+ toscr_delay_sh[1] = 0;
+ }
+ else {
+ toscr_delay_sh[0] = (shdelay1 & 3) >> toscr_res;
+ toscr_delay_sh[1] = (shdelay2 & 3) >> toscr_res;
+ }
+ if (hpos >= 0 && (toscr_delay_sh[0] != o0 || toscr_delay_sh[1] != o1)) {
+ record_color_change(hpos, 0, COLOR_CHANGE_SHRES_DELAY | toscr_delay_sh[0]);
+ current_colors.extra &= ~(1 << CE_SHRES_DELAY);
+ current_colors.extra &= ~(1 << (CE_SHRES_DELAY + 1));
+ current_colors.extra |= toscr_delay_sh[0] << CE_SHRES_DELAY;
+ remembered_color_entry = -1;
+ thisline_changed = true;
+ }
+}
+
+static void update_denise_shifter_planes(int hpos)
+{
+ int np = GET_PLANES(bplcon0d);
// if DMA has ended but there is still data waiting in todisplay,
// it must be flushed out before number of planes change
if (np < toscr_nr_planes_shifter && hpos > thisline_decision.plfright && thisline_decision.plfright && (todisplay_fetched[0] || todisplay_fetched[1])) {
int diff = (hpos - thisline_decision.plfright) << (1 + toscr_res);
while (diff >= 16) {
- toscr_1 (16, fetchmode);
+ toscr_1(16, fetchmode);
diff -= 16;
}
if (diff)
- toscr_1 (diff, fetchmode);
+ toscr_1(diff, fetchmode);
thisline_decision.plfright += hpos - thisline_decision.plfright;
}
// FIXME: Samplers / Back In 90 vs Disposable Hero title screen in fast modes
@@ -1336,78 +1640,84 @@ static void update_denise_shifter_planes (int hpos)
}
}
-static void update_denise (int hpos)
+static void update_denise(int hpos)
{
- int res = GET_RES_DENISE (bplcon0d);
+ int res = GET_RES_DENISE(bplcon0d);
if (res != toscr_res)
- flush_display (fetchmode);
- toscr_res = GET_RES_DENISE (bplcon0d);
+ flush_display(fetchmode);
+ toscr_res = GET_RES_DENISE(bplcon0d);
toscr_res2p = 2 << toscr_res;
delay_cycles = (hpos * 2) << toscr_res;
if (bplcon0dd != bplcon0d) {
- record_color_change2 (hpos, 0x100 + 0x1000, bplcon0d);
+ record_color_change2(hpos, 0x100 + 0x1000, bplcon0d);
bplcon0dd = bplcon0d;
}
- toscr_nr_planes = GET_PLANES (bplcon0d);
- if (isocs7planes ()) {
+ toscr_nr_planes = GET_PLANES(bplcon0d);
+ if (isocs7planes()) {
if (toscr_nr_planes2 < 6)
toscr_nr_planes2 = 6;
- } else {
+ }
+ else {
toscr_nr_planes2 = toscr_nr_planes;
}
toscr_nr_planes_shifter = toscr_nr_planes2;
+ hack_shres_delay(hpos);
}
-STATIC_INLINE void fetch_start (void)
+STATIC_INLINE void fetch_start(int hpos)
{
fetch_state = fetch_started;
}
/* Called when all planes have been fetched, i.e. when a new block
- of data is available to be displayed. The data in fetched[] is
- moved into todisplay[]. */
-STATIC_INLINE void beginning_of_plane_block (int hpos, int fm)
+of data is available to be displayed. The data in fetched[] is
+moved into todisplay[]. */
+static void beginning_of_plane_block(int hpos, int fm)
{
int i;
if (fm == 0)
for (i = 0; i < MAX_PLANES; i++) {
todisplay[i] = fetched[i];
- }
+ }
+#ifdef AGA
else
for (i = 0; i < MAX_PLANES; i++) {
todisplay_aga[i] = fetched_aga[i];
- }
+ }
+#endif
todisplay_fetched[0] = todisplay_fetched[1] = true;
- maybe_first_bpl1dat (hpos);
- update_denise (hpos);
+ maybe_first_bpl1dat(hpos);
+ update_denise(hpos);
if (toscr_nr_planes_agnus > thisline_decision.nr_planes)
- update_toscr_planes (fm);
+ update_toscr_planes(fm);
}
+#ifdef SPEEDUP
/* The usual inlining tricks - don't touch unless you know what you are doing. */
-STATIC_INLINE void long_fetch_16 (int plane, int nwords, int weird_number_of_bits, int dma)
+STATIC_INLINE void long_fetch_16(int plane, int nwords, int weird_number_of_bits, int dma)
{
- uae_u16 *real_pt = (uae_u16 *)pfield_xlateptr (bplpt[plane], nwords * 2);
+ uae_u16 *real_pt = reinterpret_cast(pfield_xlateptr(bplpt[plane], nwords * 2));
int delay = toscr_delay_adjusted[plane & 1];
- int tmp_nbits = out_nbits;
- uae_u32 shiftbuffer;
- uae_u32 outval = outword[plane];
- uae_u32 fetchval = fetched[plane];
- uae_u32 *dataptr = (uae_u32 *)(line_data[next_lineno] + 2 * plane * MAX_WORDS_PER_LINE + 4 * out_offs);
+ int tmp_nbits = out_nbits;
+ uae_u32 shiftbuffer;
+ uae_u32 outval = outword[plane];
+ uae_u32 fetchval = fetched[plane];
+ uae_u32 *dataptr = reinterpret_cast(line_data[next_lineno] + 2 * plane * MAX_WORDS_PER_LINE + 4 * out_offs);
- if (dma) {
- bplpt[plane] += nwords *2;
- }
+ if (dma) {
+ bplpt[plane] += nwords * 2;
+ bplptx[plane] += nwords * 2;
+ }
- if (real_pt == 0)
+ if (real_pt == nullptr)
/* @@@ Don't do this, fall back on chipmem_wget instead. */
- return;
+ return;
shiftbuffer = todisplay2[plane] << delay;
- while (nwords > 0) {
+ while (nwords > 0) {
int bits_left = 32 - tmp_nbits;
uae_u32 t;
@@ -1418,51 +1728,48 @@ STATIC_INLINE void long_fetch_16 (int plane, int nwords, int weird_number_of_bit
if (weird_number_of_bits && bits_left < 16) {
outval <<= bits_left;
outval |= t >> (16 - bits_left);
- *dataptr++ = outval;
+ thisline_changed |= *dataptr ^ outval;
+ *dataptr++ = outval;
- outval = t;
+ outval = t;
tmp_nbits = 16 - bits_left;
- } else {
+ }
+ else {
outval = (outval << 16) | t;
tmp_nbits += 16;
if (tmp_nbits == 32) {
- *dataptr++ = outval;
+ thisline_changed |= *dataptr ^ outval;
+ *dataptr++ = outval;
tmp_nbits = 0;
}
}
shiftbuffer <<= 16;
nwords--;
if (dma) {
-#ifdef ARMV6_ASSEMBLY
- __asm__ (
- "ldrh %[val], [%[pt]], #2 \n\t"
- "rev16 %[val], %[val] \n\t"
- : [val] "=r" (fetchval), [pt] "+r" (real_pt) );
-#else
- fetchval = do_get_mem_word (real_pt);
+ fetchval = do_get_mem_word(real_pt);
real_pt++;
-#endif
}
}
- fetched[plane] = fetchval;
+ fetched[plane] = fetchval;
todisplay2[plane] = shiftbuffer >> delay;
- outword[plane] = outval;
+ outword[plane] = outval;
}
-STATIC_INLINE void long_fetch_32 (int plane, int nwords, int weird_number_of_bits, int dma)
+#ifdef AGA
+STATIC_INLINE void long_fetch_32(int plane, int nwords, int weird_number_of_bits, int dma)
{
- uae_u32 *real_pt = (uae_u32 *)pfield_xlateptr (bplpt[plane] & ~3, nwords * 2);
+ uae_u32 *real_pt = reinterpret_cast(pfield_xlateptr(bplpt[plane], nwords * 2));
int delay = toscr_delay_adjusted[plane & 1];
int tmp_nbits = out_nbits;
uae_u64 shiftbuffer;
uae_u32 outval = outword[plane];
- uae_u32 fetchval = (uae_u32)fetched_aga[plane];
- uae_u32 *dataptr = (uae_u32 *)(line_data[next_lineno] + 2 * plane * MAX_WORDS_PER_LINE + 4 * out_offs);
- bool unaligned = (bplpt[plane] & 2) != 0;
+ uae_u32 fetchval = fetched_aga[plane];
+ uae_u32 *dataptr = reinterpret_cast(line_data[next_lineno] + 2 * plane * MAX_WORDS_PER_LINE + 4 * out_offs);
if (dma) {
bplpt[plane] += nwords * 2;
- }
+ bplptx[plane] += nwords * 2;
+ }
if (real_pt == 0)
/* @@@ Don't do this, fall back on chipmem_wget instead. */
@@ -1475,7 +1782,7 @@ STATIC_INLINE void long_fetch_32 (int plane, int nwords, int weird_number_of_bit
shiftbuffer |= fetchval;
for (int i = 0; i < 2; i++) {
- uae_u32 t;
+ uae_u32 t;
int bits_left = 32 - tmp_nbits;
t = (shiftbuffer >> (16 + delay)) & 0xffff;
@@ -1484,46 +1791,36 @@ STATIC_INLINE void long_fetch_32 (int plane, int nwords, int weird_number_of_bit
outval <<= bits_left;
outval |= t >> (16 - bits_left);
- *dataptr++ = outval;
+ thisline_changed |= *dataptr ^ outval;
+ *dataptr++ = outval;
outval = t;
tmp_nbits = 16 - bits_left;
- } else {
+ }
+ else {
outval = (outval << 16) | t;
tmp_nbits += 16;
if (tmp_nbits == 32) {
- *dataptr++ = outval;
- tmp_nbits = 0;
+ thisline_changed |= *dataptr ^ outval;
+ *dataptr++ = outval;
+ tmp_nbits = 0;
}
}
shiftbuffer <<= 16;
}
nwords -= 2;
if (dma) {
-#ifdef ARMV6_ASSEMBLY
- __asm__ (
- "ldr %[val], [%[pt]], #4 \n\t"
- "rev %[val], %[val] \n\t"
- : [val] "=r" (fetchval), [pt] "+r" (real_pt) );
-#else
- fetchval = do_get_mem_long (real_pt);
+ fetchval = do_get_mem_long(real_pt);
real_pt++;
-#endif
- if (unaligned) {
- fetchval &= 0x0000ffff;
- fetchval |= fetchval << 16;
- } else if (fetchmode_fmode & 2) {
- fetchval &= 0xffff0000;
- fetchval |= fetchval >> 16;
- }
}
+
}
fetched_aga[plane] = fetchval;
todisplay2_aga[plane] = (shiftbuffer >> delay) & 0xffffffff;
outword[plane] = outval;
}
-STATIC_INLINE void shift32plus (uae_u64 *p, int n)
+STATIC_INLINE void shift32plus(uae_u64 *p, int n)
{
uae_u64 t = p[1];
t <<= n;
@@ -1531,14 +1828,14 @@ STATIC_INLINE void shift32plus (uae_u64 *p, int n)
p[1] = t;
}
-STATIC_INLINE void aga_shift (uae_u64 *p, int n)
+STATIC_INLINE void aga_shift(uae_u64 *p, int n)
{
if (n == 0) return;
- shift32plus (p, n);
+ shift32plus(p, n);
p[0] <<= n;
}
-STATIC_INLINE void shift32plusn (uae_u64 *p, int n)
+STATIC_INLINE void shift32plusn(uae_u64 *p, int n)
{
uae_u64 t = p[0];
t >>= n;
@@ -1546,148 +1843,165 @@ STATIC_INLINE void shift32plusn (uae_u64 *p, int n)
p[0] = t;
}
-STATIC_INLINE void aga_shift_n (uae_u64 *p, int n)
+STATIC_INLINE void aga_shift_n(uae_u64 *p, int n)
{
if (n == 0) return;
- shift32plusn (p, n);
+ shift32plusn(p, n);
p[1] >>= n;
}
-STATIC_INLINE void long_fetch_64 (int plane, int nwords, int weird_number_of_bits, int dma)
+STATIC_INLINE void long_fetch_64(int plane, int nwords, int weird_number_of_bits, int dma)
{
- uae_u32 *real_pt = (uae_u32 *)pfield_xlateptr (bplpt[plane] & ~7, nwords * 2);
+ uae_u32 *real_pt = reinterpret_cast(pfield_xlateptr(bplpt[plane], nwords * 2));
int delay = toscr_delay_adjusted[plane & 1];
int tmp_nbits = out_nbits;
+#ifdef HAVE_UAE_U128
+ uae_u128 shiftbuffer;
+#else
uae_u64 shiftbuffer[2];
+#endif
uae_u32 outval = outword[plane];
uae_u64 fetchval = fetched_aga[plane];
- uae_u32 *dataptr = (uae_u32 *)(line_data[next_lineno] + 2 * plane * MAX_WORDS_PER_LINE + 4 * out_offs);
+ uae_u32 *dataptr = reinterpret_cast(line_data[next_lineno] + 2 * plane * MAX_WORDS_PER_LINE + 4 * out_offs);
int shift = (64 - 16) + delay;
- bool unaligned2 = (bplpt[plane] & 2) != 0;
- bool unaligned4 = (bplpt[plane] & 4) != 0;
if (dma) {
bplpt[plane] += nwords * 2;
- }
+ bplptx[plane] += nwords * 2;
+ }
if (real_pt == 0)
/* @@@ Don't do this, fall back on chipmem_wget instead. */
return;
+#ifdef HAVE_UAE_U128
+ shiftbuffer = todisplay2_aga[plane] << delay;
+#else
shiftbuffer[1] = 0;
shiftbuffer[0] = todisplay2_aga[plane];
- aga_shift (shiftbuffer, delay);
+ aga_shift(shiftbuffer, delay);
+#endif
while (nwords > 0) {
int i;
+#ifdef HAVE_UAE_U128
+ shiftbuffer |= fetchval;
+#else
shiftbuffer[0] |= fetchval;
+#endif
for (i = 0; i < 4; i++) {
- uae_u32 t;
+ uae_u32 t;
int bits_left = 32 - tmp_nbits;
+#ifdef HAVE_UAE_U128
+ t = (shiftbuffer >> shift) & 0xffff;
+#else
if (64 - shift > 0) {
- t = (uae_u32)(shiftbuffer[1] << (64 - shift));
+ t = shiftbuffer[1] << (64 - shift);
t |= shiftbuffer[0] >> shift;
- } else {
- t = (uae_u32)(shiftbuffer[1] >> (shift - 64));
+ }
+ else {
+ t = shiftbuffer[1] >> (shift - 64);
}
t &= 0xffff;
+#endif
if (weird_number_of_bits && bits_left < 16) {
outval <<= bits_left;
outval |= t >> (16 - bits_left);
- *dataptr++ = outval;
+ thisline_changed |= *dataptr ^ outval;
+ *dataptr++ = outval;
outval = t;
tmp_nbits = 16 - bits_left;
- } else {
+ }
+ else {
outval = (outval << 16) | t;
tmp_nbits += 16;
if (tmp_nbits == 32) {
- *dataptr++ = outval;
- tmp_nbits = 0;
- }
+ thisline_changed |= *dataptr ^ outval;
+ *dataptr++ = outval;
+ tmp_nbits = 0;
}
- aga_shift (shiftbuffer, 16);
}
+#ifdef HAVE_UAE_U128
+ shiftbuffer <<= 16;
+#else
+ aga_shift(shiftbuffer, 16);
+#endif
+ }
nwords -= 4;
if (dma) {
- uae_u32 *real_pt1, *real_pt2;
- if (unaligned4) {
- real_pt1 = real_pt + 1;
- real_pt2 = real_pt + 1;
- } else {
- real_pt1 = real_pt;
- real_pt2 = real_pt + 1;
- }
- if (unaligned2) {
- uae_u32 v1 = do_get_mem_long (real_pt1);
- uae_u32 v2 = do_get_mem_long (real_pt2);
- v1 &= 0x0000ffff;
- v1 |= v1 << 16;
- v2 &= 0x0000ffff;
- v2 |= v2 << 16;
- fetchval = (((uae_u64)v1) << 32) | v2;
- } else {
- fetchval = ((uae_u64)do_get_mem_long (real_pt1)) << 32;
- fetchval |= do_get_mem_long (real_pt2);
- }
- real_pt += 2;
+ fetchval = static_cast(do_get_mem_long(real_pt)) << 32;
+ fetchval |= do_get_mem_long(real_pt + 1);
+ real_pt += 2;
}
- }
+}
fetched_aga[plane] = fetchval;
- aga_shift_n (shiftbuffer, delay);
+#ifdef HAVE_UAE_U128
+ todisplay2_aga[plane] = shiftbuffer >> delay;
+#else
+ aga_shift_n(shiftbuffer, delay);
todisplay2_aga[plane] = shiftbuffer[0];
+#endif
outword[plane] = outval;
}
+#endif
-static void long_fetch_16_0 (int hpos, int nwords, int dma) { long_fetch_16 (hpos, nwords, 0, dma); }
-static void long_fetch_16_1 (int hpos, int nwords, int dma) { long_fetch_16 (hpos, nwords, 1, dma); }
-static void long_fetch_32_0 (int hpos, int nwords, int dma) { long_fetch_32 (hpos, nwords, 0, dma); }
-static void long_fetch_32_1 (int hpos, int nwords, int dma) { long_fetch_32 (hpos, nwords, 1, dma); }
-static void long_fetch_64_0 (int hpos, int nwords, int dma) { long_fetch_64 (hpos, nwords, 0, dma); }
-static void long_fetch_64_1 (int hpos, int nwords, int dma) { long_fetch_64 (hpos, nwords, 1, dma); }
+static void long_fetch_16_0(int hpos, int nwords, int dma) { long_fetch_16(hpos, nwords, 0, dma); }
+static void long_fetch_16_1(int hpos, int nwords, int dma) { long_fetch_16(hpos, nwords, 1, dma); }
+#ifdef AGA
+static void long_fetch_32_0(int hpos, int nwords, int dma) { long_fetch_32(hpos, nwords, 0, dma); }
+static void long_fetch_32_1(int hpos, int nwords, int dma) { long_fetch_32(hpos, nwords, 1, dma); }
+static void long_fetch_64_0(int hpos, int nwords, int dma) { long_fetch_64(hpos, nwords, 0, dma); }
+static void long_fetch_64_1(int hpos, int nwords, int dma) { long_fetch_64(hpos, nwords, 1, dma); }
+#endif
-static void do_long_fetch (int hpos, int nwords, int dma, int fm)
+static void do_long_fetch(int hpos, int nwords, int dma, int fm)
{
int i;
- flush_display (fm);
- beginning_of_plane_block (hpos, fm);
+ flush_display(fm);
+ beginning_of_plane_block(hpos, fm);
switch (fm) {
- case 0:
- if (out_nbits & 15) {
- for (i = 0; i < toscr_nr_planes; i++)
- long_fetch_16_1 (i, nwords, dma);
- } else {
- for (i = 0; i < toscr_nr_planes; i++)
- long_fetch_16_0 (i, nwords, dma);
- }
- break;
- case 1:
- if (out_nbits & 15) {
- for (i = 0; i < toscr_nr_planes; i++)
- long_fetch_32_1 (i, nwords, dma);
- } else {
- for (i = 0; i < toscr_nr_planes; i++)
- long_fetch_32_0 (i, nwords, dma);
- }
- break;
- case 2:
- if (out_nbits & 15) {
- for (i = 0; i < toscr_nr_planes; i++)
- long_fetch_64_1 (i, nwords, dma);
- } else {
- for (i = 0; i < toscr_nr_planes; i++)
- long_fetch_64_0 (i, nwords, dma);
- }
- break;
+ case 0:
+ if (out_nbits & 15) {
+ for (i = 0; i < toscr_nr_planes; i++)
+ long_fetch_16_1(i, nwords, dma);
+ }
+ else {
+ for (i = 0; i < toscr_nr_planes; i++)
+ long_fetch_16_0(i, nwords, dma);
+ }
+ break;
+#ifdef AGA
+ case 1:
+ if (out_nbits & 15) {
+ for (i = 0; i < toscr_nr_planes; i++)
+ long_fetch_32_1(i, nwords, dma);
+ }
+ else {
+ for (i = 0; i < toscr_nr_planes; i++)
+ long_fetch_32_0(i, nwords, dma);
+ }
+ break;
+ case 2:
+ if (out_nbits & 15) {
+ for (i = 0; i < toscr_nr_planes; i++)
+ long_fetch_64_1(i, nwords, dma);
+ }
+ else {
+ for (i = 0; i < toscr_nr_planes; i++)
+ long_fetch_64_0(i, nwords, dma);
+ }
+ break;
+#endif
}
out_nbits += nwords * 16;
@@ -1695,29 +2009,31 @@ static void do_long_fetch (int hpos, int nwords, int dma, int fm)
out_nbits &= 31;
delay_cycles += nwords * 16;
- if (dma && toscr_nr_planes > 0)
+ if (dma && toscr_nr_planes > 0)
fetch_state = fetch_was_plane0;
}
-STATIC_INLINE void finish_last_fetch (int pos, int fm, bool reallylast)
+#endif
+
+static void finish_last_fetch(int pos, int fm, bool reallylast)
{
- if (thisline_decision.plfleft < 0)
- return;
+ if (thisline_decision.plfleft < 0)
+ return;
if (plfr_state >= plfr_end)
- return;
+ return;
plfr_state = plfr_end;
- flush_display (fm);
+ flush_display(fm);
// This may not be the last fetch, store current endpos for future use.
// There is at least one demo that has two DDFSTRT-DDFSTOP horizontal sections
// Subtle Shades / Nuance.
- thisline_decision.plfright = pos;
+ thisline_decision.plfright = pos;
if (!reallylast) {
- if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
- ddfstate = DIW_waiting_start;
- fetch_state = fetch_not_started;
- }
+ if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
+ ddfstate = DIW_waiting_start;
+ fetch_state = fetch_not_started;
+ }
}
}
@@ -1730,43 +2046,129 @@ static void reset_bpl_vars(void)
}
/* check special case where last fetch wraps to next line
- * this makes totally corrupted and flickering display on
- * real hardware due to refresh cycle conflicts
- */
-static void maybe_finish_last_fetch (int pos, int fm)
+* this makes totally corrupted and flickering display on
+* real hardware due to refresh cycle conflicts
+* Exception: AGA + 64 bit fetch: glitch free overrun is possible.
+*/
+static void maybe_finish_last_fetch(int pos, int fm)
{
- if (plf_state > plf_passed_stop2 || plf_state < plf_passed_stop || (fetch_state != fetch_started && fetch_state != fetch_started_first) || !dmaen (DMA_BITPLANE) || bitplane_maybe_start_hpos >= 0x100) {
- finish_last_fetch (pos, fm, true);
- } else {
- SET_LINE_CYCLEBASED;
+ if (plf_state > plf_passed_stop2 || plf_state < plf_passed_stop || (fetch_state != fetch_started && fetch_state != fetch_started_first) || !dmaen(DMA_BITPLANE)) {
+ finish_last_fetch(pos, fm, true);
+ }
+ else {
+ bitplane_overrun_fetch_cycle = fetch_cycle - 1;
+ int cycle_start = bitplane_overrun_fetch_cycle & fetchstart_mask;
+ int left = fetchunit - cycle_start;
+ if (plf_state == plf_passed_stop_act) {
+ // not passed stop: remaining cycles + full block.
+ bitplane_overrun = 2;
+ bitplane_overrun_hpos = left + fm_maxplane;
+ }
+ else {
+ // already passsed stop but some cycles remaining.
+ bitplane_overrun = -1;
+ // only idle cycles left?
+ left -= fetchunit - fm_maxplane;
+ if (left <= 0)
+ bitplane_overrun = 0;
+ bitplane_overrun_hpos = left;
+ }
+ bitplane_overrun_cycle_diagram_shift = fetchunit - (bitplane_overrun_fetch_cycle & fetchstart_mask);
finish_last_fetch(pos, fm, true);
}
}
+static void do_overrun_fetch(int until, int fm)
+{
+ static int warned = 20;
+ bool hit = false;
+
+ if (until <= 0)
+ return;
+ for (int pos = last_fetch_hpos; pos < until; pos++) {
+ bool bpl0 = false;
+ int cycle_start = bitplane_overrun_fetch_cycle & fetchstart_mask;
+
+ if (pos < 0)
+ continue;
+
+ if ((bitplane_overrun_fetch_cycle & fetchunit_mask) == 0 && bitplane_overrun < 0) {
+ bitplane_overrun = 0;
+ return;
+ }
+
+ bool modulo = bitplane_overrun < 2;
+ switch (fm_maxplane) {
+ case 8:
+ switch (cycle_start) {
+ case 0: fetch(7, fm, modulo, pos); hit = true; break;
+ case 1: fetch(3, fm, modulo, pos); hit = true; break;
+ case 2: fetch(5, fm, modulo, pos); hit = true; break;
+ case 3: fetch(1, fm, modulo, pos); hit = true; break;
+ case 4: fetch(6, fm, modulo, pos); hit = true; break;
+ case 5: fetch(2, fm, modulo, pos); hit = true; break;
+ case 6: fetch(4, fm, modulo, pos); hit = true; break;
+ case 7: fetch(0, fm, modulo, pos); hit = true; bpl0 = true; break;
+ default:
+ break;
+ }
+ break;
+ case 4:
+ switch (cycle_start) {
+ case 0: fetch(3, fm, modulo, pos); hit = true; break;
+ case 1: fetch(1, fm, modulo, pos); hit = true; break;
+ case 2: fetch(2, fm, modulo, pos); hit = true; break;
+ case 3: fetch(0, fm, modulo, pos); hit = true; bpl0 = true; break;
+ default:
+ break;
+ }
+ break;
+ case 2:
+ switch (cycle_start) {
+ case 0: fetch(1, fm, modulo, pos); hit = true; break;
+ case 1: fetch(0, fm, modulo, pos); hit = true; bpl0 = true; break;
+ default:
+ break;
+ }
+ break;
+ }
+
+ if ((bitplane_overrun_fetch_cycle & fetchunit_mask) == 0) {
+ bitplane_overrun--;
+ if (hit && warned > 0) {
+ warned--;
+ write_log(_T("WARNING: bitplane DMA crossing scanlines!\n"));
+ }
+ if (bitplane_overrun <= 0)
+ break;
+ }
+
+ bitplane_overrun_fetch_cycle++;
+ }
+}
/* make sure fetch that goes beyond maxhpos is finished */
-STATIC_INLINE void finish_final_fetch (void)
+static void finish_final_fetch(void)
{
if (thisline_decision.plfleft < 0)
- return;
+ return;
if (plfr_state < plfr_end)
- finish_last_fetch (maxhpos, fetchmode, true);
+ finish_last_fetch(maxhpos, fetchmode, true);
plfr_state = plfr_finished;
// workaround for too long fetches that don't pass plf_passed_stop2 before end of scanline
if (aga_plf_passed_stop2 && plf_state >= plf_passed_stop)
plf_state = plf_end;
-
+
// This is really the end of scanline, we can finally flush all remaining data.
- thisline_decision.plfright += flush_plane_data (fetchmode);
- // This can overflow if display setup is really bad.
- if (out_offs > MAX_PIXELS_PER_LINE / 32)
- out_offs = MAX_PIXELS_PER_LINE / 32;
+ thisline_decision.plfright += flush_plane_data(fetchmode);
thisline_decision.plflinelen = out_offs;
+
+ finish_playfield_line();
}
-STATIC_INLINE int one_fetch_cycle_0 (int pos, int dma, int fm)
+STATIC_INLINE int one_fetch_cycle_0(int pos, int dma, int fm)
{
bool bplactive = true;
bool diw = diwstate == DIW_waiting_stop;
@@ -1781,12 +2183,14 @@ STATIC_INLINE int one_fetch_cycle_0 (int pos, int dma, int fm)
if (bitplane_off_delay == 0) {
if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
plf_state = plf_passed_stop;
- } else {
+ }
+ else {
plf_state = plf_active;
}
}
}
- } else if (!dma || !diw) {
+ }
+ else if (!dma || !diw) {
bplactive = false;
// dma off: turn off bitplane output after 4 cycles
// (yes, switching DMA off won't disable it immediately)
@@ -1816,7 +2220,8 @@ STATIC_INLINE int one_fetch_cycle_0 (int pos, int dma, int fm)
plf_state = plf_passed_stop;
}
plf_end_hpos = pos + DDF_OFFSET;
- } else if (pos == plf_end_hpos) {
+ }
+ else if (pos == plf_end_hpos) {
ddfstop_matched = true;
if (plf_state < plf_passed_stop_act) {
plf_state = plf_passed_stop_act;
@@ -1840,60 +2245,67 @@ STATIC_INLINE int one_fetch_cycle_0 (int pos, int dma, int fm)
if (pos == HARD_DDF_STOP) {
if (plf_state < plf_wait) {
plf_state = plf_passed_stop_act;
- }
+ }
}
- maybe_check (pos);
+ maybe_check(pos);
if (bplactive) {
- /* fetchstart_mask can be larger than fm_maxplane if FMODE > 0. This means
- that the remaining cycles are idle; we'll fall through the whole switch
- without doing anything. */
+ /* fetchstart_mask can be larger than fm_maxplane if FMODE > 0. This means
+ that the remaining cycles are idle; we'll fall through the whole switch
+ without doing anything. */
int cycle_start = fetch_cycle & fetchstart_mask;
- bool modulo = plf_state == plf_passed_stop2 && fetch_cycle >= (fetch_cycle & ~fetchunit_mask) + fetch_modulo_cycle;
+ bool modulo = plf_state == plf_passed_stop2 && fetch_cycle >= (fetch_cycle & ~fetchunit_mask) + fetch_modulo_cycle;
+
switch (fm_maxplane) {
- case 8:
- switch (cycle_start) {
- case 0: fetch (7, fm, modulo, pos); break;
- case 1: fetch (3, fm, modulo, pos); break;
- case 2: fetch (5, fm, modulo, pos); break;
- case 3: fetch (1, fm, modulo, pos); break;
- case 4: fetch (6, fm, modulo, pos); break;
- case 5: fetch (2, fm, modulo, pos); break;
- case 6: fetch (4, fm, modulo, pos); break;
- case 7: fetch (0, fm, modulo, pos); break;
- default:
- // if AGA: consider plf_passed_stop2 already
- // active when last plane has been written,
- // even if there is still idle cycles left
- if (!aga_plf_passed_stop2 && plf_state >= plf_passed_stop_act)
- aga_plf_passed_stop2 = pos + ((8 << fetchmode) - cycle_start);
- break;
- }
+ case 8:
+ switch (cycle_start) {
+ case 0: fetch(7, fm, modulo, pos); break;
+ case 1: fetch(3, fm, modulo, pos); break;
+ case 2: fetch(5, fm, modulo, pos); break;
+ case 3: fetch(1, fm, modulo, pos); break;
+ case 4: fetch(6, fm, modulo, pos); break;
+ case 5: fetch(2, fm, modulo, pos); break;
+ case 6: fetch(4, fm, modulo, pos); break;
+ case 7: fetch(0, fm, modulo, pos); break;
+#ifdef AGA
+ default:
+ // if AGA: consider plf_passed_stop2 already
+ // active when last plane has been written,
+ // even if there is still idle cycles left
+ if (plf_state == plf_passed_stop_act)
+ aga_plf_passed_stop2 = true;
break;
- case 4:
- switch (cycle_start) {
- case 0: fetch (3, fm, modulo, pos); break;
- case 1: fetch (1, fm, modulo, pos); break;
- case 2: fetch (2, fm, modulo, pos); break;
- case 3: fetch (0, fm, modulo, pos); break;
- default:
- if (!aga_plf_passed_stop2 && plf_state >= plf_passed_stop_act)
- aga_plf_passed_stop2 = pos + ((8 << fetchmode) - cycle_start);
- break;
- }
+#endif
+ }
+ break;
+ case 4:
+ switch (cycle_start) {
+ case 0: fetch(3, fm, modulo, pos); break;
+ case 1: fetch(1, fm, modulo, pos); break;
+ case 2: fetch(2, fm, modulo, pos); break;
+ case 3: fetch(0, fm, modulo, pos); break;
+#ifdef AGA
+ default:
+ if (plf_state == plf_passed_stop_act)
+ aga_plf_passed_stop2 = true;
break;
- case 2:
- switch (cycle_start) {
- case 0: fetch (1, fm, modulo, pos); break;
- case 1: fetch (0, fm, modulo, pos); break;
- default:
- if (!aga_plf_passed_stop2 && plf_state >= plf_passed_stop_act)
- aga_plf_passed_stop2 = pos + ((8 << fetchmode) - cycle_start);
- break;
- }
+#endif
+ }
+ break;
+ case 2:
+ switch (cycle_start) {
+ case 0: fetch(1, fm, modulo, pos); break;
+ case 1: fetch(0, fm, modulo, pos); break;
+#ifdef AGA
+ default:
+ if (plf_state == plf_passed_stop_act)
+ aga_plf_passed_stop2 = true;
break;
+#endif
+ }
+ break;
}
}
@@ -1910,45 +2322,46 @@ STATIC_INLINE int one_fetch_cycle_0 (int pos, int dma, int fm)
toscr_nbits += toscr_res2p;
if (bplcon1_written) {
- flush_display (fm);
- compute_toscr_delay (bplcon1);
+ flush_display(fm);
+ compute_toscr_delay(bplcon1);
bplcon1_written = false;
}
if (toscr_nbits > 16) {
- uae_abort (_T("toscr_nbits > 16 (%d)"), toscr_nbits);
+ uae_abort(_T("toscr_nbits > 16 (%d)"), toscr_nbits);
toscr_nbits = 0;
}
-
if (toscr_nbits == 16)
- flush_display (fm);
-
+ flush_display(fm);
+
return 0;
}
-static int one_fetch_cycle_fm0 (int pos, int dma) { return one_fetch_cycle_0 (pos, dma, 0); }
-static int one_fetch_cycle_fm1 (int pos, int dma) { return one_fetch_cycle_0 (pos, dma, 1); }
-static int one_fetch_cycle_fm2 (int pos, int dma) { return one_fetch_cycle_0 (pos, dma, 2); }
+static int one_fetch_cycle_fm0(int pos, int dma) { return one_fetch_cycle_0(pos, dma, 0); }
+static int one_fetch_cycle_fm1(int pos, int dma) { return one_fetch_cycle_0(pos, dma, 1); }
+static int one_fetch_cycle_fm2(int pos, int dma) { return one_fetch_cycle_0(pos, dma, 2); }
-STATIC_INLINE int one_fetch_cycle (int pos, int dma, int fm)
+STATIC_INLINE int one_fetch_cycle(int pos, int dma, int fm)
{
- switch (fm) {
- case 0: return one_fetch_cycle_fm0 (pos, dma);
- case 1: return one_fetch_cycle_fm1 (pos, dma);
- case 2: return one_fetch_cycle_fm2 (pos, dma);
- default: uae_abort (_T("fm corrupt")); return 0;
- }
+ switch (fm) {
+ case 0: return one_fetch_cycle_fm0(pos, dma);
+#ifdef AGA
+ case 1: return one_fetch_cycle_fm1(pos, dma);
+ case 2: return one_fetch_cycle_fm2(pos, dma);
+#endif
+ default: uae_abort(_T("fm corrupt")); return 0;
+ }
}
-static void update_fetch_x (int until, int fm)
+static void update_fetch_x(int until, int fm)
{
int pos;
- if (nodraw ())
+ if (nodraw())
return;
pos = last_fetch_hpos;
- update_toscr_planes (fm);
+ update_toscr_planes(fm);
// not optimized, update_fetch_x() is extremely rarely used.
for (; pos < until; pos++) {
@@ -1956,41 +2369,41 @@ static void update_fetch_x (int until, int fm)
toscr_nbits += toscr_res2p;
if (toscr_nbits > 16) {
- uae_abort (_T("xtoscr_nbits > 16 (%d)"), toscr_nbits);
+ uae_abort(_T("xtoscr_nbits > 16 (%d)"), toscr_nbits);
toscr_nbits = 0;
}
if (toscr_nbits == 16)
- flush_display (fm);
+ flush_display(fm);
}
if (until >= maxhpos) {
- maybe_finish_last_fetch (pos, fm);
+ maybe_finish_last_fetch(pos, fm);
return;
}
- flush_display (fm);
+ flush_display(fm);
}
-STATIC_INLINE void update_fetch (int until, int fm)
+static void update_fetch(int until, int fm)
{
int pos;
- int dma = dmaen (DMA_BITPLANE);
+ int dma = dmaen(DMA_BITPLANE);
- if (nodraw() || plf_state >= plf_end)
+ if (nodraw() || plf_state >= plf_end)
return;
pos = last_fetch_hpos;
- cycle_diagram_shift = last_fetch_hpos - fetch_cycle;
+ cycle_diagram_shift = last_fetch_hpos - fetch_cycle;
/* First, a loop that prepares us for the speedup code. We want to enter
the SPEEDUP case with fetch_state == fetch_was_plane0 or it is the very
first fetch cycle (which equals to same state as fetch_was_plane0)
- and then unroll whole blocks, so that we end on the same fetch_state again. */
+ and then unroll whole blocks, so that we end on the same fetch_state again. */
for (; ; pos++) {
if (pos == until) {
if (until >= maxhpos) {
- maybe_finish_last_fetch (pos, fm);
+ maybe_finish_last_fetch(pos, fm);
return;
}
return;
@@ -1998,15 +2411,20 @@ STATIC_INLINE void update_fetch (int until, int fm)
if (fetch_state == fetch_was_plane0)
break;
- fetch_start ();
- if (one_fetch_cycle (pos, dma, fm))
- return;
- }
+ fetch_start(pos);
+ if (one_fetch_cycle(pos, dma, fm))
+ return;
+ }
+
+#if SPEEDUP
/* Unrolled version of the for loop below. */
if (plf_state == plf_active && !line_cyclebased && dma
&& (fetch_cycle & fetchstart_mask) == (fm_maxplane & fetchstart_mask)
&& !badmode
+#ifdef DEBUGGER
+ && !debug_dma
+#endif
&& toscr_nr_planes == toscr_nr_planes_agnus)
{
int ddfstop_to_test_ddf = HARD_DDF_STOP;
@@ -2025,15 +2443,15 @@ STATIC_INLINE void update_fetch (int until, int fm)
int stoppos = pos + count;
if (thisline_decision.plfleft < 0) {
- compute_toscr_delay (bplcon1);
+ compute_toscr_delay(bplcon1);
}
- do_long_fetch (pos, count >> (3 - toscr_res), dma, fm);
+ do_long_fetch(pos, count >> (3 - toscr_res), dma, fm);
- /* This must come _after_ do_long_fetch so as not to confuse flush_display
- into thinking the first fetch has produced any output worth emitting to
- the screen. But the calculation of delay_offset must happen _before_. */
- maybe_first_bpl1dat (pos);
+ /* This must come _after_ do_long_fetch so as not to confuse flush_display
+ into thinking the first fetch has produced any output worth emitting to
+ the screen. But the calculation of delay_offset must happen _before_. */
+ maybe_first_bpl1dat(pos);
if (pos <= plfstop && stoppos > plfstop) {
plf_state = plf_passed_stop;
@@ -2047,71 +2465,106 @@ STATIC_INLINE void update_fetch (int until, int fm)
if (pos <= HARD_DDF_STOP && stoppos > HARD_DDF_STOP) {
if (plf_state < plf_wait)
plf_state = plf_passed_stop_act;
- }
- if (pos <= ddfstop_to_test && stoppos > ddf2) {
+ }
+ if (pos <= ddfstop_to_test && stoppos > ddf2) {
plf_state = plf_passed_stop2;
- }
- if (pos <= ddf2 && stoppos >= ddf2 + fm_maxplane) {
- add_modulos ();
- }
+ }
+ if (pos <= ddf2 && stoppos >= ddf2 + fm_maxplane) {
+ add_modulos();
+ }
pos += count;
fetch_cycle += count;
}
}
-
+#endif
for (; pos < until; pos++) {
+
if (fetch_state == fetch_was_plane0) {
- flush_display (fm);
- beginning_of_plane_block (pos, fm);
- }
+ flush_display(fm);
+ beginning_of_plane_block(pos, fm);
+ }
- fetch_start ();
+ fetch_start(pos);
- if (one_fetch_cycle (pos, dma, fm))
- return;
+ if (one_fetch_cycle(pos, dma, fm))
+ return;
}
if (until >= maxhpos) {
- maybe_finish_last_fetch (pos, fm);
+ maybe_finish_last_fetch(pos, fm);
return;
}
- flush_display (fm);
+ flush_display(fm);
}
-static void update_fetch_0 (int hpos) { update_fetch (hpos, 0); }
-static void update_fetch_1 (int hpos) { update_fetch (hpos, 1); }
-static void update_fetch_2 (int hpos) { update_fetch (hpos, 2); }
+static void update_fetch_0(int hpos) { update_fetch(hpos, 0); }
+static void update_fetch_1(int hpos) { update_fetch(hpos, 1); }
+static void update_fetch_2(int hpos) { update_fetch(hpos, 2); }
-STATIC_INLINE void decide_fetch (int hpos)
+static void decide_fetch(int hpos)
{
if (hpos > last_fetch_hpos) {
+ if (bitplane_overrun) {
+ if (fetch_state != fetch_not_started) {
+ bitplane_overrun = 0;
+ }
+ else {
+ do_overrun_fetch(hpos, fetchmode);
+ }
+ }
if (fetch_state != fetch_not_started) {
- switch (fetchmode) {
- case 0: update_fetch_0 (hpos); break;
- case 1: update_fetch_1 (hpos); break;
- case 2: update_fetch_2 (hpos); break;
- default: uae_abort (_T("fetchmode corrupt"));
- }
- } else if (bpl1dat_written_at_least_once) {
+ switch (fetchmode) {
+ case 0: update_fetch_0(hpos); break;
+#ifdef AGA
+ case 1: update_fetch_1(hpos); break;
+ case 2: update_fetch_2(hpos); break;
+#endif
+ default: uae_abort(_T("fetchmode corrupt"));
+ }
+ }
+ else if (bpl1dat_written_at_least_once) {
// "PIO" mode display
- update_fetch_x (hpos, fetchmode);
+ update_fetch_x(hpos, fetchmode);
bpl1dat_written = false;
- }
+ }
- maybe_check (hpos);
- last_fetch_hpos = hpos;
- }
+ maybe_check(hpos);
+ last_fetch_hpos = hpos;
+ }
}
-STATIC_INLINE void decide_fetch_safe (int hpos)
+STATIC_INLINE void decide_fetch_safe(int hpos)
{
- decide_fetch (hpos);
+ if (!blitter_dangerous_bpl) {
+ decide_fetch(hpos);
+ decide_blitter(hpos);
+ }
+ else {
+ while (hpos > last_fetch_hpos) {
+ decide_fetch(last_fetch_hpos + 1);
+ decide_blitter(last_fetch_hpos + 1);
+ }
+ }
}
-STATIC_INLINE void start_bpl_dma (int hstart)
+static void start_bpl_dma(int hstart)
{
+ if (first_bpl_vpos < 0)
+ first_bpl_vpos = vpos;
+
+ if (doflickerfix() && interlace_seen > 0 && !scandoubled_line) {
+ int i;
+ for (i = 0; i < 8; i++) {
+ prevbpl[lof_current][vpos][i] = bplptx[i];
+ if (!lof_current && (bplcon0 & 4))
+ bplpt[i] = prevbpl[1 - lof_current][vpos][i];
+ if (!(bplcon0 & 4) || interlace_seen < 0)
+ prevbpl[1 - lof_current][vpos][i] = prevbpl[lof_current][vpos][i] = 0;
+ }
+ }
+
fetch_state = fetch_started;
plfr_state = plfr_active;
- ddfstate = DIW_waiting_stop;
+ ddfstate = DIW_waiting_stop;
bpl_hstart = hstart;
if (!bpldmawasactive) {
@@ -2123,72 +2576,77 @@ STATIC_INLINE void start_bpl_dma (int hstart)
// sprite fetch and bitplane cycle sequence start.
if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
plfstrt_sprite--;
- fetch_cycle = 0;
- update_denise (last_fetch_hpos);
- if (bpl1dat_written_at_least_once && hstart > last_fetch_hpos) {
- update_fetch_x (hstart, fetchmode);
- bpl1dat_written_at_least_once = false;
- } else {
- reset_bpl_vars ();
- }
- cycle_diagram_shift = hstart;
+ fetch_cycle = 0;
+ update_denise(last_fetch_hpos);
+ if (bpl1dat_written_at_least_once && hstart > last_fetch_hpos) {
+ update_fetch_x(hstart, fetchmode);
+ bpl1dat_written_at_least_once = false;
+ }
+ else {
+ reset_bpl_vars();
+ }
+ cycle_diagram_shift = hstart;
bpldmawasactive = true;
- } else {
+ }
+ else {
- // Bitplane DMA restart during FMODE>0 idle cycles?
- if (aga_plf_passed_stop2) {
- if (aga_plf_passed_stop2 > hstart)
- aga_plf_passed_stop2 = hstart;
- thisline_decision.plfright = aga_plf_passed_stop2;
- aga_plf_passed_stop2 = 0;
- }
-
- flush_display (fetchmode);
+ flush_display(fetchmode);
// Calculate difference between last end to new start
int diff = (hstart - thisline_decision.plfright) << (1 + toscr_res);
// Render all missing pixels, use toscr because previous data may
// still be in buffers.
while (diff >= 16) {
- toscr_1 (16, fetchmode);
+ toscr_1(16, fetchmode);
diff -= 16;
}
if (diff)
- toscr_1 (diff, fetchmode);
+ toscr_1(diff, fetchmode);
- fetch_cycle = 0;
cycle_diagram_shift = hstart;
- update_denise (last_fetch_hpos);
- update_fetch_x (hstart, fetchmode);
- }
+ update_denise(last_fetch_hpos);
+ update_fetch_x(hstart, fetchmode);
+ }
+
+ last_fetch_hpos = hstart;
+ estimate_last_fetch_cycle(hstart);
- last_fetch_hpos = hstart;
- estimate_last_fetch_cycle (hstart);
}
-/* This function is responsible for turning on datafetch if necessary. */
-static void decide_line (int hpos)
+STATIC_INLINE bool cant_this_last_line(void)
+{
+ // Last line..
+ // ..works normally if A1000 Agnus
+ if (currprefs.cs_dipagnus)
+ return false;
+ // ..inhibits bitplane and sprite DMA if later Agnus revision.
+ return vpos + 1 >= maxvpos + lof_store;
+}
+
+/* This function is responsible for turning on datafetch if necessary. */
+STATIC_INLINE void decide_line(int hpos)
{
bool ecs = (currprefs.chipset_mask & CSMASK_ECS_AGNUS) != 0;
/* Take care of the vertical DIW. */
if (vpos == plffirstline) {
- if (vpos >= 0) {
- diwstate = DIW_waiting_stop;
- SET_LINE_CYCLEBASED;
- }
+ // A1000 Agnus won't start bitplane DMA if vertical diw is zero.
+ if (vpos > 0 || (vpos == 0 && !currprefs.cs_dipagnus)) {
+ diwstate = DIW_waiting_stop;
+ SET_LINE_CYCLEBASED;
+ }
}
// last line of field can never have bitplane dma active if not A1000 Agnus.
- if (vpos == plflastline) {
+ if (vpos == plflastline || cant_this_last_line() || (vpos == 0 && currprefs.cs_dipagnus)) {
diwstate = DIW_waiting_start;
SET_LINE_CYCLEBASED;
}
-
- if (hpos <= last_decide_line_hpos)
- return;
- bool dma = dmaen (DMA_BITPLANE) != 0;
+ if (hpos <= last_decide_line_hpos)
+ return;
+
+ bool dma = dmaen(DMA_BITPLANE) != 0;
bool diw = diwstate == DIW_waiting_stop;
if (ecs) {
@@ -2197,7 +2655,8 @@ static void decide_line (int hpos)
ddfstop_matched = false;
}
}
- } else {
+ }
+ else {
if (1) {
if (last_decide_line_hpos < plfstrt && hpos >= plfstrt) {
ddfstop_matched = false;
@@ -2208,7 +2667,7 @@ static void decide_line (int hpos)
}
}
- if (fetch_state == fetch_not_started || (aga_plf_passed_stop2 && plfstrt >= last_decide_line_hpos)) {
+ if (fetch_state == fetch_not_started) {
bool strtpassed = false;
plfstate nextstate = plf_end;
int hstart;
@@ -2244,7 +2703,8 @@ static void decide_line (int hpos)
}
}
}
- } else {
+ }
+ else {
if (1) {
int start = HARD_DDF_START_REAL;
if (last_decide_line_hpos < start && hpos >= start) {
@@ -2283,7 +2743,8 @@ static void decide_line (int hpos)
test = false;
}
}
- } else {
+ }
+ else {
test = (plf_state == plf_active);
// if DMA enabled mid-scanline but ddfstrt not matched (dma was off): start when ddfstop is matched
// (Crash Landing crack intro / Scoopex)
@@ -2292,13 +2753,11 @@ static void decide_line (int hpos)
hstart = plfstop + DDF_OFFSET;
test = true;
nextstate = plf_passed_stop;
- // inform overrun code that this won't overrun.
- bitplane_maybe_start_hpos = 0x100;
}
}
}
if (test) {
- start_bpl_dma (hstart);
+ start_bpl_dma(hstart);
// if ECS: pre-set plf_end_hpos if we have already passed virtual ddfstop
if (ecs) {
if (last_decide_line_hpos < hstart && hstart >= plfstop && hstart - plfstop <= DDF_OFFSET) {
@@ -2319,7 +2778,7 @@ static void decide_line (int hpos)
estimate_last_fetch_cycle(hstart);
}
last_decide_line_hpos = hpos;
- do_sprites (hpos);
+ do_sprites(hpos);
return;
}
@@ -2339,7 +2798,8 @@ static void decide_line (int hpos)
plf_state = plf_passed_stop_act;
}
}
- } else {
+ }
+ else {
if (dma && diw) {
if (last_decide_line_hpos < plfstop && hpos >= plfstop && plfstop <= maxhpos - DDF_OFFSET && plf_state != plf_wait) {
ddfstop_matched = true;
@@ -2348,31 +2808,31 @@ static void decide_line (int hpos)
}
}
- if (hpos > last_sprite_hpos && last_sprite_hpos < SPR0_HPOS + 4 * MAX_SPRITES)
- do_sprites (hpos);
-
- last_decide_line_hpos = hpos;
+ if (hpos > last_sprite_hpos && last_sprite_hpos < SPR0_HPOS + 4 * MAX_SPRITES)
+ do_sprites(hpos);
+
+ last_decide_line_hpos = hpos;
}
/* Called when a color is about to be changed (write to a color register),
- * but the new color has not been entered into the table yet. */
-static void record_color_change (int hpos, int regno, unsigned long value)
+* but the new color has not been entered into the table yet. */
+static void record_color_change(int hpos, int regno, unsigned long value)
{
- if (regno < 0x1000 && nodraw ())
+ if (regno < 0x1000 && nodraw())
return;
/* Early positions don't appear on-screen. */
- if (vpos < minfirstline)
+ if (vpos < minfirstline)
return;
-
- decide_diw (hpos);
- decide_line (hpos);
-
+
+ decide_diw(hpos);
+ decide_line(hpos);
+
if (thisline_decision.ctable < 0)
- remember_ctable ();
-
- if ((regno < 0x1000 || regno == 0x1000 + 0x10c) && hpos < HBLANK_OFFSET && !(beamcon0 & 0x80) && prev_lineno >= 0) {
- struct draw_info *pdip = curr_drawinfo + prev_lineno;
- int idx = pdip->last_color_change;
+ remember_ctable();
+
+ if ((regno < 0x1000 || regno == 0x1000 + 0x10c) && hpos < HBLANK_OFFSET && !(beamcon0 & 0x80) && prev_lineno >= 0) {
+ struct draw_info *pdip = curr_drawinfo + prev_lineno;
+ int idx = pdip->last_color_change;
int extrahpos = regno == 0x1000 + 0x10c ? 1 : 0;
bool lastsync = false;
/* Move color changes in horizontal cycles 0 to HBLANK_OFFSET to end of previous line.
@@ -2382,41 +2842,54 @@ static void record_color_change (int hpos, int regno, unsigned long value)
idx--;
lastsync = true;
}
- pdip->last_color_change++;
- pdip->nr_color_changes++;
- curr_color_changes[idx].linepos = ((hpos + maxhpos) * 2 + extrahpos) * 4;
- curr_color_changes[idx].regno = regno;
- curr_color_changes[idx].value = value;
+ pdip->last_color_change++;
+ pdip->nr_color_changes++;
+ curr_color_changes[idx].linepos = (hpos + maxhpos) * 2 + extrahpos;
+ curr_color_changes[idx].regno = regno;
+ curr_color_changes[idx].value = value;
if (lastsync) {
- curr_color_changes[idx + 1].linepos = (hsyncstartpos * 2) * 4;
+ curr_color_changes[idx + 1].linepos = hsyncstartpos * 2;
curr_color_changes[idx + 1].regno = 0xffff;
curr_color_changes[idx + 2].regno = -1;
- } else {
- curr_color_changes[idx + 1].regno = -1;
}
- }
- record_color_change2 (hpos, regno, value);
+ else {
+ curr_color_changes[idx + 1].regno = -1;
+ }
+ }
+ record_color_change2(hpos, regno, value);
}
-static bool isbrdblank (int hpos, uae_u16 bplcon0, uae_u16 bplcon3)
+static bool isbrdblank(int hpos, uae_u16 bplcon0, uae_u16 bplcon3)
{
- bool brdblank;
+ bool brdblank, brdntrans;
+#ifdef ECS_DENISE
brdblank = (currprefs.chipset_mask & CSMASK_ECS_DENISE) && (bplcon0 & 1) && (bplcon3 & 0x20);
- if (hpos >= 0 && (ce_is_borderblank(current_colors.extra) != brdblank)) {
- record_color_change (hpos, 0, COLOR_CHANGE_BRDBLANK | (brdblank ? 1 : 0) | (ce_is_bordersprite(current_colors.extra) ? 2 : 0));
+ brdntrans = (currprefs.chipset_mask & CSMASK_ECS_DENISE) && (bplcon0 & 1) && (bplcon3 & 0x10);
+#else
+ brdblank = false;
+ brdntrans = false;
+#endif
+ if (hpos >= 0 && (ce_is_borderblank(current_colors.extra) != brdblank || ce_is_borderntrans(current_colors.extra) != brdntrans)) {
+ record_color_change(hpos, 0, COLOR_CHANGE_BRDBLANK | (brdblank ? 1 : 0) | (ce_is_bordersprite(current_colors.extra) ? 2 : 0) | (brdntrans ? 4 : 0));
current_colors.extra &= ~(1 << CE_BORDERBLANK);
+ current_colors.extra &= ~(1 << CE_BORDERNTRANS);
current_colors.extra |= brdblank ? (1 << CE_BORDERBLANK) : 0;
+ current_colors.extra |= brdntrans ? (1 << CE_BORDERNTRANS) : 0;
remembered_color_entry = -1;
}
return brdblank;
}
-static bool issprbrd (int hpos, uae_u16 bplcon0, uae_u16 bplcon3)
+static bool issprbrd(int hpos, uae_u16 bplcon0, uae_u16 bplcon3)
{
bool brdsprt;
- brdsprt = (aga_mode) && (bplcon0 & 1) && (bplcon3 & 0x02);
+#ifdef AGA
+ brdsprt = (currprefs.chipset_mask & CSMASK_AGA) && (bplcon0 & 1) && (bplcon3 & 0x02);
+#else
+ brdsprt = false;
+#endif
if (hpos >= 0 && ce_is_bordersprite(current_colors.extra) != brdsprt) {
- record_color_change (hpos, 0, COLOR_CHANGE_BRDBLANK | (ce_is_borderblank(current_colors.extra) ? 1 : 0) | (brdsprt ? 2 : 0));
+ record_color_change(hpos, 0, COLOR_CHANGE_BRDBLANK | (ce_is_borderblank(current_colors.extra) ? 1 : 0) | (ce_is_borderntrans(current_colors.extra) ? 4 : 0) | (brdsprt ? 2 : 0));
current_colors.extra &= ~(1 << CE_BORDERSPRITE);
current_colors.extra |= brdsprt ? (1 << CE_BORDERSPRITE) : 0;
remembered_color_entry = -1;
@@ -2426,48 +2899,57 @@ static bool issprbrd (int hpos, uae_u16 bplcon0, uae_u16 bplcon3)
return brdsprt && !ce_is_borderblank(current_colors.extra);
}
-static void record_register_change (int hpos, int regno, uae_u16 value)
+static void record_register_change(int hpos, int regno, uae_u16 value)
{
- if (regno == 0x100) { // BPLCON0
- if (value & 0x800)
- thisline_decision.ham_seen = 1;
- isbrdblank (hpos, value, bplcon3);
- issprbrd (hpos, value, bplcon3);
- } else if (regno == 0x106) { // BPLCON3
- isbrdblank (hpos, bplcon0, value);
- issprbrd (hpos, bplcon0, value);
- }
- record_color_change (hpos, regno + 0x1000, value);
+ if (regno == 0x100) { // BPLCON0
+ if (value & 0x800)
+ thisline_decision.ham_seen = 1;
+ thisline_decision.ehb_seen = isehb(value, bplcon2);
+ isbrdblank(hpos, value, bplcon3);
+ issprbrd(hpos, value, bplcon3);
+ }
+ else if (regno == 0x104) { // BPLCON2
+ thisline_decision.ehb_seen = isehb(bplcon0, value);
+ }
+ else if (regno == 0x106) { // BPLCON3
+ isbrdblank(hpos, bplcon0, value);
+ issprbrd(hpos, bplcon0, value);
+ }
+ record_color_change(hpos, regno + 0x1000, value);
}
typedef int sprbuf_res_t, cclockres_t, hwres_t, bplres_t;
-static int expand_sprres (uae_u16 con0, uae_u16 con3)
+static int expand_sprres(uae_u16 con0, uae_u16 con3)
{
- int res;
+ int res;
- switch ((con3 >> 6) & 3)
- {
- default:
- res = RES_LORES;
- break;
- case 0: /* ECS defaults (LORES,HIRES=LORES sprite,SHRES=HIRES sprite) */
- if ((currprefs.chipset_mask & CSMASK_ECS_DENISE) && GET_RES_DENISE (con0) == RES_SUPERHIRES)
- res = RES_HIRES;
- else
- res = RES_LORES;
- break;
- case 1:
- res = RES_LORES;
- break;
- case 2:
+ switch ((con3 >> 6) & 3)
+ {
+ default:
+ res = RES_LORES;
+ break;
+#ifdef ECS_DENISE
+ case 0: /* ECS defaults (LORES,HIRES=LORES sprite,SHRES=HIRES sprite) */
+ if ((currprefs.chipset_mask & CSMASK_ECS_DENISE) && GET_RES_DENISE(con0) == RES_SUPERHIRES)
res = RES_HIRES;
- break;
- case 3:
- res = RES_SUPERHIRES;
- break;
+ else
+ res = RES_LORES;
+ break;
+#endif
+#ifdef AGA
+ case 1:
+ res = RES_LORES;
+ break;
+ case 2:
+ res = RES_HIRES;
+ break;
+ case 3:
+ res = RES_SUPERHIRES;
+ break;
+#endif
}
- return res;
+ return res;
}
#define DO_PLAYFIELD_COLLISIONS \
@@ -2481,165 +2963,188 @@ static int expand_sprres (uae_u16 con0, uae_u16 con3)
/* handle very rarely needed playfield collision (CLXDAT bit 0) */
/* only known game needing this is Rotor */
-static void do_playfield_collisions (void)
+static void do_playfield_collisions(void)
{
- int bplres = bplcon0_res;
- hwres_t ddf_left = thisline_decision.plfleft * 2 << bplres;
- hwres_t hw_diwlast = coord_window_to_diw_x (thisline_decision.diwlastword);
- hwres_t hw_diwfirst = coord_window_to_diw_x (thisline_decision.diwfirstword);
- int i, collided, minpos, maxpos;
- int planes = (aga_mode) ? 8 : 6;
+ int bplres = bplcon0_res;
+ hwres_t ddf_left = thisline_decision.plfleft * 2 << bplres;
+ hwres_t hw_diwlast = coord_window_to_diw_x(thisline_decision.diwlastword);
+ hwres_t hw_diwfirst = coord_window_to_diw_x(thisline_decision.diwfirstword);
+ int i, collided, minpos, maxpos;
+#ifdef AGA
+ int planes = (currprefs.chipset_mask & CSMASK_AGA) ? 8 : 6;
+#else
+ int planes = 6;
+#endif
- collided = 0;
- minpos = thisline_decision.plfleft * 2;
- if (minpos < hw_diwfirst)
- minpos = hw_diwfirst;
- maxpos = thisline_decision.plfright * 2;
- if (maxpos > hw_diwlast)
- maxpos = hw_diwlast;
- for (i = minpos; i < maxpos && !collided; i+= 32) {
- int offs = ((i << bplres) - ddf_left) >> 3;
- int j;
- uae_u32 total = 0xffffffff;
- for (j = 0; j < planes; j++) {
- int ena = (clxcon_bpl_enable >> j) & 1;
- int match = (clxcon_bpl_match >> j) & 1;
- uae_u32 t = 0xffffffff;
- if (ena) {
- if (j < thisline_decision.nr_planes) {
- t = *(uae_u32 *)(line_data[next_lineno] + offs + 2 * j * MAX_WORDS_PER_LINE);
- t ^= (match & 1) - 1;
- } else {
- t = (match & 1) - 1;
- }
- }
- total &= t;
- }
- if (total) {
- collided = 1;
- }
- }
- if (collided)
- clxdat |= 1;
+ //if (clxcon_bpl_enable == 0) {
+ // clxdat |= 1;
+ // return;
+ //}
+ //// collision bit already set?
+ //if (clxdat & 1)
+ // return;
+
+ collided = 0;
+ minpos = thisline_decision.plfleft * 2;
+ if (minpos < hw_diwfirst)
+ minpos = hw_diwfirst;
+ maxpos = thisline_decision.plfright * 2;
+ if (maxpos > hw_diwlast)
+ maxpos = hw_diwlast;
+ for (i = minpos; i < maxpos && !collided; i += 32) {
+ int offs = ((i << bplres) - ddf_left) >> 3;
+ int j;
+ uae_u32 total = 0xffffffff;
+ for (j = 0; j < planes; j++) {
+ int ena = (clxcon_bpl_enable >> j) & 1;
+ int match = (clxcon_bpl_match >> j) & 1;
+ uae_u32 t = 0xffffffff;
+ if (ena) {
+ if (j < thisline_decision.nr_planes) {
+ t = *(uae_u32 *)(line_data[next_lineno] + offs + 2 * j * MAX_WORDS_PER_LINE);
+ t ^= (match & 1) - 1;
+ }
+ else {
+ t = (match & 1) - 1;
+ }
+ }
+ total &= t;
+ }
+ if (total) {
+ collided = 1;
+ }
+ }
+ if (collided)
+ clxdat |= 1;
}
#define DO_SPRITE_COLLISIONS \
{ \
- if (clxcon_bpl_enable || curr_drawinfo[next_lineno].nr_sprites) { \
- /* all sprite to bitplane collision bits already set? */ \
- if ((clxdat & 0x1fe) != 0x1fe) \
+ if (!clxcon_bpl_enable) \
+ clxdat |= 0x1FE; \
+ else \
do_sprite_collisions (); \
- } \
}
/* Sprite-to-sprite collisions are taken care of in record_sprite. This one does
- playfield/sprite collisions. */
-static void do_sprite_collisions (void)
+playfield/sprite collisions. */
+static void do_sprite_collisions(void)
{
- int nr_sprites = curr_drawinfo[next_lineno].nr_sprites;
- int first = curr_drawinfo[next_lineno].first_sprite_entry;
- int i;
- unsigned int collision_mask = clxmask[clxcon >> 12];
- int bplres = bplcon0_res;
- hwres_t ddf_left = thisline_decision.plfleft * 2 << bplres;
- hwres_t hw_diwlast = coord_window_to_diw_x (thisline_decision.diwlastword);
- hwres_t hw_diwfirst = coord_window_to_diw_x (thisline_decision.diwfirstword);
+ int nr_sprites = curr_drawinfo[next_lineno].nr_sprites;
+ int first = curr_drawinfo[next_lineno].first_sprite_entry;
+ int i;
+ unsigned int collision_mask = clxmask[clxcon >> 12];
+ int bplres = bplcon0_res;
+ hwres_t ddf_left = thisline_decision.plfleft * 2 << bplres;
+ hwres_t hw_diwlast = coord_window_to_diw_x(thisline_decision.diwlastword);
+ hwres_t hw_diwfirst = coord_window_to_diw_x(thisline_decision.diwfirstword);
- for (i = 0; i < nr_sprites; i++) {
- struct sprite_entry *e = curr_sprite_entries + first + i;
- sprbuf_res_t j;
- sprbuf_res_t minpos = e->pos;
- sprbuf_res_t maxpos = e->max;
- hwres_t minp1 = minpos >> sprite_buffer_res;
- hwres_t maxp1 = maxpos >> sprite_buffer_res;
+ //if (clxcon_bpl_enable == 0 && !nr_sprites)
+ // return;
+ //// all sprite to bitplane collision bits already set?
+ //if ((clxdat & 0x1fe) == 0x1fe)
+ // return;
- if (maxp1 > hw_diwlast)
- maxpos = hw_diwlast << sprite_buffer_res;
- if (maxp1 > thisline_decision.plfright * 2)
- maxpos = thisline_decision.plfright * 2 << sprite_buffer_res;
- if (minp1 < hw_diwfirst)
- minpos = hw_diwfirst << sprite_buffer_res;
- if (minp1 < thisline_decision.plfleft * 2)
- minpos = thisline_decision.plfleft * 2 << sprite_buffer_res;
+ for (i = 0; i < nr_sprites; i++) {
+ struct sprite_entry *e = curr_sprite_entries + first + i;
+ sprbuf_res_t j;
+ sprbuf_res_t minpos = e->pos;
+ sprbuf_res_t maxpos = e->max;
+ hwres_t minp1 = minpos >> sprite_buffer_res;
+ hwres_t maxp1 = maxpos >> sprite_buffer_res;
- for (j = minpos; j < maxpos; j++) {
- int sprpix = spixels[e->first_pixel + j - e->pos] & collision_mask;
- int k, offs, match = 1;
+ if (maxp1 > hw_diwlast)
+ maxpos = hw_diwlast << sprite_buffer_res;
+ if (maxp1 > thisline_decision.plfright * 2)
+ maxpos = thisline_decision.plfright * 2 << sprite_buffer_res;
+ if (minp1 < hw_diwfirst)
+ minpos = hw_diwfirst << sprite_buffer_res;
+ if (minp1 < thisline_decision.plfleft * 2)
+ minpos = thisline_decision.plfleft * 2 << sprite_buffer_res;
- if (sprpix == 0)
- continue;
+ for (j = minpos; j < maxpos; j++) {
+ int sprpix = spixels[e->first_pixel + j - e->pos] & collision_mask;
+ int k, offs, match = 1;
- offs = ((j << bplres) >> sprite_buffer_res) - ddf_left;
- sprpix = sprite_ab_merge[sprpix & 255] | (sprite_ab_merge[sprpix >> 8] << 2);
- sprpix <<= 1;
+ if (sprpix == 0)
+ continue;
+
+ offs = ((j << bplres) >> sprite_buffer_res) - ddf_left;
+ sprpix = sprite_ab_merge[sprpix & 255] | (sprite_ab_merge[sprpix >> 8] << 2);
+ sprpix <<= 1;
// both odd and even collision bits already set?
if ((clxdat & (sprpix << 0)) && (clxdat & (sprpix << 4)))
continue;
- /* Loop over number of playfields. */
- for (k = 1; k >= 0; k--) {
- int l;
- int planes = (aga_mode) ? 8 : 6;
- if (bplcon0 & 0x400)
- match = 1;
- for (l = k; match && l < planes; l += 2) {
- int t = 0;
- if (l < thisline_decision.nr_planes) {
- uae_u32 *ldata = (uae_u32 *)(line_data[next_lineno] + 2 * l * MAX_WORDS_PER_LINE);
- uae_u32 word = ldata[offs >> 5];
- t = (word >> (31 - (offs & 31))) & 1;
- }
- if (clxcon_bpl_enable & (1 << l)) {
- if (t != ((clxcon_bpl_match >> l) & 1))
- match = 0;
- }
- }
- if (match) {
- clxdat |= sprpix << (k * 4);
- }
- }
- }
- }
+ /* Loop over number of playfields. */
+ for (k = 1; k >= 0; k--) {
+ int l;
+#ifdef AGA
+ int planes = (currprefs.chipset_mask & CSMASK_AGA) ? 8 : 6;
+#else
+ int planes = 6;
+#endif
+ if (bplcon0 & 0x400)
+ match = 1;
+ for (l = k; match && l < planes; l += 2) {
+ int t = 0;
+ if (l < thisline_decision.nr_planes) {
+ uae_u32 *ldata = reinterpret_cast(line_data[next_lineno] + 2 * l * MAX_WORDS_PER_LINE);
+ uae_u32 word = ldata[offs >> 5];
+ t = (word >> (31 - (offs & 31))) & 1;
+ }
+ if (clxcon_bpl_enable & (1 << l)) {
+ if (t != ((clxcon_bpl_match >> l) & 1))
+ match = 0;
+ }
+ }
+ if (match) {
+ clxdat |= sprpix << (k * 4);
+ }
+ }
+ }
+ }
}
-static void record_sprite_1 (int sprxp, uae_u16 *buf, uae_u32 datab, int num, int dbl,
- unsigned int mask, int do_collisions, uae_u32 collision_mask)
+static void record_sprite_1(int sprxp, uae_u16 *buf, uae_u32 datab, int num, int dbl,
+ unsigned int mask, int do_collisions, uae_u32 collision_mask)
{
int j = 0;
while (datab) {
- unsigned int col = 0;
- unsigned int coltmp = 0;
-
- if ((sprxp >= sprite_minx && sprxp < sprite_maxx) || (bplcon3 & 2))
- col = (datab & 3) << (2 * num);
+ unsigned int col = 0;
+ unsigned coltmp = 0;
+
+ if ((sprxp >= sprite_minx && sprxp < sprite_maxx) || (bplcon3 & 2))
+ col = (datab & 3) << (2 * num);
+
if ((j & mask) == 0) {
- unsigned int tmp = (*buf) | col;
+ unsigned int tmp = (*buf) | col;
*buf++ = tmp;
- if (do_collisions)
- coltmp |= tmp;
- sprxp++;
- }
- if (dbl > 0) {
- unsigned int tmp = (*buf) | col;
+ if (do_collisions)
+ coltmp |= tmp;
+ sprxp++;
+ }
+ if (dbl > 0) {
+ unsigned int tmp = (*buf) | col;
*buf++ = tmp;
- if (do_collisions)
- coltmp |= tmp;
- sprxp++;
- }
- if (dbl > 1) {
- unsigned int tmp;
- tmp = (*buf) | col;
- *buf++ = tmp;
- if (do_collisions)
- coltmp |= tmp;
- tmp = (*buf) | col;
- *buf++ = tmp;
- if (do_collisions)
- coltmp |= tmp;
- sprxp++;
- sprxp++;
- }
+ if (do_collisions)
+ coltmp |= tmp;
+ sprxp++;
+ }
+ if (dbl > 1) {
+ unsigned int tmp;
+ tmp = (*buf) | col;
+ *buf++ = tmp;
+ if (do_collisions)
+ coltmp |= tmp;
+ tmp = (*buf) | col;
+ *buf++ = tmp;
+ if (do_collisions)
+ coltmp |= tmp;
+ sprxp++;
+ sprxp++;
+ }
j++;
datab >>= 2;
if (do_collisions) {
@@ -2661,7 +3166,7 @@ static void record_sprite_1 (int sprxp, uae_u16 *buf, uae_u32 datab, int num, in
The data is recorded either in lores pixels (if OCS/ECS), or in hires or
superhires pixels (if AGA). */
-static void record_sprite (int line, int num, int sprxp, uae_u16 *data, uae_u16 *datb, unsigned int ctl)
+static void record_sprite(int line, int num, int sprxp, uae_u16 *data, uae_u16 *datb, unsigned int ctl)
{
struct sprite_entry *e = curr_sprite_entries + next_sprite_entry;
int i;
@@ -2669,57 +3174,58 @@ static void record_sprite (int line, int num, int sprxp, uae_u16 *data, uae_u16
uae_u32 collision_mask;
int width, dbl, half;
unsigned int mask = 0;
- int attachment;
-
- half = 0;
+ int attachment;
+
+ half = 0;
dbl = sprite_buffer_res - sprres;
- if (dbl < 0) {
- half = -dbl;
- dbl = 0;
- mask = 1 << half;
- }
- width = (sprite_width << sprite_buffer_res) >> sprres;
- attachment = sprctl[num | 1] & 0x80;
+ if (dbl < 0) {
+ half = -dbl;
+ dbl = 0;
+ mask = 1 << half;
+ }
+ width = (sprite_width << sprite_buffer_res) >> sprres;
+ attachment = sprctl[num | 1] & 0x80;
/* Try to coalesce entries if they aren't too far apart */
- if (! next_sprite_forced && e[-1].max + sprite_width >= sprxp) {
+ if (!next_sprite_forced && e[-1].max + sprite_width >= sprxp) {
e--;
- } else {
+ }
+ else {
next_sprite_entry++;
e->pos = sprxp;
e->has_attached = 0;
}
-
+
if (sprxp < e->pos)
- uae_abort (_T("sprxp < e->pos"));
+ uae_abort(_T("sprxp < e->pos"));
e->max = sprxp + width;
e[1].first_pixel = e->first_pixel + ((e->max - e->pos + 3) & ~3);
next_sprite_forced = 0;
-
+
collision_mask = clxmask[clxcon >> 12];
word_offs = e->first_pixel + sprxp - e->pos;
-
+
for (i = 0; i < sprite_width; i += 16) {
unsigned int da = *data;
unsigned int db = *datb;
uae_u32 datab = ((sprtaba[da & 0xFF] << 16) | sprtaba[da >> 8]
- | (sprtabb[db & 0xFF] << 16) | sprtabb[db >> 8]);
- int off = (i << dbl) >> half;
+ | (sprtabb[db & 0xFF] << 16) | sprtabb[db >> 8]);
+ int off = (i << dbl) >> half;
uae_u16 *buf = spixels + word_offs + off;
- if (currprefs.collision_level > 0 && collision_mask)
- record_sprite_1 (sprxp + off, buf, datab, num, dbl, mask, 1, collision_mask);
- else
- record_sprite_1 (sprxp + off, buf, datab, num, dbl, mask, 0, collision_mask);
+ if (currprefs.collision_level > 0 && collision_mask)
+ record_sprite_1(sprxp + off, buf, datab, num, dbl, mask, 1, collision_mask);
+ else
+ record_sprite_1(sprxp + off, buf, datab, num, dbl, mask, 0, collision_mask);
data++;
datb++;
}
-
+
/* We have 8 bits per pixel in spixstate, two for every sprite pair. The
- low order bit records whether the attach bit was set for this pair. */
- if (attachment && !ecsshres ()) {
- uae_u8 state = 0x03 << (num & ~1);
- uae_u8 *stb1 = spixstate.bytes + word_offs;
+ low order bit records whether the attach bit was set for this pair. */
+ if (attachment && !ecsshres()) {
+ uae_u32 state = 0x01010101 << (num & ~1);
+ uae_u8 *stb1 = spixstate.bytes + word_offs;
for (i = 0; i < width; i += 8) {
stb1[0] |= state;
stb1[1] |= state;
@@ -2730,81 +3236,87 @@ static void record_sprite (int line, int num, int sprxp, uae_u16 *data, uae_u16
stb1[6] |= state;
stb1[7] |= state;
stb1 += 8;
- }
+ }
e->has_attached = 1;
}
}
-static void add_sprite (int *countp, int num, int sprxp, int posns[], int nrs[])
+static void add_sprite(int *countp, int num, int sprxp, int posns[], int nrs[])
{
- int count = *countp;
- int j, bestp;
+ int count = *countp;
+ int j, bestp;
/* Sort the sprites in order of ascending X position before recording them. */
for (bestp = 0; bestp < count; bestp++) {
if (posns[bestp] > sprxp)
break;
- if (posns[bestp] == sprxp && nrs[bestp] < num)
+ if (posns[bestp] == sprxp && nrs[bestp] < num)
break;
}
for (j = count; j > bestp; j--) {
- posns[j] = posns[j-1];
+ posns[j] = posns[j - 1];
nrs[j] = nrs[j - 1];
}
posns[j] = sprxp;
nrs[j] = num;
count++;
- *countp = count;
+ *countp = count;
}
-static int tospritexdiw (int diw)
+static int tospritexdiw(int diw)
{
- return coord_window_to_hw_x (diw - (DIW_DDF_OFFSET << lores_shift)) << sprite_buffer_res;
+ return coord_window_to_hw_x(diw - (DIW_DDF_OFFSET << lores_shift)) << sprite_buffer_res;
}
-static int tospritexddf (int ddf)
+static int tospritexddf(int ddf)
{
- return (ddf * 2 - DIW_DDF_OFFSET) << sprite_buffer_res;
+ return (ddf * 2 - DIW_DDF_OFFSET) << sprite_buffer_res;
+}
+static int fromspritexdiw(int ddf)
+{
+ return coord_hw_to_window_x(ddf >> sprite_buffer_res) + (DIW_DDF_OFFSET << lores_shift);
}
-static void calcsprite (void)
+static void calcsprite(void)
{
- sprite_maxx = 0x7fff;
- sprite_minx = 0;
- if (thisline_decision.diwlastword >= 0)
- sprite_maxx = tospritexdiw (thisline_decision.diwlastword);
- if (thisline_decision.diwfirstword >= 0)
- sprite_minx = tospritexdiw (thisline_decision.diwfirstword);
- if (thisline_decision.plfleft >= 0) {
- int min, max;
- min = tospritexddf (thisline_decision.plfleft);
- max = tospritexddf (thisline_decision.plfright);
+ sprite_maxx = 0x7fff;
+ sprite_minx = 0;
+ if (thisline_decision.diwlastword >= 0)
+ sprite_maxx = tospritexdiw(thisline_decision.diwlastword);
+ if (thisline_decision.diwfirstword >= 0)
+ sprite_minx = tospritexdiw(thisline_decision.diwfirstword);
+ if (thisline_decision.plfleft >= 0) {
+ int min, max;
+ min = tospritexddf(thisline_decision.plfleft);
+ max = tospritexddf(thisline_decision.plfright);
if (min > sprite_minx && min < max) { /* min < max = full line ddf */
if (currprefs.chipset_mask & CSMASK_ECS_DENISE) {
- sprite_minx = min;
- } else {
+ sprite_minx = min;
+ }
+ else {
if (thisline_decision.plfleft >= 0x28 || bpldmawasactive)
sprite_minx = min;
}
}
- /* sprites are visible from first BPL1DAT write to end of line
- * ECS Denise/AGA: no limits
- * OCS Denise: BPL1DAT write only enables sprite if hpos >= 0x28 or so.
- * (undocumented feature)
- */
- }
+ /* sprites are visible from first BPL1DAT write to end of line
+ * ECS Denise/AGA: no limits
+ * OCS Denise: BPL1DAT write only enables sprite if hpos >= 0x28 or so.
+ * (undocumented feature)
+ */
+ }
}
-static void decide_sprites(int spnr, int hpos, bool quick)
+static void decide_sprites(int spnr, int hpos, bool usepointx, bool quick)
{
int nrs[MAX_SPRITES * 2], posns[MAX_SPRITES * 2];
int count, i;
int point;
int width = sprite_width;
- int sscanmask = 0x100 << sprite_buffer_res;
+ int sscanmask = 0x100 << sprite_buffer_res;
+ int gotdata = 0;
int startnr = 0, endnr = MAX_SPRITES - 1;
if (thisline_decision.plfleft < 0 && !(bplcon3 & 2))
- return;
+ return;
// let sprite shift register empty completely
// if sprite is at the very edge of right border
@@ -2812,181 +3324,310 @@ static void decide_sprites(int spnr, int hpos, bool quick)
if (hpos >= maxhpos)
point += ((9 - 2) * 2) * sprite_buffer_res;
- if (nodraw () || hpos < 0x14 || nr_armed == 0 || point == last_sprite_point)
+ if (nodraw() || hpos < 0x14 || nr_armed == 0 || point == last_sprite_point)
return;
-
+
if (spnr >= 0) {
startnr = spnr;
endnr = spnr;
}
if (!quick) {
- decide_diw (hpos);
- decide_line (hpos);
- calcsprite ();
+ decide_diw(hpos);
+ decide_line(hpos);
+ calcsprite();
}
-
+
count = 0;
for (i = startnr; i <= endnr; i++) {
int xpos = spr[i].xpos;
int sprxp = (fmode & 0x8000) ? (xpos & ~sscanmask) : xpos;
int hw_xp = sprxp >> sprite_buffer_res;
-
- if (xpos < 0)
- continue;
+ int pointx = usepointx && (sprctl[i] & sprite_sprctlmask) ? 0 : 1;
- if (! spr[i].armed)
+ if (xpos < 0)
continue;
- if (hw_xp > last_sprite_point && hw_xp <= point) {
- add_sprite (&count, i, sprxp, posns, nrs);
+ if (!((false & magic_sprite_mask) & (1 << i)))
+ continue;
+
+ if (!spr[i].armed)
+ continue;
+
+ if (hw_xp > last_sprite_point && hw_xp <= point + pointx) {
+ add_sprite(&count, i, sprxp, posns, nrs);
}
- /* SSCAN2-bit is fun.. */
- if ((fmode & 0x8000) && !(sprxp & sscanmask)) {
- sprxp |= sscanmask;
- hw_xp = sprxp >> sprite_buffer_res;
- if (hw_xp > last_sprite_point && hw_xp <= point) {
- add_sprite (&count, MAX_SPRITES + i, sprxp, posns, nrs);
- }
- } else if (!(fmode & 0x80) && xpos >= (2 << sprite_buffer_res) && xpos <= (9 << sprite_buffer_res)) {
+ /* SSCAN2-bit is fun.. */
+ if ((fmode & 0x8000) && !(sprxp & sscanmask)) {
+ sprxp |= sscanmask;
+ hw_xp = sprxp >> sprite_buffer_res;
+ if (hw_xp > last_sprite_point && hw_xp <= point + pointx) {
+ add_sprite(&count, MAX_SPRITES + i, sprxp, posns, nrs);
+ }
+ }
+ else if (!(fmode & 0x80) && xpos >= (2 << sprite_buffer_res) && xpos <= (9 << sprite_buffer_res)) {
// right border wrap around. SPRxCTL horizontal bits do not matter.
sprxp += (maxhpos * 2) << sprite_buffer_res;
hw_xp = sprxp >> sprite_buffer_res;
- if (hw_xp > last_sprite_point && hw_xp <= point) {
+ if (hw_xp > last_sprite_point && hw_xp <= point + pointx) {
add_sprite(&count, MAX_SPRITES + i, sprxp, posns, nrs);
}
// (not really mutually exclusive of SSCAN2-bit but not worth the trouble)
- }
+ }
}
for (i = 0; i < count; i++) {
- int nr = nrs[i] & (MAX_SPRITES - 1);
- record_sprite (next_lineno, nr, posns[i], sprdata[nr], sprdatb[nr], sprctl[nr]);
+ int nr = nrs[i] & (MAX_SPRITES - 1);
+ record_sprite(next_lineno, nr, posns[i], sprdata[nr], sprdatb[nr], sprctl[nr]);
+ /* get left and right sprite edge if brdsprt enabled */
+#if AUTOSCALE_SPRITES
+ if (dmaen(DMA_SPRITE) && (bplcon0 & 1) && (bplcon3 & 0x02) && !(bplcon3 & 0x20) && nr > 0) {
+ int j, jj;
+ for (j = 0, jj = 0; j < sprite_width; j += 16, jj++) {
+ int nx = fromspritexdiw(posns[i] + j);
+ if (sprdata[nr][jj] || sprdatb[nr][jj]) {
+ if (diwfirstword_total > nx && nx >= (48 << currprefs.gfx_resolution))
+ diwfirstword_total = nx;
+ if (diwlastword_total < nx + 16 && nx <= (448 << currprefs.gfx_resolution))
+ diwlastword_total = nx + 16;
+ }
+ }
+ gotdata = 1;
+ }
+#endif
}
last_sprite_point = point;
-}
-STATIC_INLINE void decide_sprites(int spnr, int hpos)
-{
- decide_sprites(spnr, hpos, false);
+#if AUTOSCALE_SPRITES
+ /* get upper and lower sprite position if brdsprt enabled */
+ if (gotdata) {
+ if (vpos < first_planes_vpos)
+ first_planes_vpos = vpos;
+ if (vpos < plffirstline_total)
+ plffirstline_total = vpos;
+ if (vpos > last_planes_vpos)
+ last_planes_vpos = vpos;
+ if (vpos > plflastline_total)
+ plflastline_total = vpos;
+ }
+#endif
}
-STATIC_INLINE void maybe_decide_sprites(int spnr, int hpos)
+static void decide_sprites(int spnr, int hpos)
+{
+ decide_sprites(spnr, hpos, false, false);
+}
+static void maybe_decide_sprites(int spnr, int hpos)
{
if (!spr[spnr].armed)
return;
if (!sprdata[spnr] && !sprdatb[spnr])
return;
- decide_sprites(spnr, hpos, true);
+ decide_sprites(spnr, hpos, true, true);
+}
+
+static int sprites_differ(struct draw_info *dip, struct draw_info *dip_old)
+{
+ struct sprite_entry *this_first = curr_sprite_entries + dip->first_sprite_entry;
+ struct sprite_entry *this_last = curr_sprite_entries + dip->last_sprite_entry;
+ struct sprite_entry *prev_first = prev_sprite_entries + dip_old->first_sprite_entry;
+ int npixels;
+ int i;
+
+ if (dip->nr_sprites != dip_old->nr_sprites)
+ return 1;
+
+ if (dip->nr_sprites == 0)
+ return 0;
+
+ for (i = 0; i < dip->nr_sprites; i++) {
+ if (this_first[i].pos != prev_first[i].pos
+ || this_first[i].max != prev_first[i].max
+ || this_first[i].has_attached != prev_first[i].has_attached)
+ return 1;
+ }
+
+ npixels = this_last->first_pixel + (this_last->max - this_last->pos) - this_first->first_pixel;
+ if (memcmp(spixels + this_first->first_pixel, spixels + prev_first->first_pixel,
+ npixels * sizeof(uae_u16)) != 0)
+ return 1;
+ if (memcmp(spixstate.bytes + this_first->first_pixel, spixstate.bytes + prev_first->first_pixel, npixels) != 0)
+ return 1;
+ return 0;
+}
+
+static int color_changes_differ(struct draw_info *dip, struct draw_info *dip_old)
+{
+ if (dip->nr_color_changes != dip_old->nr_color_changes)
+ return 1;
+
+ if (dip->nr_color_changes == 0)
+ return 0;
+ if (memcmp(curr_color_changes + dip->first_color_change,
+ prev_color_changes + dip_old->first_color_change,
+ dip->nr_color_changes * sizeof *curr_color_changes) != 0)
+ return 1;
+ return 0;
}
/* End of a horizontal scan line. Finish off all decisions that were not
- * made yet. */
-STATIC_INLINE void finish_decisions (void)
+* made yet. */
+static void finish_decisions(void)
{
struct draw_info *dip;
+ struct draw_info *dip_old;
struct decision *dp;
+ int changed;
int hpos = maxhpos;
-
- if (nodraw ())
+
+ if (nodraw())
return;
-
- decide_diw (hpos);
- decide_line (hpos);
- decide_fetch_safe (hpos);
- finish_final_fetch ();
-
- record_color_change2 (hsyncstartpos, 0xffff, 0);
- if (thisline_decision.plfleft >= 0 && thisline_decision.plflinelen < 0) {
- thisline_decision.plfright = thisline_decision.plfleft;
- thisline_decision.plflinelen = 0;
- thisline_decision.bplres = RES_LORES;
- }
-
+
+ decide_diw(hpos);
+ decide_line(hpos);
+ decide_fetch_safe(hpos);
+ finish_final_fetch();
+
+ record_color_change2(hsyncstartpos, 0xffff, 0);
+ if (thisline_decision.plfleft >= 0 && thisline_decision.plflinelen < 0) {
+ if (fetch_state != fetch_not_started) {
+ write_log(_T("fetch_state=%d plfleft=%d,len=%d,vpos=%d,hpos=%d\n"),
+ fetch_state, thisline_decision.plfleft, thisline_decision.plflinelen,
+ vpos, hpos);
+ uae_abort(_T("fetch_state != fetch_not_started"));
+ }
+ thisline_decision.plfright = thisline_decision.plfleft;
+ thisline_decision.plflinelen = 0;
+ thisline_decision.bplres = RES_LORES;
+ }
+
/* Large DIWSTOP values can cause the stop position never to be
- * reached, so the state machine always stays in the same state and
- * there's a more-or-less full-screen DIW. */
- if (hdiwstate == DIW_waiting_stop) {
+ * reached, so the state machine always stays in the same state and
+ * there's a more-or-less full-screen DIW. */
+ if (hdiwstate == DIW_waiting_stop) {
thisline_decision.diwlastword = max_diwlastword;
if (thisline_decision.diwfirstword < 0)
thisline_decision.diwfirstword = min_diwlastword;
}
+ if (thisline_decision.diwfirstword != line_decisions[next_lineno].diwfirstword)
+ MARK_LINE_CHANGED;
+ if (thisline_decision.diwlastword != line_decisions[next_lineno].diwlastword)
+ MARK_LINE_CHANGED;
+
dip = curr_drawinfo + next_lineno;
+ dip_old = prev_drawinfo + next_lineno;
dp = line_decisions + next_lineno;
+ changed = thisline_changed | custom_frame_redraw_necessary;
+ if (thisline_decision.plfleft >= 0 && thisline_decision.nr_planes > 0)
+ record_diw_line(thisline_decision.plfleft, diwfirstword, diwlastword);
decide_sprites(-1, hpos + 1);
-
+
dip->last_sprite_entry = next_sprite_entry;
dip->last_color_change = next_color_change;
-
+
if (thisline_decision.ctable < 0) {
- remember_ctable();
- }
-
+ if (thisline_decision.plfleft < 0)
+ remember_ctable_for_border();
+ else
+ remember_ctable();
+ }
+
dip->nr_color_changes = next_color_change - dip->first_color_change;
dip->nr_sprites = next_sprite_entry - dip->first_sprite_entry;
-
- *dp = thisline_decision;
- /* leave free space for possible extra color changes at the end of line */
- next_color_change += (HBLANK_OFFSET + 1) / 2;
+ line_decisions[next_lineno] = thisline_decision;
+
+ if (thisline_decision.plfleft != line_decisions[next_lineno].plfleft)
+ changed = 1;
+ if (!changed && color_changes_differ(dip, dip_old))
+ changed = 1;
+ if (!changed && /* bitplane visible in this line OR border sprites enabled */
+ (thisline_decision.plfleft >= 0 || ((thisline_decision.bplcon0 & 1) && (thisline_decision.bplcon3 & 0x02) && !(thisline_decision.bplcon3 & 0x20)))
+ && sprites_differ(dip, dip_old))
+ {
+ changed = 1;
+ }
+
+ if (changed) {
+ thisline_changed = 1;
+ *dp = thisline_decision;
+ }
+ else {
+ /* The only one that may differ: */
+ dp->ctable = thisline_decision.ctable;
+ }
+
+ /* leave free space for possible extra color changes at the end of line */
+ next_color_change += (HBLANK_OFFSET + 1) / 2;
diw_hcounter += maxhpos * 2;
- if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE) && vpos == get_equ_vblank_endline () - 1)
+ if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE) && vpos == get_equ_vblank_endline() - 1)
diw_hcounter++;
- if ((currprefs.chipset_mask & CSMASK_ECS_DENISE) || vpos > get_equ_vblank_endline ()) {
+ if ((currprefs.chipset_mask & CSMASK_ECS_DENISE) || vpos > get_equ_vblank_endline() || (currprefs.cs_dipagnus && vpos == 0)) {
diw_hcounter = maxhpos * 2;
last_hdiw = 2 - 1;
}
+
+ if (next_color_change >= MAX_REG_CHANGE - 30) {
+ //write_log(_T("color_change buffer overflow!\n"));
+ next_color_change = 0;
+ dip->nr_color_changes = 0;
+ dip->first_color_change = 0;
+ dip->last_color_change = 0;
+ }
}
/* Set the state of all decisions to "undecided" for a new scanline. */
-static void reset_decisions (void)
+static void reset_decisions(void)
{
- if (nodraw ())
- return;
-
+ if (nodraw())
+ return;
+
toscr_nr_planes = toscr_nr_planes2 = 0;
- thisline_decision.bplres = bplcon0_res;
- thisline_decision.nr_planes = 0;
+ thisline_decision.bplres = bplcon0_res;
+ thisline_decision.nr_planes = 0;
bpl1dat_written = false;
bpl1dat_written_at_least_once = false;
-
- thisline_decision.plfleft = -1;
- thisline_decision.plflinelen = -1;
- thisline_decision.ham_seen = !! (bplcon0 & 0x800);
- thisline_decision.ham_at_start = !! (bplcon0 & 0x800);
- thisline_decision.bordersprite_seen = issprbrd (-1, bplcon0, bplcon3);
- thisline_decision.xor_seen = (bplcon4 & 0xff00) != 0;
-
- /* decided_res shouldn't be touched before it's initialized by decide_line(). */
- thisline_decision.diwfirstword = -1;
- thisline_decision.diwlastword = -1;
- if (hdiwstate == DIW_waiting_stop) {
- thisline_decision.diwfirstword = min_diwlastword;
- }
- thisline_decision.ctable = -1;
-
- curr_drawinfo[next_lineno].first_color_change = next_color_change;
- curr_drawinfo[next_lineno].first_sprite_entry = next_sprite_entry;
- next_sprite_forced = 1;
-
- last_sprite_point = 0;
- fetch_state = fetch_not_started;
+
+ thisline_decision.plfleft = -1;
+ thisline_decision.plflinelen = -1;
+ thisline_decision.ham_seen = !!(bplcon0 & 0x800);
+ thisline_decision.ehb_seen = !!isehb(bplcon0, bplcon2);
+ thisline_decision.ham_at_start = !!(bplcon0 & 0x800);
+ thisline_decision.bordersprite_seen = issprbrd(-1, bplcon0, bplcon3);
+
+ /* decided_res shouldn't be touched before it's initialized by decide_line(). */
+ thisline_decision.diwfirstword = -1;
+ thisline_decision.diwlastword = -1;
+ if (hdiwstate == DIW_waiting_stop) {
+ thisline_decision.diwfirstword = min_diwlastword;
+ if (thisline_decision.diwfirstword != line_decisions[next_lineno].diwfirstword)
+ MARK_LINE_CHANGED;
+ }
+ thisline_decision.ctable = -1;
+
+ thisline_changed = 0;
+ curr_drawinfo[next_lineno].first_color_change = next_color_change;
+ curr_drawinfo[next_lineno].first_sprite_entry = next_sprite_entry;
+ next_sprite_forced = 1;
+
+ last_sprite_point = 0;
+ fetch_state = fetch_not_started;
if (bpldmasetuphpos >= 0) {
// this can happen in "too fast" modes
- BPLCON0_Denise (0, bplcon0, true);
- setup_fmodes (0);
+ BPLCON0_Denise(0, bplcon0, true);
+ setup_fmodes(0);
}
bpldmasetuphpos = -1;
bpldmasetupphase = 0;
bpldmawasactive = false;
- reset_moddelays ();
+ reset_moddelays();
delay_cycles = 0;
- compute_toscr_delay (bplcon1);
+ compute_toscr_delay(bplcon1);
if (plf_state >= plf_passed_stop2 || plf_state == plf_wait)
- plf_state = plf_idle;
+ plf_state = plf_idle;
// Only ECS Agnus can keep DDF open between lines
if ((currprefs.chipset_mask & CSMASK_ECS_AGNUS)) {
@@ -2994,7 +3635,7 @@ static void reset_decisions (void)
plf_state = plf_active;
}
}
-
+
bpl_hstart = 256;
plfr_state = plfr_idle;
plf_start_hpos = 256 + DDF_OFFSET;
@@ -3002,81 +3643,155 @@ static void reset_decisions (void)
ddfstop_written_hpos = -1;
bitplane_maybe_start_hpos = -1;
bitplane_off_delay = -1;
+ hack_delay_shift = 0;
if (line_cyclebased) {
line_cyclebased--;
if (!line_cyclebased) {
bpl_dma_off_when_active = 0;
- }
+ }
}
- memset (outword, 0, sizeof outword);
+ memset(outword, 0, sizeof outword);
// fetched[] must not be cleared (Sony VX-90 / Royal Amiga Force)
todisplay_fetched[0] = todisplay_fetched[1] = false;
- memset (todisplay, 0, sizeof todisplay);
- memset (todisplay2, 0, sizeof todisplay2);
+ memset(todisplay, 0, sizeof todisplay);
+ memset(todisplay2, 0, sizeof todisplay2);
+#ifdef AGA
if (currprefs.chipset_mask & CSMASK_AGA) {
- memset (todisplay_aga, 0, sizeof todisplay_aga);
- memset (todisplay2_aga, 0, sizeof todisplay2_aga);
- }
- aga_plf_passed_stop2 = 0;
-
- reset_bpl_vars ();
+ memset(todisplay_aga, 0, sizeof todisplay_aga);
+ memset(todisplay2_aga, 0, sizeof todisplay2_aga);
+ }
+ aga_plf_passed_stop2 = false;
+#endif
+
+ if (bitplane_line_crossing) {
+ // BPL1DAT would have been written after end of last scanline.
+ // Set BPL1DAT "written at least once" state for new scanline.
+ bitplane_line_crossing -= maxhpos - HPOS_SHIFT;
+ if (bitplane_line_crossing > 0) {
+ bpl1dat_written = true;
+ bpl1dat_written_at_least_once = true;
+ reset_bpl_vars();
+ beginning_of_plane_block(bitplane_line_crossing, fetchmode);
+ }
+ bitplane_line_crossing = 0;
+ }
+ else {
+ reset_bpl_vars();
+ }
last_decide_line_hpos = -(DDF_OFFSET + 1);
- last_sprite_hpos = -1;
- last_fetch_hpos = -1;
+ last_ddf_pix_hpos = -1;
+ last_sprite_hpos = -1;
+ last_fetch_hpos = -1;
- /* These are for comparison. */
- thisline_decision.bplcon0 = bplcon0;
- thisline_decision.bplcon2 = bplcon2;
- thisline_decision.bplcon3 = bplcon3;
- thisline_decision.bplcon4 = bplcon4;
+ if (sprite_ignoreverticaluntilnextline) {
+ sprite_ignoreverticaluntilnextline = false;
+ for (int i = 0; i < MAX_SPRITES; i++)
+ spr[i].ignoreverticaluntilnextline = false;
+ }
+
+ /* These are for comparison. */
+ thisline_decision.bplcon0 = bplcon0;
+ thisline_decision.bplcon2 = bplcon2;
+#ifdef ECS_DENISE
+ thisline_decision.bplcon3 = bplcon3;
+#endif
+#ifdef AGA
+ thisline_decision.bplcon4 = bplcon4;
+#endif
+ scanlinecount++;
}
int vsynctimebase_orig;
-void compute_vsynctime (void)
+void compute_vsynctime(void)
{
- float svpos = maxvpos_nom;
- float shpos = maxhpos;
- float syncadjust = 1.0;
+ double svpos = maxvpos_nom;
+ double shpos = maxhpos_short;
+ double syncadjust = 1.0;
fake_vblank_hz = 0;
- if (fabs (currprefs.chipset_refreshrate) > 0.1) {
- syncadjust = currprefs.chipset_refreshrate / vblank_hz_nom;
- vblank_hz = currprefs.chipset_refreshrate;
- }
+ vblank_hz_mult = 0;
+ vblank_hz_state = 1;
+ if (fabs(currprefs.chipset_refreshrate) > 0.1) {
+ syncadjust = currprefs.chipset_refreshrate / vblank_hz_nom;
+ vblank_hz = currprefs.chipset_refreshrate;
+ if (isvsync_chipset()) {
+ int mult = 0;
+ if (getvsyncrate(vblank_hz, &mult) != vblank_hz) {
+ vblank_hz = getvsyncrate(vblank_hz, &vblank_hz_mult);
+ if (vblank_hz_mult > 0)
+ vblank_hz_state = 0;
+ }
+ }
+ }
if (!fake_vblank_hz)
fake_vblank_hz = vblank_hz;
- vsynctimebase = (int)(syncbase / fake_vblank_hz);
+ if (currprefs.turbo_emulation) {
+ if (currprefs.turbo_emulation_limit > 0) {
+ vsynctimebase = int(syncbase / currprefs.turbo_emulation_limit);
+ }
+ else {
+ vsynctimebase = 1;
+ }
+ }
+ else {
+ vsynctimebase = int(syncbase / fake_vblank_hz);
+ }
vsynctimebase_orig = vsynctimebase;
- if (currprefs.ntscmode) {
+ if (islinetoggle()) {
shpos += 0.5;
}
if (interlace_seen) {
svpos += 0.5;
- } else if (lof_current) {
+ }
+ else if (lof_current) {
svpos += 1.0;
}
- if (currprefs.produce_sound > 1) {
- float clk = svpos * shpos * fake_vblank_hz;
- devices_update_sound(clk, syncadjust);
- }
- devices_update_sync(svpos, syncadjust);
+ if (currprefs.produce_sound > 1) {
+ double clk = svpos * shpos * fake_vblank_hz;
+ //write_log (_T("SNDRATE %.1f*%.1f*%.6f=%.6f\n"), svpos, shpos, fake_vblank_hz, clk);
+ update_sound(clk);
+ //devices_update_sound(clk, syncadjust); //TODO
+ }
+ //devices_update_sync(svpos, syncadjust); //TODO
}
-int current_maxvpos (void)
+void getsyncregisters(uae_u16 *phsstrt, uae_u16 *phsstop, uae_u16 *pvsstrt, uae_u16 *pvsstop)
+{
+ *phsstrt = hsstrt;
+ *phsstop = hsstop;
+ *pvsstrt = vsstrt;
+ *pvsstop = vsstop;
+}
+
+//static void dumpsync(void)
+//{
+// static int cnt = 100;
+// if (cnt < 0)
+// return;
+// cnt--;
+// write_log(_T("BEAMCON0=%04X VTOTAL=%04X HTOTAL=%04X\n"), new_beamcon0, vtotal, htotal);
+// write_log(_T(" HSSTOP=%04X HBSTRT=%04X HBSTOP=%04X\n"), hsstop, hbstrt, hbstop);
+// write_log(_T(" VSSTOP=%04X VBSTRT=%04X VBSTOP=%04X\n"), vsstop, vbstrt, vbstop);
+// write_log(_T(" HSSTRT=%04X VSSTRT=%04X HCENTER=%04X\n"), hsstrt, vsstrt, hcenter);
+// write_log(_T(" HSYNCSTART=%04X HSYNCEND=%04X\n"), hsyncstartpos, hsyncendpos);
+//}
+
+int current_maxvpos(void)
{
return maxvpos + (lof_store ? 1 : 0);
}
-struct chipset_refresh *get_chipset_refresh (void)
+struct chipset_refresh *get_chipset_refresh(void)
{
int islace = interlace_seen ? 1 : 0;
int isntsc = (beamcon0 & 0x20) ? 0 : 1;
+ int custom = (beamcon0 & 0x80) ? 1 : 0;
if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
isntsc = currprefs.ntscmode ? 1 : 0;
@@ -3086,152 +3801,205 @@ struct chipset_refresh *get_chipset_refresh (void)
struct chipset_refresh *cr = &currprefs.cr[i];
if (cr->defaultdata)
def = i;
- if ((cr->horiz < 0 || cr->horiz == maxhpos) &&
- (cr->vert < 0 || cr->vert == maxvpos_display) &&
- (cr->ntsc < 0 || (cr->ntsc > 0 && isntsc) || (cr->ntsc == 0 && !isntsc)) &&
- (cr->lace < 0 || (cr->lace > 0 && islace) || (cr->lace == 0 && !islace)) &&
- (cr->resolution == 0 || cr->resolution == 7) &&
- ((cr->rtg && picasso_on) || (!cr->rtg && !picasso_on)) &&
- (cr->vsync < 0 || (cr->vsync > 0 && isvsync_chipset ()) || (cr->vsync == 0 && !isvsync_chipset ())))
+ if (cr->inuse) {
+ if ((cr->horiz < 0 || cr->horiz == maxhpos) &&
+ (cr->vert < 0 || cr->vert == maxvpos_display) &&
+ (cr->ntsc < 0 || (cr->ntsc == 1 && isntsc && !custom) || (cr->ntsc == 0 && !isntsc && !custom) || (cr->ntsc == 2 && custom)) &&
+ (cr->lace < 0 || (cr->lace > 0 && islace) || (cr->lace == 0 && !islace)) &&
+ (cr->resolution == 0 || cr->resolution == 7 || (cr->resolution & (1 << detected_screen_resolution))) &&
+ (cr->framelength < 0 || (cr->framelength > 0 && lof_store) || (cr->framelength == 0 && !lof_store) || (cr->framelength >= 0 && islace)) &&
+ ((cr->rtg && picasso_on) || (!cr->rtg && !picasso_on)) &&
+ (cr->vsync < 0 || (cr->vsync > 0 && isvsync_chipset()) || (cr->vsync == 0 && !isvsync_chipset())))
return cr;
+ }
}
if (def >= 0)
return &currprefs.cr[def];
- return NULL;
+ return nullptr;
}
-static bool changed_chipset_refresh (void)
+static bool changed_chipset_refresh(void)
{
- return stored_chipset_refresh != get_chipset_refresh ();
+ return stored_chipset_refresh != get_chipset_refresh();
}
-static void compute_framesync (void)
+void compute_framesync(void)
{
int islace = interlace_seen ? 1 : 0;
+ int isntsc = (beamcon0 & 0x20) ? 0 : 1;
bool found = false;
if (islace) {
vblank_hz = vblank_hz_lace;
- } else if (lof_current) {
+ }
+ else if (lof_current) {
vblank_hz = vblank_hz_lof;
- } else {
+ }
+ else {
vblank_hz = vblank_hz_shf;
}
- struct chipset_refresh *cr = get_chipset_refresh ();
+ //vblank_hz = target_adjust_vblank_hz(vblank_hz);
+
+ struct chipset_refresh *cr = get_chipset_refresh();
while (cr) {
- float v = -1;
- if (!picasso_on && !picasso_requested_on) {
- if (isvsync_chipset ()) {
+ double v = -1;
+ if (!picasso_on && !picasso_requested_on) {
+ if (isvsync_chipset()) {
if (cr->index == CHIPSET_REFRESH_PAL || cr->index == CHIPSET_REFRESH_NTSC) {
- if ((fabs (vblank_hz - 50) < 1 || fabs (vblank_hz - 60) < 1 || fabs (vblank_hz - 100) < 1 || fabs (vblank_hz - 120) < 1) && currprefs.gfx_apmode[0].gfx_vsync == 2) {
- vsync_switchmode ((int)vblank_hz);
- }
- } else if (isvsync_chipset () > 0) {
- if (currprefs.gfx_apmode[0].gfx_refreshrate)
- v = abs (currprefs.gfx_apmode[0].gfx_refreshrate);
+ if ((fabs(vblank_hz - 50) < 1 || fabs(vblank_hz - 60) < 1 || fabs(vblank_hz - 100) < 1 || fabs(vblank_hz - 120) < 1) && currprefs.gfx_apmode[0].gfx_vsync == 2 && currprefs.gfx_apmode[0].gfx_fullscreen > 0) {
+ vsync_switchmode(int(vblank_hz));
+ }
}
- } else {
+
+ else if (isvsync_chipset() > 0) {
+ if (currprefs.gfx_apmode[0].gfx_refreshrate)
+ v = abs(currprefs.gfx_apmode[0].gfx_refreshrate);
+ }
+ }
+ else {
if (cr->locked == false) {
changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate = vblank_hz;
+ cfgfile_parse_lines(&changed_prefs, cr->commands, -1);
+ if (cr->commands[0])
+ write_log(_T("CMD1: '%s'\n"), cr->commands);
break;
- } else {
+ }
+ else {
v = cr->rate;
}
- }
+ }
if (v < 0)
v = cr->rate;
if (v > 0) {
changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate = v;
+ cfgfile_parse_lines(&changed_prefs, cr->commands, -1);
+ if (cr->commands[0])
+ write_log(_T("CMD2: '%s'\n"), cr->commands);
}
- } else {
+ }
+ else {
if (cr->locked == false)
v = vblank_hz;
else
v = cr->rate;
changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate = v;
- vsync_switchmode((int)v);
- }
+ cfgfile_parse_lines(&changed_prefs, cr->commands, -1);
+ if (cr->commands[0])
+ write_log(_T("CMD3: '%s'\n"), cr->commands);
+ }
found = true;
break;
- }
+ }
if (!found) {
- vsync_switchmode((int)vblank_hz);
- changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate = vblank_hz;
+ changed_prefs.chipset_refreshrate = currprefs.chipset_refreshrate = vblank_hz;
}
stored_chipset_refresh = cr;
interlace_changed = 0;
lof_togglecnt_lace = 0;
lof_togglecnt_nlace = 0;
- lof_changing = 0;
+ lof_changing = 0;
- if (beamcon0 & 0x80) {
- gui_message(_T("Variable beam counter comparator enabled. Not supported in UAE4ARM."));
- }
+ if (beamcon0 & 0x80) {
+ int res = GET_RES_AGNUS(bplcon0);
+ int vres = islace ? 1 : 0;
+ int res2, vres2;
- memset (line_decisions, 0, sizeof line_decisions);
- memset (curr_drawinfo, 0, sizeof curr_drawinfo);
- for (int i = 0; i < sizeof (line_decisions) / sizeof *line_decisions; i++) {
+ res2 = currprefs.gfx_resolution;
+ if (doublescan > 0)
+ res2++;
+ if (res2 > RES_MAX)
+ res2 = RES_MAX;
+
+ vres2 = currprefs.gfx_vresolution;
+ if (doublescan > 0 && !islace)
+ vres2--;
+
+ if (vres2 < 0)
+ vres2 = 0;
+ if (vres2 > VRES_QUAD)
+ vres2 = VRES_QUAD;
+
+ int start = hsyncstartpos; //hbstrt;
+ int stop = hsyncendpos; //hbstop;
+
+ gfxvidinfo.outwidth = ((maxhpos - (maxhpos - start + DISPLAY_LEFT_SHIFT / 2) + 1) * 2) << res2;
+ gfxvidinfo.outheight = ((firstblankedline < maxvpos ? firstblankedline : maxvpos) - minfirstline + 1) << vres2;
+
+ }
+ else {
+ gfxvidinfo.outwidth = AMIGA_WIDTH_MAX << currprefs.gfx_resolution;
+ gfxvidinfo.outheight = (maxvpos_display - minfirstline + 1) << currprefs.gfx_vresolution;
+ }
+
+ memset(line_decisions, 0, sizeof line_decisions);
+ memset(line_drawinfo, 0, sizeof line_drawinfo);
+ for (int i = 0; i < sizeof(line_decisions) / sizeof *line_decisions; i++) {
line_decisions[i].plfleft = -2;
}
- compute_vsynctime ();
+ compute_vsynctime();
- hblank_hz = (float)(currprefs.ntscmode ? CHIPSET_CLOCK_NTSC : CHIPSET_CLOCK_PAL) / (maxhpos + (currprefs.ntscmode ? 0.5 : 0));
+ hblank_hz = double(currprefs.ntscmode ? CHIPSET_CLOCK_NTSC : CHIPSET_CLOCK_PAL) / (maxhpos + (islinetoggle() ? 0.5 : 0));
- set_config_changed ();
+ set_config_changed();
- if (target_graphics_buffer_update ()) {
- reset_drawing ();
+ if (target_graphics_buffer_update()) {
+ reset_drawing();
}
}
/* set PAL/NTSC or custom timing variables */
-static void init_hz (bool checkvposw)
+static void init_hz(bool checkvposw)
{
int isntsc, islace;
- int omaxvpos = maxvpos;
- int hzc = 0;
+ int odbl = doublescan, omaxvpos = maxvpos;
+ double ovblank = vblank_hz;
+ int hzc = 0;
if (!checkvposw)
vpos_count = 0;
vpos_count_diff = vpos_count;
- if ((beamcon0 & 0xA0) != (new_beamcon0 & 0xA0))
- hzc = 1;
- if (beamcon0 != new_beamcon0) {
+ doublescan = 0;
+ programmedmode = false;
+ if ((beamcon0 & 0xA0) != (new_beamcon0 & 0xA0))
+ hzc = 1;
+ if (beamcon0 != new_beamcon0) {
+ //write_log(_T("BEAMCON0 %04x -> %04x PC=%08x\n"), beamcon0, new_beamcon0, M68K_GETPC);
vpos_count_diff = vpos_count = 0;
- }
+ }
beamcon0 = new_beamcon0;
isntsc = (beamcon0 & 0x20) ? 0 : 1;
islace = (interlace_seen) ? 1 : 0;
- if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
- isntsc = currprefs.ntscmode ? 1 : 0;
+ if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
+ isntsc = currprefs.ntscmode ? 1 : 0;
int clk = currprefs.ntscmode ? CHIPSET_CLOCK_NTSC : CHIPSET_CLOCK_PAL;
- if (!isntsc) {
- maxvpos = MAXVPOS_PAL;
- maxhpos = MAXHPOS_PAL;
- minfirstline = VBLANK_ENDLINE_PAL;
+ if (!isntsc) {
+ maxvpos = MAXVPOS_PAL;
+ maxhpos = MAXHPOS_PAL;
+ minfirstline = VBLANK_ENDLINE_PAL;
vblank_hz_nom = vblank_hz = VBLANK_HZ_PAL;
- sprite_vblank_endline = VBLANK_SPRITE_PAL;
+ sprite_vblank_endline = VBLANK_SPRITE_PAL;
equ_vblank_endline = EQU_ENDLINE_PAL;
equ_vblank_toggle = true;
- vblank_hz_shf = (float)((float)clk / ((maxvpos + 0) * maxhpos));
- vblank_hz_lof = (float)((float)clk / ((maxvpos + 1) * maxhpos));
- vblank_hz_lace = (float)((float)clk / ((maxvpos + 0.5) * maxhpos));
- } else {
- maxvpos = MAXVPOS_NTSC;
- maxhpos = MAXHPOS_NTSC;
- minfirstline = VBLANK_ENDLINE_NTSC;
+ vblank_hz_shf = double(clk) / ((maxvpos + 0) * maxhpos);
+ vblank_hz_lof = double(clk) / ((maxvpos + 1) * maxhpos);
+ vblank_hz_lace = double(clk) / ((maxvpos + 0.5) * maxhpos);
+ }
+ else {
+ maxvpos = MAXVPOS_NTSC;
+ maxhpos = MAXHPOS_NTSC;
+ minfirstline = VBLANK_ENDLINE_NTSC;
vblank_hz_nom = vblank_hz = VBLANK_HZ_NTSC;
- sprite_vblank_endline = VBLANK_SPRITE_NTSC;
+ sprite_vblank_endline = VBLANK_SPRITE_NTSC;
equ_vblank_endline = EQU_ENDLINE_NTSC;
equ_vblank_toggle = false;
- vblank_hz_shf = (float)((float)clk / ((maxvpos + 0) * (maxhpos + 0.5)));
- vblank_hz_lof = (float)((float)clk / ((maxvpos + 1) * (maxhpos + 0.5)));
- vblank_hz_lace = (float)((float)clk / ((maxvpos + 0.5) * (maxhpos + 0.5)));
- }
+ vblank_hz_shf = double(clk) / ((maxvpos + 0) * (maxhpos + 0.5));
+ vblank_hz_lof = double(clk) / ((maxvpos + 1) * (maxhpos + 0.5));
+ vblank_hz_lace = double(clk) / ((maxvpos + 0.5) * (maxhpos + 0.5));
+ }
maxvpos_nom = maxvpos;
maxvpos_display = maxvpos;
@@ -3245,84 +4013,194 @@ static void init_hz (bool checkvposw)
maxvpos_nom = vpos_count - (lof_current ? 1 : 0);
if ((maxvpos_nom >= 256 && maxvpos_nom <= 313) || (beamcon0 & 0x80)) {
maxvpos_display = maxvpos_nom;
- } else if (maxvpos_nom < 256) {
+ }
+ else if (maxvpos_nom < 256) {
maxvpos_display = 255;
- } else {
+ }
+ else {
maxvpos_display = 313;
}
- reset_drawing ();
- } else if (vpos_count == 0) {
+ reset_drawing();
+ }
+ else if (vpos_count == 0) {
// mode reset
vpos_count = maxvpos;
vpos_count_diff = maxvpos;
}
+ firstblankedline = maxvpos + 1;
- if (beamcon0 & 0x80) {
+ if (beamcon0 & 0x80) {
// programmable scanrates (ECS Agnus)
-#ifdef WITH_INGAME_WARNING
- InGameMessage("Programmable scanrates (ECS Agnus) not supported.");
-#endif
- }
+ if (vtotal >= MAXVPOS)
+ vtotal = MAXVPOS - 1;
+ maxvpos = vtotal + 1;
+ firstblankedline = maxvpos + 1;
+ if (htotal >= MAXHPOS)
+ htotal = MAXHPOS - 1;
+ maxhpos = htotal + 1;
+ vblank_hz_nom = vblank_hz = 227.0 * 312.0 * 50.0 / (maxvpos * maxhpos);
+ vblank_hz_shf = vblank_hz;
+ vblank_hz_lof = 227.0 * 313.0 * 50.0 / (maxvpos * maxhpos);;
+ vblank_hz_lace = 227.0 * 312.5 * 50.0 / (maxvpos * maxhpos);;
+
+ if ((beamcon0 & 0x1000) && (beamcon0 & 0x0200)) { // VARVBEN + VARVSYEN
+ minfirstline = vsstop > vbstop ? vsstop : vbstop;
+ if (minfirstline > maxvpos / 2)
+ minfirstline = vsstop > vbstop ? vbstop : vsstop;
+ firstblankedline = vbstrt;
+ }
+ else if (beamcon0 & 0x0200) {
+ minfirstline = vsstop;
+ if (minfirstline > maxvpos / 2)
+ minfirstline = 0;
+ }
+ else if (beamcon0 & 0x1000) {
+ minfirstline = vbstop;
+ if (minfirstline > maxvpos / 2)
+ minfirstline = 0;
+ firstblankedline = vbstrt;
+ }
+
+ if (minfirstline < 2)
+ minfirstline = 2;
+ if (minfirstline >= maxvpos)
+ minfirstline = maxvpos - 1;
+
+ if (firstblankedline < minfirstline)
+ firstblankedline = maxvpos + 1;
+
+ sprite_vblank_endline = minfirstline - 2;
+ maxvpos_nom = maxvpos;
+ maxvpos_display = maxvpos;
+ equ_vblank_endline = -1;
+ doublescan = htotal <= 164 && vtotal >= 350 ? 1 : 0;
+ // if superhires and wide enough: not doublescan
+ if (doublescan && htotal >= 140 && (bplcon0 & 0x0040))
+ doublescan = 0;
+ programmedmode = true;
+ varsync_changed = true;
+ vpos_count = maxvpos_nom;
+ vpos_count_diff = maxvpos_nom;
+ hzc = 1;
+ }
if (maxvpos_nom >= MAXVPOS)
maxvpos_nom = MAXVPOS;
if (maxvpos_display >= MAXVPOS)
maxvpos_display = MAXVPOS;
- if (maxvpos != omaxvpos)
+ if (currprefs.gfx_scandoubler && doublescan == 0)
+ doublescan = -1;
+ if (doublescan != odbl || maxvpos != omaxvpos)
hzc = 1;
- /* limit to sane values */
- if (vblank_hz < 10)
- vblank_hz = 10;
- if (vblank_hz > 300)
- vblank_hz = 300;
- set_delay_lastcycle ();
+ /* limit to sane values */
+ if (vblank_hz < 10)
+ vblank_hz = 10;
+ if (vblank_hz > 300)
+ vblank_hz = 300;
+ maxhpos_short = maxhpos;
+ set_delay_lastcycle();
+ if ((beamcon0 & 0x80) && (beamcon0 & 0x0100)) {
- hsyncstartpos = maxhpos + 13;
+ hsyncstartpos = hsstrt;
+ hsyncendpos = hsstop;
+
+ if ((bplcon0 & 1) && (bplcon3 & 1)) {
+
+ if (hbstrt > maxhpos / 2) {
+ if (hsyncstartpos < hbstrt)
+ hsyncstartpos = hbstrt;
+ }
+ else {
+ if (hsyncstartpos > hbstrt)
+ hsyncstartpos = hbstrt;
+ }
+
+ if (hbstop > maxhpos / 2) {
+ if (hsyncendpos > hbstop)
+ hsyncendpos = hbstop;
+ }
+ else {
+ if (hsyncendpos < hbstop)
+ hsyncendpos = hbstop;
+ }
+ }
+
+ if (hsyncstartpos < hsyncendpos)
+ hsyncstartpos = maxhpos + hsyncstartpos;
+
+ hsyncendpos--;
+
+ if (hsyncendpos < 2)
+ hsyncendpos = 2;
+
+ if (hsyncstartpos - hsyncendpos < maxhpos / 2)
+ hsyncstartpos = maxhpos;
+
+ }
+ else {
+
+ hsyncstartpos = maxhpos_short + 13;
hsyncendpos = 24;
- eventtab[ev_hsync].oldcycles = get_cycles ();
- eventtab[ev_hsync].evtime = get_cycles() + HSYNCTIME;
- events_schedule ();
- if (hzc) {
+ }
+ hpos_offset = 0;
+ eventtab[ev_hsync].oldcycles = get_cycles();
+ eventtab[ev_hsync].evtime = get_cycles() + HSYNCTIME;
+ events_schedule();
+ if (hzc) {
interlace_seen = islace;
- reset_drawing ();
- }
+ reset_drawing();
+ }
maxvpos_total = (currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? (MAXVPOS_LINES_ECS - 1) : (MAXVPOS_LINES_OCS - 1);
if (maxvpos_total > MAXVPOS)
maxvpos_total = MAXVPOS;
+#ifdef PICASSO96
+ if (!p96refresh_active) {
+ maxvpos_stored = maxvpos;
+ maxhpos_stored = maxhpos;
+ vblank_hz_stored = vblank_hz;
+ }
+#endif
- compute_framesync ();
+ compute_framesync();
+ //devices_syncchange();
#ifdef PICASSO96
- init_hz_p96 ();
+ init_hz_p96();
#endif
- inputdevice_tablet_strobe ();
+ if (vblank_hz != ovblank)
+ updatedisplayarea();
+ inputdevice_tablet_strobe();
- varsync_changed = false;
+ if (varsync_changed) {
+ varsync_changed = false;
+ //dumpsync();
+ }
}
-static void init_hz_vposw (void)
+static void init_hz_vposw(void)
{
- init_hz (true);
+ init_hz(true);
}
-void init_hz_normal (void)
+void init_hz_normal(void)
{
- init_hz (false);
+ init_hz(false);
}
-static void calcdiw (void)
+static void calcdiw(void)
{
int hstrt = diwstrt & 0xFF;
int hstop = diwstop & 0xFF;
int vstrt = diwstrt >> 8;
int vstop = diwstop >> 8;
-
+
// vertical in ECS Agnus
if (diwhigh_written && (currprefs.chipset_mask & CSMASK_ECS_AGNUS)) {
vstrt |= (diwhigh & 7) << 8;
vstop |= ((diwhigh >> 8) & 7) << 8;
- } else {
+ }
+ else {
if ((vstop & 0x80) == 0)
vstop |= 0x100;
}
@@ -3330,23 +4208,24 @@ static void calcdiw (void)
if (diwhigh_written && (currprefs.chipset_mask & CSMASK_ECS_DENISE)) {
hstrt |= ((diwhigh >> 5) & 1) << 8;
hstop |= ((diwhigh >> 13) & 1) << 8;
- } else {
+ }
+ else {
hstop += 0x100;
}
diw_hstrt = hstrt;
diw_hstop = hstop;
-
- diwfirstword = coord_diw_to_window_x (hstrt);
- diwlastword = coord_diw_to_window_x (hstop);
-
- if (diwfirstword >= diwlastword) {
+
+ diwfirstword = coord_diw_to_window_x(hstrt);
+ diwlastword = coord_diw_to_window_x(hstop);
+
+ if (diwfirstword >= diwlastword) {
diwfirstword = min_diwlastword;
- diwlastword = max_diwlastword;
- }
+ diwlastword = max_diwlastword;
+ }
if (diwfirstword < min_diwlastword)
diwfirstword = min_diwlastword;
-
+
if (vstrt == vpos && vstop != vpos && diwstate == DIW_waiting_start) {
// This may start BPL DMA immediately.
SET_LINE_CYCLEBASED;
@@ -3355,126 +4234,190 @@ static void calcdiw (void)
plffirstline = vstrt;
plflastline = vstop;
-
+
plfstrt = ddfstrt - DDF_OFFSET;
plfstop = ddfstop - DDF_OFFSET;
+
+ diw_change = 2;
}
/* display mode changed (lores, doubling etc..), recalculate everything */
-void init_custom (void)
+void init_custom(void)
{
- update_mirrors();
- create_cycle_diagram_table ();
- reset_drawing ();
+ update_mirrors();
+ create_cycle_diagram_table();
+ reset_drawing();
init_hz_normal();
- calcdiw ();
+ calcdiw();
}
static int timehack_alive = 0;
-static uae_u32 REGPARAM2 timehack_helper (TrapContext *context)
+static uae_u32 REGPARAM2 timehack_helper(TrapContext *context)
{
#ifdef HAVE_GETTIMEOFDAY
- struct timeval tv;
- if (m68k_dreg (regs, 0) == 0)
- return timehack_alive;
+ struct timeval tv;
+ if (m68k_dreg(regs, 0) == 0)
+ return timehack_alive;
- timehack_alive = 10;
+ timehack_alive = 10;
- gettimeofday (&tv, NULL);
- put_long (m68k_areg (regs, 0), tv.tv_sec - (((365 * 8 + 2) * 24) * 60 * 60));
- put_long (m68k_areg (regs, 0) + 4, tv.tv_usec);
- return 0;
+ gettimeofday(&tv, nullptr);
+ put_long(m68k_areg(regs, 0), tv.tv_sec - (((365 * 8 + 2) * 24) * 60 * 60));
+ put_long(m68k_areg(regs, 0) + 4, tv.tv_usec);
+ return 0;
#else
- return 2;
+ return 2;
#endif
}
- /*
- * register functions
- */
-STATIC_INLINE uae_u16 DENISEID (int *missing)
+/*
+* register functions
+*/
+static uae_u16 DENISEID(int *missing)
{
*missing = 0;
- if (aga_mode) {
+ if (currprefs.cs_deniserev >= 0)
+ return currprefs.cs_deniserev;
+#ifdef AGA
+ if (currprefs.chipset_mask & CSMASK_AGA) {
if (currprefs.cs_ide == IDE_A4000)
return 0xFCF8;
return 0x00F8;
- }
+ }
+#endif
if (currprefs.chipset_mask & CSMASK_ECS_DENISE)
return 0xFFFC;
- if (currprefs.cpu_model == 68000 && currprefs.cpu_compatible)
+ if (currprefs.cpu_model == 68000 && (currprefs.cpu_compatible || currprefs.cpu_memory_cycle_exact))
*missing = 1;
return 0xFFFF;
}
-STATIC_INLINE uae_u16 DMACONR (int hpos)
+
+STATIC_INLINE uae_u16 DMACONR(int hpos)
{
+ decide_line(hpos);
+ decide_fetch_safe(hpos);
dmacon &= ~(0x4000 | 0x2000);
- dmacon |= ((blit_interrupt) ? 0 : 0x4000)
- | (blt_info.blitzero ? 0x2000 : 0);
- return dmacon;
+ dmacon |= ((blit_interrupt || (!blit_interrupt && currprefs.cs_agnusbltbusybug && !blt_info.got_cycle)) ? 0 : 0x4000)
+ | (blt_info.blitzero ? 0x2000 : 0);
+ return dmacon;
}
-STATIC_INLINE uae_u16 INTENAR (void)
+STATIC_INLINE uae_u16 INTENAR(void)
{
- return intena;
+ return intena;
}
-STATIC_INLINE uae_u16 ADKCONR (void)
+uae_u16 INTREQR(void)
{
- return adkcon;
+ return intreq;
+}
+STATIC_INLINE uae_u16 ADKCONR(void)
+{
+ return adkcon;
}
-STATIC_INLINE int issyncstopped (void)
+STATIC_INLINE int islightpentriggered(void)
{
- return (bplcon0 & 2);
+ if (beamcon0 & 0x2000) // LPENDIS
+ return 0;
+ return lightpen_triggered > 0;
+}
+STATIC_INLINE int issyncstopped(void)
+{
+ return (bplcon0 & 2) && !currprefs.genlock;
}
-STATIC_INLINE int GETVPOS (void)
+STATIC_INLINE int GETVPOS(void)
{
- return issyncstopped () ? vpos_previous : vpos;
+ return islightpentriggered() ? vpos_lpen : (issyncstopped() ? vpos_previous : vpos);
}
-STATIC_INLINE int GETHPOS (void)
+STATIC_INLINE int GETHPOS(void)
{
- return issyncstopped () ? hpos_previous : current_hpos ();
+ return islightpentriggered() ? hpos_lpen : (issyncstopped() ? hpos_previous : current_hpos());
}
-#define CPU_ACCURATE (currprefs.cpu_model < 68020)
+// fake changing hpos when rom genlock test runs and genlock is connected
+static bool hsyncdelay(void)
+{
+ if (!currprefs.genlock)
+ return false;
+ //if (currprefs.cpu_memory_cycle_exact || currprefs.m68k_speed >= 0)
+ if (currprefs.m68k_speed >= 0)
+ return false;
+ if (bplcon0 == (0x0100 | 0x0002)) {
+ return true;
+ }
+ return false;
+}
+
+#define CPU_ACCURATE (currprefs.cpu_model < 68020 || (currprefs.cpu_model == 68020 && currprefs.cpu_memory_cycle_exact))
// DFF006 = 0.W must be valid result but better do this only in 68000 modes (whdload black screen!)
// HPOS is shifted by 3 cycles and VPOS increases when shifted HPOS==1
#define HPOS_OFFSET (CPU_ACCURATE ? HPOS_SHIFT : 0)
#define VPOS_INC_DELAY (HPOS_OFFSET ? 1 : 0)
-STATIC_INLINE uae_u16 VPOSR (void)
+static uae_u16 VPOSR(void)
{
- unsigned int csbit = 0;
- uae_u16 vp = GETVPOS ();
- uae_u16 hp = GETHPOS ();
+ unsigned int csbit = 0;
+ uae_u16 vp = GETVPOS();
+ uae_u16 hp = GETHPOS();
+ int lof = lof_store;
+ if (vp + 1 == maxvpos + lof_store && (hp == maxhpos - 1 || hp == maxhpos - 2)) {
+ // lof toggles 2 cycles before maxhpos, so do fake toggle here.
+ if ((bplcon0 & 4) && CPU_ACCURATE)
+ lof = lof ? 0 : 1;
+ }
if (hp + HPOS_OFFSET >= maxhpos + VPOS_INC_DELAY) {
vp++;
if (vp >= maxvpos + lof_store)
vp = 0;
}
- vp = (vp >> 8) & 7;
+ vp = (vp >> 8) & 7;
- csbit |= (aga_mode) ? 0x2300 : 0;
- csbit |= (currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? 0x2000 : 0;
- if (currprefs.ntscmode)
- csbit |= 0x1000;
+ if (currprefs.cs_agnusrev >= 0) {
+ csbit |= currprefs.cs_agnusrev << 8;
+ }
+ else {
+#ifdef AGA
+ csbit |= (currprefs.chipset_mask & CSMASK_AGA) ? 0x2300 : 0;
+#endif
+ csbit |= (currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? 0x2000 : 0;
+ if (currprefs.ntscmode)
+ csbit |= 0x1000;
+ }
- if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
- vp &= 1;
- vp |= (lof_store ? 0x8000 : 0) | csbit;
- return vp;
+ if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
+ vp &= 1;
+ vp |= (lof ? 0x8000 : 0) | csbit;
+ if (currprefs.chipset_mask & CSMASK_ECS_AGNUS)
+ vp |= lol ? 0x80 : 0;
+ hsyncdelay();
+
+ return vp;
}
-static void VPOSW (uae_u16 v)
+static void vposback(int oldvpos)
+{
+ if (cop_state.state == COP_wait && oldvpos == cop_state.vcmp) {
+ copper_enabled_thisline = 0;
+ unset_special(SPCFLAG_COPPER);
+ }
+}
+
+static void VPOSW(uae_u16 v)
{
int oldvpos = vpos;
+
if (lof_store != ((v & 0x8000) ? 1 : 0)) {
- lof_store = (v & 0x8000) ? 1 : 0;
+ lof_store = (v & 0x8000) ? 1 : 0;
lof_changing = lof_store ? 1 : -1;
- }
+ }
+ if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
+ lol = (v & 0x0080) ? 1 : 0;
+ if (!islinetoggle())
+ lol = 0;
+ }
if (lof_changing)
return;
vpos &= 0x00ff;
@@ -3488,11 +4431,22 @@ static void VPOSW (uae_u16 v)
vpos = oldvpos;
}
-static void VHPOSW (uae_u16 v)
+static void VHPOSW(uae_u16 v)
{
int oldvpos = vpos;
bool changed = false;
+ if (currprefs.cpu_memory_cycle_exact && currprefs.cpu_model == 68000) {
+ /* Special hack for Smooth Copper in CoolFridge / Upfront demo */
+ int chp = current_hpos_safe();
+ int hp = v & 0xff;
+ if (chp >= 0x21 && chp <= 0x29 && hp == 0x2d) {
+ hack_delay_shift = 4;
+ record_color_change(chp, 0, COLOR_CHANGE_HSYNC_HACK | 6);
+ thisline_changed = true;
+ }
+ }
+
v >>= 8;
vpos &= 0xff00;
vpos |= v;
@@ -3500,268 +4454,335 @@ static void VHPOSW (uae_u16 v)
vposw_change++;
if (vpos < oldvpos) {
vpos = oldvpos;
- } else if (vpos < minfirstline && oldvpos < minfirstline) {
+ }
+ else if (vpos < minfirstline && oldvpos < minfirstline) {
vpos = oldvpos;
}
}
-STATIC_INLINE uae_u16 VHPOSR (void)
+static uae_u16 VHPOSR(void)
{
- uae_u16 vp = GETVPOS ();
- uae_u16 hp = GETHPOS ();
+ static uae_u16 oldhp;
+ uae_u16 vp = GETVPOS();
+ uae_u16 hp = GETHPOS();
hp += HPOS_OFFSET;
- if (hp >= maxhpos) {
- hp -= maxhpos;
+ if (hp >= maxhpos) {
+ hp -= maxhpos;
// vpos increases when hp==1, not when hp==0
if (hp >= VPOS_INC_DELAY) {
- vp++;
- if (vp >= maxvpos + lof_store)
- vp = 0;
- }
+ vp++;
+ if (vp >= maxvpos + lof_store)
+ vp = 0;
+ }
}
if (HPOS_OFFSET) {
- hp += 1;
- if (hp >= maxhpos)
- hp -= maxhpos;
+ hp += 1;
+ if (hp >= maxhpos)
+ hp -= maxhpos;
}
- vp <<= 8;
- vp |= hp;
- return vp;
+ vp <<= 8;
+
+ if (hsyncdelay()) {
+ // fake continuously changing hpos in fastest possible modes
+ hp = oldhp % maxhpos;
+ oldhp++;
+ }
+
+ vp |= hp;
+ return vp;
}
-static int test_copper_dangerous (unsigned int address)
+static void REFPTR(uae_u16 v)
{
- int addr = address & 0x01fe;
- if (addr < ((copcon & 2) ? ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? 0 : 0x40) : 0x80)) {
- cop_state.state = COP_stop;
- copper_enabled_thisline = 0;
- unset_special (SPCFLAG_COPPER);
- return 1;
- }
- return 0;
+ /*
+ ECS Agnus:
+
+ b15 8000: R 040
+ b14 4000: R 020
+ b13 2000: R 010
+ b12 1000: R 008
+ b11 0800: R 004
+ b10 0400: R 002
+ b09 0200: R 001
+ b08 0100: C 080
+ b07 0080: C 040
+ b06 0040: C 020
+ b05 0020: C 010
+ b04 0010: C 008
+ b03 0008: C 004
+ b02 0004: C 002 C 100
+ b01 0002: C 001 R 100
+ b00 0001: R 080
+
+ */
+
+ refptr = v;
+ refptr_val = (v & 0xfe00) | ((v & 0x01fe) >> 1);
+ if (v & 1) {
+ refptr_val |= 0x80 << 9;
+ }
+ if (v & 2) {
+ refptr_val |= 1;
+ refptr_val |= 0x100 << 9;
+ }
+ if (v & 4) {
+ refptr_val |= 2;
+ refptr_val |= 0x100;
+ }
}
-static void immediate_copper (int num)
+static int test_copper_dangerous(unsigned int address)
{
- int pos = 0;
- int oldpos = 0;
-
- cop_state.state = COP_stop;
- cop_state.hpos = current_hpos () & ~1;
- cop_state.ip = num == 1 ? cop1lc : cop2lc;
-
- while (pos < (maxvpos << 5)) {
- if (oldpos > pos)
- pos = oldpos;
- if (!dmaen(DMA_COPPER))
- break;
- if (cop_state.ip >= currprefs.chipmem_size)
- break;
- pos++;
- oldpos = pos;
- cop_state.i1 = chipmem_wget_indirect (cop_state.ip);
- cop_state.i2 = chipmem_wget_indirect (cop_state.ip + 2);
- cop_state.ip += 4;
- if (!(cop_state.i1 & 1)) { // move
- cop_state.i1 &= 0x1fe;
- if (cop_state.i1 == 0x88) {
- cop_state.ip = cop1lc;
- continue;
- }
- if (cop_state.i1 == 0x8a) {
- cop_state.ip = cop2lc;
- continue;
- }
- if (test_copper_dangerous (cop_state.i1))
- break;
- custom_wput_1 (0, cop_state.i1, cop_state.i2, 0);
- } else { // wait or skip
- if ((cop_state.i1 >> 8) > ((pos >> 5) & 0xff))
- pos = (((pos >> 5) & 0x100) | ((cop_state.i1 >> 8)) << 5) | ((cop_state.i1 & 0xff) >> 3);
- if (cop_state.i1 >= 0xffdf && cop_state.i2 == 0xfffe)
- break;
- }
- }
- cop_state.state = COP_stop;
- unset_special (SPCFLAG_COPPER);
+ int addr = address & 0x01fe;
+ if (addr < ((copcon & 2) ? ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? 0 : 0x40) : 0x80)) {
+ cop_state.state = COP_stop;
+ copper_enabled_thisline = 0;
+ unset_special(SPCFLAG_COPPER);
+ return 1;
+ }
+ return 0;
}
-STATIC_INLINE void COP1LCH (uae_u16 v)
+static void immediate_copper(int num)
+{
+ int pos = 0;
+ int oldpos = 0;
+
+ cop_state.state = COP_stop;
+ cop_state.vpos = vpos;
+ cop_state.hpos = current_hpos() & ~1;
+ cop_state.ip = num == 1 ? cop1lc : cop2lc;
+
+ while (pos < (maxvpos << 5)) {
+ if (oldpos > pos)
+ pos = oldpos;
+ if (!dmaen(DMA_COPPER))
+ break;
+ if (cop_state.ip >= currprefs.chipmem_size && cop_state.ip < currprefs.z3chipmem_start && cop_state.ip >= currprefs.z3chipmem_start + currprefs.z3chipmem_size)
+ break;
+ pos++;
+ oldpos = pos;
+ cop_state.i1 = chipmem_wget_indirect(cop_state.ip);
+ cop_state.i2 = chipmem_wget_indirect(cop_state.ip + 2);
+ cop_state.ip += 4;
+ if (!(cop_state.i1 & 1)) { // move
+ cop_state.i1 &= 0x1fe;
+ if (cop_state.i1 == 0x88) {
+ cop_state.ip = cop1lc;
+ continue;
+ }
+ if (cop_state.i1 == 0x8a) {
+ cop_state.ip = cop2lc;
+ continue;
+ }
+ if (test_copper_dangerous(cop_state.i1))
+ break;
+ custom_wput_1(0, cop_state.i1, cop_state.i2, 0);
+ }
+ else { // wait or skip
+ if ((cop_state.i1 >> 8) > ((pos >> 5) & 0xff))
+ pos = (((pos >> 5) & 0x100) | ((cop_state.i1 >> 8)) << 5) | ((cop_state.i1 & 0xff) >> 3);
+ if (cop_state.i1 >= 0xffdf && cop_state.i2 == 0xfffe)
+ break;
+ }
+ }
+ cop_state.state = COP_stop;
+ unset_special(SPCFLAG_COPPER);
+}
+
+STATIC_INLINE void COP1LCH(uae_u16 v)
{
cop1lc = (cop1lc & 0xffff) | ((uae_u32)v << 16);
}
-STATIC_INLINE void COP1LCL (uae_u16 v)
+STATIC_INLINE void COP1LCL(uae_u16 v)
{
cop1lc = (cop1lc & ~0xffff) | (v & 0xfffe);
}
-STATIC_INLINE void COP2LCH (uae_u16 v)
+STATIC_INLINE void COP2LCH(uae_u16 v)
{
cop2lc = (cop2lc & 0xffff) | ((uae_u32)v << 16);
}
-STATIC_INLINE void COP2LCL (uae_u16 v)
+STATIC_INLINE void COP2LCL(uae_u16 v)
{
cop2lc = (cop2lc & ~0xffff) | (v & 0xfffe);
}
-static void compute_spcflag_copper (int hpos);
+static void compute_spcflag_copper(int hpos);
// vblank = copper starts at hpos=2
// normal COPJMP write: takes 2 more cycles
-static void COPJMP (int num, int vblank)
+static void COPJMP(int num, int vblank)
{
- int was_active = eventtab[ev_copper].active;
- int oldstrobe = cop_state.strobe;
+ int oldstrobe = cop_state.strobe;
bool wasstopped = cop_state.state == COP_stop && !vblank;
- unset_special (SPCFLAG_COPPER);
+ unset_special(SPCFLAG_COPPER);
cop_state.ignore_next = 0;
- if (!oldstrobe)
- cop_state.state_prev = cop_state.state;
+ if (!oldstrobe)
+ cop_state.state_prev = cop_state.state;
if ((cop_state.state == COP_wait || cop_state.state == COP_waitforever) && !vblank && dmaen(DMA_COPPER)) {
cop_state.state = COP_strobe_delay1x;
- } else {
+ }
+ else {
cop_state.state = vblank ? COP_start_delay : (copper_access ? COP_strobe_delay1 : COP_strobe_extra);
}
- cop_state.hpos = current_hpos () & ~1;
- copper_enabled_thisline = 0;
- cop_state.strobe = num;
-
- eventtab[ev_copper].active = 0;
+ cop_state.vpos = vpos;
+ cop_state.hpos = current_hpos() & ~1;
+ copper_enabled_thisline = 0;
+ cop_state.strobe = num;
- if (nocustom()) {
- immediate_copper (num);
- return;
- }
+ if (nocustom()) {
+ immediate_copper(num);
+ return;
+ }
- if (was_active)
- events_schedule ();
-
- if (dmaen (DMA_COPPER)) {
- compute_spcflag_copper (current_hpos ());
- } else if (wasstopped || (oldstrobe > 0 && oldstrobe != num && cop_state.state_prev == COP_wait)) {
- /* dma disabled, copper idle and accessed both COPxJMPs -> copper stops! */
- cop_state.state = COP_stop;
+ if (dmaen(DMA_COPPER)) {
+ compute_spcflag_copper(current_hpos());
+ }
+ else if (wasstopped || (oldstrobe > 0 && oldstrobe != num && cop_state.state_prev == COP_wait)) {
+ /* dma disabled, copper idle and accessed both COPxJMPs -> copper stops! */
+ cop_state.state = COP_stop;
}
}
-STATIC_INLINE void COPCON (uae_u16 a)
+STATIC_INLINE void COPCON(uae_u16 a)
{
- copcon = a;
+ copcon = a;
}
-STATIC_INLINE void check_copper_stop(void)
+static void check_copper_stop(void)
{
if (copper_enabled_thisline < 0 && !((dmacon & DMA_COPPER) && (dmacon & DMA_MASTER))) {
copper_enabled_thisline = 0;
- unset_special (SPCFLAG_COPPER);
+ unset_special(SPCFLAG_COPPER);
}
}
-STATIC_INLINE void copper_stop(void)
+static void copper_stop(void)
{
if (copper_enabled_thisline) {
// let MOVE to finish
switch (cop_state.state)
{
- case COP_read2:
- copper_enabled_thisline = -1;
- break;
+ case COP_read2:
+ copper_enabled_thisline = -1;
+ break;
}
}
if (copper_enabled_thisline >= 0) {
copper_enabled_thisline = 0;
- unset_special (SPCFLAG_COPPER);
+ unset_special(SPCFLAG_COPPER);
}
}
-static void DMACON (int hpos, uae_u16 v)
+static void DMACON(int hpos, uae_u16 v)
{
int oldcop, newcop;
- uae_u16 changed;
-
+ uae_u16 changed;
+
uae_u16 oldcon = dmacon;
-
- decide_line (hpos);
- decide_fetch_safe (hpos);
-
- setclr (&dmacon, v);
+
+ decide_line(hpos);
+ decide_fetch_safe(hpos);
+
+ setclr(&dmacon, v);
dmacon &= 0x07FF;
-
- changed = dmacon ^ oldcon;
- oldcop = (oldcon & DMA_COPPER) && (oldcon & DMA_MASTER);
- newcop = (dmacon & DMA_COPPER) && (dmacon & DMA_MASTER);
- if (oldcop != newcop) {
- eventtab[ev_copper].active = 0;
+ changed = dmacon ^ oldcon;
- if (newcop && !oldcop) {
- compute_spcflag_copper (hpos);
- } else if (!newcop) {
+ oldcop = (oldcon & DMA_COPPER) && (oldcon & DMA_MASTER);
+ newcop = (dmacon & DMA_COPPER) && (dmacon & DMA_MASTER);
+
+ if (oldcop != newcop) {
+ if (newcop && !oldcop) {
+ compute_spcflag_copper(hpos);
+ }
+ else if (!newcop) {
copper_stop();
- }
+ }
}
if ((dmacon & DMA_BLITPRI) > (oldcon & DMA_BLITPRI) && bltstate != BLT_done)
- set_special (SPCFLAG_BLTNASTY);
+ set_special(SPCFLAG_BLTNASTY);
- if (dmaen (DMA_BLITTER) && bltstate == BLT_init) {
- blitter_check_start ();
+ if (dmaen(DMA_BLITTER) && bltstate == BLT_init) {
+ blitter_check_start();
}
if ((dmacon & (DMA_BLITPRI | DMA_BLITTER | DMA_MASTER)) != (DMA_BLITPRI | DMA_BLITTER | DMA_MASTER))
- unset_special (SPCFLAG_BLTNASTY);
-
- if (changed & (DMA_MASTER | 0x0f))
- audio_state_machine ();
+ unset_special(SPCFLAG_BLTNASTY);
- if (changed & (DMA_MASTER | DMA_BITPLANE)) {
- SET_LINE_CYCLEBASED;
+ if (changed & (DMA_MASTER | 0x0f))
+ audio_state_machine();
+
+ if (changed & (DMA_MASTER | DMA_BITPLANE)) {
+ SET_LINE_CYCLEBASED;
bitplane_maybe_start_hpos = hpos;
- }
-
- events_schedule();
+ }
}
-int intlev (void)
+static int irq_nmi;
+
+void NMI_delayed(void)
{
- uae_u16 imask = intreq & intena;
- if (!(imask && (intena & 0x4000)))
- return -1;
- if (imask & (0x4000 | 0x2000)) // 13 14
- return 6;
- if (imask & (0x1000 | 0x0800)) // 11 12
- return 5;
- if (imask & (0x0400 | 0x0200 | 0x0100 | 0x0080)) // 7 8 9 10
- return 4;
- if (imask & (0x0040 | 0x0020 | 0x0010)) // 4 5 6
- return 3;
- if (imask & 0x0008) // 3
- return 2;
- if (imask & (0x0001 | 0x0002 | 0x0004)) // 0 1 2
- return 1;
- return -1;
+ irq_nmi = 1;
}
+static uae_u16 intreq_internal, intena_internal;
+
+int intlev(void)
+{
+ uae_u16 imask = intreq_internal & intena_internal;
+ if (irq_nmi) {
+ irq_nmi = 0;
+ return 7;
+ }
+ if (!(imask && (intena_internal & 0x4000)))
+ return -1;
+ if (imask & (0x4000 | 0x2000)) // 13 14
+ return 6;
+ if (imask & (0x1000 | 0x0800)) // 11 12
+ return 5;
+ if (imask & (0x0400 | 0x0200 | 0x0100 | 0x0080)) // 7 8 9 10
+ return 4;
+ if (imask & (0x0040 | 0x0020 | 0x0010)) // 4 5 6
+ return 3;
+ if (imask & 0x0008) // 3
+ return 2;
+ if (imask & (0x0001 | 0x0002 | 0x0004)) // 0 1 2
+ return 1;
+ return -1;
+}
+
+#define INT_PROCESSING_DELAY (3 * CYCLE_UNIT)
+STATIC_INLINE int use_eventmode(uae_u16 v)
+{
+ if (currprefs.cpu_memory_cycle_exact && currprefs.cpu_model <= 68020)
+ return 1;
+ return 0;
+}
+
+
void rethink_uae_int(void)
{
bool irq2 = false;
bool irq6 = false;
- if (uae_int_requested) {
+ if (uae_int_requested) {
if (uae_int_requested & 0xff00)
irq6 = true;
if (uae_int_requested & 0x00ff)
irq2 = true;
- }
+ }
{
- extern void bsdsock_fake_int_handler (void);
+ extern void bsdsock_fake_int_handler(void);
extern int volatile bsd_int_requested;
if (bsd_int_requested)
- bsdsock_fake_int_handler ();
+ bsdsock_fake_int_handler();
}
uae_u16 mask = (irq6 ? 0x2000 : 0) | (irq2 ? 0x0008 : 0);
@@ -3769,322 +4790,487 @@ void rethink_uae_int(void)
INTREQ_0(0x8000 | mask);
}
-STATIC_INLINE void rethink_intreq (void)
+static void rethink_intreq(void)
{
- devices_rethink();
+ //serial_check_irq(); //TODO
+ rethink_cias();
+#ifdef A2065
+ rethink_a2065();
+#endif
+#ifdef A2091
+ rethink_a2091();
+#endif
+#ifdef CDTV
+ rethink_cdtv();
+#endif
+#ifdef CD32
+ rethink_akiko();
+#endif
+ //rethink_gayle(); //TODO
}
-static void INTENA (uae_u16 v)
+static void send_interrupt_do(uae_u32 v)
+{
+ INTREQ_0(0x8000 | (1 << v));
+}
+
+void send_interrupt(int num, int delay)
+{
+ if (use_eventmode(0x8000) && delay > 0) {
+ // always queue interrupt if it is active because
+ // next instruction in bad code can switch it off..
+ // Absolute Inebriation / Virtual Dreams "big glenz" part
+ if (!(intreq & (1 << num)) || (intena & (1 << num)))
+ event2_newevent_xx(-1, delay, num, send_interrupt_do);
+ }
+ else {
+ send_interrupt_do(num);
+ }
+}
+
+static int int_recursive; // yes, bad idea.
+
+static void send_intena_do(uae_u32 v)
+{
+ setclr(&intena_internal, v);
+ doint();
+}
+
+static void send_intreq_do(uae_u32 v)
+{
+ setclr(&intreq_internal, v);
+ int_recursive++;
+ rethink_intreq();
+ int_recursive--;
+ doint();
+}
+
+static void INTENA(uae_u16 v)
{
uae_u16 old = intena;
- setclr (&intena,v);
+ setclr(&intena, v);
- if (!(v & 0x8000) && old == intena)
+ if (!(v & 0x8000) && old == intena && intena == intena_internal)
return;
- if (v & 0x8000)
- doint();
+ //write_log (_T("%04x %04x %04x %04x\n"), intena, intena_internal, intreq, intreq_internal);
+
+ if (use_eventmode(v)) {
+ if (old == intena && intena == intena_internal)
+ return;
+ event2_newevent_xx(-1, INT_PROCESSING_DELAY, v, send_intena_do);
+ }
+ else {
+ intena_internal = intena;
+ if (v & 0x8000)
+ doint();
+ }
}
-void INTREQ_f (uae_u16 v)
+static void INTREQ_nodelay(uae_u16 v)
{
- setclr (&intreq, v);
+ setclr(&intreq, v);
+ setclr(&intreq_internal, v);
+ doint();
}
-bool INTREQ_0 (uae_u16 v)
+void INTREQ_f(uae_u16 v)
+{
+ if (use_eventmode(v)) {
+ setclr(&intreq, v);
+ send_intreq_do(v);
+ }
+ else {
+ uae_u16 old = intreq;
+ setclr(&intreq, v);
+ setclr(&intreq_internal, v);
+ //if ((old & 0x0800) && !(intreq & 0x0800))
+ // serial_rbf_clear();
+ }
+}
+
+bool INTREQ_0(uae_u16 v)
{
uae_u16 old = intreq;
- setclr (&intreq, v);
+ setclr(&intreq, v);
- if (old == intreq)
+ //if ((old & 0x0800) && !(intreq & 0x0800))
+ // serial_rbf_clear();
+
+ if (int_recursive) {
+ // don't add new event if this call came from send_intreq_do/rethink
+ // and intreq didn't change.
+ // it wouldn't make any difference except to slow down everything
+ if (old == intreq)
+ return false;
+ }
+
+ if (use_eventmode(v)) {
+ // don't bother to waste time for interrupt queuing if nothing changes
+ // but only if we are sure there is no other queued changes
+ if (old == intreq && intreq_internal == intreq)
+ return false;
+ event2_newevent_xx(-1, INT_PROCESSING_DELAY, v, send_intreq_do);
return false;
- if (v & 0x8000)
- doint();
- return true;
+ }
+ else {
+ uae_u16 old2 = intreq_internal;
+ intreq_internal = intreq;
+ if (old == intreq && old2 == intreq_internal)
+ return false;
+ if (v & 0x8000)
+ doint();
+ return true;
+ }
}
-void INTREQ (uae_u16 data)
+void INTREQ(uae_u16 data)
{
- if (INTREQ_0 (data))
- rethink_intreq ();
+ if (INTREQ_0(data))
+ rethink_intreq();
}
-static void ADKCON (int hpos, uae_u16 v)
+static void ADKCON(int hpos, uae_u16 v)
{
- if (currprefs.produce_sound > 0)
- update_audio ();
- DISK_update (hpos);
- DISK_update_adkcon (hpos, v);
- setclr (&adkcon,v);
- audio_update_adkmasks ();
+ if (currprefs.produce_sound > 0)
+ update_audio();
+ DISK_update(hpos);
+ DISK_update_adkcon(hpos, v);
+ setclr(&adkcon, v);
+ audio_update_adkmasks();
+ //if ((v >> 11) & 1)
+ // serial_uartbreak((adkcon >> 11) & 1);
}
-static void BEAMCON0 (uae_u16 v)
+static void BEAMCON0(uae_u16 v)
{
- if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
- new_beamcon0 = v;
+ if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
+ if (v != new_beamcon0) {
+ new_beamcon0 = v;
+ //if (v & ~0x20) {
+ //write_log(_T("warning: %04X written to BEAMCON0 PC=%08X\n"), v, M68K_GETPC);
+ //dumpsync();
+ //}
+ }
calcdiw();
- }
+ }
}
-STATIC_INLINE void varsync (void)
+static void varsync(void)
{
- if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
- return;
- if (!(beamcon0 & 0x80))
- return;
+ if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
+ return;
+#ifdef PICASSO96
+ if (picasso_on && p96refresh_active) {
+ vtotal = p96refresh_active;
+ return;
+ }
+#endif
+ if (!(beamcon0 & 0x80))
+ return;
varsync_changed = true;
}
-static void BPLxPTH (int hpos, uae_u16 v, int num)
+#ifdef PICASSO96
+void set_picasso_hack_rate(int hz)
{
- decide_line (hpos);
- decide_fetch_safe (hpos);
- if (copper_access && is_bitplane_dma (hpos + 1) == num + 1) {
+ if (!picasso_on)
+ return;
+ vpos_count = 0;
+ p96refresh_active = int(maxvpos_stored * vblank_hz_stored / hz);
+ if (!currprefs.cs_ciaatod)
+ changed_prefs.cs_ciaatod = currprefs.cs_ciaatod = currprefs.ntscmode ? 2 : 1;
+ if (p96refresh_active > 0) {
+ new_beamcon0 |= 0x80;
+ }
+}
+#endif
+
+
+/* "Dangerous" blitter D-channel: Writing to memory which is also currently
+* read by bitplane DMA
+*/
+static void dcheck_is_blit_dangerous(void)
+{
+ check_is_blit_dangerous(bplpt, bplcon0_planes, 50 << bplcon0_res);
+}
+static void BPLxPTH(int hpos, uae_u16 v, int num)
+{
+ decide_line(hpos);
+ decide_fetch_safe(hpos);
+ if (copper_access && is_bitplane_dma(hpos + 1) == num + 1) {
SET_LINE_CYCLEBASED;
return;
}
- bplpt[num] = (bplpt[num] & 0x0000ffff) | ((uae_u32)v << 16);
+ bplpt[num] = (bplpt[num] & 0x0000ffff) | ((uae_u32)v << 16);
+ bplptx[num] = (bplptx[num] & 0x0000ffff) | ((uae_u32)v << 16);
+ dcheck_is_blit_dangerous();
+ //write_log (_T("%d:%d:BPL%dPTH %08X COP=%08x\n"), hpos, vpos, num, bplpt[num], cop_state.ip);
}
-
-static void BPLxPTL (int hpos, uae_u16 v, int num)
+static void BPLxPTL(int hpos, uae_u16 v, int num)
{
- decide_line (hpos);
- decide_fetch_safe (hpos);
+ decide_line(hpos);
+ decide_fetch_safe(hpos);
/* chipset feature:
- * BPLxPTL write and next cycle doing DMA fetch using same pointer register ->
- * next DMA cycle uses old value.
- * (Multiscroll / Cult)
- *
- * If following cycle is not BPL DMA: written value is lost
- *
- * last fetch block does not have this side-effect, probably due to modulo adds.
- * Also it seems only plane 0 fetches have this feature (because of above reason!)
- * (MoreNewStuffy / PlasmaForce)
- */
+ * BPLxPTL write and next cycle doing DMA fetch using same pointer register ->
+ * next DMA cycle uses old value.
+ * (Multiscroll / Cult)
+ *
+ * If following cycle is not BPL DMA: written value is lost
+ *
+ * last fetch block does not have this side-effect, probably due to modulo adds.
+ * Also it seems only plane 0 fetches have this feature (because of above reason!)
+ * (MoreNewStuffy / PlasmaForce)
+ */
/* only detect copper accesses to prevent too fast CPU mode glitches */
- if (copper_access && is_bitplane_dma (hpos + 1) == num + 1) {
+ if (copper_access && is_bitplane_dma(hpos + 1) == num + 1) {
SET_LINE_CYCLEBASED;
return;
- }
- bplpt[num] = (bplpt[num] & 0xffff0000) | (v & 0x0000fffe);
+ }
+ bplpt[num] = (bplpt[num] & 0xffff0000) | (v & 0x0000fffe);
+ bplptx[num] = (bplptx[num] & 0xffff0000) | (v & 0x0000fffe);
+ dcheck_is_blit_dangerous();
+ //write_log (_T("%d:%d:BPL%dPTL %08X COP=%08x\n"), hpos, vpos, num, bplpt[num], cop_state.ip);
}
-static void BPLCON0_Denise (int hpos, uae_u16 v, bool immediate)
+static void BPLCON0_Denise(int hpos, uae_u16 v, bool immediate)
{
- if (! (currprefs.chipset_mask & CSMASK_ECS_DENISE))
+ if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE))
v &= ~0x00F1;
- else if (! (aga_mode))
+ else if (!(currprefs.chipset_mask & CSMASK_AGA))
v &= ~0x00B0;
v &= ~(0x0200 | 0x0100 | 0x0080 | 0x0020);
+#if SPRBORDER
+ v |= 1;
+#endif
if (bplcon0d == v && !immediate)
return;
bplcon0dd = -1;
-
+ // fake unused 0x0080 bit as an EHB bit (see below)
+ if (isehb(bplcon0d, bplcon2))
+ v |= 0x80;
if (immediate) {
- record_register_change (hpos, 0x100, v);
- } else {
- record_register_change (hpos, 0x100, (bplcon0d & ~(0x800 | 0x400 | 0x80)) | (v & (0x0800 | 0x400 | 0x80 | 0x01)));
+ record_register_change(hpos, 0x100, v);
+ }
+ else {
+ record_register_change(hpos, 0x100, (bplcon0d & ~(0x800 | 0x400 | 0x80)) | (v & (0x0800 | 0x400 | 0x80 | 0x01)));
}
- bplcon0d = v;
+ bplcon0d = v & ~0x80;
+#ifdef ECS_DENISE
if (currprefs.chipset_mask & CSMASK_ECS_DENISE) {
decide_sprites(-1, hpos);
- sprres = expand_sprres (v, bplcon3);
+ sprres = expand_sprres(v, bplcon3);
}
+#endif
if (thisline_decision.plfleft < 0)
- update_denise (hpos);
+ update_denise(hpos);
else
- update_denise_shifter_planes (hpos);
+ update_denise_shifter_planes(hpos);
}
-static void BPLCON0 (int hpos, uae_u16 v)
+static void BPLCON0(int hpos, uae_u16 v)
{
- if (! (currprefs.chipset_mask & CSMASK_ECS_DENISE))
+ if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE))
v &= ~0x00F1;
- else if (! (aga_mode))
+ else if (!(currprefs.chipset_mask & CSMASK_AGA))
v &= ~0x00B0;
v &= ~0x0080;
-
+
+#if SPRBORDER
+ v |= 1;
+#endif
if (bplcon0 == v)
return;
-
- SET_LINE_CYCLEBASED;
- decide_diw (hpos);
- decide_line (hpos);
- decide_fetch_safe (hpos);
- if (!issyncstopped ()) {
+ SET_LINE_CYCLEBASED;
+ decide_diw(hpos);
+ decide_line(hpos);
+ decide_fetch_safe(hpos);
+
+ if (!issyncstopped()) {
vpos_previous = vpos;
hpos_previous = hpos;
}
+ if (bplcon0 & 4)
+ bplcon0_interlace_seen = true;
+
bplcon0 = v;
- bpldmainitdelay (hpos);
+ bpldmainitdelay(hpos);
if (thisline_decision.plfleft < 0)
- BPLCON0_Denise (hpos, v, true);
+ BPLCON0_Denise(hpos, v, true);
}
-STATIC_INLINE void BPLCON1 (int hpos, uae_u16 v)
+static void BPLCON1(int hpos, uae_u16 v)
{
- if (!(aga_mode))
- v &= 0xff;
+ if (!(currprefs.chipset_mask & CSMASK_AGA))
+ v &= 0xff;
if (bplcon1 == v)
return;
SET_LINE_CYCLEBASED;
- decide_line (hpos);
- decide_fetch_safe (hpos);
+ decide_line(hpos);
+ decide_fetch_safe(hpos);
bplcon1_written = true;
bplcon1 = v;
+ hack_shres_delay(hpos);
}
-STATIC_INLINE void BPLCON2 (int hpos, uae_u16 v)
+static void BPLCON2(int hpos, uae_u16 v)
{
- if (!(aga_mode))
- v &= 0x7f;
+ if (!(currprefs.chipset_mask & CSMASK_AGA))
+ v &= 0x7f;
if ((bplcon2 & 0x3fff) == (v & 0x3fff))
return;
- decide_line (hpos);
+ decide_line(hpos);
bplcon2 = v;
- record_register_change (hpos, 0x104, bplcon2);
+ record_register_change(hpos, 0x104, bplcon2);
}
-STATIC_INLINE void BPLCON3 (int hpos, uae_u16 v)
+#ifdef ECS_DENISE
+static void BPLCON3(int hpos, uae_u16 v)
{
- if (! (currprefs.chipset_mask & CSMASK_ECS_DENISE))
- return;
- if (!(aga_mode)) {
- v &= 0x003f;
- v |= 0x0c00;
- }
+ if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE))
+ return;
+ if (!(currprefs.chipset_mask & CSMASK_AGA)) {
+ v &= 0x003f;
+ v |= 0x0c00;
+ }
+#if SPRBORDER
+ v |= 2;
+#endif
if (bplcon3 == v)
return;
- decide_line (hpos);
+ decide_line(hpos);
decide_sprites(-1, hpos);
bplcon3 = v;
- sprres = expand_sprres (bplcon0, bplcon3);
- record_register_change (hpos, 0x106, v);
+ sprres = expand_sprres(bplcon0, bplcon3);
+ record_register_change(hpos, 0x106, v);
}
-
-STATIC_INLINE void BPLCON4 (int hpos, uae_u16 v)
+#endif
+#ifdef AGA
+static void BPLCON4(int hpos, uae_u16 v)
{
- if (! (aga_mode))
+ if (!(currprefs.chipset_mask & CSMASK_AGA))
return;
if (bplcon4 == v)
return;
- decide_line (hpos);
+ decide_line(hpos);
bplcon4 = v;
- record_register_change (hpos, 0x10c, v);
+ record_register_change(hpos, 0x10c, v);
}
+#endif
-static void BPL1MOD (int hpos, uae_u16 v)
+static void BPL1MOD(int hpos, uae_u16 v)
{
- v &= ~1;
- if ((uae_s16)bpl1mod != (uae_s16)v) {
- decide_line (hpos);
- decide_fetch_safe (hpos);
+ v &= ~1;
+ if (uae_s16(bpl1mod) != uae_s16(v)) {
+ decide_line(hpos);
+ decide_fetch_safe(hpos);
}
// write to BPLxMOD one cycle before
// BPL fetch that also adds modulo:
// Old BPLxMOD value is added.
- if (1 && (is_bitplane_dma (hpos + 1) & 1)) {
+ if (1 && (is_bitplane_dma(hpos + 1) & 1)) {
dbpl1mod = v;
dbpl1mod_on = hpos + 1;
- } else {
+ }
+ else {
bpl1mod = v;
dbpl1mod_on = 0;
}
}
-static void BPL2MOD (int hpos, uae_u16 v)
+static void BPL2MOD(int hpos, uae_u16 v)
{
- v &= ~1;
- if ((uae_s16)bpl2mod != (uae_s16)v) {
- decide_line (hpos);
- decide_fetch_safe (hpos);
+ v &= ~1;
+ if (uae_s16(bpl2mod) != uae_s16(v)) {
+ decide_line(hpos);
+ decide_fetch_safe(hpos);
}
- if (1 && (is_bitplane_dma (hpos + 1) & 2)) {
+ if (1 && (is_bitplane_dma(hpos + 1) & 2)) {
dbpl2mod = v;
dbpl2mod_on = hpos + 1;
- } else {
- bpl2mod = v;
+ }
+ else {
+ bpl2mod = v;
dbpl2mod_on = 0;
}
}
/* Needed in special OCS/ECS "7-plane" mode,
- * also handles CPU generated bitplane data
- */
-static void BPLxDAT (int hpos, int num, uae_u16 v)
+* also handles CPU generated bitplane data
+*/
+static void BPLxDAT(int hpos, int num, uae_u16 v)
{
// only BPL1DAT access can do anything visible
if (num == 0 && hpos >= 8) {
- decide_line (hpos);
- decide_fetch_safe (hpos);
+ decide_line(hpos);
+ decide_fetch_safe(hpos);
}
- flush_display (fetchmode);
+ flush_display(fetchmode);
fetched[num] = v;
fetched_aga[num] = v;
if (num == 0 && hpos >= 8) {
- bpl1dat_written = true;
- bpl1dat_written_at_least_once = true;
+ bpl1dat_written = true;
+ bpl1dat_written_at_least_once = true;
if (thisline_decision.plfleft < 0)
- reset_bpl_vars ();
- beginning_of_plane_block (hpos, fetchmode);
- }
+ reset_bpl_vars();
+ beginning_of_plane_block(hpos, fetchmode);
+ }
}
-static void DIWSTRT (int hpos, uae_u16 v)
+static void DIWSTRT(int hpos, uae_u16 v)
{
- if (diwstrt == v && ! diwhigh_written)
+ if (diwstrt == v && !diwhigh_written)
return;
- decide_diw (hpos);
- decide_line (hpos);
+ decide_diw(hpos);
+ decide_line(hpos);
diwhigh_written = 0;
diwstrt = v;
- calcdiw ();
+ calcdiw();
}
-static void DIWSTOP (int hpos, uae_u16 v)
+static void DIWSTOP(int hpos, uae_u16 v)
{
- if (diwstop == v && ! diwhigh_written)
+ if (diwstop == v && !diwhigh_written)
return;
- decide_diw (hpos);
- decide_line (hpos);
+ decide_diw(hpos);
+ decide_line(hpos);
diwhigh_written = 0;
diwstop = v;
- calcdiw ();
+ calcdiw();
}
-static void DIWHIGH (int hpos, uae_u16 v)
+static void DIWHIGH(int hpos, uae_u16 v)
{
- if (!(currprefs.chipset_mask & (CSMASK_ECS_DENISE | CSMASK_ECS_AGNUS)))
- return;
- if (!(aga_mode))
- v &= ~(0x0008 | 0x0010 | 0x1000 | 0x0800);
- v &= ~(0x8000 | 0x4000 | 0x0080 | 0x0040);
- if (diwhigh_written && diwhigh == v)
+ if (!(currprefs.chipset_mask & (CSMASK_ECS_DENISE | CSMASK_ECS_AGNUS)))
return;
- decide_line (hpos);
+ if (!(currprefs.chipset_mask & CSMASK_AGA))
+ v &= ~(0x0008 | 0x0010 | 0x1000 | 0x0800);
+ v &= ~(0x8000 | 0x4000 | 0x0080 | 0x0040);
+ if (diwhigh_written && diwhigh == v)
+ return;
+ decide_line(hpos);
diwhigh_written = 1;
diwhigh = v;
- calcdiw ();
+ calcdiw();
}
-static void DDFSTRT (int hpos, uae_u16 v)
+static void DDFSTRT(int hpos, uae_u16 v)
{
- v &= 0xfe;
- if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
- v &= 0xfc;
- decide_line (hpos);
- SET_LINE_CYCLEBASED;
+ v &= 0xfe;
+ if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
+ v &= 0xfc;
+ decide_line(hpos);
+ SET_LINE_CYCLEBASED;
// Move state back to passed_enable if this DDFSTRT write was done exactly when
// it would match and start bitplane DMA.
if (hpos == ddfstrt - DDF_OFFSET && plf_state == plf_passed_start && plf_start_hpos == hpos + DDF_OFFSET) {
@@ -4092,18 +5278,24 @@ static void DDFSTRT (int hpos, uae_u16 v)
plf_start_hpos = maxhpos;
}
ddfstrt = v;
- calcdiw ();
+ calcdiw();
if (fetch_state != fetch_not_started)
- estimate_last_fetch_cycle (hpos);
+ estimate_last_fetch_cycle(hpos);
+ if (ddfstop > 0xD4 && (ddfstrt & 4) == 4) {
+ static int last_warned;
+ last_warned = (last_warned + 1) & 4095;
+ if (last_warned == 0)
+ write_log(_T("WARNING! Very strange DDF values (%x %x).\n"), ddfstrt, ddfstop);
+ }
}
-static void DDFSTOP (int hpos, uae_u16 v)
+static void DDFSTOP(int hpos, uae_u16 v)
{
v &= 0xfe;
- if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
- v &= 0xfc;
- decide_line (hpos);
- decide_fetch_safe (hpos);
+ if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
+ v &= 0xfc;
+ decide_line(hpos);
+ decide_fetch_safe(hpos);
SET_LINE_CYCLEBASED;
// DDFSTOP write when old DDFSTOP value match: old value matches normally.
// Works differently than DDFSTRT which is interesting.
@@ -4114,7 +5306,8 @@ static void DDFSTOP (int hpos, uae_u16 v)
// don't let one_fetch_cycle_0() to do this again
ddfstop_written_hpos = hpos;
}
- } else if (hpos == ddfstop - DDF_OFFSET) {
+ }
+ else if (hpos == ddfstop - DDF_OFFSET) {
// if old ddfstop would have matched, emulate it here
if (plf_state == plf_active) {
plf_state = plf_passed_stop;
@@ -4122,15 +5315,23 @@ static void DDFSTOP (int hpos, uae_u16 v)
}
}
ddfstop = v;
- calcdiw ();
+ calcdiw();
if (fetch_state != fetch_not_started)
- estimate_last_fetch_cycle (hpos);
+ estimate_last_fetch_cycle(hpos);
+ if (ddfstop > 0xD4 && (ddfstrt & 4) == 4) {
+ static int last_warned;
+ if (last_warned == 0)
+ write_log(_T("WARNING! Very strange DDF values (%x).\n"), ddfstop);
+ last_warned = (last_warned + 1) & 4095;
+ }
}
-static void FMODE (int hpos, uae_u16 v)
+static void FMODE(int hpos, uae_u16 v)
{
- if (!(aga_mode)) {
- v = 0;
+ if (!(currprefs.chipset_mask & CSMASK_AGA)) {
+ //if (currprefs.monitoremu)
+ // specialmonitor_store_fmode(vpos, hpos, v);
+ v = 0;
}
v &= 0xC00F;
if (fmode == v)
@@ -4138,326 +5339,465 @@ static void FMODE (int hpos, uae_u16 v)
SET_LINE_CYCLEBASED;
fmode_saved = v;
set_chipset_mode();
- bpldmainitdelay (hpos);
+ bpldmainitdelay(hpos);
}
-static void FNULL (uae_u16 v)
+static void FNULL(uae_u16 v)
{
}
-static void BLTADAT (uae_u16 v)
+static void BLTADAT(int hpos, uae_u16 v)
{
- maybe_blit (0);
+ maybe_blit(hpos, 0);
- blt_info.bltadat = v;
+ blt_info.bltadat = v;
}
+
/*
- * "Loading data shifts it immediately" says the HRM. Well, that may
- * be true for BLTBDAT, but not for BLTADAT - it appears the A data must be
- * loaded for every word so that AFWM and ALWM can be applied.
- */
-static void BLTBDAT (uae_u16 v)
+* "Loading data shifts it immediately" says the HRM. Well, that may
+* be true for BLTBDAT, but not for BLTADAT - it appears the A data must be
+* loaded for every word so that AFWM and ALWM can be applied.
+*/
+static void BLTBDAT(int hpos, uae_u16 v)
{
- maybe_blit (0);
+ maybe_blit(hpos, 0);
- int shift = bltcon1 >> 12;
-
- if (bltcon1 & 2)
- blt_info.bltbhold = (((uae_u32)v << 16) | blt_info.bltbold) >> (16 - shift);
- else
- blt_info.bltbhold = (((uae_u32)blt_info.bltbold << 16) | v) >> shift;
-
- blt_info.bltbdat = v;
- blt_info.bltbold = v;
+ if (bltcon1 & 2)
+ blt_info.bltbhold = v << (bltcon1 >> 12);
+ else
+ blt_info.bltbhold = v >> (bltcon1 >> 12);
+ blt_info.bltbdat = v;
}
-STATIC_INLINE void BLTCDAT (uae_u16 v) { maybe_blit (0); blt_info.bltcdat = v; }
+static void BLTCDAT(int hpos, uae_u16 v) { maybe_blit(hpos, 0); blt_info.bltcdat = v; reset_blit(0); }
-STATIC_INLINE void BLTAMOD (uae_u16 v) { maybe_blit (1); blt_info.bltamod = (uae_s16)(v & 0xFFFE); }
-STATIC_INLINE void BLTBMOD (uae_u16 v) { maybe_blit (1); blt_info.bltbmod = (uae_s16)(v & 0xFFFE); }
-STATIC_INLINE void BLTCMOD (uae_u16 v) { maybe_blit (1); blt_info.bltcmod = (uae_s16)(v & 0xFFFE); }
-STATIC_INLINE void BLTDMOD (uae_u16 v) { maybe_blit (1); blt_info.bltdmod = (uae_s16)(v & 0xFFFE); }
-
-STATIC_INLINE void BLTCON0 (uae_u16 v) { maybe_blit (2); bltcon0 = v; reset_blit (1); }
+static void BLTAMOD(int hpos, uae_u16 v) { maybe_blit(hpos, 1); blt_info.bltamod = uae_s16(v & 0xFFFE); reset_blit(0); }
+static void BLTBMOD(int hpos, uae_u16 v) { maybe_blit(hpos, 1); blt_info.bltbmod = uae_s16(v & 0xFFFE); reset_blit(0); }
+static void BLTCMOD(int hpos, uae_u16 v) { maybe_blit(hpos, 1); blt_info.bltcmod = uae_s16(v & 0xFFFE); reset_blit(0); }
+static void BLTDMOD(int hpos, uae_u16 v) { maybe_blit(hpos, 1); blt_info.bltdmod = uae_s16(v & 0xFFFE); reset_blit(0); }
+static void BLTCON0(int hpos, uae_u16 v) { maybe_blit(hpos, 2); bltcon0 = v; reset_blit(1); }
/* The next category is "Most useless hardware register".
- * And the winner is... */
-static void BLTCON0L (uae_u16 v)
+* And the winner is... */
+static void BLTCON0L(int hpos, uae_u16 v)
{
- if (! (currprefs.chipset_mask & CSMASK_ECS_AGNUS))
+ if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
return; // ei voittoa.
- maybe_blit (2);
- bltcon0 = (bltcon0 & 0xFF00) | (v & 0xFF);
- reset_blit (1);
+ maybe_blit(hpos, 2); bltcon0 = (bltcon0 & 0xFF00) | (v & 0xFF);
+ reset_blit(1);
}
-STATIC_INLINE void BLTCON1 (uae_u16 v) { maybe_blit (2); bltcon1 = v; reset_blit (2); }
+static void BLTCON1(int hpos, uae_u16 v) { maybe_blit(hpos, 2); bltcon1 = v; reset_blit(2); }
-STATIC_INLINE void BLTAFWM (uae_u16 v) { maybe_blit (2); blt_info.bltafwm = v; }
-STATIC_INLINE void BLTALWM (uae_u16 v) { maybe_blit (2); blt_info.bltalwm = v; }
+static void BLTAFWM(int hpos, uae_u16 v) { maybe_blit(hpos, 2); blt_info.bltafwm = v; reset_blit(0); }
+static void BLTALWM(int hpos, uae_u16 v) { maybe_blit(hpos, 2); blt_info.bltalwm = v; reset_blit(0); }
-STATIC_INLINE void BLTAPTH (uae_u16 v)
+static void BLTAPTH(int hpos, uae_u16 v)
{
- maybe_blit (0);
- bltapt = (bltapt & 0xffff) | ((uae_u32)v << 16);
+ maybe_blit(hpos, 0);
+ if (bltstate != BLT_done && currprefs.blitter_cycle_exact && currprefs.cpu_memory_cycle_exact) {
+ bltptx = (bltapt & 0xffff) | ((uae_u32)v << 16);
+ bltptxpos = hpos;
+ bltptxc = 1;
+ }
+ else {
+ bltapt = (bltapt & 0xffff) | ((uae_u32)v << 16);
+ }
}
-STATIC_INLINE void BLTAPTL (uae_u16 v)
-{
- maybe_blit (0);
- bltapt = (bltapt & ~0xffff) | (v & 0xFFFE);
-}
-STATIC_INLINE void BLTBPTH (uae_u16 v)
-{
- maybe_blit (0);
- bltbpt = (bltbpt & 0xffff) | ((uae_u32)v << 16);
-}
-STATIC_INLINE void BLTBPTL (uae_u16 v)
-{
- maybe_blit (0);
- bltbpt = (bltbpt & ~0xffff) | (v & 0xFFFE);
-}
-STATIC_INLINE void BLTCPTH (uae_u16 v)
-{
- maybe_blit (0);
- bltcpt = (bltcpt & 0xffff) | ((uae_u32)v << 16);
-}
-STATIC_INLINE void BLTCPTL (uae_u16 v)
-{
- maybe_blit (0);
- bltcpt = (bltcpt & ~0xffff) | (v & 0xFFFE);
-}
-STATIC_INLINE void BLTDPTH (uae_u16 v)
-{
- maybe_blit (0);
- bltdpt = (bltdpt & 0xffff) | ((uae_u32)v << 16);
-}
-STATIC_INLINE void BLTDPTL (uae_u16 v)
-{
- maybe_blit (0);
- bltdpt = (bltdpt & ~0xffff) | (v & 0xFFFE);
-}
-
-STATIC_INLINE void BLTSIZE (uae_u16 v)
+static void BLTAPTL(int hpos, uae_u16 v)
{
- maybe_blit (0);
-
- blt_info.vblitsize = v >> 6;
- blt_info.hblitsize = v & 0x3F;
- if (!blt_info.vblitsize)
- blt_info.vblitsize = 1024;
- if (!blt_info.hblitsize)
- blt_info.hblitsize = 64;
- do_blitter ();
+ maybe_blit(hpos, 0);
+ if (bltstate != BLT_done && currprefs.blitter_cycle_exact && currprefs.cpu_memory_cycle_exact) {
+ bltptx = (bltapt & ~0xffff) | (v & 0xFFFE);
+ bltptxpos = hpos;
+ bltptxc = 1;
+ }
+ else {
+ bltapt = (bltapt & ~0xffff) | (v & 0xFFFE);
+ }
+}
+static void BLTBPTH(int hpos, uae_u16 v)
+{
+ maybe_blit(hpos, 0);
+ if (bltstate != BLT_done && currprefs.blitter_cycle_exact && currprefs.cpu_memory_cycle_exact) {
+ bltptx = (bltbpt & 0xffff) | ((uae_u32)v << 16);
+ bltptxpos = hpos;
+ bltptxc = 2;
+ }
+ else {
+ bltbpt = (bltbpt & 0xffff) | ((uae_u32)v << 16);
+ }
+}
+static void BLTBPTL(int hpos, uae_u16 v)
+{
+ maybe_blit(hpos, 0);
+ if (bltstate != BLT_done && currprefs.blitter_cycle_exact && currprefs.cpu_memory_cycle_exact) {
+ bltptx = (bltbpt & ~0xffff) | (v & 0xFFFE);
+ bltptxpos = hpos;
+ bltptxc = 2;
+ }
+ else {
+ bltbpt = (bltbpt & ~0xffff) | (v & 0xFFFE);
+ }
+}
+static void BLTCPTH(int hpos, uae_u16 v)
+{
+ maybe_blit(hpos, 0);
+ if (bltstate != BLT_done && currprefs.blitter_cycle_exact && currprefs.cpu_memory_cycle_exact) {
+ bltptx = (bltcpt & 0xffff) | ((uae_u32)v << 16);
+ bltptxpos = hpos;
+ bltptxc = 3;
+ }
+ else {
+ bltcpt = (bltcpt & 0xffff) | ((uae_u32)v << 16);
+ }
+}
+static void BLTCPTL(int hpos, uae_u16 v)
+{
+ maybe_blit(hpos, 0);
+ if (bltstate != BLT_done && currprefs.blitter_cycle_exact && currprefs.cpu_memory_cycle_exact) {
+ bltptx = (bltcpt & ~0xffff) | (v & 0xFFFE);
+ bltptxpos = hpos;
+ bltptxc = 3;
+ }
+ else {
+ bltcpt = (bltcpt & ~0xffff) | (v & 0xFFFE);
+ }
+}
+static void BLTDPTH(int hpos, uae_u16 v)
+{
+ maybe_blit(hpos, 0);
+ if (bltstate != BLT_done && currprefs.blitter_cycle_exact && currprefs.cpu_memory_cycle_exact) {
+ bltptx = (bltdpt & 0xffff) | ((uae_u32)v << 16);
+ bltptxpos = hpos;
+ bltptxc = 4;
+ }
+ else {
+ bltdpt = (bltdpt & 0xffff) | ((uae_u32)v << 16);
+ }
+}
+static void BLTDPTL(int hpos, uae_u16 v)
+{
+ maybe_blit(hpos, 0);
+ if (bltstate != BLT_done && currprefs.blitter_cycle_exact && currprefs.cpu_memory_cycle_exact) {
+ bltptx = (bltdpt & ~0xffff) | (v & 0xFFFE);
+ bltptxpos = hpos;
+ bltptxc = 4;
+ }
+ else {
+ bltdpt = (bltdpt & ~0xffff) | (v & 0xFFFE);
+ }
}
-STATIC_INLINE void BLTSIZV (uae_u16 v)
+static void BLTSIZE(int hpos, uae_u16 v)
{
- if (! (currprefs.chipset_mask & CSMASK_ECS_AGNUS))
+ maybe_blit(hpos, 0);
+
+ blt_info.vblitsize = v >> 6;
+ blt_info.hblitsize = v & 0x3F;
+ if (!blt_info.vblitsize)
+ blt_info.vblitsize = 1024;
+ if (!blt_info.hblitsize)
+ blt_info.hblitsize = 64;
+ do_blitter(hpos, copper_access);
+ dcheck_is_blit_dangerous();
+}
+
+static void BLTSIZV(int hpos, uae_u16 v)
+{
+ if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
return;
- maybe_blit (0);
+ maybe_blit(hpos, 0);
blt_info.vblitsize = v & 0x7FFF;
}
-STATIC_INLINE void BLTSIZH (uae_u16 v)
+static void BLTSIZH(int hpos, uae_u16 v)
{
- if (! (currprefs.chipset_mask & CSMASK_ECS_AGNUS))
+ if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
return;
- maybe_blit (0);
+ maybe_blit(hpos, 0);
blt_info.hblitsize = v & 0x7FF;
- if (!blt_info.vblitsize)
- blt_info.vblitsize = 0x8000;
- if (!blt_info.hblitsize)
- blt_info.hblitsize = 0x0800;
- do_blitter ();
+ if (!blt_info.vblitsize)
+ blt_info.vblitsize = 0x8000;
+ if (!blt_info.hblitsize)
+ blt_info.hblitsize = 0x0800;
+ do_blitter(hpos, copper_access);
}
-STATIC_INLINE void spr_arm (int num, int state)
+STATIC_INLINE void spr_arm(int num, int state)
{
- switch (state) {
- case 0:
- nr_armed -= spr[num].armed;
- spr[num].armed = 0;
- break;
- default:
- nr_armed += 1 - spr[num].armed;
- spr[num].armed = 1;
- break;
- }
+ switch (state) {
+ case 0:
+ nr_armed -= spr[num].armed;
+ spr[num].armed = 0;
+ break;
+ default:
+ nr_armed += 1 - spr[num].armed;
+ spr[num].armed = 1;
+ break;
+ }
}
-STATIC_INLINE void sprstartstop (struct sprite *s)
+STATIC_INLINE void sprstartstop(struct sprite *s)
{
- if (vpos < sprite_vblank_endline)
+ if (vpos < sprite_vblank_endline || cant_this_last_line() || s->ignoreverticaluntilnextline)
return;
- if (vpos == s->vstart)
- s->dmastate = 1;
- if (vpos == s->vstop)
- s->dmastate = 0;
+ if (vpos == s->vstart)
+ s->dmastate = 1;
+ if (vpos == s->vstop)
+ s->dmastate = 0;
}
-STATIC_INLINE void SPRxCTLPOS (int num)
+static void SPRxCTLPOS(int num)
{
- int sprxp;
- struct sprite *s = &spr[num];
+ int sprxp;
+ struct sprite *s = &spr[num];
- sprstartstop (s);
- sprxp = (sprpos[num] & 0xFF) * 2 + (sprctl[num] & 1);
- sprxp <<= sprite_buffer_res;
- /* Quite a bit salad in this register... */
- if (aga_mode) {
+ sprstartstop(s);
+ sprxp = (sprpos[num] & 0xFF) * 2 + (sprctl[num] & 1);
+ sprxp <<= sprite_buffer_res;
+ /* Quite a bit salad in this register... */
+ if (false) {
+ }
+#ifdef AGA
+ else if (currprefs.chipset_mask & CSMASK_AGA) {
sprxp |= ((sprctl[num] >> 3) & 3) >> (RES_MAX - sprite_buffer_res);
s->dblscan = sprpos[num] & 0x80;
}
+#endif
+#ifdef ECS_DENISE
else if (currprefs.chipset_mask & CSMASK_ECS_DENISE) {
sprxp |= ((sprctl[num] >> 3) & 2) >> (RES_MAX - sprite_buffer_res);
- }
- s->xpos = sprxp;
- s->vstart = sprpos[num] >> 8;
- s->vstart |= (sprctl[num] & 0x04) ? 0x0100 : 0;
- s->vstop = sprctl[num] >> 8;
- s->vstop |= (sprctl[num] &0x02) ? 0x100 : 0;
- if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
+ }
+#endif
+ s->xpos = sprxp;
+ s->vstart = sprpos[num] >> 8;
+ s->vstart |= (sprctl[num] & 0x04) ? 0x0100 : 0;
+ s->vstop = sprctl[num] >> 8;
+ s->vstop |= (sprctl[num] & 0x02) ? 0x100 : 0;
+ if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
s->vstart |= (sprctl[num] & 0x40) ? 0x0200 : 0;
s->vstop |= (sprctl[num] & 0x20) ? 0x0200 : 0;
- }
- sprstartstop (s);
+ }
+ sprstartstop(s);
}
-STATIC_INLINE void SPRxCTL_1 (uae_u16 v, int num)
+static void SPRxCTL_1(uae_u16 v, int num, int hpos)
{
- sprctl[num] = v;
- spr_arm (num, 0);
- SPRxCTLPOS (num);
+ if (hpos >= maxhpos - 2 && sprctl[num] != v && vpos < maxvpos - 1) {
+ struct sprite *s = &spr[num];
+ vpos++;
+ sprstartstop(s);
+ vpos--;
+ s->ignoreverticaluntilnextline = true;
+ sprite_ignoreverticaluntilnextline = true;
+ }
+ sprctl[num] = v;
+ spr_arm(num, 0);
+ SPRxCTLPOS(num);
}
-STATIC_INLINE void SPRxPOS_1 (uae_u16 v, int num)
+static void SPRxPOS_1(uae_u16 v, int num, int hpos)
{
- sprpos[num] = v;
- SPRxCTLPOS (num);
+ if (hpos >= maxhpos - 2 && sprpos[num] != v && vpos < maxvpos - 1) {
+ struct sprite *s = &spr[num];
+ vpos++;
+ sprstartstop(s);
+ vpos--;
+ s->ignoreverticaluntilnextline = true;
+ sprite_ignoreverticaluntilnextline = true;
+ }
+ sprpos[num] = v;
+ SPRxCTLPOS(num);
+ }
+static void SPRxDATA_1(uae_u16 v, int num, int hpos)
+{
+ sprdata[num][0] = v;
+#ifdef AGA
+ sprdata[num][1] = v;
+ sprdata[num][2] = v;
+ sprdata[num][3] = v;
+#endif
+ spr_arm(num, 1);
}
-STATIC_INLINE void SPRxDATA_1 (uae_u16 v, int num)
+static void SPRxDATB_1(uae_u16 v, int num, int hpos)
{
- sprdata[num][0] = v;
- sprdata[num][1] = v;
- sprdata[num][2] = v;
- sprdata[num][3] = v;
- spr_arm (num, 1);
-}
-STATIC_INLINE void SPRxDATB_1 (uae_u16 v, int num)
-{
- sprdatb[num][0] = v;
- sprdatb[num][1] = v;
- sprdatb[num][2] = v;
- sprdatb[num][3] = v;
+ sprdatb[num][0] = v;
+#ifdef AGA
+ sprdatb[num][1] = v;
+ sprdatb[num][2] = v;
+ sprdatb[num][3] = v;
+#endif
}
/*
- SPRxDATA and SPRxDATB is moved to shift register when SPRxPOS matches.
+SPRxDATA and SPRxDATB is moved to shift register when SPRxPOS matches.
- When copper writes to SPRxDATx exactly when SPRxPOS matches:
- - If sprite low x bit (SPRCTL bit 0) is not set, shift register copy
- is done first (previously loaded SPRxDATx value is shown) and then
- new SPRxDATx gets stored for future use.
- - If sprite low x bit is set, new SPRxDATx is stored, then SPRxPOS
- matches and value written to SPRxDATx is visible.
+When copper writes to SPRxDATx exactly when SPRxPOS matches:
+- If sprite low x bit (SPRCTL bit 0) is not set, shift register copy
+is done first (previously loaded SPRxDATx value is shown) and then
+new SPRxDATx gets stored for future use.
+- If sprite low x bit is set, new SPRxDATx is stored, then SPRxPOS
+matches and value written to SPRxDATx is visible.
- - Writing to SPRxPOS when SPRxPOS matches: shift register
- copy is always done first, then new SPRxPOS value is stored
- for future use. (SPRxCTL not tested)
+- Writing to SPRxPOS when SPRxPOS matches: shift register
+copy is always done first, then new SPRxPOS value is stored
+for future use. (SPRxCTL not tested)
*/
-STATIC_INLINE void SPRxDATA (int hpos, uae_u16 v, int num)
-{
- decide_sprites(-1, hpos, false);
- SPRxDATA_1 (v, num);
+static void SPRxDATA(int hpos, uae_u16 v, int num)
+{
+ decide_sprites(-1, hpos, true, false);
+ SPRxDATA_1(v, num, hpos);
}
-STATIC_INLINE void SPRxDATB (int hpos, uae_u16 v, int num)
-{
- decide_sprites(-1, hpos, false);
- SPRxDATB_1 (v, num);
+static void SPRxDATB(int hpos, uae_u16 v, int num)
+{
+ decide_sprites(-1, hpos, true, false);
+ SPRxDATB_1(v, num, hpos);
}
-STATIC_INLINE void SPRxCTL (int hpos, uae_u16 v, int num)
-{
- decide_sprites(-1, hpos);
- SPRxCTL_1 (v, num);
-}
-STATIC_INLINE void SPRxPOS (int hpos, uae_u16 v, int num)
+static void SPRxCTL(int hpos, uae_u16 v, int num)
{
decide_sprites(-1, hpos);
- SPRxPOS_1 (v, num);
+ SPRxCTL_1(v, num, hpos);
+}
+static void SPRxPOS(int hpos, uae_u16 v, int num)
+{
+ struct sprite *s = &spr[num];
+ int oldvpos;
+
+ decide_sprites(-1, hpos);
+ oldvpos = s->vstart;
+ SPRxPOS_1(v, num, hpos);
+ // Superfrog flashing intro bees fix.
+ // if SPRxPOS is written one cycle before sprite's first DMA slot and sprite's vstart matches after
+ // SPRxPOS write, current line's DMA slot's stay idle. DMA decision seems to be done 4 cycles earlier.
+ if (hpos >= SPR0_HPOS + num * 4 - 4 && hpos <= SPR0_HPOS + num * 4 - 1 && oldvpos != vpos) {
+ s->ptxvpos2 = vpos;
+ s->ptxhpos2 = hpos + 4;
+ }
}
-static void SPRxPTH (int hpos, uae_u16 v, int num)
+static void SPRxPTH(int hpos, uae_u16 v, int num)
{
decide_sprites(-1, hpos);
- if (hpos - 1 != MAXHPOS) {
- spr[num].pt &= 0xffff;
- spr[num].pt |= (uae_u32)v << 16;
- }
+ if (hpos - 1 != spr[num].ptxhpos) {
+ spr[num].pt &= 0xffff;
+ spr[num].pt |= (uae_u32)v << 16;
+ }
}
-static void SPRxPTL (int hpos, uae_u16 v, int num)
+static void SPRxPTL(int hpos, uae_u16 v, int num)
{
decide_sprites(-1, hpos);
- if (hpos - 1 != MAXHPOS) {
- spr[num].pt &= ~0xffff;
+ if (hpos - 1 != spr[num].ptxhpos) {
+ spr[num].pt &= ~0xffff;
spr[num].pt |= v & ~1;
- }
+ }
}
-static void CLXCON (uae_u16 v)
+static void CLXCON(uae_u16 v)
{
- clxcon = v;
- clxcon_bpl_enable = (v >> 6) & 63;
- clxcon_bpl_match = v & 63;
+ clxcon = v;
+ clxcon_bpl_enable = (v >> 6) & 63;
+ clxcon_bpl_match = v & 63;
}
-static void CLXCON2 (uae_u16 v)
+static void CLXCON2(uae_u16 v)
{
- if (!(aga_mode))
+ if (!(currprefs.chipset_mask & CSMASK_AGA))
return;
clxcon2 = v;
- clxcon_bpl_enable |= v & (0x40|0x80);
- clxcon_bpl_match |= (v & (0x01|0x02)) << 6;
+ clxcon_bpl_enable |= v & (0x40 | 0x80);
+ clxcon_bpl_match |= (v & (0x01 | 0x02)) << 6;
}
-static uae_u16 CLXDAT (void)
+static uae_u16 CLXDAT(void)
{
- uae_u16 v = clxdat | 0x8000;
- clxdat = 0;
- return v;
+ uae_u16 v = clxdat | 0x8000;
+ clxdat = 0;
+ return v;
}
-static uae_u16 COLOR_READ (int num)
+#ifdef AGA
+
+//void dump_aga_custom(void)
+//{
+// int c1, c2, c3, c4;
+// uae_u32 rgb1, rgb2, rgb3, rgb4;
+//
+// for (c1 = 0; c1 < 64; c1++) {
+// c2 = c1 + 64;
+// c3 = c2 + 64;
+// c4 = c3 + 64;
+// rgb1 = current_colors.color_regs_aga[c1];
+// rgb2 = current_colors.color_regs_aga[c2];
+// rgb3 = current_colors.color_regs_aga[c3];
+// rgb4 = current_colors.color_regs_aga[c4];
+// write_log(_T("%3d %08X %3d %08X %3d %08X %3d %08X\n"),
+// c1, rgb1, c2, rgb2, c3, rgb3, c4, rgb4);
+// }
+//}
+
+static uae_u16 COLOR_READ(int num)
{
int cr, cg, cb, colreg;
uae_u16 cval;
-
- if (!(aga_mode) || !(bplcon2 & 0x0100))
+
+ if (!(currprefs.chipset_mask & CSMASK_AGA) || !(bplcon2 & 0x0100))
return 0xffff;
-
+
colreg = ((bplcon3 >> 13) & 7) * 32 + num;
cr = (current_colors.color_regs_aga[colreg] >> 16) & 0xFF;
cg = (current_colors.color_regs_aga[colreg] >> 8) & 0xFF;
cb = current_colors.color_regs_aga[colreg] & 0xFF;
if (bplcon3 & 0x200) {
cval = ((cr & 15) << 8) | ((cg & 15) << 4) | ((cb & 15) << 0);
- } else {
- cval = ((cr >> 4) << 8) | ((cg >> 4) << 4) | ((cb >> 4) << 0);
}
- return cval;
+ else {
+ cval = ((cr >> 4) << 8) | ((cg >> 4) << 4) | ((cb >> 4) << 0);
+ if (color_regs_genlock[num])
+ cval |= 0x8000;
+ }
+ return cval;
+}
+#endif
+
+static void checkautoscalecol0(void)
+{
+ if (!copper_access)
+ return;
+ if (vpos < 20)
+ return;
+ if (isbrdblank(-1, bplcon0, bplcon3))
+ return;
+ // autoscale if copper changes COLOR00 on top or bottom of screen
+ if (vpos >= minfirstline) {
+ int vpos2 = autoscale_bordercolors ? minfirstline : vpos;
+ if (first_planes_vpos == 0)
+ first_planes_vpos = vpos2 - 2;
+ if (plffirstline_total == current_maxvpos())
+ plffirstline_total = vpos2 - 2;
+ if (vpos2 > last_planes_vpos || vpos2 > plflastline_total)
+ plflastline_total = last_planes_vpos = vpos2 + 3;
+ autoscale_bordercolors = 0;
+ }
+ else {
+ autoscale_bordercolors++;
+ }
}
-static void COLOR_WRITE (int hpos, uae_u16 v, int num)
+static void COLOR_WRITE(int hpos, uae_u16 v, int num)
{
- if (aga_mode) {
- int r,g,b;
- int cr,cg,cb;
+ bool colzero = false;
+#ifdef AGA
+ if (currprefs.chipset_mask & CSMASK_AGA) {
+ int r, g, b;
+ int cr, cg, cb;
int colreg;
uae_u32 cval;
-
+
/* writing is disabled when RDRAM=1 */
if (bplcon2 & 0x0100)
return;
-
+
colreg = ((bplcon3 >> 13) & 7) * 32 + num;
r = (v & 0xF00) >> 8;
g = (v & 0xF0) >> 4;
@@ -4465,40 +5805,56 @@ static void COLOR_WRITE (int hpos, uae_u16 v, int num)
cr = (current_colors.color_regs_aga[colreg] >> 16) & 0xFF;
cg = (current_colors.color_regs_aga[colreg] >> 8) & 0xFF;
cb = current_colors.color_regs_aga[colreg] & 0xFF;
-
+
if (bplcon3 & 0x200) {
cr &= 0xF0; cr |= r;
cg &= 0xF0; cg |= g;
cb &= 0xF0; cb |= b;
- } else {
+ }
+ else {
cr = r + (r << 4);
cg = g + (g << 4);
cb = b + (b << 4);
+ color_regs_genlock[colreg] = v >> 15;
}
- cval = (cr << 16) | (cg << 8) | cb;
+ cval = (cr << 16) | (cg << 8) | cb | (color_regs_genlock[colreg] ? 0x80000000 : 0);
+ if (cval && colreg == 0)
+ colzero = true;
if (cval == current_colors.color_regs_aga[colreg])
return;
-
+
+ if (colreg == 0)
+ checkautoscalecol0();
+
/* Call this with the old table still intact. */
- record_color_change (hpos, colreg, cval);
+ record_color_change(hpos, colreg, cval);
remembered_color_entry = -1;
current_colors.color_regs_aga[colreg] = cval;
- current_colors.acolors[colreg] = CONVERT_RGB (cval);
+ current_colors.acolors[colreg] = getxcolor(cval);
- } else {
+ }
+ else {
+#endif
v &= 0x8fff;
if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE))
v &= 0xfff;
- if (current_colors.color_regs_ecs[num] == v)
+ color_regs_genlock[num] = v >> 15;
+ if (num && v == 0)
+ colzero = true;
+ if (current_colors.color_regs_ecs[num] == v)
return;
+ if (num == 0)
+ checkautoscalecol0();
/* Call this with the old table still intact. */
- record_color_change (hpos, num, v);
+ record_color_change(hpos, num, v);
remembered_color_entry = -1;
- current_colors.color_regs_ecs[num] = v;
- current_colors.acolors[num] = xcolors[v];
+ current_colors.color_regs_ecs[num] = v;
+ current_colors.acolors[num] = getxcolor(v);
+#ifdef AGA
}
+#endif
}
/* The copper code. The biggest nightmare in the whole emulator.
@@ -4540,499 +5896,396 @@ static void COLOR_WRITE (int hpos, uae_u16 v, int num)
/* Determine which cycles are available for the copper in a display
* with a agiven number of planes. */
-STATIC_INLINE int copper_cant_read (int hpos)
+STATIC_INLINE int copper_cant_read2(int hpos, int alloc)
{
- if (hpos + 1 >= maxhpos) // first refresh slot
- return 1;
- if ((hpos == maxhpos - 3) && (maxhpos & 1)) {
+ if (hpos + 1 >= maxhpos) // first refresh slot
+ return 1;
+ if ((hpos == maxhpos - 3) && (maxhpos & 1) && alloc >= 0) {
+ if (alloc) {
+ alloc_cycle(hpos, CYCLE_COPPER);
+ }
return -1;
}
- return is_bitplane_dma (hpos);
+ return is_bitplane_dma_inline(hpos);
}
-
-/* The future, Conan?
- We try to look ahead in the copper list to avoid doing continuous calls
- to updat_copper (which is what happens when SPCFLAG_COPPER is set). If
- we find that the same effect can be achieved by setting a delayed event
- and then doing multiple copper insns in one batch, we can get a massive
- speedup.
-
- We don't try to be precise here. All copper reads take exactly 2 cycles,
- the effect of bitplane contention is ignored. Trying to get it exactly
- right would be much more complex and as such carry a huge risk of getting
- it subtly wrong; and it would also be more expensive - we want this code
- to be fast. */
-
-static void predict_copper (void)
+static int copper_cant_read(int hpos, int alloc)
{
- uaecptr ip = cop_state.ip;
- unsigned int c_hpos = cop_state.hpos;
- enum copper_states state = cop_state.state;
- unsigned int w1, w2, cycle_count;
- unsigned int modified = REGTYPE_FORCE;
-
- switch (state) {
- case COP_read1:
- break;
-
- case COP_read2:
- w1 = cop_state.i1;
- w2 = chipmem_wget_indirect (ip);
- if (w1 & 1) {
- if (w2 & 1)
- return; // SKIP
- state = COP_wait; // WAIT
- c_hpos += 4;
- } else { // MOVE
- modified |= regtypes[w1 & 0x1FE];
- state = COP_read1;
- c_hpos += 2;
- }
- ip += 2;
- break;
-
- case COP_strobe_delay2:
- case COP_strobe_delay2x:
- case COP_start_delay:
- c_hpos += 2;
- state = COP_read1;
- break;
-
- case COP_strobe_extra:
- c_hpos += 6;
- state = COP_read1;
- break;
-
- case COP_strobe_delay1:
- case COP_strobe_delay1x:
- c_hpos += 4;
- state = COP_read1;
- break;
-
- case COP_stop:
- case COP_waitforever:
- case COP_bltwait:
- case COP_skip_in2:
- case COP_skip1:
- return;
-
- case COP_wait_in2:
- c_hpos += 2;
- case COP_wait1:
- w1 = cop_state.i1;
- w2 = cop_state.i2;
- state = COP_wait;
- break;
-
- case COP_wait:
- w1 = cop_state.i1;
- w2 = cop_state.i2;
- break;
-
- default:
- return;
- }
- /* Only needed for COP_wait, but let's shut up the compiler. */
- cop_state.first_sync = c_hpos;
-
- while (c_hpos + 1 < maxhpos) {
- if (state == COP_read1) {
- w1 = chipmem_wget_indirect (ip);
- if (w1 & 1) {
- w2 = chipmem_wget_indirect (ip + 2);
- if (w2 & 1)
- break; // SKIP
- state = COP_wait; // WAIT
- c_hpos += 6;
- } else { // MOVE
- modified |= regtypes[w1 & 0x1FE];
- c_hpos += 4;
- }
- ip += 4;
- } else { // state is COP_wait
- if ((w2 & 0xFE) != 0xFE)
- break;
- else {
- unsigned int vcmp = (w1 & (w2 | 0x8000)) >> 8;
- unsigned int hcmp = (w1 & 0xFE);
-
- unsigned int vp = vpos & (((w2 >> 8) & 0x7F) | 0x80);
- if (vp < vcmp) {
- /* Whee. We can wait until the end of the line! */
- c_hpos = maxhpos;
- } else if (vp > vcmp || hcmp <= c_hpos) {
- state = COP_read1;
- /* minimum wakeup time */
- c_hpos += 2;
- } else {
- state = COP_read1;
- c_hpos = hcmp + 2;
- }
- /* If this is the current instruction, remember that we don't
- need to sync CPU and copper anytime soon. */
- if (cop_state.ip == ip) {
- cop_state.first_sync = c_hpos;
- }
- }
- }
- }
-
- cycle_count = c_hpos - cop_state.hpos;
- if (cycle_count >= 8) {
- cop_state.regtypes_modified = modified;
- unset_special (SPCFLAG_COPPER);
- eventtab[ev_copper].active = 1;
- eventtab[ev_copper].evtime = get_cycles () + cycle_count * CYCLE_UNIT;
- events_schedule ();
- }
+ int cant = copper_cant_read2(hpos, alloc);
+#ifdef DEBUGGER
+ if (cant && debug_dma)
+ record_dma_event(DMA_EVENT_COPPERWANTED, hpos, vpos);
+#endif
+ return cant;
}
-STATIC_INLINE int custom_wput_copper (int hpos, uaecptr addr, uae_u32 value, int noget)
+static int custom_wput_copper(int hpos, uaecptr addr, uae_u32 value, int noget)
{
int v;
+ hpos += hack_delay_shift;
+ //value = debug_wputpeekdma_chipset(0xdff000 + addr, value, MW_MASK_COPPER, 0x08c);
copper_access = 1;
- v = custom_wput_1 (hpos, addr, value, noget);
+ v = custom_wput_1(hpos, addr, value, noget);
copper_access = 0;
return v;
}
+//static void dump_copper(const TCHAR *error, int until_hpos)
+//{
+// write_log(_T("\n"));
+// write_log(_T("%s: vpos=%d until_hpos=%d vp=%d\n"),
+// error, vpos, until_hpos, vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80));
+// write_log(_T("cvcmp=%d chcmp=%d chpos=%d cvpos=%d ci1=%04X ci2=%04X\n"),
+// cop_state.vcmp, cop_state.hcmp, cop_state.hpos, cop_state.vpos, cop_state.saved_i1, cop_state.saved_i2);
+// write_log(_T("cstate=%d ip=%x SPCFLAGS=%x iscline=%d\n"),
+// cop_state.state, cop_state.ip, regs.spcflags, copper_enabled_thisline);
+// write_log(_T("\n"));
+//}
+
// "emulate" chip internal delays, not the right place but fast and 99.9% programs
// use only copper to write BPLCON1 etc.. (exception is HulkaMania/TSP..)
// this table should be filled with zeros and done somewhere else..
static int customdelay[]= {
- 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* 32 0x00 - 0x3e */
+ 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* 32 0x00 - 0x3e */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x40 - 0x5e */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x60 - 0x7e */
0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0, /* 0x80 - 0x9e */
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 32 0xa0 - 0xde */
- /* BPLxPTH/BPLxPTL */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 16 */
- /* BPLCON0-3,BPLMOD1-2 */
+ /* BPLxPTH/BPLxPTL */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 16 */
+ /* BPLCON0-3,BPLMOD1-2 */
0,0,0,0,0,0,0,0, /* 8 */
/* BPLxDAT */
0,0,0,0,0,0,0,0, /* 8 */
- /* SPRxPTH/SPRxPTL */
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 16 */
- /* SPRxPOS/SPRxCTL/SPRxDATA/SPRxDATB */
+ /* SPRxPTH/SPRxPTL */
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 16 */
+ /* SPRxPOS/SPRxCTL/SPRxDATA/SPRxDATB */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- /* COLORxx */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- /* RESERVED */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+ /* COLORxx */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ /* RESERVED */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
/*
- CPU write COPJMP wakeup sequence when copper is waiting:
- - Idle cycle (can be used by other DMA channel)
- - Read word from current copper pointer (next word after wait instruction) to 1FE
- This cycle can conflict with blitter DMA.
- Normal copper cycles resume
- - Write word from new copper pointer to 8C
+CPU write COPJMP wakeup sequence when copper is waiting:
+- Idle cycle (can be used by other DMA channel)
+- Read word from current copper pointer (next word after wait instruction) to 1FE
+This cycle can conflict with blitter DMA.
+Normal copper cycles resume
+- Write word from new copper pointer to 8C
*/
-static void update_copper (int until_hpos)
+static void update_copper(int until_hpos)
{
- int vp = vpos & (((cop_state.i2 >> 8) & 0x7F) | 0x80);
+ int vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80);
int c_hpos = cop_state.hpos;
-
- if (nocustom()) {
- eventtab[ev_copper].active = 0;
- return;
- }
- if(currprefs.fast_copper) {
- if (eventtab[ev_copper].active) {
- eventtab[ev_copper].active = 0;
- return;
- }
- }
-
- if (cop_state.state == COP_wait && vp < cop_state.vcmp) {
- eventtab[ev_copper].active = 0;
- copper_enabled_thisline = 0;
- cop_state.state = COP_stop;
- unset_special(SPCFLAG_COPPER);
+ if (nocustom())
+ return;
+
+ if (cop_state.state == COP_wait && vp < cop_state.vcmp) {
+ //dump_copper(_T("error2"), until_hpos);
+ copper_enabled_thisline = 0;
+ cop_state.state = COP_stop;
+ unset_special(SPCFLAG_COPPER);
return;
}
-
+
if (until_hpos <= last_copper_hpos)
return;
-
+
if (until_hpos > (maxhpos & ~1))
until_hpos = maxhpos & ~1;
-
+
for (;;) {
int old_hpos = c_hpos;
int hp;
-
+
if (c_hpos >= until_hpos)
break;
-
- /* So we know about the fetch state. */
- decide_line (c_hpos);
- // bitplane only, don't want blitter to steal our cycles.
- decide_fetch (c_hpos);
- if (cop_state.movedelay) { // cop_state.movedelay is 0 or 1
- cop_state.movedelay = 0;
- custom_wput_copper (c_hpos, cop_state.moveaddr, cop_state.movedata, 0);
- if (! copper_enabled_thisline)
- goto out;
- }
+ /* So we know about the fetch state. */
+ decide_line(c_hpos);
+ // bitplane only, don't want blitter to steal our cycles.
+ decide_fetch(c_hpos);
+
+ if (cop_state.movedelay > 0) {
+ cop_state.movedelay--;
+ if (cop_state.movedelay == 0) {
+ custom_wput_copper(c_hpos, cop_state.moveaddr, cop_state.movedata, 0);
+ }
+ }
if ((c_hpos == maxhpos - 3) && (maxhpos & 1))
c_hpos += 1;
else
- c_hpos += 2;
+ c_hpos += 2;
- switch (cop_state.state)
- {
- case COP_wait_in2:
- if (copper_cant_read (old_hpos))
- continue;
- cop_state.state = COP_wait1;
- break;
- case COP_skip_in2:
- if (copper_cant_read (old_hpos))
- continue;
- cop_state.state = COP_skip1;
- break;
+ switch (cop_state.state)
+ {
+ case COP_wait_in2:
+ if (copper_cant_read(old_hpos, 0))
+ continue;
+ cop_state.state = COP_wait1;
+ break;
+ case COP_skip_in2:
+ if (copper_cant_read(old_hpos, 0))
+ continue;
+ cop_state.state = COP_skip1;
+ break;
- case COP_strobe_extra:
- // Wait 1 copper cycle doing nothing
- cop_state.state = COP_strobe_delay1;
- break;
- case COP_strobe_delay1:
- // First cycle after COPJMP is just like normal first read cycle
- // Cycle is used and needs to be free.
- if (copper_cant_read (old_hpos))
- continue;
- if (old_hpos == maxhpos - 2) {
- // if COP_strobe_delay2 would cross scanlines (positioned immediately
- // after first strobe/refresh slot) it will disappear!
- cop_state.state = COP_read1;
- if (cop_state.strobe == 1)
- cop_state.ip = cop1lc;
- else
- cop_state.ip = cop2lc;
- cop_state.strobe = 0;
- } else {
- cop_state.state = COP_strobe_delay2;
- cop_state.ip += 2;
- }
- break;
- case COP_strobe_delay2:
- // Second cycle after COPJMP. This is the strange one.
- // This cycle does not need to be free
- // But it still gets allocated by copper if it is free = CPU and blitter can't use it.
- cop_state.state = COP_read1;
- // Next cycle finally reads from new pointer
- if (cop_state.strobe == 1)
- cop_state.ip = cop1lc;
- else
- cop_state.ip = cop2lc;
- cop_state.strobe = 0;
- break;
+ case COP_strobe_extra:
+ // Wait 1 copper cycle doing nothing
+ cop_state.state = COP_strobe_delay1;
+ break;
+ case COP_strobe_delay1:
+ // First cycle after COPJMP is just like normal first read cycle
+ // Cycle is used and needs to be free.
+ if (copper_cant_read(old_hpos, 1))
+ continue;
+#ifdef CPUEMU_13
+ alloc_cycle(old_hpos, CYCLE_COPPER);
+#endif
+ if (old_hpos == maxhpos - 2) {
+ // if COP_strobe_delay2 would cross scanlines (positioned immediately
+ // after first strobe/refresh slot) it will disappear!
+ cop_state.state = COP_read1;
+ if (cop_state.strobe == 1)
+ cop_state.ip = cop1lc;
+ else
+ cop_state.ip = cop2lc;
+ cop_state.strobe = 0;
+ }
+ else {
+ cop_state.state = COP_strobe_delay2;
+ cop_state.ip += 2;
+ }
+ break;
+ case COP_strobe_delay2:
+ // Second cycle after COPJMP. This is the strange one.
+ // This cycle does not need to be free
+ // But it still gets allocated by copper if it is free = CPU and blitter can't use it.
+#ifdef CPUEMU_13
+ if (!copper_cant_read(old_hpos, 0)) {
+ alloc_cycle(old_hpos, CYCLE_COPPER);
+#ifdef DEBUGGER
+ if (debug_dma)
+ record_dma(0x1fe, chipmem_wget_indirect(cop_state.ip), cop_state.ip, old_hpos, vpos, DMARECORD_COPPER);
+ if (memwatch_enabled)
+ debug_wgetpeekdma_chipram(cop_state.ip, chipmem_wget_indirect(cop_state.ip), MW_MASK_COPPER, 0x1fe);
+#endif
+ }
+#endif
+ cop_state.state = COP_read1;
+ // Next cycle finally reads from new pointer
+ if (cop_state.strobe == 1)
+ cop_state.ip = cop1lc;
+ else
+ cop_state.ip = cop2lc;
+ cop_state.strobe = 0;
+ break;
- case COP_strobe_delay1x:
+ case COP_strobe_delay1x:
// First cycle after COPJMP and Copper was waiting.
- cop_state.state = COP_strobe_delay2x;
- break;
- case COP_strobe_delay2x:
+ cop_state.state = COP_strobe_delay2x;
+ break;
+ case COP_strobe_delay2x:
// Second cycle fetches following word and tosses it away.
// Cycle can be free and copper won't allocate it.
// If Blitter uses this cycle = Copper's PC gets copied to blitter DMA pointer..
- if (copper_cant_read (old_hpos))
- continue;
- cop_state.state = COP_read1;
- // Next cycle finally reads from new pointer
- if (cop_state.strobe == 1)
- cop_state.ip = cop1lc;
- else
- cop_state.ip = cop2lc;
- cop_state.strobe = 0;
- break;
+ if (copper_cant_read(old_hpos, 1))
+ continue;
+#ifdef CPUEMU_13
+ cycle_line[old_hpos] |= CYCLE_COPPER_SPECIAL;
+#endif
+ cop_state.state = COP_read1;
+ // Next cycle finally reads from new pointer
+ if (cop_state.strobe == 1)
+ cop_state.ip = cop1lc;
+ else
+ cop_state.ip = cop2lc;
+ cop_state.strobe = 0;
+ break;
- case COP_start_delay:
+ case COP_start_delay:
// cycle after vblank strobe fetches word from old pointer first
- if (copper_cant_read (old_hpos))
- continue;
- cop_state.state = COP_read1;
- cop_state.i1 = last_custom_value1 = chipmem_wget_indirect (cop_state.ip);
- cop_state.ip = cop1lc;
- break;
+ if (copper_cant_read(old_hpos, 1))
+ continue;
+ cop_state.state = COP_read1;
+ cop_state.i1 = last_custom_value1 = chipmem_wget_indirect(cop_state.ip);
+#ifdef CPUEMU_13
+ alloc_cycle(old_hpos, CYCLE_COPPER);
+#endif
+ cop_state.ip = cop1lc;
+ break;
- case COP_read1:
- if (copper_cant_read (old_hpos))
- continue;
- cop_state.i1 = last_custom_value1 = chipmem_wget_indirect (cop_state.ip);
- cop_state.ip += 2;
- cop_state.state = COP_read2;
- break;
-
- case COP_read2:
- if (copper_cant_read (old_hpos))
- continue;
- cop_state.i2 = last_custom_value1 = chipmem_wget_indirect (cop_state.ip);
- cop_state.ip += 2;
-
- if (cop_state.i1 & 1) { // WAIT or SKIP
- cop_state.ignore_next = 0;
- if (cop_state.i2 & 1)
- cop_state.state = COP_skip_in2;
- else
- cop_state.state = COP_wait_in2;
- } else { // MOVE
- unsigned int reg = cop_state.i1 & 0x1FE;
- uae_u16 data = cop_state.i2;
- cop_state.state = COP_read1;
- test_copper_dangerous (reg);
- if (! copper_enabled_thisline)
- goto out; // was "dangerous" register -> copper stopped
+ case COP_read1:
+ if (copper_cant_read(old_hpos, 1))
+ continue;
+ cop_state.i1 = last_custom_value1 = chipmem_wget_indirect(cop_state.ip);
+#ifdef CPUEMU_13
+ alloc_cycle(old_hpos, CYCLE_COPPER);
+#endif
+ cop_state.ip += 2;
+ cop_state.state = COP_read2;
+ break;
- if (cop_state.ignore_next) {
- reg = 0x1fe;
- cop_state.ignore_next = 0;
- }
+ case COP_read2:
+ if (copper_cant_read(old_hpos, 1))
+ continue;
+ cop_state.i2 = last_custom_value1 = chipmem_wget_indirect(cop_state.ip);
+#ifdef CPUEMU_13
+ alloc_cycle(old_hpos, CYCLE_COPPER);
+#endif
+ cop_state.ip += 2;
+ cop_state.saved_i1 = cop_state.i1;
+ cop_state.saved_i2 = cop_state.i2;
+ cop_state.saved_ip = cop_state.ip;
- if (reg == 0x88) {
- cop_state.strobe = 1;
- cop_state.state = COP_strobe_delay1;
- } else if (reg == 0x8a) {
- cop_state.strobe = 2;
- cop_state.state = COP_strobe_delay1;
- } else {
- // FIX: all copper writes happen 1 cycle later than CPU writes
- if (customdelay[reg / 2]) {
- cop_state.moveaddr = reg;
- cop_state.movedata = data;
- cop_state.movedelay = 1;
- } else {
- custom_wput_copper (old_hpos, reg, data, 0);
- }
- }
- }
- check_copper_stop();
- break;
-
- case COP_wait1:
- cop_state.state = COP_wait;
-
- cop_state.vcmp = (cop_state.i1 & (cop_state.i2 | 0x8000)) >> 8;
- cop_state.hcmp = (cop_state.i1 & cop_state.i2 & 0xFE);
-
- vp = vpos & (((cop_state.i2 >> 8) & 0x7F) | 0x80);
-
- if (cop_state.i1 == 0xFFFF && cop_state.i2 == 0xFFFE) {
- cop_state.state = COP_waitforever;
+ if (cop_state.i1 & 1) { // WAIT or SKIP
+ cop_state.ignore_next = 0;
+ if (cop_state.i2 & 1)
+ cop_state.state = COP_skip_in2;
+ else
+ cop_state.state = COP_wait_in2;
+
+ }
+ else { // MOVE
+
+ unsigned int reg = cop_state.i1 & 0x1FE;
+ uae_u16 data = cop_state.i2;
+ cop_state.state = COP_read1;
+
+ test_copper_dangerous(reg);
+ if (!copper_enabled_thisline)
+ goto out; // was "dangerous" register -> copper stopped
+
+ if (cop_state.ignore_next)
+ reg = 0x1fe;
+
+ if (reg == 0x88) {
+ cop_state.strobe = 1;
+ cop_state.state = COP_strobe_delay1;
+ }
+ else if (reg == 0x8a) {
+ cop_state.strobe = 2;
+ cop_state.state = COP_strobe_delay1;
+ }
+ else {
+
+ // FIX: all copper writes happen 1 cycle later than CPU writes
+ if (customdelay[reg / 2]) {
+ cop_state.moveaddr = reg;
+ cop_state.movedata = data;
+ cop_state.movedelay = customdelay[cop_state.moveaddr / 2];
+ }
+ else {
+ custom_wput_copper(old_hpos, reg, data, 0);
+ }
+ }
+ cop_state.ignore_next = 0;
+ }
+ check_copper_stop();
+ break;
+
+ case COP_wait1:
+ cop_state.state = COP_wait;
+
+ cop_state.vcmp = (cop_state.saved_i1 & (cop_state.saved_i2 | 0x8000)) >> 8;
+ cop_state.hcmp = (cop_state.saved_i1 & cop_state.saved_i2 & 0xFE);
+
+ vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80);
+
+ if (cop_state.saved_i1 == 0xFFFF && cop_state.saved_i2 == 0xFFFE) {
+ cop_state.state = COP_waitforever;
+ copper_enabled_thisline = 0;
+ unset_special(SPCFLAG_COPPER);
+ goto out;
+ }
+ if (vp < cop_state.vcmp) {
+ copper_enabled_thisline = 0;
+ unset_special(SPCFLAG_COPPER);
+ goto out;
+ }
+
+ /* fall through */
+ case COP_wait:
+ {
+ int ch_comp = c_hpos;
+ if (ch_comp & 1)
+ ch_comp = 0;
+
+ /* First handle possible blitter wait
+ * Must be before following free cycle check
+ */
+ if ((cop_state.saved_i2 & 0x8000) == 0) {
+ decide_blitter(old_hpos);
+ if (bltstate != BLT_done) {
+ /* We need to wait for the blitter. */
+ cop_state.state = COP_bltwait;
copper_enabled_thisline = 0;
- unset_special (SPCFLAG_COPPER);
+ unset_special(SPCFLAG_COPPER);
goto out;
}
- if (vp < cop_state.vcmp) {
- copper_enabled_thisline = 0;
- unset_special (SPCFLAG_COPPER);
- goto out;
- }
-
- /* fall through */
- case COP_wait:
- {
- int ch_comp = c_hpos;
- if (ch_comp & 1)
- ch_comp = 0;
+ }
- /* First handle possible blitter wait
- * Must be before following free cycle check
- */
- if ((cop_state.i2 & 0x8000) == 0) {
- if (bltstate != BLT_done) {
- /* We need to wait for the blitter. */
- cop_state.state = COP_bltwait;
- copper_enabled_thisline = 0;
- unset_special (SPCFLAG_COPPER);
- goto out;
- }
- }
-
- if (copper_cant_read (old_hpos))
- continue;
-
- hp = ch_comp & (cop_state.i2 & 0xFE);
- if (vp == cop_state.vcmp && hp < cop_state.hcmp) {
- /* Position not reached yet. */
- if(currprefs.fast_copper) {
- if ((cop_state.i2 & 0xFE) == 0xFE) {
- int wait_finish = cop_state.hcmp - 2;
- /* This will leave c_hpos untouched if it's equal to wait_finish. */
- if (wait_finish < c_hpos)
- return;
- else if (wait_finish <= until_hpos) {
- c_hpos = wait_finish;
- } else
- c_hpos = until_hpos;
- }
- }
- break;
- }
-
- cop_state.state = COP_read1;
- }
+ if (copper_cant_read(old_hpos, 0))
+ continue;
+
+ hp = ch_comp & (cop_state.saved_i2 & 0xFE);
+ if (vp == cop_state.vcmp && hp < cop_state.hcmp)
break;
-
- case COP_skip1:
- {
- unsigned int vcmp, hcmp, vp1, hp1;
- if (c_hpos >= (maxhpos & ~1) || (c_hpos & 1))
- break;
+ cop_state.state = COP_read1;
+ }
+ break;
- if (copper_cant_read (old_hpos))
- continue;
+ case COP_skip1:
+ {
+ unsigned int vcmp, hcmp, vp1, hp1;
- vcmp = (cop_state.i1 & (cop_state.i2 | 0x8000)) >> 8;
- hcmp = (cop_state.i1 & cop_state.i2 & 0xFE);
- vp1 = vpos & (((cop_state.i2 >> 8) & 0x7F) | 0x80);
- hp1 = c_hpos & (cop_state.i2 & 0xFE);
-
- if ((vp1 > vcmp || (vp1 == vcmp && hp1 >= hcmp)) && ((cop_state.i2 & 0x8000) != 0 || bltstate == BLT_done))
- cop_state.ignore_next = 1;
-
- cop_state.state = COP_read1;
- break;
- }
- default:
+ if (c_hpos >= (maxhpos & ~1) || (c_hpos & 1))
break;
+
+ if (copper_cant_read(old_hpos, 0))
+ continue;
+
+ vcmp = (cop_state.saved_i1 & (cop_state.saved_i2 | 0x8000)) >> 8;
+ hcmp = (cop_state.saved_i1 & cop_state.saved_i2 & 0xFE);
+ vp1 = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80);
+ hp1 = c_hpos & (cop_state.saved_i2 & 0xFE);
+
+ if ((vp1 > vcmp || (vp1 == vcmp && hp1 >= hcmp)) && ((cop_state.saved_i2 & 0x8000) != 0 || bltstate == BLT_done))
+ cop_state.ignore_next = 1;
+
+ cop_state.state = COP_read1;
+
+ break;
+ }
+ default:
+ break;
}
}
-
+
out:
cop_state.hpos = c_hpos;
last_copper_hpos = until_hpos;
-
- if(currprefs.fast_copper) {
- /* The test against maxhpos also prevents us from calling predict_copper
- when we are being called from hsync_handler, which would not only be
- stupid, but actively harmful. */
- if ((regs.spcflags & SPCFLAG_COPPER) && (c_hpos + 8 < maxhpos))
- predict_copper ();
- }
}
-static void compute_spcflag_copper (int hpos)
+static void compute_spcflag_copper(int hpos)
{
int wasenabled = copper_enabled_thisline;
copper_enabled_thisline = 0;
- unset_special (SPCFLAG_COPPER);
- if (!dmaen (DMA_COPPER) || cop_state.state == COP_stop || cop_state.state == COP_waitforever || cop_state.state == COP_bltwait || nocustom())
+ unset_special(SPCFLAG_COPPER);
+ if (!dmaen(DMA_COPPER) || cop_state.state == COP_stop || cop_state.state == COP_waitforever || cop_state.state == COP_bltwait || nocustom())
return;
-
+
if (cop_state.state == COP_wait) {
- int vp = vpos & (((cop_state.i2 >> 8) & 0x7F) | 0x80);
-
+ int vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80);
+
if (vp < cop_state.vcmp)
return;
}
@@ -5040,8 +6293,8 @@ static void compute_spcflag_copper (int hpos)
// (write to DMACON for example) hpos+1 for long lines
if (!wasenabled && cop_state.hpos < hpos && hpos < maxhpos) {
hpos = (hpos + 2) & ~1;
- if (hpos > (maxhpos & ~1))
- hpos = maxhpos & ~1;
+ if (hpos >(maxhpos_short & ~1))
+ hpos = maxhpos_short & ~1;
cop_state.hpos = hpos;
}
@@ -5052,167 +6305,145 @@ static void compute_spcflag_copper (int hpos)
cop_state.state = COP_strobe_delay1;
copper_enabled_thisline = 1;
-
- if(currprefs.fast_copper) {
- predict_copper ();
- if (! eventtab[ev_copper].active)
- set_special (SPCFLAG_COPPER);
- }
- else
- set_special (SPCFLAG_COPPER);
+ set_special(SPCFLAG_COPPER);
}
-static void copper_handler (void)
-{
- /* This will take effect immediately, within the same cycle. */
- set_special (SPCFLAG_COPPER);
-
- if (! copper_enabled_thisline)
- return;
-
- eventtab[ev_copper].active = 0;
-}
-
-void blitter_done_notify (void)
+void blitter_done_notify(int hpos)
{
if (cop_state.state != COP_bltwait)
return;
-
- int vp_wait = vpos & (((cop_state.i2 >> 8) & 0x7F) | 0x80);
+
+ int vp_wait = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80);
int vp = vpos;
- int hpos = current_hpos() + 1;
+ hpos++;
hpos &= ~1;
if (hpos >= maxhpos) {
hpos -= maxhpos;
vp++;
}
cop_state.hpos = hpos;
+ cop_state.vpos = vp;
cop_state.state = COP_wait;
/* No need to check blitter state again */
- cop_state.i2 |= 0x8000;
+ cop_state.saved_i2 |= 0x8000;
if (dmaen(DMA_COPPER) && vp_wait >= cop_state.vcmp) {
copper_enabled_thisline = 1;
set_special(SPCFLAG_COPPER);
- } else {
- unset_special (SPCFLAG_COPPER);
+ }
+ else {
+ unset_special(SPCFLAG_COPPER);
}
}
-void do_copper (void)
+void do_copper(void)
{
- int hpos = current_hpos ();
- update_copper (hpos);
+ int hpos = current_hpos();
+ update_copper(hpos);
}
/* ADDR is the address that is going to be read/written; this access is
- the reason why we want to update the copper. This function is also
- used from hsync_handler to finish up the line; for this case, we check
- hpos against maxhpos. */
-STATIC_INLINE void sync_copper_with_cpu (int hpos, int do_schedule, unsigned int addr)
+the reason why we want to update the copper. This function is also
+used from hsync_handler to finish up the line; for this case, we check
+hpos against maxhpos. */
+STATIC_INLINE void sync_copper_with_cpu(int hpos, int do_schedule)
{
- if (eventtab[ev_copper].active) {
- if (hpos != maxhpos) {
- /* There might be reasons why we don't actually need to bother
- updating the copper. */
- if (hpos < cop_state.first_sync)
- return;
-
- if ((cop_state.regtypes_modified & regtypes[addr & 0x1FE]) == 0)
- return;
- }
-
- eventtab[ev_copper].active = 0;
- if (do_schedule)
- events_schedule ();
- set_special (SPCFLAG_COPPER);
- }
-
/* Need to let the copper advance to the current position. */
if (copper_enabled_thisline)
- update_copper (hpos);
+ update_copper(hpos);
}
-STATIC_INLINE uae_u16 sprite_fetch(struct sprite *s, uaecptr pt)
+static void cursorsprite(void)
{
- last_custom_value1 = chipmem_wget_indirect (pt);
- return last_custom_value1;
-}
-
-STATIC_INLINE void sprite_fetch_full(struct sprite *s, int hpos, uae_u16 *v0, uae_u32 *v1, uae_u32 *v2)
-{
- uae_u32 data321 = 0, data322 = 0;
- uae_u16 data16;
-
- if (sprite_width == 16) {
-
- data16 = sprite_fetch (s, s->pt);
- s->pt += 2;
-
- } else if (sprite_width == 64) {
-
- uaecptr pm = s->pt & ~7;
- uaecptr pm1, pm2;
- if (s->pt & 4) {
- pm1 = pm + 4;
- pm2 = pm + 4;
- } else {
- pm1 = pm;
- pm2 = pm + 4;
- }
- data321 = sprite_fetch(s, pm1) << 16;
- data321 |= chipmem_wget_indirect(pm1 + 2);
- data322 = chipmem_wget_indirect(pm2) << 16;
- data322 |= chipmem_wget_indirect(pm2 + 2);
- if (s->pt & 2) {
- data321 &= 0x0000ffff;
- data322 &= 0x0000ffff;
- data321 |= data321 << 16;
- data322 |= data322 << 16;
- }
- data16 = data321 >> 16;
- s->pt += 8;
-
- } else { // 32
-
- uaecptr pm = s->pt & ~3;
- data321 = sprite_fetch(s, pm) << 16;
- data321 |= chipmem_wget_indirect(pm + 2);
- if (s->pt & 2) {
- data321 &= 0x0000ffff;
- data321 |= data321 << 16;
- } else if (fetchmode_fmode & 8) {
- data321 &= 0xffff0000;
- data321 |= data321 >> 16;
- }
- data16 = data321 >> 16;
- s->pt += 4;
-
+ if (!dmaen(DMA_SPRITE) || first_planes_vpos == 0)
+ return;
+ sprite_0 = spr[0].pt;
+ sprite_0_height = spr[0].vstop - spr[0].vstart;
+ sprite_0_colors[0] = 0;
+ sprite_0_doubled = 0;
+ if (sprres == 0)
+ sprite_0_doubled = 1;
+ if (currprefs.chipset_mask & CSMASK_AGA) {
+ int sbasecol = ((bplcon4 >> 4) & 15) << 4;
+ sprite_0_colors[1] = current_colors.color_regs_aga[sbasecol + 1];
+ sprite_0_colors[2] = current_colors.color_regs_aga[sbasecol + 2];
+ sprite_0_colors[3] = current_colors.color_regs_aga[sbasecol + 3];
}
-
- *v0 = data16;
- *v1 = data321;
- *v2 = data322;
+ else {
+ sprite_0_colors[1] = xcolors[current_colors.color_regs_ecs[17]];
+ sprite_0_colors[2] = xcolors[current_colors.color_regs_ecs[18]];
+ sprite_0_colors[3] = xcolors[current_colors.color_regs_ecs[19]];
+ }
+ sprite_0_width = sprite_width;
+ //if (currprefs.input_tablet && (currprefs.input_mouse_untrap & MOUSEUNTRAP_MAGIC)) {
+ // if (currprefs.input_magic_mouse_cursor == MAGICMOUSE_HOST_ONLY && mousehack_alive())
+ // magic_sprite_mask &= ~1;
+ // else
+ // magic_sprite_mask |= 1;
+ //}
}
-STATIC_INLINE void do_sprites_1(int num, int cycle, int hpos)
+static uae_u16 sprite_fetch(struct sprite *s, int dma, int hpos, int cycle, int mode)
+{
+ uae_u16 data = last_custom_value1;
+ if (dma) {
+ if (cycle && currprefs.cpu_memory_cycle_exact)
+ s->ptxhpos = hpos;
+ data = last_custom_value1 = chipmem_wget_indirect(s->pt);
+ alloc_cycle(hpos, CYCLE_SPRITE);
+ }
+ s->pt += 2;
+ return data;
+}
+static uae_u16 sprite_fetch2(struct sprite *s, int hpos, int cycle, int mode)
+{
+ uae_u16 data = chipmem_wget_indirect(s->pt);
+ s->pt += 2;
+ return data;
+}
+
+static void do_sprites_1(int num, int cycle, int hpos)
{
struct sprite *s = &spr[num];
int posctl = 0;
uae_u16 data;
// fetch both sprite pairs even if DMA was switched off between sprites
- int isdma = dmaen (DMA_SPRITE) || ((num & 1) && spr[num & ~1].dmacycle);
- bool unaligned = (spr[num].pt & 2) != 0;
+ int isdma = dmaen(DMA_SPRITE) || ((num & 1) && spr[num & ~1].dmacycle);
+ if (cant_this_last_line())
+ return;
+
+ // see SPRxCTRL below
+ // if (isdma && vpos == sprite_vblank_endline)
+ // spr_arm (num, 0);
+
+#ifdef AGA
if (isdma && s->dblscan && (fmode & 0x8000) && (vpos & 1) != (s->vstart & 1) && s->dmastate) {
- spr_arm (num, 1);
+ spr_arm(num, 1);
return;
}
+#endif
+#if SPRITE_DEBUG >= 3 * 256
+ if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY && (SPRITE_DEBUG & (1 << num)))
+ write_log(_T("%d:%d:slot%d:%d\n"), vpos, hpos, num, cycle);
+#endif
if (vpos == s->vstart) {
+#if SPRITE_DEBUG > 0
+ if (!s->dmastate && vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY && (SPRITE_DEBUG & (1 << num)))
+ write_log(_T("%d:%d:SPR%d START\n"), vpos, hpos, num);
+#endif
s->dmastate = 1;
+ if (s->ptxvpos2 == vpos && hpos < s->ptxhpos2)
+ return;
+ if (num == 0 && cycle == 0)
+ cursorsprite();
}
if (vpos == s->vstop || vpos == sprite_vblank_endline) {
+#if SPRITE_DEBUG > 0
+ if (s->dmastate && vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY && (SPRITE_DEBUG & (1 << num)))
+ write_log(_T("%d:%d:SPR%d STOP\n"), vpos, hpos, num);
+#endif
s->dmastate = 0;
}
@@ -5226,151 +6457,248 @@ STATIC_INLINE void do_sprites_1(int num, int cycle, int hpos)
s->dmastate = 0;
posctl = 1;
if (dma) {
- uae_u32 data321, data322;
- sprite_fetch_full(s, hpos, &data, &data321, &data322);
+ data = sprite_fetch(s, dma, hpos, cycle, 0);
+ switch (sprite_width)
+ {
+ case 64:
+ sprite_fetch2(s, hpos, cycle, 0);
+ sprite_fetch2(s, hpos, cycle, 0);
+ case 32:
+ sprite_fetch2(s, hpos, cycle, 0);
+ break;
+ }
if (cycle == 0) {
if (start_before_dma && s->armed) {
maybe_decide_sprites(num, hpos);
}
- SPRxPOS_1 (data, num);
+ SPRxPOS_1(data, num, hpos);
s->dmacycle = 1;
- } else {
+ }
+ else {
// This is needed to disarm previous field's sprite.
// It can be seen on OCS Agnus + ECS Denise combination where
// this cycle is disabled due to weird DDFTSTR=$18 copper list
// which causes corrupted sprite to "wrap around" the display.
- SPRxCTL_1 (data, num);
+ SPRxCTL_1(data, num, hpos);
s->dmastate = 0;
- sprstartstop (s);
+ sprstartstop(s);
}
}
if (vpos == sprite_vblank_endline) {
// s->vstart == sprite_vblank_endline won't enable the sprite.
s->dmastate = 0;
}
+#if SPRITE_DEBUG >= 256
+ if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY && (SPRITE_DEBUG & (1 << num))) {
+ write_log(_T("%d:%d:dma:P=%06X "), vpos, hpos, s->pt);
+ }
+#endif
}
if (s->dmastate && !posctl && dma) {
- uae_u32 data321, data322;
- sprite_fetch_full(s, hpos, &data, &data321, &data322);
+ data = sprite_fetch(s, dma, hpos, cycle, 1);
+#if SPRITE_DEBUG >= 256
+ if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY && (SPRITE_DEBUG & (1 << num))) {
+ write_log(_T("%d:%d:dma:P=%06X "), vpos, hpos, s->pt);
+ }
+#endif
if (cycle == 0) {
// if xpos is earlier than this cycle, decide it first.
if (start_before_dma) {
maybe_decide_sprites(num, hpos);
}
- SPRxDATA_1 (data, num);
+ SPRxDATA_1(data, num, hpos);
s->dmacycle = 1;
- } else {
+ }
+ else {
// This is needed if xpos is between DATA and DATB fetches
// Test does not need to be accurate, only purpose is to
// not lose performance when sprites have "normal" positioning.
if (start_before_dma) {
maybe_decide_sprites(num, hpos);
}
- SPRxDATB_1 (data, num);
+ SPRxDATB_1(data, num, hpos);
}
+#ifdef AGA
switch (sprite_width)
{
case 64:
- if (cycle == 0) {
- sprdata[num][1] = data321;
- sprdata[num][2] = data322 >> 16;
- sprdata[num][3] = data322;
- } else {
- sprdatb[num][1] = data321;
- sprdatb[num][2] = data322 >> 16;
- sprdatb[num][3] = data322;
+ {
+ uae_u16 data32 = sprite_fetch2(s, hpos, cycle, 1);
+ uae_u16 data641 = sprite_fetch2(s, hpos, cycle, 1);
+ uae_u16 data642 = sprite_fetch2(s, hpos, cycle, 1);
+ if (dma) {
+ if (cycle == 0) {
+ sprdata[num][3] = data642;
+ sprdata[num][2] = data641;
+ sprdata[num][1] = data32;
+ }
+ else {
+ sprdatb[num][3] = data642;
+ sprdatb[num][2] = data641;
+ sprdatb[num][1] = data32;
+ }
}
- break;
+ }
+ break;
case 32:
- if (cycle == 0)
- sprdata[num][1] = data321;
- else
- sprdatb[num][1] = data321;
+ {
+ uae_u16 data32 = sprite_fetch2(s, hpos, cycle, 1);
+ if (dma) {
+ if (cycle == 0)
+ sprdata[num][1] = data32;
+ else
+ sprdatb[num][1] = data32;
+ }
+ }
+ break;
+ }
+#endif
+ }
+}
+
+static void do_sprites(int hpos)
+{
+ int maxspr, minspr;
+ int i;
+
+ if (vpos < sprite_vblank_endline)
+ return;
+
+ if (doflickerfix() && interlace_seen && (next_lineno & 1))
+ return;
+
+ maxspr = hpos;
+ minspr = last_sprite_hpos + 1;
+
+ if (minspr >= maxspr || last_sprite_hpos == hpos)
+ return;
+
+ if (maxspr >= SPR0_HPOS + MAX_SPRITES * 4)
+ maxspr = SPR0_HPOS + MAX_SPRITES * 4 - 1;
+ if (minspr < SPR0_HPOS)
+ minspr = SPR0_HPOS;
+
+ if (minspr == maxspr)
+ return;
+
+ for (i = minspr; i <= maxspr; i++) {
+ int cycle = -1;
+ int num = (i - SPR0_HPOS) / 4;
+ switch ((i - SPR0_HPOS) & 3)
+ {
+ case 0:
+ cycle = 0;
+ spr[num].dmacycle = 0;
+ break;
+ case 2:
+ cycle = 1;
break;
}
+ if (cycle >= 0) {
+ spr[num].ptxhpos = MAXHPOS;
+ do_sprites_1(num, cycle, i);
+ }
}
+
+ last_sprite_hpos = hpos;
}
-static void do_sprites (int hpos)
+static void init_sprites(void)
{
- int maxspr, minspr;
- int i;
-
- if (vpos < sprite_vblank_endline)
- return;
-
- maxspr = hpos;
- minspr = last_sprite_hpos + 1;
-
- if (minspr >= maxspr || last_sprite_hpos == hpos)
- return;
-
- if (maxspr >= SPR0_HPOS + MAX_SPRITES * 4)
- maxspr = SPR0_HPOS + MAX_SPRITES * 4 - 1;
- if (minspr < SPR0_HPOS)
- minspr = SPR0_HPOS;
-
- if (minspr == maxspr)
- return;
-
- for (i = minspr; i <= maxspr; i++) {
- int cycle = -1;
- int num = (i - SPR0_HPOS) / 4;
- switch ((i - SPR0_HPOS) & 3)
- {
- case 0:
- cycle = 0;
- spr[num].dmacycle = 0;
- break;
- case 2:
- cycle = 1;
- break;
- }
- if (cycle >= 0) {
- do_sprites_1 (num, cycle, i);
- }
- }
-
- last_sprite_hpos = hpos;
+ memset(sprpos, 0, sizeof sprpos);
+ memset(sprctl, 0, sizeof sprctl);
}
-static void init_sprites (void)
+static void init_hardware_frame(void)
{
- memset (sprpos, 0, sizeof sprpos);
- memset (sprctl, 0, sizeof sprctl);
+ int i;
+
+ first_bpl_vpos = -1;
+ next_lineno = 0;
+ prev_lineno = -1;
+ nextline_how = nln_normal;
+ diwstate = DIW_waiting_start;
+ ddfstate = DIW_waiting_start;
+
+ if (first_bplcon0 != first_bplcon0_old) {
+ vertical_changed = horizontal_changed = true;
+ }
+ first_bplcon0_old = first_bplcon0;
+
+ if (first_planes_vpos != first_planes_vpos_old ||
+ last_planes_vpos != last_planes_vpos_old) {
+ vertical_changed = true;
+ }
+ first_planes_vpos_old = first_planes_vpos;
+ last_planes_vpos_old = last_planes_vpos;
+
+ if (diwfirstword_total != diwfirstword_total_old ||
+ diwlastword_total != diwlastword_total_old ||
+ ddffirstword_total != ddffirstword_total_old ||
+ ddflastword_total != ddflastword_total_old) {
+ horizontal_changed = true;
+ }
+ diwfirstword_total_old = diwfirstword_total;
+ diwlastword_total_old = diwlastword_total;
+ ddffirstword_total_old = ddffirstword_total;
+ ddflastword_total_old = ddflastword_total;
+
+ first_planes_vpos = 0;
+ last_planes_vpos = 0;
+ diwfirstword_total = max_diwlastword;
+ diwlastword_total = 0;
+ ddffirstword_total = max_diwlastword;
+ ddflastword_total = 0;
+ plflastline_total = 0;
+ plffirstline_total = current_maxvpos();
+ first_bplcon0 = 0;
+ autoscale_bordercolors = 0;
+
+ for (i = 0; i < MAX_SPRITES; i++) {
+ spr[i].ptxhpos = MAXHPOS;
+ spr[i].ptxvpos2 = -1;
+ }
+ plf_state = plf_end;
}
-static void init_hardware_frame (void)
-{
- next_lineno = 0;
- prev_lineno = -1;
- diwstate = DIW_waiting_start;
- ddfstate = DIW_waiting_start;
- plf_state = plf_end;
-}
-
-void init_hardware_for_drawing_frame (void)
+void init_hardware_for_drawing_frame(void)
{
/* Avoid this code in the first frame after a customreset. */
- if (next_sprite_entry > 0) {
- int npixels = curr_sprite_entries[next_sprite_entry].first_pixel;
- memset(spixels, 0, npixels * sizeof *spixels);
- memset(spixstate.bytes, 0, npixels * sizeof *spixstate.bytes);
+ if (prev_sprite_entries) {
+ int first_pixel = prev_sprite_entries[0].first_pixel;
+ int npixels = prev_sprite_entries[prev_next_sprite_entry].first_pixel - first_pixel;
+ memset(spixels + first_pixel, 0, npixels * sizeof *spixels);
+ memset(spixstate.bytes + first_pixel, 0, npixels * sizeof *spixstate.bytes);
}
-
+ prev_next_sprite_entry = next_sprite_entry;
+
next_color_change = 0;
next_sprite_entry = 0;
next_color_entry = 0;
remembered_color_entry = -1;
-
- curr_sprite_entries[0].first_pixel = 0;
+
+ prev_sprite_entries = sprite_entries[current_change_set];
+ curr_sprite_entries = sprite_entries[current_change_set ^ 1];
+ prev_color_changes = color_changes[current_change_set];
+ curr_color_changes = color_changes[current_change_set ^ 1];
+ prev_color_tables = color_tables[current_change_set];
+ curr_color_tables = color_tables[current_change_set ^ 1];
+
+ prev_drawinfo = line_drawinfo[current_change_set];
+ curr_drawinfo = line_drawinfo[current_change_set ^ 1];
+ current_change_set ^= 1;
+
+ color_src_match = color_dest_match = -1;
+
+ /* Use both halves of the array in alternating fashion. */
+ curr_sprite_entries[0].first_pixel = current_change_set * MAX_SPR_PIXELS;
next_sprite_forced = 1;
}
-static int rpt_vsync (void)
+static int rpt_vsync(int adjust)
{
- frame_time_t curr_time = read_processor_time ();
- int v = curr_time - vsyncwaittime;
+ frame_time_t curr_time = read_processor_time();
+ int v = curr_time - vsyncwaittime + adjust;
if (v > syncbase || v < -syncbase) {
vsyncmintime = vsyncmaxtime = vsyncwaittime = curr_time;
v = 0;
@@ -5378,17 +6706,30 @@ static int rpt_vsync (void)
return v;
}
-STATIC_INLINE void rtg_vsync (void)
+static void rtg_vsync(void)
{
#ifdef PICASSO96
frame_time_t start, end;
- start = read_processor_time ();
- picasso_handle_vsync ();
- end = read_processor_time ();
+ start = read_processor_time();
+ picasso_handle_vsync();
+ end = read_processor_time();
frameskiptime += end - start;
#endif
}
+static void rtg_vsynccheck(void)
+{
+ //if (vblank_found_rtg) {
+ // vblank_found_rtg = false;
+ rtg_vsync();
+ //}
+}
+
+static void maybe_process_pull_audio(void)
+{
+ //audio_finish_pull();
+}
+
// moving average algorithm
#define MAVG_MAX_SIZE 128
struct mavg_data
@@ -5399,19 +6740,20 @@ struct mavg_data
int mavg;
};
-static void mavg_clear (struct mavg_data *md)
+static void mavg_clear(struct mavg_data *md)
{
md->size = 0;
md->offset = 0;
md->mavg = 0;
}
-static int mavg (struct mavg_data *md, int newval, int size)
+static int mavg(struct mavg_data *md, int newval, int size)
{
if (md->size < size) {
md->values[md->size++] = newval;
md->mavg += newval;
- } else {
+ }
+ else {
md->mavg -= md->values[md->offset];
md->values[md->offset] = newval;
md->mavg += newval;
@@ -5424,45 +6766,69 @@ static int mavg (struct mavg_data *md, int newval, int size)
#define MAVG_VSYNC_SIZE 128
-static bool framewait (void)
+extern int log_vsync, debug_vsync_min_delay, debug_vsync_forced_delay;
+static bool framewait(void)
{
+ //return true always //TODO check if this is needed
+ return true;
+
frame_time_t curr_time;
frame_time_t start;
- frame_time_t time_for_next_frame = vsynctimebase;
- int vs = isvsync_chipset ();
+ int vs = isvsync_chipset();
int status = 0;
is_syncline = 0;
static struct mavg_data ma_frameskipt;
- int frameskipt_avg = mavg (&ma_frameskipt, frameskiptime, MAVG_VSYNC_SIZE);
+ int frameskipt_avg = mavg(&ma_frameskipt, frameskiptime, MAVG_VSYNC_SIZE);
frameskiptime = 0;
if (vs > 0) {
- if(!nodraw()) {
- if (!frame_rendered && !picasso_on)
- frame_rendered = render_screen (false);
-
- if (!frame_shown) {
- show_screen (1);
- }
- curr_time = target_lastsynctime();
- } else {
- curr_time = target_lastsynctime() + vsynctimebase;
-
- if(read_processor_time () > curr_time)
- time_for_next_frame = curr_time - read_processor_time ();
- }
+ static struct mavg_data ma_legacy;
+ static frame_time_t vsync_time;
+ int t;
+ curr_time = read_processor_time();
vsyncwaittime = vsyncmaxtime = curr_time + vsynctimebase;
- vsyncmintime = curr_time;
-
+ if (!frame_rendered && !picasso_on) {
+ updatedisplayarea();
+ frame_rendered = true;
+ }
+
+ start = read_processor_time();
+ t = 0;
+ if (int(start) - int(vsync_time) >= 0 && int(start) - int(vsync_time) < vsynctimebase)
+ t += int(start) - int(vsync_time);
+
+ if (!frame_shown) {
+ updatedisplayarea();
+ if (currprefs.gfx_apmode[0].gfx_strobo)
+ updatedisplayarea();
+ }
+
+ maybe_process_pull_audio();
+
+ int legacy_avg = mavg(&ma_legacy, t, MAVG_VSYNC_SIZE);
+ if (t > legacy_avg)
+ legacy_avg = t;
+ t = legacy_avg;
+
+ /*if (debug_vsync_min_delay && t < debug_vsync_min_delay * vsynctimebase / 100)
+ t = debug_vsync_min_delay * vsynctimebase / 100;
+ if (debug_vsync_forced_delay > 0)
+ t = debug_vsync_forced_delay * vsynctimebase / 100;*/
+
+ vsync_time = read_processor_time();
+ if (t > vsynctimebase * 2 / 3)
+ t = vsynctimebase * 2 / 3;
+
if (currprefs.m68k_speed < 0) {
- vsynctimeperline = (time_for_next_frame) / (maxvpos_display + 1);
- } else {
- vsynctimeperline = (time_for_next_frame) / 3;
+ vsynctimeperline = (vsynctimebase - t) / (maxvpos_display + 1);
+ }
+ else {
+ vsynctimeperline = (vsynctimebase - t) / 3;
}
if (vsynctimeperline < 1)
@@ -5470,59 +6836,256 @@ static bool framewait (void)
frame_shown = true;
return 1;
+
+ }
+ else if (vs < 0) {
+
+ int freetime;
+ extern int extraframewait, extraframewait2;
+
+ if (!vblank_hz_state)
+ return status != 0;
+
+ if (vs == -2 || vs == -3) {
+
+ // fastest possible
+ int max, adjust, flipdelay, val;
+ frame_time_t now;
+ static struct mavg_data ma_skip, ma_adjust;
+
+ val = 0;
+
+ if (!frame_rendered && !picasso_on) {
+ frame_time_t start, end;
+ start = read_processor_time();
+ updatedisplayarea();
+ frame_rendered = true;
+ end = read_processor_time();
+ val += end - start;
+ }
+
+ curr_time = 0;//vsync_busywait_end(&flipdelay); // vsync time
+ status = 0; //vsync_busywait_do(NULL, (bplcon0 & 4) != 0 && !lof_changed && !lof_changing, lof_store != 0);
+ //vsync_busywait_start();
+
+ now = read_processor_time(); // current time
+ adjust = (int)now - (int)curr_time;
+ //write_log (_T("%d "), adjust);
+ if (adjust < 0 || adjust >= vsynctimebase)
+ adjust = 0;
+ if (adjust > vsynctimebase * 2 / 3)
+ adjust = vsynctimebase * 2 / 3;
+
+ int adjust_avg = mavg(&ma_adjust, adjust, MAVG_VSYNC_SIZE);
+
+ val += adjust_avg;
+
+ int flipdelay_avg = mavg(&ma_skip, flipdelay, MAVG_VSYNC_SIZE);
+ if (flipdelay > flipdelay_avg)
+ flipdelay_avg = flipdelay;
+ if (currprefs.gfx_apmode[0].gfx_vflip == 0) {
+ val += flipdelay_avg;
+ //write_log (_T("%d "), skipcnt);
+ }
+ val += frameskipt_avg;
+
+ //if (currprefs.gfx_apmode[0].gfx_vflip == 0) {
+ // if (debug_vsync_min_delay && val < debug_vsync_min_delay * vsynctimebase / 100)
+ // val = debug_vsync_min_delay * vsynctimebase / 100;
+ // if (debug_vsync_forced_delay > 0)
+ // val = debug_vsync_forced_delay * vsynctimebase / 100;
+ //}
+
+ //write_log (_T("%d "), adjust);
+
+ if (val > vsynctimebase * 2 / 3)
+ val = vsynctimebase * 2 / 3;
+
+ max = (int)((vsynctimebase - val) * (1000.0 + currprefs.m68k_speed_throttle) / 1000.0);
+ if (max < 1)
+ max = 1;
+
+ vsyncmintime = now;
+ vsyncwaittime = curr_time + (vsynctimebase - 0);
+
+ vsynctimeperline = max / (maxvpos_display + 1);
+ if (status <= 0 || vsynctimeperline < 1)
+ vsynctimeperline = 1;
+ vsyncmaxtime = now + max;
+
+ //if (0 || (log_vsync & 2)) {
+ // write_log(_T("%05d:%05d:%05d=%05d:%05d/%05d %03d%%\n"), adjust_avg, frameskipt_avg, flipdelay_avg,
+ // val, vsynctimeperline, vsynctimebase, val * 100 / vsynctimebase);
+ //}
+
+ frame_shown = true;
+
+ }
+ else {
+
+ int max, adjust, flipdelay, flipdelay_avg;
+ static struct mavg_data ma_skip;
+ frame_time_t now;
+
+ flipdelay = 0;
+ curr_time = 0;//vsync_busywait_end(&flipdelay);
+ if (!frame_rendered && !picasso_on)
+ {
+ updatedisplayarea();
+ frame_rendered = true;
+ }
+
+
+ status = 0;//vsync_busywait_do(&freetime, (bplcon0 & 4) != 0 && !lof_changed && !lof_changing, lof_store != 0);
+ //vsync_busywait_start();
+
+ now = read_processor_time();
+
+ maybe_process_pull_audio();
+ //if (extraframewait && !currprefs.turbo_emulation) {
+ // cpu_sleep_millis(-extraframewait);
+ // maybe_process_pull_audio();
+ //}
+ //else if (extraframewait2 && !currprefs.turbo_emulation) {
+ // uae_time_t add = ((uae_s64)extraframewait2) * syncbase / (1000 * 1000);
+ // frame_time_t efw = read_processor_time() + add;
+ // for (;;) {
+ // frame_time_t nfw = read_processor_time();
+ // if (audio_is_pull_event())
+ // break;
+ // if ((int)efw - (int)nfw <= 0)
+ // break;
+ // }
+ // maybe_process_pull_audio();
+ //}
+
+ adjust = (int)now - (int)curr_time;
+ int adjustx = adjust;
+ if (adjust < 0)
+ adjust = 0;
+ if (adjust > vsynctimebase)
+ adjust = 0;
+ if (adjust > vsynctimebase / 2)
+ adjust = vsynctimebase / 2;
+
+ vsyncmintime = now;
+ vsyncwaittime = curr_time + vsynctimebase;
+
+ if (currprefs.gfx_apmode[0].gfx_vflip == 0) {
+ flipdelay_avg = mavg(&ma_skip, flipdelay, MAVG_VSYNC_SIZE);
+ if (flipdelay > flipdelay_avg)
+ flipdelay_avg = flipdelay;
+ }
+ else {
+ flipdelay_avg = 0;
+ }
+
+ max = vsynctimebase - adjust - flipdelay_avg;
+
+ //if (currprefs.gfx_apmode[0].gfx_vflip == 0) {
+ // int val = vsynctimebase - max;
+ // if (debug_vsync_min_delay && val < debug_vsync_min_delay * vsynctimebase / 100)
+ // val = debug_vsync_min_delay * vsynctimebase / 100;
+ // if (debug_vsync_forced_delay > 0)
+ // val = debug_vsync_forced_delay * vsynctimebase / 100;
+ // max = vsynctimebase - val;
+ //}
+
+ vsynctimeperline = max / 3;
+ if (status <= 0 || vsynctimeperline < 1)
+ vsynctimeperline = 1;
+ vsyncmaxtime = now + max;
+
+ //if (0 || (log_vsync & 2)) {
+ // write_log(_T("%06d:%06d:%06d:%06d %06d/%06d %03d%%\n"), frameskipt_avg, flipdelay_avg, adjust, adjustx,
+ // vsynctimeperline, vsynctimebase, (vsynctimebase - max) * 100 / vsynctimebase);
+ //}
+
+ frame_shown = true;
+
+ }
+ return status != 0;
}
status = 1;
+ int clockadjust = 0;
int vstb = vsynctimebase;
+ //if (currprefs.m68k_speed < 0 && !cpu_sleepmode && !currprefs.cpu_memory_cycle_exact) {
if (currprefs.m68k_speed < 0) {
- if (!frame_rendered && !picasso_on)
- frame_rendered = render_screen (false);
+ if (!frame_rendered && !picasso_on) {
+ updatedisplayarea();
+ frame_rendered = true;
+ }
- curr_time = read_processor_time ();
+ if (currprefs.m68k_speed_throttle) {
+ // this delay can safely overshoot frame time by 1-2 ms, following code will compensate for it.
+ for (;;) {
+ curr_time = read_processor_time();
+ if ((int)vsyncwaittime - (int)curr_time <= 0 || (int)vsyncwaittime - (int)curr_time > 2 * vsynctimebase)
+ break;
+ rtg_vsynccheck();
+ //if (cpu_sleep_millis(1) < 0) {
+ // curr_time = read_processor_time();
+ // break;
+ //}
+ }
+ }
+ else {
+ curr_time = read_processor_time();
+ }
int max;
int adjust = 0;
if ((int)curr_time - (int)vsyncwaittime > 0 && (int)curr_time - (int)vsyncwaittime < vstb / 2)
adjust += curr_time - vsyncwaittime;
- max = (int)(vstb * (1000.0) / 1000.0 - adjust);
+ adjust += clockadjust;
+ max = (int)(vstb * (1000.0 + currprefs.m68k_speed_throttle) / 1000.0 - adjust);
vsyncwaittime = curr_time + vstb - adjust;
vsyncmintime = curr_time;
if (max < 0) {
max = 0;
vsynctimeperline = 1;
- } else {
+ }
+ else {
vsynctimeperline = max / (maxvpos_display + 1);
}
vsyncmaxtime = curr_time + max;
-
- } else {
+ }
+ else {
int t = 0;
if (!frame_rendered && !picasso_on) {
- start = read_processor_time ();
- frame_rendered = render_screen (false);
- t = read_processor_time () - start;
+ start = read_processor_time();
+ updatedisplayarea();
+ frame_rendered = true;
+ t = read_processor_time() - start;
}
- while (1) {
- float v = rpt_vsync () / (syncbase / 1000.0);
+ while (!currprefs.turbo_emulation) {
+ double v = rpt_vsync(clockadjust) / (syncbase / 1000.0);
if (v >= -2)
break;
+ rtg_vsynccheck();
+ maybe_process_pull_audio();
+ //if (cpu_sleep_millis(1) < 0)
+ // break;
+ }
+ while (rpt_vsync(clockadjust) < 0) {
+ rtg_vsynccheck();
+ //if (audio_is_pull_event())
+ // break;
}
- curr_time = start = read_processor_time ();
- while (rpt_vsync () < 0)
- ;
idletime += read_processor_time() - start;
- curr_time = read_processor_time ();
+ curr_time = read_processor_time();
vsyncmintime = curr_time;
vsyncmaxtime = vsyncwaittime = curr_time + vstb;
if (frame_rendered) {
- show_screen (0);
- t += read_processor_time () - curr_time;
+ updatedisplayarea();
+ t += read_processor_time() - curr_time;
}
t += frameskipt_avg;
vsynctimeperline = (vstb - t) / 3;
@@ -5530,123 +7093,212 @@ static bool framewait (void)
vsynctimeperline = 0;
else if (vsynctimeperline > vstb / 3)
vsynctimeperline = vstb / 3;
-
+
frame_shown = true;
- }
+
+ }
return status != 0;
}
+static void reset_cpu_idle(void)
+{
+ cpu_sleepmode_cnt = 0;
+ if (cpu_sleepmode) {
+ cpu_sleepmode = 0;
+ }
+}
+
#define FPSCOUNTER_MAVG_SIZE 10
static struct mavg_data fps_mavg, idle_mavg;
-void fpscounter_reset (void)
+void fpscounter_reset(void)
{
- mavg_clear (&fps_mavg);
- mavg_clear (&idle_mavg);
- lastframetime = read_processor_time ();
+ mavg_clear(&fps_mavg);
+ mavg_clear(&idle_mavg);
+ bogusframe = 2;
+ lastframetime = read_processor_time();
idletime = 0;
}
-static void fpscounter (void)
+static void fpscounter(bool frameok)
{
- frame_time_t now, last;
+ frame_time_t now, last;
- now = read_processor_time ();
- last = now - lastframetime;
- lastframetime = now;
+ now = read_processor_time();
+ last = now - lastframetime;
+ lastframetime = now;
- if ((int)last < 0)
+ if (bogusframe || int(last) < 0)
return;
- if(currprefs.gfx_framerate)
- idletime >>= 1;
-
- mavg (&fps_mavg, last / 10, FPSCOUNTER_MAVG_SIZE);
- mavg (&idle_mavg, idletime / 10, FPSCOUNTER_MAVG_SIZE);
+ mavg(&fps_mavg, last / 10, FPSCOUNTER_MAVG_SIZE);
+ mavg(&idle_mavg, idletime / 10, FPSCOUNTER_MAVG_SIZE);
idletime = 0;
- timeframes++;
+ frametime += last;
+ timeframes++;
if ((timeframes & 7) == 0) {
- float idle = 1000 - (idle_mavg.mavg == 0 ? 0.0 : (float)idle_mavg.mavg * 1000.0 / vsynctimebase);
+ double idle = 1000 - (idle_mavg.mavg == 0 ? 0.0 : double(idle_mavg.mavg) * 1000.0 / vsynctimebase);
int fps = fps_mavg.mavg == 0 ? 0 : syncbase * 10 / fps_mavg.mavg;
- if (fps > 9999)
- fps = 9999;
+ if (fps > 99999)
+ fps = 99999;
if (idle < 0)
idle = 0;
if (idle > 100 * 10)
idle = 100 * 10;
+ if (fake_vblank_hz * 10 > fps) {
+ double mult = double(fake_vblank_hz) * 10.0 / fps;
+ idle *= mult;
+ }
+ if (currprefs.turbo_emulation && idle < 100 * 10)
+ idle = 100 * 10;
gui_data.fps = fps;
- gui_data.idle = (int)idle;
- }
+ gui_data.idle = int(idle);
+ gui_data.fps_color = frameok ? 0 : 1;
+ if ((timeframes & 15) == 0) {
+ gui_fps(fps, int(idle), frameok ? 0 : 1);
+ }
+ }
}
// vsync functions that are not hardware timing related
-static void vsync_handler_pre (void)
+static void vsync_handler_pre(void)
{
- config_check_vsync ();
- if (timehack_alive > 0)
- timehack_alive--;
+ if (currprefs.m68k_speed < 0) {
+ if (regs.stopped) {
+ cpu_stopped_lines += maxvpos - cpu_last_stop_vpos;
+ }
+ int mv = 12 - currprefs.cpu_idle / 15;
+ if (mv >= 1 && mv <= 11) {
+ mv = 11 - mv;
+ if (cpu_stopped_lines >= maxvpos * (mv * 10) / 100) {
+ cpu_sleepmode_cnt++;
+ if (cpu_sleepmode_cnt >= 50) {
+ cpu_sleepmode_cnt = 50;
+ if (!cpu_sleepmode) {
+ cpu_sleepmode = 1;
+ //write_log(_T("sleep\n"));
+ }
+ }
+ }
+ else {
+ reset_cpu_idle();
+ }
+ }
+ else {
+ reset_cpu_idle();
+ }
+ }
+ if (regs.halted < 0)
+ reset_cpu_idle();
+ cpu_last_stop_vpos = 0;
+ cpu_stopped_lines = 0;
- devices_vsync_pre();
+ if (bogusframe > 0)
+ bogusframe--;
+
+ config_check_vsync();
+ if (timehack_alive > 0)
+ timehack_alive--;
+
+ //audio_vsync(); //TODO
+ blkdev_vsync();
+ CIA_vsync_prehandler();
+ inputdevice_vsync();
+ filesys_vsync();
+ //sampler_vsync(); //TODO
+ //clipboard_vsync(); //TODO
#ifdef PICASSO96
- rtg_vsync ();
+ if (isvsync_rtg() >= 0)
+ rtg_vsync();
#endif
if (!vsync_rendered) {
frame_time_t start, end;
- start = read_processor_time ();
- vsync_handle_redraw ();
+ start = read_processor_time();
+ vsync_handle_redraw(lof_store, lof_changed, bplcon0, bplcon3);
vsync_rendered = true;
- end = read_processor_time ();
+ end = read_processor_time();
frameskiptime += end - start;
}
- framewait ();
-
- if (!picasso_on && !nodraw()) {
- if (!frame_rendered) {
- frame_rendered = render_screen (false);
- }
- if (frame_rendered && !frame_shown) {
- frame_shown = show_screen_maybe (true);
- }
- }
+ bool frameok = framewait();
- if(!nodraw() || (picasso_on && picasso_rendered))
- fpscounter();
+ //if (!picasso_on) {
+ // if (!frame_rendered && vblank_hz_state) {
+ // updatedisplayarea();
+ // frame_rendered = true;
+ // }
+ // if (frame_rendered && !frame_shown) {
+ // updatedisplayarea();
+ // frame_shown = true;
+ // }
+ //}
- handle_events ();
+ fpscounter(frameok);
+
+ bool waspaused = false;
+ //while (handle_events()) {
+ // if (!waspaused) {
+ // render_screen(true);
+ // show_screen(0);
+ // waspaused = true;
+ // }
+ // // we are paused, do all config checks but don't do any emulation
+ // if (vsync_handle_check()) {
+ // redraw_frame();
+ // render_screen(true);
+ // show_screen(0);
+ // }
+ // config_check_vsync();
+ //}
if (quit_program > 0) {
- /* prevent possible infinite loop at wait_cycles().. */
+ /* prevent possible infinite loop at wait_cycles().. */
framecnt = 0;
- reset_decisions ();
- return;
- }
-
+ reset_decisions();
+ return;
+ }
+
vsync_rendered = false;
frame_shown = false;
frame_rendered = false;
- vsync_handle_check ();
+ if (vblank_hz_mult > 0)
+ vblank_hz_state ^= 1;
+ else
+ vblank_hz_state = 1;
+
+ vsync_handle_check();
}
// emulated hardware vsync
-static void vsync_handler_post (void)
+static void vsync_handler_post(void)
{
- DISK_vsync ();
+ static frame_time_t prevtime;
+ prevtime = read_processor_time();
+
+ DISK_vsync();
+
+#ifdef WITH_LUA
+ uae_lua_run_handler("on_uae_vsync");
+#endif
if (bplcon0 & 4) {
lof_store = lof_store ? 0 : 1;
}
+ if ((bplcon0 & 2) && currprefs.genlock) {
+ genlockvtoggle = lof_store ? 1 : 0;
+ }
if (lof_prev_lastline != lof_lastline) {
if (lof_togglecnt_lace < LOF_TOGGLES_NEEDED)
lof_togglecnt_lace++;
if (lof_togglecnt_lace >= LOF_TOGGLES_NEEDED)
lof_togglecnt_nlace = 0;
- } else {
+ }
+ else {
// only 1-2 vblanks with bplcon0 lace bit set?
// lets check if lof has changed
if (!(bplcon0 & 4) && lof_togglecnt_lace > 0 && lof_togglecnt_lace < LOF_TOGGLES_NEEDED && !interlace_seen) {
@@ -5658,9 +7310,16 @@ static void vsync_handler_post (void)
lof_prev_lastline = lof_lastline;
lof_current = lof_store;
if (lof_togglecnt_lace >= LOF_TOGGLES_NEEDED) {
- interlace_changed = notice_interlace_seen (true);
- } else if (lof_togglecnt_nlace >= LOF_TOGGLES_NEEDED) {
- interlace_changed = notice_interlace_seen (false);
+ interlace_changed = notice_interlace_seen(true);
+ if (interlace_changed) {
+ notice_screen_contents_lost();
+ }
+ }
+ else if (lof_togglecnt_nlace >= LOF_TOGGLES_NEEDED) {
+ interlace_changed = notice_interlace_seen(false);
+ if (interlace_changed) {
+ notice_screen_contents_lost();
+ }
}
if (lof_changing) {
// still same? Trigger change now.
@@ -5679,99 +7338,249 @@ static void vsync_handler_post (void)
lof_changed = 0;
}
lof_changing = 0;
- } else {
+ }
+ else {
lof_changed_previous_field = 0;
lof_lace = false;
}
-
+
+#ifdef PICASSO96
+ if (p96refresh_active) {
+ vpos_count = p96refresh_active;
+ vtotal = vpos_count;
+ }
+#endif
+#ifdef GFXBOARD
+ if (!picasso_on)
+ gfxboard_vsync_handler();
+#endif
+
if (varsync_changed || (beamcon0 & (0x10 | 0x20 | 0x80 | 0x100 | 0x200)) != (new_beamcon0 & (0x10 | 0x20 | 0x80 | 0x100 | 0x200))) {
init_hz_normal();
- } else if (vpos_count > 0 && abs (vpos_count - vpos_count_diff) > 1 && vposw_change < 4) {
+ }
+ else if (vpos_count > 0 && abs(vpos_count - vpos_count_diff) > 1 && vposw_change < 4) {
init_hz_vposw();
- } else if (interlace_changed || changed_chipset_refresh () || lof_changed) {
- compute_framesync ();
- }
+ }
+ else if (interlace_changed || changed_chipset_refresh() || lof_changed) {
+ compute_framesync();
+ }
lof_changed = 0;
vposw_change = 0;
+ bplcon0_interlace_seen = false;
- eventtab[ev_copper].active = 0;
- COPJMP (1, 1);
-
- init_hardware_frame ();
+ COPJMP(1, 1);
+
+ init_hardware_frame();
+
+ vsync_cycles = get_cycles();
}
+static void copper_check(int n)
+{
+ if (cop_state.state == COP_wait) {
+ int vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80);
+ //if (vp < cop_state.vcmp) {
+ //if (copper_enabled_thisline)
+ // write_log(_T("COPPER BUG %d: vp=%d vpos=%d vcmp=%d thisline=%d\n"), n, vp, vpos, cop_state.vcmp, copper_enabled_thisline);
+ //}
+ }
+}
+
+/*
+
+0 0 -
+1 1 --
+2 2 -
+3 3 --
+4 4 -
+5 5 --
+
+0 x -
+1 0 --
+2 1 -
+3 2 --
+4 3 -
+5 4 --
+
+*/
+
+static void hsync_scandoubler(void)
+{
+ int i, idx1;
+ struct draw_info *dip1;
+ uaecptr bpltmp[8], bpltmpx[8];
+
+ if (lof_store && vpos >= maxvpos_nom - 1)
+ return;
+
+ next_lineno++;
+ scandoubled_line = 1;
+#ifdef DEBUGGER
+ debug_dma = 0;
+#endif
+
+ for (i = 0; i < 8; i++) {
+ int diff;
+ bpltmp[i] = bplpt[i];
+ bpltmpx[i] = bplptx[i];
+ if (prevbpl[lof_store][vpos][i] && prevbpl[1 - lof_store][vpos][i]) {
+ diff = prevbpl[lof_store][vpos][i] - prevbpl[1 - lof_store][vpos][i];
+ if (lof_store) {
+ if (bplcon0 & 4)
+ bplpt[i] = prevbpl[lof_store][vpos][i] - diff;
+ }
+ else {
+ if (bplcon0 & 4)
+ bplpt[i] = prevbpl[lof_store][vpos][i];
+ else
+ bplpt[i] = bplpt[i] - diff;
+
+ }
+ }
+ }
+
+ reset_decisions();
+ plf_state = plf_idle;
+ plfr_state = plfr_idle;
+
+ // copy color changes
+ dip1 = curr_drawinfo + next_lineno - 1;
+ for (idx1 = dip1->first_color_change; idx1 < dip1->last_color_change; idx1++) {
+ struct color_change *cs2 = &curr_color_changes[idx1];
+ int regno = cs2->regno;
+ int hpos = cs2->linepos;
+ if (regno < 0x1000 && hpos < HBLANK_OFFSET && !(beamcon0 & 0x80) && prev_lineno >= 0) {
+ struct draw_info *pdip = curr_drawinfo + next_lineno - 1;
+ int idx = pdip->last_color_change;
+ pdip->last_color_change++;
+ pdip->nr_color_changes++;
+ curr_color_changes[idx].linepos = hpos + maxhpos + 1;
+ curr_color_changes[idx].regno = regno;
+ curr_color_changes[idx].value = cs2->value;
+ curr_color_changes[idx + 1].regno = -1;
+ }
+ else {
+ struct color_change *cs1 = &curr_color_changes[next_color_change];
+ memcpy(cs1, cs2, sizeof(struct color_change));
+ next_color_change++;
+ }
+ }
+ curr_color_changes[next_color_change].regno = -1;
+
+ finish_decisions();
+ hsync_record_line_state(next_lineno, nln_normal, thisline_changed);
+ hardware_line_completed(next_lineno);
+ scandoubled_line = 0;
+
+ for (i = 0; i < 8; i++) {
+ bplpt[i] = bpltmp[i];
+ bplptx[i] = bpltmpx[i];
+ }
+}
+
+static void events_dmal(int);
static uae_u16 dmal, dmal_hpos;
-static void dmal_func2 (void)
+static void dmal_emu(uae_u32 v)
{
- event_remevent(ev_dmal);
-
// Disk and Audio DMA bits are ignored by Agnus, Agnus only checks DMAL and master bit
if (!(dmacon & DMA_MASTER))
return;
+ int hpos = current_hpos();
+ if (v >= 6) {
+ v -= 6;
+ int nr = v / 2;
+ uaecptr pt = audio_getpt(nr, (v & 1) != 0);
+ uae_u16 dat = chipmem_wget_indirect(pt);
+ last_custom_value1 = dat;
+ AUDxDAT(nr, dat, pt);
+ }
+ else {
+ uae_u16 dat;
+ int w = v & 1;
+ uaecptr pt = disk_getpt();
+ // disk_fifostatus() needed in >100% disk speed modes
+ if (w) {
+ // write to disk
+ if (disk_fifostatus() <= 0) {
+ dat = chipmem_wget_indirect(pt);
+ last_custom_value1 = dat;
+ DSKDAT(dat);
+ }
+ }
+ else {
+ // read from disk
+ if (disk_fifostatus() >= 0) {
+ dat = DSKDATR();
+ chipmem_wput_indirect(pt, dat);
+ }
+ }
+
+ }
+}
+
+static void dmal_func(uae_u32 v)
+{
+ dmal_emu(v);
+ events_dmal(0);
+}
+
+static void dmal_func2(uae_u32 v)
+{
while (dmal) {
- if (dmal & 3) {
- if (dmal_hpos >= 6) {
- int nr = (dmal_hpos - 6) >> 1;
- audio_dmal_do (nr, (dmal & 2) ? true : false);
- } else {
- uae_u16 dat;
- int w = (dmal & 2) ? 1 : 0;
- uaecptr pt = disk_getpt ();
- // disk_fifostatus() needed in >100% disk speed modes
- if (w) {
- // write to disk
- if (disk_fifostatus () <= 0) {
- dat = chipmem_wget_indirect (pt);
- last_custom_value1 = dat;
- DSKDAT (dat);
- }
- } else {
- // read from disk
- if (disk_fifostatus () >= 0) {
- dat = DSKDATR ();
- chipmem_wput_indirect (pt, dat);
- }
- }
- }
- }
-
+ if (dmal & 3)
+ dmal_emu(dmal_hpos + ((dmal & 2) ? 1 : 0));
dmal_hpos += 2;
dmal >>= 2;
}
}
-STATIC_INLINE void events_dmal (void)
+static void events_dmal(int hp)
{
- if (currprefs.cachesize) {
- dmal_func2 ();
- } else {
- event_newevent (ev_dmal, 7);
+ if (!dmal)
+ return;
+ if (currprefs.cpu_memory_cycle_exact) {
+ while (dmal) {
+ if (dmal & 3)
+ break;
+ hp += 2;
+ dmal >>= 2;
+ dmal_hpos += 2;
+ }
+ event2_newevent2(hp, dmal_hpos + ((dmal & 2) ? 1 : 0), dmal_func);
+ dmal &= ~3;
+ }
+ else if (currprefs.cachesize) {
+ dmal_func2(0);
+ }
+ else {
+ event2_newevent2(hp, 13, dmal_func2);
}
}
-static void events_dmal_hsync (void)
+static void events_dmal_hsync(void)
{
- uae_u16 dmal_disk = disk_dmal ();
-
- dmal = audio_dmal ();
- if (!dmal && !dmal_disk)
+ if (dmal)
+ write_log(_T("DMAL error!? %04x\n"), dmal);
+ dmal = audio_dmal();
+ dmal <<= 6;
+ dmal |= disk_dmal();
+ if (!dmal)
return;
-
- if(dmal_disk)
- {
- dmal_hpos = 0;
- dmal <<= 6;
- dmal |= dmal_disk;
- }
- else
- dmal_hpos = 6;
- events_dmal ();
+ dmal_hpos = 0;
+ if (currprefs.cpu_memory_cycle_exact) {
+ for (int i = 0; i < 6 + 8; i += 2) {
+ if (dmal & (3 << i)) {
+ alloc_cycle_ext(i + 7, CYCLE_MISC);
+ }
+ }
+ }
+ events_dmal(7);
}
-static bool is_custom_vsync (void)
+static bool is_custom_vsync(void)
{
int vp = vpos + 1;
int vpc = vpos_count + 1;
@@ -5785,69 +7594,133 @@ static bool is_custom_vsync (void)
return false;
}
-static void set_hpos (void)
+static void set_hpos(void)
{
- eventtab[ev_hsync].evtime = get_cycles () + HSYNCTIME;
- eventtab[ev_hsync].oldcycles = get_cycles ();
+ maxhpos = maxhpos_short + lol;
+ hpos_offset = 0;
+ eventtab[ev_hsync].evtime = get_cycles() + HSYNCTIME;
+ eventtab[ev_hsync].oldcycles = get_cycles();
}
// this finishes current line
-static void hsync_handler_pre (bool onvsync)
+static void hsync_handler_pre(bool onvsync)
{
- int hpos = current_hpos ();
+ int hpos = current_hpos();
- if (!nocustom()) {
- /* Using 0x8A makes sure that we don't accidentally trip over the
- modified_regtypes check. */
- sync_copper_with_cpu (maxhpos, 0, 0x8A);
+ if (!nocustom()) {
+ sync_copper_with_cpu(maxhpos, 0);
- finish_decisions ();
- if (thisline_decision.plfleft >= 0) {
- if (currprefs.collision_level > 1)
- DO_SPRITE_COLLISIONS
- if (currprefs.collision_level > 2)
- DO_PLAYFIELD_COLLISIONS
- }
- hsync_record_line_state (next_lineno);
- }
-
- devices_hsync();
+ // Seven Seas scrolling quick fix hack
+ // checks if copper is going to modify BPLCON1 in next cycle.
+ if (copper_enabled_thisline && cop_state.state == COP_read2 && (cop_state.i1 & 0x1fe) == 0x102) {
+ // it did, pre-load value for Denise shifter emulation
+ hpos_is_zero_bplcon1_hack = chipmem_wget_indirect(cop_state.ip);
+ // following finish_decision() is going to finish this line
+ // it is too late when copper actually does the move
+ }
- hsync_counter++;
+ finish_decisions();
+ if (thisline_decision.plfleft >= 0) {
+ if (currprefs.collision_level > 1)
+ DO_SPRITE_COLLISIONS
+ if (currprefs.collision_level > 2)
+ DO_PLAYFIELD_COLLISIONS
+ }
+ hsync_record_line_state(next_lineno, nextline_how, thisline_changed);
+ /* reset light pen latch */
+ if (vpos == sprite_vblank_endline) {
+ lightpen_triggered = 0;
+ sprite_0 = 0;
+ }
+ if (lightpen_enabled && lightpen_cx > 0 && (bplcon0 & 8) && !lightpen_triggered && lightpen_cy == vpos) {
+ vpos_lpen = vpos;
+ hpos_lpen = lightpen_cx;
+ lightpen_triggered = 1;
+ }
+ hardware_line_completed(next_lineno);
+ if (doflickerfix() && interlace_seen > 0)
+ hsync_scandoubler();
+ notice_resolution_seen(GET_RES_AGNUS(bplcon0), interlace_seen != 0);
+ }
- vpos++;
+#ifdef A2065
+ a2065_hsync_handler();
+#endif
+#ifdef CD32
+ AKIKO_hsync_handler();
+#endif
+#ifdef CDTV
+ CDTV_hsync_handler();
+#endif
+ decide_blitter(-1);
+
+#ifdef PICASSO96
+ picasso_handle_hsync();
+#endif
+ {
+ //void ahi_hsync(void);
+ //ahi_hsync();
+ }
+
+ DISK_hsync();
+ if (currprefs.produce_sound)
+ audio_hsync();
+
+ hsync_counter++;
+
+ refptr += 0x0200 * 4;
+ refptr_val += 0x0200 * 4;
+
+ if (islinetoggle())
+ lol ^= 1;
+ else
+ lol = 0;
+
+ vpos++;
vpos_count++;
- if (vpos >= maxvpos_total)
- vpos=0;
+ if (vpos >= maxvpos_total)
+ vpos = 0;
if (onvsync) {
vpos = 0;
+ vsync_counter++;
}
- set_hpos ();
+ set_hpos();
}
-STATIC_INLINE bool is_last_line (void)
+STATIC_INLINE bool is_last_line(void)
{
return vpos + 1 == maxvpos + lof_store;
}
// this prepares for new line
-static void hsync_handler_post (bool onvsync)
+static void hsync_handler_post(bool onvsync)
{
last_copper_hpos = 0;
+#ifdef CPUEMU_13
+ if (currprefs.cpu_memory_cycle_exact || currprefs.blitter_cycle_exact) {
+ memset(cycle_line, 0, sizeof cycle_line);
+ }
+#endif
- bool ciahsyncs = !(bplcon0 & 2);
- bool ciavsyncs = !(bplcon0 & 2);
+ // genlock active:
+ // vertical: interlaced = toggles every other field, non-interlaced = both fields (normal)
+ // horizontal: PAL = every line, NTSC = every other line
+ genlockhtoggle = !genlockhtoggle;
+ bool ciahsyncs = !(bplcon0 & 2) || ((bplcon0 & 2) && currprefs.genlock && (!currprefs.ntscmode || genlockhtoggle));
+ bool ciavsyncs = !(bplcon0 & 2) || ((bplcon0 & 2) && currprefs.genlock && genlockvtoggle);
- CIA_hsync_posthandler(false);
+ CIA_hsync_posthandler(false, false);
if (currprefs.cs_cd32cd) {
- CIA_hsync_posthandler(true);
+ CIA_hsync_posthandler(true, true);
CIAB_tod_handler(18);
- } else if (ciahsyncs) {
- CIA_hsync_posthandler(true);
+ }
+ else if (ciahsyncs) {
+ CIA_hsync_posthandler(true, ciahsyncs);
if (beamcon0 & (0x80 | 0x100)) {
if (hsstop < (maxhpos & ~1) && hsstrt < maxhpos)
CIAB_tod_handler(hsstop);
- } else {
+ }
+ else {
CIAB_tod_handler(18);
}
}
@@ -5857,285 +7730,431 @@ static void hsync_handler_post (bool onvsync)
if (cia_hsync < maxhpos) {
CIAA_tod_inc(cia_hsync);
cia_hsync += (akiko_ntscmode() ? 262 : 313) * maxhpos;
- } else {
+ }
+ else {
cia_hsync -= maxhpos;
}
- } else if (currprefs.cs_ciaatod > 0) {
+ }
+ else if (currprefs.cs_ciaatod > 0) {
if (cia_hsync < maxhpos) {
int newcount;
- CIAA_tod_inc (cia_hsync);
- newcount = (int)((vblank_hz * (2 * maxvpos + (interlace_seen ? 1 : 0)) * (2 * maxhpos + (currprefs.ntscmode ? 1 : 0))) / ((currprefs.cs_ciaatod == 2 ? 60 : 50) * 4));
+ CIAA_tod_inc(cia_hsync);
+ newcount = (vblank_hz * (2 * maxvpos + (interlace_seen ? 1 : 0)) * (2 * maxhpos + (islinetoggle() ? 1 : 0))) / ((currprefs.cs_ciaatod == 2 ? 60 : 50) * 4);
cia_hsync += newcount;
- } else {
+ }
+ else {
cia_hsync -= maxhpos;
}
- } else if (currprefs.cs_ciaatod == 0 && ciavsyncs) {
+ }
+ else if (currprefs.cs_ciaatod == 0 && ciavsyncs) {
// CIA-A TOD counter increases when vsync pulse ends
if (beamcon0 & (0x80 | 0x200)) {
if (vpos == vsstop && vsstrt <= maxvpos)
- CIAA_tod_inc (lof_store ? hsstop : hsstop + hcenter);
- } else {
+ CIAA_tod_inc(lof_store ? hsstop : hsstop + hcenter);
+ }
+ else {
if (vpos == (currprefs.ntscmode ? VSYNC_ENDLINE_NTSC : VSYNC_ENDLINE_PAL)) {
- CIAA_tod_inc (lof_store ? 132 : 18);
+ CIAA_tod_inc(lof_store ? 132 : 18);
}
}
}
- inputdevice_hsync ();
+ inputdevice_hsync();
- if (!nocustom()) {
- if (bltstate != BLT_done && dmaen (DMA_BITPLANE) && diwstate == DIW_waiting_stop) {
- blitter_slowdown (thisline_decision.plfleft, thisline_decision.plfright - (16 << fetchmode),
- cycle_diagram_total_cycles[fetchmode][bplcon0_res][bplcon0_planes_limit],
- cycle_diagram_free_cycles[fetchmode][bplcon0_res][bplcon0_planes_limit]);
- }
- }
+ if (!nocustom()) {
+ if (!currprefs.blitter_cycle_exact && bltstate != BLT_done && dmaen(DMA_BITPLANE) && diwstate == DIW_waiting_stop) {
+ blitter_slowdown(thisline_decision.plfleft, thisline_decision.plfright - (16 << fetchmode),
+ cycle_diagram_total_cycles[fetchmode][GET_RES_AGNUS(bplcon0)][GET_PLANES_LIMIT(bplcon0)],
+ cycle_diagram_free_cycles[fetchmode][GET_RES_AGNUS(bplcon0)][GET_PLANES_LIMIT(bplcon0)]);
+ }
+ }
if (onvsync) {
+ // vpos_count >= MAXVPOS just to not crash if VPOSW writes prevent vsync completely
+ if ((bplcon0 & 8) && !lightpen_triggered) {
+ vpos_lpen = vpos - 1;
+ hpos_lpen = maxhpos;
+ lightpen_triggered = 1;
+ }
vpos = 0;
- vsync_handler_post ();
+ vsync_handler_post();
vpos_count = 0;
- }
- if (vpos == 0)
- send_interrupt (5);
-
+ }
+ // A1000 DIP Agnus (8361): vblank interrupt is triggered on line 1!
+ if (currprefs.cs_dipagnus) {
+ if (vpos == 1)
+ send_interrupt(5, 1 * CYCLE_UNIT);
+ }
+ else {
+ if (vpos == 0)
+ send_interrupt(5, 1 * CYCLE_UNIT);
+ }
// lastline - 1?
if (vpos + 1 == maxvpos + lof_store || vpos + 1 == maxvpos + lof_store + 1) {
lof_lastline = lof_store != 0;
}
- events_dmal_hsync ();
-
- if (currprefs.m68k_speed < 0) {
- if (is_last_line ()) {
- /* really last line, just run the cpu emulation until whole vsync time has been used */
- vsyncmintime = vsyncmaxtime; /* emulate if still time left */
- if(vsyncmaxtime - read_processor_time () > -speedup_timelimit)
- is_syncline = 2;
- } else {
- /* end of scanline, run cpu emulation as long as we still have time */
- vsyncmintime += vsynctimeperline;
- is_syncline = 0;
- if ((int)vsyncmaxtime - (int)vsyncmintime > 0) {
- if ((int)vsyncwaittime - (int)vsyncmintime > 0) {
- frame_time_t rpt = read_processor_time ();
- /* Extra time left? Do some extra CPU emulation */
- if ((int)vsyncmintime - (int)rpt > -speedup_timelimit) {
- is_syncline = 1;
- }
- }
- }
- }
- } else {
- if (vpos + 1 < maxvpos + lof_store && (vpos == maxvpos_display * 1 / 3 || vpos == maxvpos_display * 2 / 3)) {
- vsyncmintime += vsynctimeperline;
+#ifdef CPUEMU_13
+ if (currprefs.cpu_memory_cycle_exact || currprefs.blitter_cycle_exact) {
+ int hp = maxhpos - 1, i;
+ for (i = 0; i < 4; i++) {
+ alloc_cycle(hp, i == 0 ? CYCLE_STROBE : CYCLE_REFRESH); /* strobe */
+#ifdef DEBUGGER
+ if (debug_dma) {
+ uae_u16 strobe = 0x3c;
+ if (vpos < equ_vblank_endline)
+ strobe = 0x38;
+ else if (vpos < minfirstline)
+ strobe = 0x3a;
+ else if (vpos + 1 == maxvpos + lof_store)
+ strobe = 0x38;
+ else if ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) && lol)
+ strobe = 0x3e;
+ record_dma(i == 0 ? strobe : 0x1fe, 0xffff, 0xffffffff, hp, vpos, DMARECORD_REFRESH);
+ }
+#endif
+ hp += 2;
+ if (hp >= maxhpos)
+ hp -= maxhpos;
}
- }
+ }
+#endif
- if (!nocustom()) {
- int lineno = vpos;
+ events_dmal_hsync();
+
+ if (currprefs.m68k_speed < 0) {
+ static int sleeps_remaining;
+ if (is_last_line()) {
+ sleeps_remaining = (165 - currprefs.cpu_idle) / 6;
+ if (sleeps_remaining < 0)
+ sleeps_remaining = 0;
+ /* really last line, just run the cpu emulation until whole vsync time has been used */
+ if (regs.stopped && currprefs.cpu_idle) {
+ // CPU in STOP state: sleep if enough time left.
+ frame_time_t rpt = read_processor_time();
+ //while (!vsync_isdone() && (int)vsyncmintime - (int)(rpt + vsynctimebase / 10) > 0 && (int)vsyncmintime - (int)rpt < vsynctimebase) {
+ // maybe_process_pull_audio();
+ // if (!execute_other_cpu(rpt + vsynctimebase / 10)) {
+ // if (cpu_sleep_millis(1) < 0)
+ // break;
+ // }
+ // rpt = read_processor_time();
+ //}
+ }
+ else if (currprefs.m68k_speed_throttle) {
+ vsyncmintime = read_processor_time(); /* end of CPU emulation time */
+ is_syncline = 0;
+ maybe_process_pull_audio();
+ }
+ else {
+ vsyncmintime = vsyncmaxtime; /* emulate if still time left */
+ is_syncline_end = read_processor_time() + vsynctimebase; /* far enough in future, we never wait that long */
+ is_syncline = 2;
+ maybe_process_pull_audio();
+ }
+ }
+ else {
+ static int linecounter;
+ /* end of scanline, run cpu emulation as long as we still have time */
+ vsyncmintime += vsynctimeperline;
+ linecounter++;
+ is_syncline = 0;
+ //if (!vsync_isdone() && !currprefs.turbo_emulation) {
+ // if ((int)vsyncmaxtime - (int)vsyncmintime > 0) {
+ // if ((int)vsyncwaittime - (int)vsyncmintime > 0) {
+ // frame_time_t rpt = read_processor_time();
+ // /* Extra time left? Do some extra CPU emulation */
+ // if ((int)vsyncmintime - (int)rpt > 0) {
+ // if (regs.stopped && currprefs.cpu_idle && sleeps_remaining > 0) {
+ // // STOP STATE: sleep.
+ // cpu_sleep_millis(1);
+ // sleeps_remaining--;
+ // maybe_process_pull_audio();
+ // }
+ // else {
+ // is_syncline = 1;
+ // /* limit extra time */
+ // is_syncline_end = rpt + vsynctimeperline;
+ // linecounter = 0;
+ // }
+ // }
+ // }
+ // if (!isvsync()) {
+ // // extra cpu emulation time if previous 10 lines without extra time.
+ // if (!is_syncline && linecounter >= 10 && (!regs.stopped || !currprefs.cpu_idle)) {
+ // is_syncline = -1;
+ // is_syncline_end = read_processor_time() + vsynctimeperline;
+ // linecounter = 0;
+ // }
+ // }
+ // }
+ //}
+ //maybe_process_pull_audio();
+ }
+ }
+ else if (!currprefs.cpu_thread) {
+ static int nextwaitvpos;
+ if (vpos == 0)
+ nextwaitvpos = maxvpos_display * 1 / 4;
+ //if (audio_is_pull() > 0 && !currprefs.turbo_emulation) {
+ // maybe_process_pull_audio();
+ // frame_time_t rpt = read_processor_time();
+ // while (audio_pull_buffer() > 1 && (!isvsync() || (!vsync_isdone() && (int)vsyncmintime - (int)(rpt + vsynctimebase / 10) > 0 && (int)vsyncmintime - (int)rpt < vsynctimebase))) {
+ // cpu_sleep_millis(1);
+ // maybe_process_pull_audio();
+ // rpt = read_processor_time();
+ // }
+ //}
+ if (vpos + 1 < maxvpos + lof_store
+ && vpos >= nextwaitvpos && vpos < maxvpos - (maxvpos / 3)
+ //&& (audio_is_pull() <= 0 || (audio_is_pull() > 0
+ // && audio_pull_buffer()))
+ )
+ {
+ nextwaitvpos += maxvpos_display * 1 / 3;
+ vsyncmintime += vsynctimeperline;
+ //if (!vsync_isdone() && !currprefs.turbo_emulation) {
+ // frame_time_t rpt = read_processor_time();
+ // // sleep if more than 2ms "free" time
+ // while (!vsync_isdone() && (int)vsyncmintime - (int)(rpt + vsynctimebase / 10) > 0 && (int)vsyncmintime - (int)rpt < vsynctimebase) {
+ // maybe_process_pull_audio();
+ // if (!execute_other_cpu(rpt + vsynctimebase / 10)) {
+ // if (cpu_sleep_millis(1) < 0)
+ // break;
+ // }
+ // rpt = read_processor_time();
+ // //write_log (_T("*"));
+ // }
+ //}
+ }
+ }
+
+ if (!nocustom()) {
+ int lineno = vpos;
if (lineno >= MAXVPOS)
lineno %= MAXVPOS;
- prev_lineno = next_lineno;
- next_lineno = lineno;
- reset_decisions ();
- }
+ nextline_how = nln_normal;
+ if (doflickerfix() && interlace_seen > 0) {
+ lineno *= 2;
+ }
+ else if (!interlace_seen && doublescan <= 0 && currprefs.gfx_vresolution && currprefs.gfx_pscanlines > 1) {
+ lineno *= 2;
+ if (timeframes & 1) {
+ lineno++;
+ nextline_how = currprefs.gfx_pscanlines == 3 ? nln_lower_black_always : nln_lower_black;
+ }
+ else {
+ nextline_how = currprefs.gfx_pscanlines == 3 ? nln_upper_black_always : nln_upper_black;
+ }
+ }
+ else if ((doublescan <= 0 || interlace_seen > 0) && currprefs.gfx_vresolution && currprefs.gfx_iscanlines) {
+ lineno *= 2;
+ if (interlace_seen) {
+ if (!lof_current) {
+ lineno++;
+ nextline_how = currprefs.gfx_iscanlines == 2 ? nln_lower_black_always : nln_lower_black;
+ }
+ else {
+ nextline_how = currprefs.gfx_iscanlines == 2 ? nln_upper_black_always : nln_upper_black;
+ }
+ }
+ else {
+ nextline_how = currprefs.gfx_vresolution > VRES_NONDOUBLE && currprefs.gfx_pscanlines == 1 ? nln_nblack : nln_doubled;
+ }
+ }
+ else if (currprefs.gfx_vresolution && (doublescan <= 0 || interlace_seen > 0)) {
+ lineno *= 2;
+ if (interlace_seen) {
+ if (!lof_current) {
+ lineno++;
+ nextline_how = nln_lower;
+ }
+ else {
+ nextline_how = nln_upper;
+ }
+ }
+ else {
+ nextline_how = currprefs.gfx_vresolution > VRES_NONDOUBLE && currprefs.gfx_pscanlines == 1 ? nln_nblack : nln_doubled;
+ }
+ }
+ prev_lineno = next_lineno;
+ next_lineno = lineno;
+ reset_decisions();
+ }
rethink_uae_int();
/* Default to no bitplane DMA overriding sprite DMA */
plfstrt_sprite = 0xff;
- /* See if there's a chance of a copper wait ending this line. */
- cop_state.hpos = 0;
- compute_spcflag_copper (maxhpos);
+ /* See if there's a chance of a copper wait ending this line. */
+ cop_state.hpos = 0;
+ compute_spcflag_copper(maxhpos);
+
+ if (GET_PLANES(bplcon0) > 0 && dmaen(DMA_BITPLANE)) {
+ if (first_bplcon0 == 0)
+ first_bplcon0 = bplcon0;
+ if (vpos > last_planes_vpos)
+ last_planes_vpos = vpos;
+ if (vpos >= minfirstline && first_planes_vpos == 0) {
+ first_planes_vpos = vpos > minfirstline ? vpos - 1 : vpos;
+ }
+ else if (vpos >= current_maxvpos() - 1) {
+ last_planes_vpos = current_maxvpos();
+ }
+ }
+ if (diw_change == 0) {
+ if (vpos >= first_planes_vpos && vpos <= last_planes_vpos) {
+ if (diwlastword > diwlastword_total) {
+ diwlastword_total = diwlastword;
+ if (diwlastword_total > coord_diw_to_window_x(hsyncstartpos * 2))
+ diwlastword_total = coord_diw_to_window_x(hsyncstartpos * 2);
+ }
+ if (diwfirstword < diwfirstword_total) {
+ diwfirstword_total = diwfirstword;
+ if (diwfirstword_total < coord_diw_to_window_x(hsyncendpos * 2))
+ diwfirstword_total = coord_diw_to_window_x(hsyncendpos * 2);
+ firstword_bplcon1 = bplcon1;
+ }
+ }
+ if (diwstate == DIW_waiting_stop) {
+ int f = 8 << fetchmode;
+ if (plfstrt + f < ddffirstword_total + f)
+ ddffirstword_total = plfstrt + f;
+ if (plfstop + 2 * f > ddflastword_total + 2 * f)
+ ddflastword_total = plfstop + 2 * f;
+ }
+ if ((plffirstline < plffirstline_total || (plffirstline_total == minfirstline && vpos > minfirstline)) && plffirstline < vpos / 2) {
+ firstword_bplcon1 = bplcon1;
+ if (plffirstline < minfirstline)
+ plffirstline_total = minfirstline;
+ else
+ plffirstline_total = plffirstline;
+ }
+ if (plflastline > plflastline_total && plflastline > plffirstline_total && plflastline > maxvpos / 2)
+ plflastline_total = plflastline;
+ }
+ if (diw_change > 0)
+ diw_change--;
/* fastest possible + last line and no vflip wait: render the frame as early as possible */
- if (is_last_line () && isvsync_chipset () > 0 && !vsync_rendered) {
+ if (is_last_line() && isvsync_chipset() <= -2 && !vsync_rendered && currprefs.gfx_apmode[0].gfx_vflip == 0) {
frame_time_t start, end;
- start = read_processor_time ();
+ start = read_processor_time();
vsync_rendered = true;
- vsync_handle_redraw ();
- frame_rendered = render_screen (true);
- end = read_processor_time ();
+ vsync_handle_redraw(lof_store, lof_changed, bplcon0, bplcon3);
+ //if (vblank_hz_state) {
+ // updatedisplayarea();
+ // frame_rendered = true;
+ //}
+ end = read_processor_time();
frameskiptime += end - start;
}
+
+ rtg_vsynccheck();
}
-static void init_regtypes (void)
+static void hsync_handler(void)
{
- int i;
- for (i = 0; i < 512; i += 2) {
- regtypes[i] = REGTYPE_ALL;
- if ((i >= 0x20 && i < 0x26) || i == 0x7E)
- regtypes[i] = REGTYPE_DISK;
- else if (i >= 0x68 && i < 0x70)
- regtypes[i] = REGTYPE_NONE;
- else if (i >= 0x40 && i < 0x76)
- regtypes[i] = REGTYPE_BLITTER;
- else if (i >= 0xA0 && i < 0xE0 && (i & 0xF) < 0xC)
- regtypes[i] = REGTYPE_AUDIO;
- else if ((i >= 0xA0 && i < 0xE0) || (i >= 0x1C0 && i < 0x1E4) || (i >= 0x1E6 && i < 0x1FC))
- regtypes[i] = REGTYPE_NONE;
- else if ((i >= 0xE0 && i < 0x100) || (i >= 0x110 && i < 0x120))
- regtypes[i] = REGTYPE_PLANE;
- else if (i >= 0x120 && i < 0x180)
- regtypes[i] = REGTYPE_SPRITE;
- else if (i >= 0x180 && i < 0x1C0)
- regtypes[i] = REGTYPE_COLOR;
- else switch (i) {
- case 0x00:
- case 0x08:
- case 0x18:
- case 0x26: case 0x28:
- case 0x30: case 0x32:
- case 0x38: case 0x3A: case 0x3C: case 0x3E:
- case 0x76: case 0x78: case 0x7A: case 0x7C:
- case 0x8C:
- case 0x1FE:
- regtypes[i] = REGTYPE_NONE;
- break;
- case 0x02:
- /* DMACONR - setting this to REGTYPE_BLITTER will cause it to
- conflict with DMACON (since that is REGTYPE_ALL), and the
- blitter registers (for the BBUSY bit), but nothing else,
- which is (I think) what we want. */
- regtypes[i] = REGTYPE_BLITTER;
- break;
- case 0x04: case 0x06: case 0x2A: case 0x2C:
- case 0x0A: case 0x0C: /* Mouse position is calculated with vpos */
- regtypes[i] = REGTYPE_POS;
- break;
- case 0x0E:
- regtypes[i] = REGTYPE_SPRITE;
- break;
- case 0x10: case 0x9E:
- regtypes[i] = REGTYPE_AUDIO | REGTYPE_DISK;
- break;
- case 0x12: case 0x14: case 0x16:
- case 0x34: case 0x36:
- regtypes[i] = REGTYPE_JOYPORT;
- break;
- case 0x1A:
- regtypes[i] = REGTYPE_DISK;
- break;
- case 0x102: case 0x104: case 0x106: case 0x108:
- case 0x10A:
- regtypes[i] = REGTYPE_PLANE;
- break;
- case 0x10C:
- regtypes[i] = REGTYPE_PLANE | REGTYPE_SPRITE;
- break;
- case 0x88: case 0x8A:
- case 0x8E: case 0x90: case 0x92: case 0x94:
- case 0x96:
- case 0x100:
- case 0x1FC:
- regtypes[i] |= REGTYPE_FORCE;
- break;
- }
- }
-}
-
-static void hsync_handler (void)
-{
- bool vs = is_custom_vsync ();
- hsync_handler_pre (vs);
+ bool vs = is_custom_vsync();
+ hsync_handler_pre(vs);
if (vs) {
- vsync_handler_pre ();
- if (savestate_check ()) {
- uae_reset (0, 0);
+ vsync_handler_pre();
+ if (savestate_check()) {
+ uae_reset(0, 0);
return;
}
}
- hsync_handler_post (vs);
+ hsync_handler_post(vs);
}
-void init_eventtab (void)
+void init_eventtab(void)
{
int i;
-
- nextevent = 0;
+
+ nextevent = 0;
for (i = 0; i < ev_max; i++) {
- eventtab[i].active = 0;
- eventtab[i].oldcycles = get_cycles ();
+ eventtab[i].active = false;
+ eventtab[i].oldcycles = get_cycles();
}
- for (i = 0; i < ev2_max; i++) {
- eventtab2[i].active = 0;
+ for (i = 0; i < ev2_max; i++) {
+ eventtab2[i].active = 0;
}
-
+
eventtab[ev_cia].handler = CIA_handler;
eventtab[ev_hsync].handler = hsync_handler;
- eventtab[ev_hsync].evtime = get_cycles () + HSYNCTIME;
- eventtab[ev_hsync].active = 1;
- eventtab[ev_copper].handler = copper_handler;
- eventtab[ev_copper].active = 0;
- eventtab[ev_misc].handler = MISC_handler;
+ eventtab[ev_hsync].evtime = get_cycles() + HSYNCTIME;
+ eventtab[ev_hsync].active = true;
+ eventtab[ev_misc].handler = MISC_handler;
eventtab[ev_audio].handler = audio_evhandler;
- eventtab[ev_blitter].handler = blitter_handler;
- eventtab[ev_dmal].handler = dmal_func2;
+ eventtab2[ev2_blitter].handler = blitter_handler;
+ eventtab2[ev2_disk].handler = DISK_handler;
- eventtab2[ev2_disk].handler = DISK_handler;
- eventtab2[ev2_ciaa_tod].handler = CIAA_tod_handler;
- eventtab2[ev2_ciab_tod].handler = CIAB_tod_inc_event;
- eventtab2[ev2_disk_motor0].handler = DISK_motordelay_func;
- eventtab2[ev2_disk_motor1].handler = DISK_motordelay_func;
- eventtab2[ev2_disk_motor2].handler = DISK_motordelay_func;
- eventtab2[ev2_disk_motor3].handler = DISK_motordelay_func;
-
- events_schedule ();
+ events_schedule();
}
-void custom_prepare (void)
+void custom_prepare(void)
{
- set_hpos ();
- hsync_handler_post (true);
+ set_hpos();
+ hsync_handler_post(true);
}
-void custom_reset (bool hardreset, bool keyboardreset)
+void custom_reset(bool hardreset, bool keyboardreset)
{
- target_reset ();
- reset_all_systems ();
- write_log (_T("Reset at %08X. Chipset mask = %08X\n"), M68K_GETPC, currprefs.chipset_mask);
+ int i;
+ target_reset();
+ reset_all_systems();
+ //write_log(_T("Reset at %08X. Chipset mask = %08X\n"), M68K_GETPC, currprefs.chipset_mask);
+ //memory_map_dump();
+
+ //lightpen_active = -1;
+ //lightpen_triggered = 0;
+ //lightpen_cx = lightpen_cy = -1;
nr_armed = 0;
- if (! savestate_state) {
+ if (!savestate_state) {
cia_hsync = 0;
- hsync_counter = 0;
+ extra_cycle = 0;
+ hsync_counter = 0;
+ vsync_counter = 0;
currprefs.chipset_mask = changed_prefs.chipset_mask;
- update_mirrors();
+ update_mirrors();
+ blitter_reset();
if (hardreset) {
- if (!aga_mode) {
- uae_u16 c = ((currprefs.chipset_mask & CSMASK_ECS_DENISE) && !(currprefs.chipset_mask & CSMASK_AGA)) ? 0xfff : 0x000;
- for (int i = 0; i < 32; i++) {
- current_colors.color_regs_ecs[i] = c;
- current_colors.acolors[i] = getxcolor (c);
- }
- } else {
+ if (!aga_mode) {
+ uae_u16 c = (((currprefs.chipset_mask & CSMASK_ECS_DENISE) && !(currprefs.chipset_mask & CSMASK_AGA)) || currprefs.cs_denisenoehb) ? 0xfff : 0x000;
+ for (i = 0; i < 32; i++) {
+ current_colors.color_regs_ecs[i] = c;
+ current_colors.acolors[i] = getxcolor(c);
+ }
+#ifdef AGA
+ }
+ else {
uae_u32 c = 0;
- for (int i = 0; i < 256; i++) {
- current_colors.color_regs_aga[i] = c;
- current_colors.acolors[i] = getxcolor (c);
- }
- }
- lof_store = lof_current = 0;
- lof_lace = false;
- }
+ for (i = 0; i < 256; i++) {
+ current_colors.color_regs_aga[i] = c;
+ current_colors.acolors[i] = getxcolor(c);
+ }
+#endif
+ }
+ lof_store = lof_current = 0;
+ lof_lace = false;
+ }
clxdat = 0;
-
+
/* Clear the armed flags of all sprites. */
- memset (spr, 0, sizeof spr);
-
+ memset(spr, 0, sizeof spr);
+
dmacon = 0;
- intreq = 0;
- intena = 0;
+ intreq_internal = 0;
+ intena = intena_internal = 0;
copcon = 0;
- DSKLEN (0, 0);
-
+ DSKLEN(0, 0);
+
bplcon0 = 0;
bplcon4 = 0x0011; /* Get AGA chipset into ECS compatibility mode */
bplcon3 = 0x0C00;
@@ -6143,134 +8162,190 @@ void custom_reset (bool hardreset, bool keyboardreset)
diwhigh = 0;
diwhigh_written = 0;
hdiwstate = DIW_waiting_start; // this does not reset at vblank
-
- FMODE (0, 0);
- CLXCON (0);
- CLXCON2 (0);
- setup_fmodes (0);
- sprite_width = GET_SPRITEWIDTH (fmode);
+
+ refptr = 0xffff;
+ FMODE(0, 0);
+ CLXCON(0);
+ CLXCON2(0);
+ setup_fmodes(0);
+ sprite_width = GET_SPRITEWIDTH(fmode);
beamcon0 = new_beamcon0 = currprefs.ntscmode ? 0x00 : 0x20;
bltstate = BLT_done;
blit_interrupt = 1;
- init_sprites ();
+ init_sprites();
}
-
- devices_reset(hardreset);
- unset_special (~(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE));
-
+ //gayle_reset(hardreset); //TODO
+#ifdef AUTOCONFIG
+ expamem_reset();
+#endif
+ //a1000_reset(); //TODO
+ DISK_reset();
+ CIA_reset();
+ //gayle_reset(0); //TODO
+#ifdef A2091
+ a2091_reset();
+#endif
+#ifdef GFXBOARD
+ gfxboard_reset();
+#endif
+#ifdef NCR
+ ncr_reset();
+#endif
+#ifdef JIT
+ compemu_reset();
+#endif
+ unset_special(~(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE));
+
vpos = 0;
vpos_count = vpos_count_diff = 0;
-
- inputdevice_reset();
- timehack_alive = 0;
-
- curr_sprite_entries[0].first_pixel = 0;
- curr_sprite_entries[1].first_pixel = 0;
- next_sprite_entry = 0;
- memset (spixels, 0, sizeof spixels);
- memset (&spixstate, 0, sizeof spixstate);
+
+ inputdevice_reset();
+ timehack_alive = 0;
+
+ curr_sprite_entries = nullptr;
+ prev_sprite_entries = nullptr;
+ sprite_entries[0][0].first_pixel = 0;
+ sprite_entries[1][0].first_pixel = MAX_SPR_PIXELS;
+ sprite_entries[0][1].first_pixel = 0;
+ sprite_entries[1][1].first_pixel = MAX_SPR_PIXELS;
+ memset(spixels, 0, 2 * MAX_SPR_PIXELS * sizeof *spixels);
+ memset(&spixstate, 0, sizeof spixstate);
toscr_delay_sh[0] = 0;
toscr_delay_sh[1] = 0;
-
+
cop_state.state = COP_stop;
cop_state.movedelay = 0;
cop_state.strobe = 0;
cop_state.ignore_next = 0;
diwstate = DIW_waiting_start;
-
+
dmal = 0;
- new_beamcon0 = currprefs.ntscmode ? 0x00 : 0x20;
- time_per_frame = 1000 * 1000 / (currprefs.ntscmode ? 60 : 50);
init_hz_normal();
// init_hz sets vpos_count
vpos_count = 0;
+ vpos_lpen = -1;
lof_changing = 0;
lof_togglecnt_nlace = lof_togglecnt_lace = 0;
-
- audio_reset ();
- if (!isrestore ()) {
- /* must be called after audio_reset */
- adkcon = 0;
- audio_update_adkmasks ();
- }
-
- init_hardware_frame ();
- drawing_init ();
-
- reset_decisions ();
-
- init_regtypes ();
+ //nlace_cnt = NLACE_CNT_NEEDED;
- if (isrestore ()) {
+ audio_reset();
+ if (!isrestore()) {
+ /* must be called after audio_reset */
+ adkcon = 0;
+ //serial_uartbreak(0);
+ audio_update_adkmasks();
+ }
+
+ init_hardware_frame();
+ drawing_init();
+
+ reset_decisions();
+
+ bogusframe = 1;
+
+ if (isrestore()) {
uae_u16 v;
uae_u32 vv;
-
- audio_update_adkmasks ();
- INTENA (0);
- INTREQ (0);
-
- if (diwhigh)
- diwhigh_written = 1;
- else
- diwhigh_written = 0;
- COPJMP (1, 1);
+
+ audio_update_adkmasks();
+ INTENA(0);
+ INTREQ(0);
+ COPJMP(1, 1);
v = bplcon0;
- BPLCON0 (0, 0);
- BPLCON0 (0, v);
- FMODE (0, fmode);
-
+ BPLCON0(0, 0);
+ BPLCON0(0, v);
+ FMODE(0, fmode);
if (!(currprefs.chipset_mask & CSMASK_AGA)) {
- for(int i = 0 ; i < 32 ; i++) {
+ for (i = 0; i < 32; i++) {
vv = current_colors.color_regs_ecs[i];
- current_colors.color_regs_ecs[i] = (unsigned short)-1;
- record_color_change (0, i, vv);
+ current_colors.color_regs_ecs[i] = -1;
+ record_color_change(0, i, vv);
remembered_color_entry = -1;
current_colors.color_regs_ecs[i] = vv;
current_colors.acolors[i] = xcolors[vv];
}
- } else {
- for(int i = 0 ; i < 256 ; i++) {
+#ifdef AGA
+ }
+ else {
+ for (i = 0; i < 256; i++) {
vv = current_colors.color_regs_aga[i];
current_colors.color_regs_aga[i] = -1;
- record_color_change (0, i, vv);
+ record_color_change(0, i, vv);
remembered_color_entry = -1;
current_colors.color_regs_aga[i] = vv;
current_colors.acolors[i] = CONVERT_RGB(vv);
}
+#endif
}
- CLXCON (clxcon);
- CLXCON2 (clxcon2);
- calcdiw ();
- for (int i = 0; i < 8; i++) {
- SPRxCTLPOS (i);
+ CLXCON(clxcon);
+ CLXCON2(clxcon2);
+ calcdiw();
+ //v = serper;
+ //serper = 0;
+ //SERPER(v);
+ for (i = 0; i < 8; i++) {
+ SPRxCTLPOS(i);
nr_armed += spr[i].armed != 0;
}
- if (! currprefs.produce_sound) {
- eventtab[ev_audio].active = 0;
- events_schedule ();
- }
+ if (!currprefs.produce_sound) {
+ eventtab[ev_audio].active = false;
+ events_schedule();
+ }
+
+ //write_log(_T("CPU=%d Chipset=%s %s\n"),
+ // currprefs.cpu_model,
+ // (currprefs.chipset_mask & CSMASK_AGA) ? _T("AGA") :
+ // (currprefs.chipset_mask & (CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE)) == (CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE) ? _T("Full ECS") :
+ // (currprefs.chipset_mask & CSMASK_ECS_DENISE) ? _T("ECS Denise") :
+ // (currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? _T("ECS") :
+ // _T("OCS"), currprefs.ntscmode ? _T("NTSC") : _T("PAL"));
+ //write_log(_T("State restored\n"));
}
- sprres = expand_sprres (bplcon0, bplcon3);
- sprite_width = GET_SPRITEWIDTH (fmode);
- setup_fmodes (0);
+ sprres = expand_sprres(bplcon0, bplcon3);
+ sprite_width = GET_SPRITEWIDTH(fmode);
+ setup_fmodes(0);
+ shdelay_disabled = false;
#ifdef ACTION_REPLAY
/* Doing this here ensures we can use the 'reset' command from within AR */
- action_replay_reset (hardreset, keyboardreset);
+ action_replay_reset(hardreset, keyboardreset);
+#endif
+#if defined(ENFORCER)
+ enforcer_disable();
#endif
- if (hardreset)
- rtc_hardreset();
+ if (hardreset)
+ rtc_hardreset();
#ifdef PICASSO96
- picasso_reset ();
+ picasso_reset();
#endif
}
-static void gen_custom_tables (void)
+//void dumpcustom(void)
+//{
+// write_log(_T("DMACON: %04x INTENA: %04x (%04x) INTREQ: %04x (%04x) VPOS: %x HPOS: %x\n"), DMACONR(current_hpos()),
+// intena, intena_internal, intreq, intreq_internal, vpos, current_hpos());
+// write_log(_T("COP1LC: %08lx, COP2LC: %08lx COPPTR: %08lx\n"), (unsigned long)cop1lc, (unsigned long)cop2lc, cop_state.ip);
+// write_log(_T("DIWSTRT: %04x DIWSTOP: %04x DDFSTRT: %04x DDFSTOP: %04x\n"),
+// (unsigned int)diwstrt, (unsigned int)diwstop, (unsigned int)ddfstrt, (unsigned int)ddfstop);
+// write_log(_T("BPLCON 0: %04x 1: %04x 2: %04x 3: %04x 4: %04x LOF=%d/%d HDIW=%d VDIW=%d\n"),
+// bplcon0, bplcon1, bplcon2, bplcon3, bplcon4,
+// lof_current, lof_store,
+// hdiwstate == DIW_waiting_start ? 0 : 1, diwstate == DIW_waiting_start ? 0 : 1);
+// if (timeframes) {
+// write_log(_T("Average frame time: %.2f ms [frames: %d time: %d]\n"),
+// double(frametime) / timeframes, timeframes, frametime);
+// if (total_skipped)
+// write_log(_T("Skipped frames: %d\n"), total_skipped);
+// }
+//}
+
+static void gen_custom_tables(void)
{
- for (int i = 0; i < 256; i++) {
+ int i;
+ for (i = 0; i < 256; i++) {
sprtaba[i] = ((((i >> 7) & 1) << 0)
| (((i >> 6) & 1) << 2)
| (((i >> 5) & 1) << 4)
@@ -6279,11 +8354,11 @@ static void gen_custom_tables (void)
| (((i >> 2) & 1) << 10)
| (((i >> 1) & 1) << 12)
| (((i >> 0) & 1) << 14));
- sprtabb[i] = sprtaba[i] * 2;
+ sprtabb[i] = sprtaba[i] * 2;
sprite_ab_merge[i] = (((i & 15) ? 1 : 0)
| ((i & 240) ? 2 : 0));
}
- for (int i = 0; i < 16; i++) {
+ for (i = 0; i < 16; i++) {
clxmask[i] = (((i & 1) ? 0xF : 0x3)
| ((i & 2) ? 0xF0 : 0x30)
| ((i & 4) ? 0xF00 : 0x300)
@@ -6297,490 +8372,510 @@ static void gen_custom_tables (void)
}
}
-static int allocate_sprite_tables (void)
+/* mousehack is now in "filesys boot rom" */
+static uae_u32 REGPARAM2 mousehack_helper_old(struct TrapContext *ctx)
{
- if(curr_sprite_entries == 0)
- curr_sprite_entries = xmalloc (struct sprite_entry, MAX_SPR_PIXELS / 16);
- if(curr_color_changes == 0)
- curr_color_changes = xmalloc (struct color_change, MAX_REG_CHANGE);
-
- return 1;
+ return 0;
}
-int custom_init (void)
+int custom_init(void)
{
- if (!allocate_sprite_tables())
- return 0;
#ifdef AUTOCONFIG
if (uae_boot_rom_type) {
- uaecptr pos;
- pos = here ();
+ uaecptr pos;
+ pos = here();
- org (rtarea_base + 0xFFA0);
- calltrap (deftrap (timehack_helper));
- dw (RTS);
+ org(rtarea_base + 0xFF70);
+ calltrap(deftrap(mousehack_helper_old));
+ dw(RTS);
- org (pos);
- }
+ org(rtarea_base + 0xFFA0);
+ calltrap(deftrap(timehack_helper));
+ dw(RTS);
+
+ org(pos);
+ }
#endif
- gen_custom_tables ();
- build_blitfilltable ();
+ gen_custom_tables();
+ build_blitfilltable();
- next_sprite_entry = 0;
- drawing_init ();
+ drawing_init();
- create_cycle_diagram_table ();
+ create_cycle_diagram_table();
- return 1;
+ return 1;
}
/* Custom chip memory bank */
-static uae_u32 REGPARAM3 custom_lget (uaecptr) REGPARAM;
-static uae_u32 REGPARAM3 custom_wget (uaecptr) REGPARAM;
-static uae_u32 REGPARAM3 custom_bget (uaecptr) REGPARAM;
-static uae_u32 REGPARAM3 custom_lgeti (uaecptr) REGPARAM;
-static uae_u32 REGPARAM3 custom_wgeti (uaecptr) REGPARAM;
-static void REGPARAM3 custom_lput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 custom_wput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 custom_bput (uaecptr, uae_u32) REGPARAM;
+static uae_u32 REGPARAM3 custom_lget(uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 custom_wget(uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 custom_bget(uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 custom_lgeti(uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 custom_wgeti(uaecptr) REGPARAM;
+static void REGPARAM3 custom_lput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 custom_wput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 custom_bput(uaecptr, uae_u32) REGPARAM;
addrbank custom_bank = {
- custom_lget, custom_wget, custom_bget,
- custom_lput, custom_wput, custom_bput,
- default_xlate, default_check, NULL, NULL, _T("Custom chipset"),
+ custom_lget, custom_wget, custom_bget,
+ custom_lput, custom_wput, custom_bput,
+ default_xlate, default_check, nullptr, nullptr, _T("Custom chipset"),
custom_lgeti, custom_wgeti,
- ABFLAG_IO, S_READ, S_WRITE, NULL, 0x1ff, 0xdff000
+ ABFLAG_IO, S_READ, S_WRITE, nullptr, 0x1ff, 0xdff000
};
-static uae_u32 REGPARAM2 custom_wgeti (uaecptr addr)
+static uae_u32 REGPARAM2 custom_wgeti(uaecptr addr)
{
- if (currprefs.cpu_model >= 68020)
- return dummy_wgeti(addr);
- return custom_wget(addr);
+ if (currprefs.cpu_model >= 68020)
+ return dummy_wgeti(addr);
+ return custom_wget(addr);
}
-static uae_u32 REGPARAM2 custom_lgeti (uaecptr addr)
+static uae_u32 REGPARAM2 custom_lgeti(uaecptr addr)
{
- if (currprefs.cpu_model >= 68020)
- return dummy_lgeti(addr);
- return custom_lget(addr);
+ if (currprefs.cpu_model >= 68020)
+ return dummy_lgeti(addr);
+ return custom_lget(addr);
}
-STATIC_INLINE uae_u32 REGPARAM2 custom_wget_1 (uaecptr addr, int noput)
+static uae_u32 REGPARAM2 custom_wget_1(int hpos, uaecptr addr, int noput, bool isbyte)
{
- uae_u16 v;
+ uae_u16 v;
int missing;
addr &= 0xfff;
- switch (addr & 0x1fe) {
- case 0x000: v = 0xffff; break; /* BPLDDAT */
- case 0x002: v = DMACONR (current_hpos ()); break;
- case 0x004: v = VPOSR (); break;
- case 0x006: v = VHPOSR (); break;
- case 0x008: v = 0xffff; break;
+ switch (addr & 0x1fe) {
+ case 0x002: v = DMACONR(hpos); break;
+ case 0x004: v = VPOSR(); break;
+ case 0x006: v = VHPOSR(); break;
- case 0x00A: v = JOY0DAT (); break;
- case 0x00C: v = JOY1DAT (); break;
- case 0x00E: v = CLXDAT (); break;
- case 0x010: v = ADKCONR (); break;
+ case 0x00A: v = JOY0DAT(); break;
+ case 0x00C: v = JOY1DAT(); break;
+ case 0x00E: v = CLXDAT(); break;
+ case 0x010: v = ADKCONR(); break;
- case 0x012: v = POT0DAT (); break;
- case 0x014: v = POT1DAT (); break;
- case 0x016: v = POTGOR (); break;
- case 0x018: v = 0x3000 /* no data */; break;
- case 0x01A: v = DSKBYTR (current_hpos ()); break;
- case 0x01C: v = INTENAR (); break;
- case 0x01E: v = INTREQR (); break;
- case 0x07C:
- v = DENISEID (&missing);
- if (missing)
- goto writeonly;
- break;
+ case 0x012: v = POT0DAT(); break;
+ case 0x014: v = POT1DAT(); break;
+ case 0x016: v = POTGOR(); break;
+ //case 0x018: v = SERDATR(); break;
+ case 0x01A: v = DSKBYTR(hpos); break;
+ case 0x01C: v = INTENAR(); break;
+ case 0x01E: v = INTREQR(); break;
+ case 0x07C:
+ v = DENISEID(&missing);
+ if (missing)
+ goto writeonly;
+ break;
- case 0x180: case 0x182: case 0x184: case 0x186: case 0x188: case 0x18A:
- case 0x18C: case 0x18E: case 0x190: case 0x192: case 0x194: case 0x196:
- case 0x198: case 0x19A: case 0x19C: case 0x19E: case 0x1A0: case 0x1A2:
- case 0x1A4: case 0x1A6: case 0x1A8: case 0x1AA: case 0x1AC: case 0x1AE:
- case 0x1B0: case 0x1B2: case 0x1B4: case 0x1B6: case 0x1B8: case 0x1BA:
- case 0x1BC: case 0x1BE:
- if (!(aga_mode))
- goto writeonly;
- v = COLOR_READ ((addr & 0x3E) / 2);
- break;
+#ifdef AGA
+ case 0x180: case 0x182: case 0x184: case 0x186: case 0x188: case 0x18A:
+ case 0x18C: case 0x18E: case 0x190: case 0x192: case 0x194: case 0x196:
+ case 0x198: case 0x19A: case 0x19C: case 0x19E: case 0x1A0: case 0x1A2:
+ case 0x1A4: case 0x1A6: case 0x1A8: case 0x1AA: case 0x1AC: case 0x1AE:
+ case 0x1B0: case 0x1B2: case 0x1B4: case 0x1B6: case 0x1B8: case 0x1BA:
+ case 0x1BC: case 0x1BE:
+ if (!(currprefs.chipset_mask & CSMASK_AGA))
+ goto writeonly;
+ v = COLOR_READ((addr & 0x3E) / 2);
+ break;
+#endif
- default:
-writeonly:
- /* OCS/ECS:
- * reading write-only register causes write with last value in chip
- * bus (custom registers, chipram, slowram)
- * and finally returns either all ones or something weird if DMA happens
- * in next (or previous) cycle.. FIXME.
- *
- * OCS-only special case: DFF000 (BLTDDAT) will always return whatever was left in bus
- *
- * AGA:
- * Can also return last CPU accessed value
- * Remembers old last_custom_value1
- */
- v = last_custom_value1;
- SET_LINE_CYCLEBASED;
- if (!noput) {
- int bmdma;
- uae_u16 l;
- int hpos = current_hpos ();
+ default:
+ writeonly:
+ /* OCS/ECS:
+ * reading write-only register causes write with last value in chip
+ * bus (custom registers, chipram, slowram)
+ * and finally returns either all ones or something weird if DMA happens
+ * in next (or previous) cycle.. FIXME.
+ *
+ * OCS-only special case: DFF000 (BLTDDAT) will always return whatever was left in bus
+ *
+ * AGA:
+ * Can also return last CPU accessed value
+ * Remembers old last_custom_value1
+ */
+ v = last_custom_value1;
+ SET_LINE_CYCLEBASED;
+ if (!noput) {
+ int r, c, bmdma;
+ uae_u16 l;
- if (aga_mode) {
- l = 0;
- } else {
- l = currprefs.cpu_compatible && currprefs.cpu_model == 68000 ? regs.irc : 0xffff;
- }
- decide_line (hpos);
- decide_fetch_safe (hpos);
- custom_wput_1 (hpos, addr, l, 1);
+ if (currprefs.chipset_mask & CSMASK_AGA) {
+ l = 0;
+ }
+ else {
+ // last chip bus value (read or write) is written to register
+ if (currprefs.cpu_compatible && currprefs.cpu_model == 68000) {
+ if (isbyte)
+ l = (regs.chipset_latch_rw << 8) | (regs.chipset_latch_rw & 0xff);
+ else
+ l = regs.chipset_latch_rw;
+ }
+ else {
+ l = regs.chipset_latch_rw;
+ }
+ }
+ decide_line(hpos);
+ decide_fetch_safe(hpos);
+ //debug_wputpeek(0xdff000 + addr, l);
+ r = custom_wput_1(hpos, addr, l, 1);
- // CPU gets back (OCS/ECS only):
- // - if last cycle was DMA cycle: DMA cycle data
- // - if last cycle was not DMA cycle: FFFF or some ANDed old data.
- //
- bmdma = is_bitplane_dma(hpos);
- if (aga_mode) {
- if (bmdma) {
- v = last_custom_value1;
- } else {
- v = last_custom_value1 >> ((addr & 2) ? 0 : 16);
- }
- } else {
- if (bmdma) {
- v = last_custom_value1;
- } else {
- // refresh checked because refresh cycles do not always
- // set last_custom_value1 for performance reasons.
- v = 0xffff;
- }
- }
- return v;
+ // CPU gets back (OCS/ECS only):
+ // - if last cycle was DMA cycle: DMA cycle data
+ // - if last cycle was not DMA cycle: FFFF or some ANDed old data.
+ //
+#ifdef CPUEMU_13
+ c = cycle_line[hpos] & CYCLE_MASK;
+ bmdma = is_bitplane_dma(hpos);
+ if (currprefs.chipset_mask & CSMASK_AGA) {
+ if (bmdma || (c > CYCLE_REFRESH && c < CYCLE_CPU)) {
+ v = last_custom_value1;
+ }
+ else if (c == CYCLE_CPU) {
+ v = regs.db;
+ }
+ else {
+ v = last_custom_value1 >> ((addr & 2) ? 0 : 16);
+ }
+ }
+ else {
+ if (bmdma || (c > CYCLE_REFRESH && c < CYCLE_CPU)) {
+ v = last_custom_value1;
+ }
+ else {
+ // refresh checked because refresh cycles do not always
+ // set last_custom_value1 for performance reasons.
+ v = 0xffff;
+ }
+ }
+#endif
+ return v;
}
- }
- return v;
+ }
+ return v;
}
-STATIC_INLINE uae_u32 custom_wget2 (uaecptr addr)
+static uae_u32 custom_wget2(uaecptr addr, bool byte)
{
- uae_u32 v;
- int hpos = current_hpos ();
+ uae_u32 v;
+ int hpos = current_hpos();
- sync_copper_with_cpu (hpos, 1, addr);
- v = custom_wget_1 (addr, 0);
-#ifdef ACTION_REPLAY
-#ifdef ACTION_REPLAY_COMMON
- addr &= 0x1ff;
- ar_custom[addr + 0] = (uae_u8)(v >> 8);
- ar_custom[addr + 1] = (uae_u8)(v);
-#endif
-#endif
- return v;
+ sync_copper_with_cpu(hpos, 1);
+ v = custom_wget_1(hpos, addr, 0, byte);
+ return v;
}
-static uae_u32 REGPARAM2 custom_wget (uaecptr addr)
+static uae_u32 REGPARAM2 custom_wget(uaecptr addr)
{
- uae_u32 v;
+ uae_u32 v;
if ((addr & 0xffff) < 0x8000 && currprefs.cs_fatgaryrev >= 0)
return dummy_get(addr, 2, false, 0);
- if (addr & 1) {
- /* think about move.w $dff005,d0.. (68020+ only) */
- addr &= ~1;
- v = custom_wget2 (addr) << 8;
- v |= custom_wget2 (addr + 2) >> 8;
- return v & 0xFFFF;
- }
- return custom_wget2 (addr);
+ if (addr & 1) {
+ /* think about move.w $dff005,d0.. (68020+ only) */
+ addr &= ~1;
+ v = custom_wget2(addr, false) << 8;
+ v |= custom_wget2(addr + 2, false) >> 8;
+ return v;
+ }
+ return custom_wget2(addr, false);
}
-static uae_u32 REGPARAM2 custom_bget (uaecptr addr)
+static uae_u32 REGPARAM2 custom_bget(uaecptr addr)
{
uae_u32 v;
if ((addr & 0xffff) < 0x8000 && currprefs.cs_fatgaryrev >= 0)
return dummy_get(addr, 1, false, 0);
- v = custom_wget2 (addr & ~1);
- v >>= (addr & 1 ? 0 : 8);
- return v & 0xFF;
+ v = custom_wget2(addr & ~1, true);
+ v >>= (addr & 1 ? 0 : 8);
+ return v;
}
-static uae_u32 REGPARAM2 custom_lget (uaecptr addr)
+static uae_u32 REGPARAM2 custom_lget(uaecptr addr)
{
if ((addr & 0xffff) < 0x8000 && currprefs.cs_fatgaryrev >= 0)
return dummy_get(addr, 4, false, 0);
- return ((uae_u32)custom_wget (addr) << 16) | custom_wget (addr + 2);
+ return (uae_u32(custom_wget(addr)) << 16) | custom_wget(addr + 2);
}
-static int REGPARAM2 custom_wput_1 (int hpos, uaecptr addr, uae_u32 value, int noget)
+static int REGPARAM2 custom_wput_1(int hpos, uaecptr addr, uae_u32 value, int noget)
{
- addr &= 0x1FE;
- value &= 0xffff;
-#ifdef ACTION_REPLAY
-#ifdef ACTION_REPLAY_COMMON
- ar_custom[addr+0]=(uae_u8)(value>>8);
- ar_custom[addr+1]=(uae_u8)(value);
+ addr &= 0x1FE;
+ value &= 0xffff;
+
+ switch (addr) {
+ case 0x00E: CLXDAT(); break;
+
+ case 0x020: DSKPTH(value); break;
+ case 0x022: DSKPTL(value); break;
+ case 0x024: DSKLEN(value, hpos); break;
+ case 0x026: /* DSKDAT (value). Writing to DMA write registers won't do anything */; break;
+ case 0x028: REFPTR(value); break;
+ case 0x02A: VPOSW(value); break;
+ case 0x02C: VHPOSW(value); break;
+ case 0x02E: COPCON(value); break;
+ //case 0x030: SERDAT(value); break;
+ //case 0x032: SERPER(value); break;
+ case 0x034: POTGO(value); break;
+
+ case 0x040: BLTCON0(hpos, value); break;
+ case 0x042: BLTCON1(hpos, value); break;
+
+ case 0x044: BLTAFWM(hpos, value); break;
+ case 0x046: BLTALWM(hpos, value); break;
+
+ case 0x050: BLTAPTH(hpos, value); break;
+ case 0x052: BLTAPTL(hpos, value); break;
+ case 0x04C: BLTBPTH(hpos, value); break;
+ case 0x04E: BLTBPTL(hpos, value); break;
+ case 0x048: BLTCPTH(hpos, value); break;
+ case 0x04A: BLTCPTL(hpos, value); break;
+ case 0x054: BLTDPTH(hpos, value); break;
+ case 0x056: BLTDPTL(hpos, value); break;
+
+ case 0x058: BLTSIZE(hpos, value); break;
+
+ case 0x064: BLTAMOD(hpos, value); break;
+ case 0x062: BLTBMOD(hpos, value); break;
+ case 0x060: BLTCMOD(hpos, value); break;
+ case 0x066: BLTDMOD(hpos, value); break;
+
+ case 0x070: BLTCDAT(hpos, value); break;
+ case 0x072: BLTBDAT(hpos, value); break;
+ case 0x074: BLTADAT(hpos, value); break;
+
+ case 0x07E: DSKSYNC(hpos, value); break;
+
+ case 0x080: COP1LCH(value); break;
+ case 0x082: COP1LCL(value); break;
+ case 0x084: COP2LCH(value); break;
+ case 0x086: COP2LCL(value); break;
+
+ case 0x088: COPJMP(1, 0); break;
+ case 0x08A: COPJMP(2, 0); break;
+
+ case 0x08E: DIWSTRT(hpos, value); break;
+ case 0x090: DIWSTOP(hpos, value); break;
+ case 0x092: DDFSTRT(hpos, value); break;
+ case 0x094: DDFSTOP(hpos, value); break;
+
+ case 0x096: DMACON(hpos, value); break;
+ case 0x098: CLXCON(value); break;
+ case 0x09A: INTENA(value); break;
+ case 0x09C: INTREQ(value); break;
+ case 0x09E: ADKCON(hpos, value); break;
+
+ case 0x0A0: AUDxLCH(0, value); break;
+ case 0x0A2: AUDxLCL(0, value); break;
+ case 0x0A4: AUDxLEN(0, value); break;
+ case 0x0A6: AUDxPER(0, value); break;
+ case 0x0A8: AUDxVOL(0, value); break;
+ case 0x0AA: AUDxDAT(0, value); break;
+
+ case 0x0B0: AUDxLCH(1, value); break;
+ case 0x0B2: AUDxLCL(1, value); break;
+ case 0x0B4: AUDxLEN(1, value); break;
+ case 0x0B6: AUDxPER(1, value); break;
+ case 0x0B8: AUDxVOL(1, value); break;
+ case 0x0BA: AUDxDAT(1, value); break;
+
+ case 0x0C0: AUDxLCH(2, value); break;
+ case 0x0C2: AUDxLCL(2, value); break;
+ case 0x0C4: AUDxLEN(2, value); break;
+ case 0x0C6: AUDxPER(2, value); break;
+ case 0x0C8: AUDxVOL(2, value); break;
+ case 0x0CA: AUDxDAT(2, value); break;
+
+ case 0x0D0: AUDxLCH(3, value); break;
+ case 0x0D2: AUDxLCL(3, value); break;
+ case 0x0D4: AUDxLEN(3, value); break;
+ case 0x0D6: AUDxPER(3, value); break;
+ case 0x0D8: AUDxVOL(3, value); break;
+ case 0x0DA: AUDxDAT(3, value); break;
+
+ case 0x0E0: BPLxPTH(hpos, value, 0); break;
+ case 0x0E2: BPLxPTL(hpos, value, 0); break;
+ case 0x0E4: BPLxPTH(hpos, value, 1); break;
+ case 0x0E6: BPLxPTL(hpos, value, 1); break;
+ case 0x0E8: BPLxPTH(hpos, value, 2); break;
+ case 0x0EA: BPLxPTL(hpos, value, 2); break;
+ case 0x0EC: BPLxPTH(hpos, value, 3); break;
+ case 0x0EE: BPLxPTL(hpos, value, 3); break;
+ case 0x0F0: BPLxPTH(hpos, value, 4); break;
+ case 0x0F2: BPLxPTL(hpos, value, 4); break;
+ case 0x0F4: BPLxPTH(hpos, value, 5); break;
+ case 0x0F6: BPLxPTL(hpos, value, 5); break;
+ case 0x0F8: BPLxPTH(hpos, value, 6); break;
+ case 0x0FA: BPLxPTL(hpos, value, 6); break;
+ case 0x0FC: BPLxPTH(hpos, value, 7); break;
+ case 0x0FE: BPLxPTL(hpos, value, 7); break;
+
+ case 0x100: BPLCON0(hpos, value); break;
+ case 0x102: BPLCON1(hpos, value); break;
+ case 0x104: BPLCON2(hpos, value); break;
+#ifdef ECS_DENISE
+ case 0x106: BPLCON3(hpos, value); break;
#endif
+
+ case 0x108: BPL1MOD(hpos, value); break;
+ case 0x10A: BPL2MOD(hpos, value); break;
+#ifdef AGA
+ case 0x10E: CLXCON2(value); break;
#endif
- switch (addr) {
- case 0x00E: CLXDAT (); break;
- case 0x020: DSKPTH (value); break;
- case 0x022: DSKPTL (value); break;
- case 0x024: DSKLEN (value, hpos); break;
- case 0x026: /* DSKDAT (value). Writing to DMA write registers won't do anything */; break;
- case 0x028: break;
- case 0x02A: VPOSW (value); break;
- case 0x02C: VHPOSW (value); break;
- case 0x02E: COPCON (value); break;
- case 0x030: break;
- case 0x032: break;
- case 0x034: POTGO (value); break;
- case 0x036: JOYTEST (value); break;
+ case 0x110: BPLxDAT(hpos, 0, value); break;
+ case 0x112: BPLxDAT(hpos, 1, value); break;
+ case 0x114: BPLxDAT(hpos, 2, value); break;
+ case 0x116: BPLxDAT(hpos, 3, value); break;
+ case 0x118: BPLxDAT(hpos, 4, value); break;
+ case 0x11A: BPLxDAT(hpos, 5, value); break;
+ case 0x11C: BPLxDAT(hpos, 6, value); break;
+ case 0x11E: BPLxDAT(hpos, 7, value); break;
- case 0x040: BLTCON0 (value); break;
- case 0x042: BLTCON1 (value); break;
+ case 0x180: case 0x182: case 0x184: case 0x186: case 0x188: case 0x18A:
+ case 0x18C: case 0x18E: case 0x190: case 0x192: case 0x194: case 0x196:
+ case 0x198: case 0x19A: case 0x19C: case 0x19E: case 0x1A0: case 0x1A2:
+ case 0x1A4: case 0x1A6: case 0x1A8: case 0x1AA: case 0x1AC: case 0x1AE:
+ case 0x1B0: case 0x1B2: case 0x1B4: case 0x1B6: case 0x1B8: case 0x1BA:
+ case 0x1BC: case 0x1BE:
+ COLOR_WRITE(hpos, value & 0xFFF, (addr & 0x3E) / 2);
+ break;
+ case 0x120: case 0x124: case 0x128: case 0x12C:
+ case 0x130: case 0x134: case 0x138: case 0x13C:
+ SPRxPTH(hpos, value, (addr - 0x120) / 4);
+ break;
+ case 0x122: case 0x126: case 0x12A: case 0x12E:
+ case 0x132: case 0x136: case 0x13A: case 0x13E:
+ SPRxPTL(hpos, value, (addr - 0x122) / 4);
+ break;
+ case 0x140: case 0x148: case 0x150: case 0x158:
+ case 0x160: case 0x168: case 0x170: case 0x178:
+ SPRxPOS(hpos, value, (addr - 0x140) / 8);
+ break;
+ case 0x142: case 0x14A: case 0x152: case 0x15A:
+ case 0x162: case 0x16A: case 0x172: case 0x17A:
+ SPRxCTL(hpos, value, (addr - 0x142) / 8);
+ break;
+ case 0x144: case 0x14C: case 0x154: case 0x15C:
+ case 0x164: case 0x16C: case 0x174: case 0x17C:
+ SPRxDATA(hpos, value, (addr - 0x144) / 8);
+ break;
+ case 0x146: case 0x14E: case 0x156: case 0x15E:
+ case 0x166: case 0x16E: case 0x176: case 0x17E:
+ SPRxDATB(hpos, value, (addr - 0x146) / 8);
+ break;
- case 0x044: BLTAFWM (value); break;
- case 0x046: BLTALWM (value); break;
+ case 0x36: JOYTEST(value); break;
+ case 0x5A: BLTCON0L(hpos, value); break;
+ case 0x5C: BLTSIZV(hpos, value); break;
+ case 0x5E: BLTSIZH(hpos, value); break;
+ case 0x1E4: DIWHIGH(hpos, value); break;
+#ifdef AGA
+ case 0x10C: BPLCON4(hpos, value); break;
+#endif
- case 0x048: BLTCPTH (value); break;
- case 0x04A: BLTCPTL (value); break;
- case 0x04C: BLTBPTH (value); break;
- case 0x04E: BLTBPTL (value); break;
- case 0x050: BLTAPTH (value); break;
- case 0x052: BLTAPTL (value); break;
- case 0x054: BLTDPTH (value); break;
- case 0x056: BLTDPTL (value); break;
+ case 0x1DC: BEAMCON0(value); break;
+ case 0x1C0: if (htotal != value) { htotal = value & (MAXHPOS_ROWS - 1); varsync(); } break;
+ case 0x1C2: if (hsstop != value) { hsstop = value & (MAXHPOS_ROWS - 1); varsync(); } break;
+ case 0x1C4: if (hbstrt != value) { hbstrt = value & (MAXHPOS_ROWS - 1); varsync(); } break;
+ case 0x1C6: if (hbstop != value) { hbstop = value & (MAXHPOS_ROWS - 1); varsync(); } break;
+ case 0x1C8: if (vtotal != value) { vtotal = value & (MAXVPOS_LINES_ECS - 1); varsync(); } break;
+ case 0x1CA: if (vsstop != value) { vsstop = value & (MAXVPOS_LINES_ECS - 1); varsync(); } break;
+ case 0x1CC: if (vbstrt < value || vbstrt >(value & (MAXVPOS_LINES_ECS - 1)) + 1) { vbstrt = value & (MAXVPOS_LINES_ECS - 1); varsync(); } break;
+ case 0x1CE: if (vbstop < value || vbstop >(value & (MAXVPOS_LINES_ECS - 1)) + 1) { vbstop = value & (MAXVPOS_LINES_ECS - 1); varsync(); } break;
+ case 0x1DE: if (hsstrt != value) { hsstrt = value & (MAXHPOS_ROWS - 1); varsync(); } break;
+ case 0x1E0: if (vsstrt != value) { vsstrt = value & (MAXVPOS_LINES_ECS - 1); varsync(); } break;
+ case 0x1E2: if (hcenter != value) { hcenter = value & (MAXHPOS_ROWS - 1); varsync(); } break;
- case 0x058: BLTSIZE (value); break;
- case 0x05A: BLTCON0L (value); break;
- case 0x05C: BLTSIZV (value); break;
- case 0x05E: BLTSIZH (value); break;
+#ifdef AGA
+ case 0x1FC: FMODE(hpos, value); break;
+#endif
+ case 0x1FE: FNULL(value); break;
- case 0x064: BLTAMOD (value); break;
- case 0x062: BLTBMOD (value); break;
- case 0x060: BLTCMOD (value); break;
- case 0x066: BLTDMOD (value); break;
-
- case 0x070: BLTCDAT (value); break;
- case 0x072: BLTBDAT (value); break;
- case 0x074: BLTADAT (value); break;
-
- case 0x07E: DSKSYNC (hpos, value); break;
-
- case 0x080: COP1LCH (value); break;
- case 0x082: COP1LCL (value); break;
- case 0x084: COP2LCH (value); break;
- case 0x086: COP2LCL (value); break;
-
- case 0x088: COPJMP (1, 0); break;
- case 0x08A: COPJMP (2, 0); break;
-
- case 0x08E: DIWSTRT (hpos, value); break;
- case 0x090: DIWSTOP (hpos, value); break;
- case 0x092: DDFSTRT (hpos, value); break;
- case 0x094: DDFSTOP (hpos, value); break;
-
- case 0x096: DMACON (hpos, value); break;
- case 0x098: CLXCON (value); break;
- case 0x09A: INTENA (value); break;
- case 0x09C: INTREQ (value); break;
- case 0x09E: ADKCON (hpos, value); break;
-
- case 0x0A0: AUDxLCH (0, value); break;
- case 0x0A2: AUDxLCL (0, value); break;
- case 0x0A4: AUDxLEN (0, value); break;
- case 0x0A6: AUDxPER (0, value); break;
- case 0x0A8: AUDxVOL (0, value); break;
- case 0x0AA: AUDxDAT (0, value); break;
-
- case 0x0B0: AUDxLCH (1, value); break;
- case 0x0B2: AUDxLCL (1, value); break;
- case 0x0B4: AUDxLEN (1, value); break;
- case 0x0B6: AUDxPER (1, value); break;
- case 0x0B8: AUDxVOL (1, value); break;
- case 0x0BA: AUDxDAT (1, value); break;
-
- case 0x0C0: AUDxLCH (2, value); break;
- case 0x0C2: AUDxLCL (2, value); break;
- case 0x0C4: AUDxLEN (2, value); break;
- case 0x0C6: AUDxPER (2, value); break;
- case 0x0C8: AUDxVOL (2, value); break;
- case 0x0CA: AUDxDAT (2, value); break;
-
- case 0x0D0: AUDxLCH (3, value); break;
- case 0x0D2: AUDxLCL (3, value); break;
- case 0x0D4: AUDxLEN (3, value); break;
- case 0x0D6: AUDxPER (3, value); break;
- case 0x0D8: AUDxVOL (3, value); break;
- case 0x0DA: AUDxDAT (3, value); break;
-
- case 0x0E0: BPLxPTH (hpos, value, 0); break;
- case 0x0E2: BPLxPTL (hpos, value, 0); break;
- case 0x0E4: BPLxPTH (hpos, value, 1); break;
- case 0x0E6: BPLxPTL (hpos, value, 1); break;
- case 0x0E8: BPLxPTH (hpos, value, 2); break;
- case 0x0EA: BPLxPTL (hpos, value, 2); break;
- case 0x0EC: BPLxPTH (hpos, value, 3); break;
- case 0x0EE: BPLxPTL (hpos, value, 3); break;
- case 0x0F0: BPLxPTH (hpos, value, 4); break;
- case 0x0F2: BPLxPTL (hpos, value, 4); break;
- case 0x0F4: BPLxPTH (hpos, value, 5); break;
- case 0x0F6: BPLxPTL (hpos, value, 5); break;
- case 0x0F8: BPLxPTH (hpos, value, 6); break;
- case 0x0FA: BPLxPTL (hpos, value, 6); break;
- case 0x0FC: BPLxPTH (hpos, value, 7); break;
- case 0x0FE: BPLxPTL (hpos, value, 7); break;
-
- case 0x100: BPLCON0 (hpos, value); break;
- case 0x102: BPLCON1 (hpos, value); break;
- case 0x104: BPLCON2 (hpos, value); break;
- case 0x106: BPLCON3 (hpos, value); break;
-
- case 0x108: BPL1MOD (hpos, value); break;
- case 0x10A: BPL2MOD (hpos, value); break;
- case 0x10C: BPLCON4 (hpos, value); break;
- case 0x10E: CLXCON2 (value); break;
-
- case 0x110: BPLxDAT (hpos, 0, value); break;
- case 0x112: BPLxDAT (hpos, 1, value); break;
- case 0x114: BPLxDAT (hpos, 2, value); break;
- case 0x116: BPLxDAT (hpos, 3, value); break;
- case 0x118: BPLxDAT (hpos, 4, value); break;
- case 0x11A: BPLxDAT (hpos, 5, value); break;
- case 0x11C: BPLxDAT (hpos, 6, value); break;
- case 0x11E: BPLxDAT (hpos, 7, value); break;
-
- case 0x180: case 0x182: case 0x184: case 0x186: case 0x188: case 0x18A:
- case 0x18C: case 0x18E: case 0x190: case 0x192: case 0x194: case 0x196:
- case 0x198: case 0x19A: case 0x19C: case 0x19E: case 0x1A0: case 0x1A2:
- case 0x1A4: case 0x1A6: case 0x1A8: case 0x1AA: case 0x1AC: case 0x1AE:
- case 0x1B0: case 0x1B2: case 0x1B4: case 0x1B6: case 0x1B8: case 0x1BA:
- case 0x1BC: case 0x1BE:
- COLOR_WRITE (hpos, value & 0xFFF, (addr & 0x3E) / 2);
- break;
- case 0x120: case 0x124: case 0x128: case 0x12C:
- case 0x130: case 0x134: case 0x138: case 0x13C:
- SPRxPTH (hpos, value, (addr - 0x120) / 4);
- break;
- case 0x122: case 0x126: case 0x12A: case 0x12E:
- case 0x132: case 0x136: case 0x13A: case 0x13E:
- SPRxPTL (hpos, value, (addr - 0x122) / 4);
- break;
- case 0x140: case 0x148: case 0x150: case 0x158:
- case 0x160: case 0x168: case 0x170: case 0x178:
- SPRxPOS (hpos, value, (addr - 0x140) / 8);
- break;
- case 0x142: case 0x14A: case 0x152: case 0x15A:
- case 0x162: case 0x16A: case 0x172: case 0x17A:
- SPRxCTL (hpos, value, (addr - 0x142) / 8);
- break;
- case 0x144: case 0x14C: case 0x154: case 0x15C:
- case 0x164: case 0x16C: case 0x174: case 0x17C:
- SPRxDATA (hpos, value, (addr - 0x144) / 8);
- break;
- case 0x146: case 0x14E: case 0x156: case 0x15E:
- case 0x166: case 0x16E: case 0x176: case 0x17E:
- SPRxDATB (hpos, value, (addr - 0x146) / 8);
- break;
-
- case 0x1C0: if (htotal != value) { htotal = value & (MAXHPOS_ROWS - 1); varsync (); } break;
- case 0x1C2: if (hsstop != value) { hsstop = value & (MAXHPOS_ROWS - 1); varsync (); } break;
- case 0x1C4: if (hbstrt != value) { hbstrt = value & (MAXHPOS_ROWS - 1); varsync (); } break;
- case 0x1C6: if (hbstop != value) { hbstop = value & (MAXHPOS_ROWS - 1); varsync (); } break;
- case 0x1C8: if (vtotal != value) { vtotal = value & (MAXVPOS_LINES_ECS - 1); varsync (); } break;
- case 0x1CA: if (vsstop != value) { vsstop = value & (MAXVPOS_LINES_ECS - 1); varsync (); } break;
- case 0x1CC: if (vbstrt < value || vbstrt > (value & (MAXVPOS_LINES_ECS - 1)) + 1) { vbstrt = value & (MAXVPOS_LINES_ECS - 1); varsync (); } break;
- case 0x1CE: if (vbstop < value || vbstop > (value & (MAXVPOS_LINES_ECS - 1)) + 1) { vbstop = value & (MAXVPOS_LINES_ECS - 1); varsync (); } break;
- case 0x1DC: BEAMCON0 (value); break;
- case 0x1DE: if (hsstrt != value) { hsstrt = value & (MAXHPOS_ROWS - 1); varsync (); } break;
- case 0x1E0: if (vsstrt != value) { vsstrt = value & (MAXVPOS_LINES_ECS - 1); varsync (); } break;
- case 0x1E2: if (hcenter != value) { hcenter = value & (MAXHPOS_ROWS - 1); varsync (); } break;
- case 0x1E4: DIWHIGH (hpos, value); break;
-
- case 0x1FC: FMODE (hpos, value); break;
- case 0x1FE: FNULL (value); break;
-
- /* writing to read-only register causes read access */
- default:
- if (!noget) {
- custom_wget_1 (addr, 1);
- }
- return 1;
- }
- return 0;
+ /* writing to read-only register causes read access */
+ default:
+ if (!noget) {
+ custom_wget_1(hpos, addr, 1, false);
+ }
+ return 1;
+ }
+ return 0;
}
-static void REGPARAM2 custom_wput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 custom_wput(uaecptr addr, uae_u32 value)
{
- int hpos = current_hpos ();
+ int hpos = current_hpos();
if ((addr & 0xffff) < 0x8000 && currprefs.cs_fatgaryrev >= 0) {
+ dummy_put(addr, 2, value);
return;
}
- sync_copper_with_cpu (hpos, 1, addr);
- if (addr & 1) {
- addr &= ~1;
- custom_wput_1 (hpos, addr, (value >> 8) | (value & 0xff00), 0);
- custom_wput_1 (hpos, addr + 2, (value << 8) | (value & 0x00ff), 0);
- return;
- }
- custom_wput_1 (hpos, addr, value, 0);
+
+ sync_copper_with_cpu(hpos, 1);
+ if (addr & 1) {
+ addr &= ~1;
+ custom_wput_1(hpos, addr, (value >> 8) | (value & 0xff00), 0);
+ custom_wput_1(hpos, addr + 2, (value << 8) | (value & 0x00ff), 0);
+ return;
+}
+ custom_wput_1(hpos, addr, value, 0);
}
-static void REGPARAM2 custom_bput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 custom_bput(uaecptr addr, uae_u32 value)
{
uae_u16 rval;
if ((addr & 0xffff) < 0x8000 && currprefs.cs_fatgaryrev >= 0) {
+ dummy_put(addr, 1, value);
return;
}
- if (aga_mode) {
- if (addr & 1) {
- rval = value & 0xff;
- } else {
- rval = (value << 8) | (value & 0xFF);
- }
- } else {
+ if (currprefs.chipset_mask & CSMASK_AGA) {
+ if (addr & 1) {
+ rval = value & 0xff;
+ }
+ else {
+ rval = (value << 8) | (value & 0xFF);
+ }
+ }
+ else {
rval = (value << 8) | (value & 0xff);
}
if (currprefs.cs_bytecustomwritebug) {
if (addr & 1)
- custom_wput (addr & ~1, rval);
+ custom_wput(addr & ~1, rval);
else
- custom_wput (addr, value << 8);
- } else {
- custom_wput (addr & ~1, rval);
+ custom_wput(addr, value << 8);
+ }
+ else {
+ custom_wput(addr & ~1, rval);
}
}
static void REGPARAM2 custom_lput(uaecptr addr, uae_u32 value)
{
if ((addr & 0xffff) < 0x8000 && currprefs.cs_fatgaryrev >= 0) {
+ dummy_put(addr, 4, value);
return;
}
- custom_wput (addr & 0xfffe, value >> 16);
- custom_wput ((addr + 2) & 0xfffe, (uae_u16)value);
+ custom_wput(addr & 0xfffe, value >> 16);
+ custom_wput((addr + 2) & 0xfffe, (uae_u16)value);
}
#ifdef SAVESTATE
-void custom_prepare_savestate (void)
+void custom_prepare_savestate(void)
{
- int i;
+ int i;
- for (i = 0; i < ev2_max; i++) {
- if (eventtab2[i].active) {
- eventtab2[i].active = 0;
- eventtab2[i].handler(eventtab2[i].data);
- }
- }
+ for (i = 0; i < ev2_max; i++) {
+ if (eventtab2[i].active) {
+ eventtab2[i].active = false;
+ eventtab2[i].handler(eventtab2[i].data);
+ }
+ }
}
#define RB restore_u8 ()
@@ -6789,484 +8884,1006 @@ void custom_prepare_savestate (void)
#define RW restore_u16 ()
#define RL restore_u32 ()
-uae_u8 *restore_custom (uae_u8 *src)
+uae_u8 *restore_custom(uae_u8 *src)
{
- uae_u16 dsklen, dskbytr, ru16;
- int dskpt;
- int i;
+ uae_u16 dsklen, dskbytr;
+ int dskpt;
+ int i;
- audio_reset ();
+ audio_reset();
- changed_prefs.chipset_mask = currprefs.chipset_mask = RL & CSMASK_MASK;
- update_mirrors();
- blt_info.bltddat = RW; /* 000 BLTDDAT */
- ru16 = RW; /* 002 DMACONR -> see also 096 */
- if((ru16 & 0x4000) == 0)
- bltstate = BLT_done;
- blt_info.blitzero = (ru16 & 0x2000 ? 1 : 0);
- RW; /* 004 VPOSR */
- RW; /* 006 VHPOSR */
- RW; /* 008 DSKDATR (dummy register) */
- JOYSET(0, RW); /* 00A JOY0DAT */
- JOYSET(1, RW); /* 00C JOY1DAT */
- clxdat = RW; /* 00E CLXDAT */
- RW; /* 010 ADKCONR -> see 09E */
- RW; /* 012 POT0DAT */
- RW; /* 014 POT1DAT */
- RW; /* 016 POTINP -> see 034 */
- RW; /* 018 SERDATR* */
- dskbytr = RW; /* 01A DSKBYTR */
- RW; /* 01C INTENAR -> see 09A */
- RW; /* 01E INTREQR -> see 09C */
- dskpt = RL; /* 020-022 DSKPT */
- dsklen = RW; /* 024 DSKLEN */
- RW; /* 026 DSKDAT */
- RW; /* 028 REFPTR */
- i = RW; lof_store = lof_current = (i & 0x8000) ? 1 : 0; /* 02A VPOSW */
- RW; /* 02C VHPOSW */
- COPCON(RW); /* 02E COPCON */
- RW; /* 030 SERDAT */
- RW; /* 032 SERPER* */
- potgo_value = 0; POTGO (RW); /* 034 POTGO */
- RW; /* 036 JOYTEST* */
- RW; /* 038 STREQU */
- RW; /* 03A STRVHBL */
- RW; /* 03C STRHOR */
- RW; /* 03E STRLONG */
- BLTCON0(RW); /* 040 BLTCON0 */
- BLTCON1(RW); /* 042 BLTCON1 */
- BLTAFWM(RW); /* 044 BLTAFWM */
- BLTALWM(RW); /* 046 BLTALWM */
- bltcpt = RL; /* 048-04B BLTCPT */
- bltbpt = RL; /* 04C-04F BLTBPT */
- bltapt = RL; /* 050-053 BLTAPT */
- bltdpt = RL; /* 054-057 BLTDPT */
- RW; /* 058 BLTSIZE */
- RW; /* 05A BLTCON0L -> see 040 */
- blt_info.vblitsize=RW; /* 05C BLTSIZV */
- blt_info.hblitsize=RW; /* 05E BLTSIZH */
- blt_info.bltcmod = RW; /* 060 BLTCMOD */
- blt_info.bltbmod = RW; /* 062 BLTBMOD */
- blt_info.bltamod = RW; /* 064 BLTAMOD */
- blt_info.bltdmod = RW; /* 066 BLTDMOD */
- RW; /* 068 ? */
- RW; /* 06A ? */
- RW; /* 06C ? */
- RW; /* 06E ? */
- blt_info.bltcdat =RW; /* 070 BLTCDAT */
- BLTBDAT(RW); /* 072 BLTBDAT */
- blt_info.bltadat=RW; /* 074 BLTADAT */
- RW; /* 076 ? */
- RW; /* 078 ? */
- RW; /* 07A ? */
- RW; /* 07C LISAID */
- ru16=RW; DSKSYNC(-1, ru16); /* 07E DSKSYNC */
- cop1lc = RL; /* 080/082 COP1LC */
- cop2lc = RL; /* 084/086 COP2LC */
- RW; /* 088 COPJMP1 */
- RW; /* 08A COPJMP2 */
- RW; /* 08C COPINS */
- diwstrt = RW; /* 08E DIWSTRT */
- diwstop = RW; /* 090 DIWSTOP */
- ddfstrt = RW; /* 092 DDFSTRT */
- ddfstop = RW; /* 094 DDFSTOP */
- dmacon = RW & ~(0x2000|0x4000); /* 096 DMACON */
- CLXCON(RW); /* 098 CLXCON */
- intena = RW; /* 09A INTENA */
- intreq = RW; /* 09C INTREQ */
- adkcon = RW; /* 09E ADKCON */
- /* 0A0 - 0DE Audio regs */
- for (i = 0; i < 8; i++)
- bplpt[i] = RL;
- bplcon0 = RW; /* 100 BPLCON0 */
- bplcon1 = RW; /* 102 BPLCON1 */
- bplcon2 = RW; /* 104 BPLCON2 */
- bplcon3 = RW; /* 106 BPLCON3 */
- bpl1mod = RW; /* 108 BPL1MOD */
- bpl2mod = RW; /* 10A BPL2MOD */
- bplcon4 = RW; /* 10C BPLCON4 */
- CLXCON2(RW); /* 10E CLXCON2* */
- for(i = 0; i < 8; i++)
- fetched[i] = RW; /* BPLXDAT */
- /* 120 - 17E Sprite regs */
- for(i = 0; i < 32; i++) {
+ changed_prefs.chipset_mask = currprefs.chipset_mask = RL & CSMASK_MASK;
+ update_mirrors();
+ RW; /* 000 BLTDDAT */
+ RW; /* 002 DMACONR */
+ RW; /* 004 VPOSR */
+ RW; /* 006 VHPOSR */
+ RW; /* 008 DSKDATR (dummy register) */
+ JOYSET(0, RW); /* 00A JOY0DAT */
+ JOYSET(1, RW); /* 00C JOY1DAT */
+ clxdat = RW; /* 00E CLXDAT */
+ RW; /* 010 ADKCONR */
+ RW; /* 012 POT0DAT* */
+ RW; /* 014 POT1DAT* */
+ RW; /* 016 POTINP* */
+ RW; /* 018 SERDATR* */
+ dskbytr = RW; /* 01A DSKBYTR */
+ RW; /* 01C INTENAR */
+ RW; /* 01E INTREQR */
+ dskpt = RL; /* 020-022 DSKPT */
+ dsklen = RW; /* 024 DSKLEN */
+ RW; /* 026 DSKDAT */
+ refptr = RW; /* 028 REFPTR */
+ i = RW; lof_store = lof_current = (i & 0x8000) ? 1 : 0; lol = (i & 0x0080) ? 1 : 0; /* 02A VPOSW */
+ RW; /* 02C VHPOSW */
+ COPCON(RW); /* 02E COPCON */
+ RW; /* 030 SERDAT* */
+ //serper = RW; /* 032 SERPER* */
+ potgo_value = 0; POTGO(RW); /* 034 POTGO */
+ RW; /* 036 JOYTEST* */
+ RW; /* 038 STREQU */
+ RW; /* 03A STRVHBL */
+ RW; /* 03C STRHOR */
+ RW; /* 03E STRLONG */
+ BLTCON0(0, RW); /* 040 BLTCON0 */
+ BLTCON1(0, RW); /* 042 BLTCON1 */
+ BLTAFWM(0, RW); /* 044 BLTAFWM */
+ BLTALWM(0, RW); /* 046 BLTALWM */
+ BLTCPTH(0, RW); BLTCPTL(0, RW); /* 048-04B BLTCPT */
+ BLTBPTH(0, RW); BLTBPTL(0, RW); /* 04C-04F BLTBPT */
+ BLTAPTH(0, RW); BLTAPTL(0, RW); /* 050-053 BLTAPT */
+ BLTDPTH(0, RW); BLTDPTL(0, RW); /* 054-057 BLTDPT */
+ RW; /* 058 BLTSIZE */
+ RW; /* 05A BLTCON0L */
+ blt_info.vblitsize = RW;/* 05C BLTSIZV */
+ blt_info.hblitsize = RW;/* 05E BLTSIZH */
+ BLTCMOD(0, RW); /* 060 BLTCMOD */
+ BLTBMOD(0, RW); /* 062 BLTBMOD */
+ BLTAMOD(0, RW); /* 064 BLTAMOD */
+ BLTDMOD(0, RW); /* 066 BLTDMOD */
+ RW; /* 068 ? */
+ RW; /* 06A ? */
+ RW; /* 06C ? */
+ RW; /* 06E ? */
+ BLTCDAT(0, RW); /* 070 BLTCDAT */
+ BLTBDAT(0, RW); /* 072 BLTBDAT */
+ BLTADAT(0, RW); /* 074 BLTADAT */
+ RW; /* 076 ? */
+ RW; /* 078 ? */
+ RW; /* 07A ? */
+ RW; /* 07C LISAID */
+ DSKSYNC(-1, RW); /* 07E DSKSYNC */
+ cop1lc = RL; /* 080/082 COP1LC */
+ cop2lc = RL; /* 084/086 COP2LC */
+ RW; /* 088 ? */
+ RW; /* 08A ? */
+ RW; /* 08C ? */
+ diwstrt = RW; /* 08E DIWSTRT */
+ diwstop = RW; /* 090 DIWSTOP */
+ ddfstrt = RW; /* 092 DDFSTRT */
+ ddfstop = RW; /* 094 DDFSTOP */
+ dmacon = RW & ~(0x2000 | 0x4000); /* 096 DMACON */
+ CLXCON(RW); /* 098 CLXCON */
+ intena = intena_internal = RW; /* 09A INTENA */
+ intreq = RW; /* 09C INTREQ */
+ intreq_internal = intreq;
+ adkcon = RW; /* 09E ADKCON */
+ for (i = 0; i < 8; i++)
+ bplptx[i] = bplpt[i] = RL;
+ bplcon0 = RW; /* 100 BPLCON0 */
+ bplcon1 = RW; /* 102 BPLCON1 */
+ bplcon2 = RW; /* 104 BPLCON2 */
+ bplcon3 = RW; /* 106 BPLCON3 */
+ bpl1mod = RW; /* 108 BPL1MOD */
+ bpl2mod = RW; /* 10A BPL2MOD */
+ bplcon4 = RW; /* 10C BPLCON4 */
+ clxcon2 = RW; /* 10E CLXCON2* */
+ for (i = 0; i < 8; i++)
+ fetched[i] = RW; /* BPLXDAT */
+ for (i = 0; i < 32; i++) {
uae_u16 v = RW;
- current_colors.color_regs_ecs[i] = v & 0xfff; /* 180-1BE COLORxx */
- }
- htotal = RW; /* 1C0 HTOTAL */
- hsstop = RW; /* 1C2 HSTOP ? */
- hbstrt = RW; /* 1C4 HBSTRT ? */
- hbstop = RW; /* 1C6 HBSTOP ? */
- vtotal = RW; /* 1C8 VTOTAL */
- vsstop = RW; /* 1CA VSSTOP */
- vbstrt = RW; /* 1CC VBSTRT */
- vbstop = RW; /* 1CE VBSTOP */
- RW; /* 1D0 ? */
- RW; /* 1D2 ? */
- RW; /* 1D4 ? */
- RW; /* 1D6 ? */
- RW; /* 1D8 ? */
- RW; /* 1DA ? */
- new_beamcon0 = RW; /* 1DC BEAMCON0 */
- hsstrt = RW; /* 1DE HSSTRT */
- vsstrt = RW; /* 1E0 VSSTT */
- hcenter = RW; /* 1E2 HCENTER */
- diwhigh = RW; /* 1E4 DIWHIGH */
- diwhigh_written = (diwhigh & 0x8000) ? 1 : 0;
- hdiwstate = (diwhigh & 0x4000) ? DIW_waiting_stop : DIW_waiting_start;
- diwhigh &= 0x3fff;
- RW; /* 1E6 ? */
- RW; /* 1E8 ? */
- RW; /* 1EA ? */
- RW; /* 1EC ? */
- RW; /* 1EE ? */
- RW; /* 1F0 ? */
- RW; /* 1F2 ? */
- RW; /* 1F4 ? */
- RW; /* 1F6 ? */
- RW; /* 1F8 ? */
- i = RW; /* 1FA ? */
- if (i & 0x8000)
- currprefs.ntscmode = changed_prefs.ntscmode = i & 1;
+ color_regs_genlock[i] = (v & 0x8000) != 0;
+ current_colors.color_regs_ecs[i] = v & 0xfff; /* 180 COLORxx */
+ }
+ htotal = RW; /* 1C0 HTOTAL */
+ hsstop = RW; /* 1C2 HSTOP ? */
+ hbstrt = RW; /* 1C4 HBSTRT ? */
+ hbstop = RW; /* 1C6 HBSTOP ? */
+ vtotal = RW; /* 1C8 VTOTAL */
+ vsstop = RW; /* 1CA VSSTOP */
+ vbstrt = RW; /* 1CC VBSTRT */
+ vbstop = RW; /* 1CE VBSTOP */
+ RW; /* 1D0 ? */
+ RW; /* 1D2 ? */
+ RW; /* 1D4 ? */
+ RW; /* 1D6 ? */
+ RW; /* 1D8 ? */
+ RW; /* 1DA ? */
+ new_beamcon0 = RW; /* 1DC BEAMCON0 */
+ hsstrt = RW; /* 1DE HSSTRT */
+ vsstrt = RW; /* 1E0 VSSTT */
+ hcenter = RW; /* 1E2 HCENTER */
+ diwhigh = RW; /* 1E4 DIWHIGH */
+ diwhigh_written = (diwhigh & 0x8000) ? 1 : 0;
+ hdiwstate = (diwhigh & 0x4000) ? DIW_waiting_stop : DIW_waiting_start;
+ diwhigh &= 0x3fff;
+ RW; /* 1E6 ? */
+ RW; /* 1E8 ? */
+ RW; /* 1EA ? */
+ RW; /* 1EC ? */
+ RW; /* 1EE ? */
+ RW; /* 1F0 ? */
+ RW; /* 1F2 ? */
+ RW; /* 1F4 ? */
+ RW; /* 1F6 ? */
+ RW; /* 1F8 ? */
+ i = RW; /* 1FA ? */
+ if (i & 0x8000)
+ currprefs.ntscmode = changed_prefs.ntscmode = i & 1;
fmode = fmode_saved = RW; /* 1FC FMODE */
- last_custom_value1 = RW; /* 1FE ? */
+ last_custom_value1 = RW;/* 1FE ? */
current_colors.extra = 0;
- if (isbrdblank (-1, bplcon0, bplcon3))
+ if (isbrdblank(-1, bplcon0, bplcon3))
current_colors.extra |= 1 << CE_BORDERBLANK;
if (issprbrd(-1, bplcon0, bplcon3))
current_colors.extra |= 1 << CE_BORDERSPRITE;
+ if ((currprefs.chipset_mask & CSMASK_ECS_DENISE) && (bplcon0 & 1) && (bplcon3 & 0x10))
+ current_colors.extra |= 1 << CE_BORDERNTRANS;
- DISK_restore_custom (dskpt, dsklen, dskbytr);
+ DISK_restore_custom(dskpt, dsklen, dskbytr);
- FMODE (0, fmode);
-
- return src;
+ return src;
}
+#endif /* SAVESTATE */
+
+#if defined SAVESTATE || defined DEBUGGER
+
#define SB save_u8
#define SW save_u16
#define SL save_u32
-uae_u8 *save_custom (int *len, uae_u8 *dstptr, int full)
+uae_u8 *save_custom(int *len, uae_u8 *dstptr, int full)
{
- uae_u8 *dstbak, *dst;
+ uae_u8 *dstbak, *dst;
int i, dummy;
- uae_u32 dskpt;
- uae_u16 dsklen, dsksync, dskbytr;
+ uae_u32 dskpt;
+ uae_u16 dsklen, dsksync, dskbytr;
- DISK_save_custom (&dskpt, &dsklen, &dsksync, &dskbytr);
+ DISK_save_custom(&dskpt, &dsklen, &dsksync, &dskbytr);
- if (dstptr)
- dstbak = dst = dstptr;
- else
- dstbak = dst = xmalloc (uae_u8, 8 + 256 * 2);
+ if (dstptr)
+ dstbak = dst = dstptr;
+ else
+ dstbak = dst = xmalloc(uae_u8, 8 + 256 * 2);
- SL (currprefs.chipset_mask);
- SW (blt_info.bltddat); /* 000 BLTDDAT */
- SW (dmacon); /* 002 DMACONR */
- SW (VPOSR()); /* 004 VPOSR */
- SW (VHPOSR()); /* 006 VHPOSR */
- SW (0); /* 008 DSKDATR */
- SW (JOYGET (0)); /* 00A JOY0DAT */
- SW (JOYGET (1)); /* 00C JOY1DAT */
- SW (clxdat | 0x8000); /* 00E CLXDAT */
- SW (ADKCONR()); /* 010 ADKCONR */
- SW (POT0DAT()); /* 012 POT0DAT */
- SW (POT1DAT()); /* 014 POT1DAT */
- SW (0) ; /* 016 POTINP * */
- SW (0); /* 018 SERDATR * */
- SW (dskbytr); /* 01A DSKBYTR */
- SW (INTENAR()); /* 01C INTENAR */
- SW (INTREQR()); /* 01E INTREQR */
- SL (dskpt); /* 020-023 DSKPT */
- SW (dsklen); /* 024 DSKLEN */
- SW (0); /* 026 DSKDAT */
- SW (0); /* 028 REFPTR */
- SW ((lof_store ? 0x8001 : 0)); /* 02A VPOSW */
- SW (0); /* 02C VHPOSW */
- SW (copcon); /* 02E COPCON */
- SW (0); /* 030 SERDAT * */
- SW (0); /* 032 SERPER * */
- SW (potgo_value); /* 034 POTGO */
- SW (0); /* 036 JOYTEST * */
- SW (0); /* 038 STREQU */
- SW (0); /* 03A STRVBL */
- SW (0); /* 03C STRHOR */
- SW (0); /* 03E STRLONG */
- SW (bltcon0); /* 040 BLTCON0 */
- SW (bltcon1); /* 042 BLTCON1 */
- SW (blt_info.bltafwm); /* 044 BLTAFWM */
- SW (blt_info.bltalwm); /* 046 BLTALWM */
- SL (bltcpt); /* 048-04B BLTCPT */
- SL (bltbpt); /* 04C-04F BLTBPT */
- SL (bltapt); /* 050-053 BLTAPT */
- SL (bltdpt); /* 054-057 BLTDPT */
- SW (0); /* 058 BLTSIZE */
- SW (0); /* 05A BLTCON0L (use BLTCON0 instead) */
- SW (blt_info.vblitsize); /* 05C BLTSIZV */
- SW (blt_info.hblitsize); /* 05E BLTSIZH */
- SW (blt_info.bltcmod); /* 060 BLTCMOD */
- SW (blt_info.bltbmod); /* 062 BLTBMOD */
- SW (blt_info.bltamod); /* 064 BLTAMOD */
- SW (blt_info.bltdmod); /* 066 BLTDMOD */
- SW (0); /* 068 ? */
- SW (0); /* 06A ? */
- SW (0); /* 06C ? */
- SW (0); /* 06E ? */
- SW (blt_info.bltcdat); /* 070 BLTCDAT */
- SW (blt_info.bltbdat); /* 072 BLTBDAT */
- SW (blt_info.bltadat); /* 074 BLTADAT */
- SW (0); /* 076 ? */
- SW (0); /* 078 ? */
- SW (0); /* 07A ? */
- SW (DENISEID (&dummy)); /* 07C DENISEID/LISAID */
- SW (dsksync); /* 07E DSKSYNC */
- SL (cop1lc); /* 080-083 COP1LC */
- SL (cop2lc); /* 084-087 COP2LC */
- SW (0); /* 088 COPJMP1 */
- SW (0); /* 08A COPJMP2 */
- SW (0); /* 08C COPINS */
- SW (diwstrt); /* 08E DIWSTRT */
- SW (diwstop); /* 090 DIWSTOP */
- SW (ddfstrt); /* 092 DDFSTRT */
- SW (ddfstop); /* 094 DDFSTOP */
- SW (dmacon); /* 096 DMACON */
- SW (clxcon); /* 098 CLXCON */
- SW (intena); /* 09A INTENA */
- SW (intreq); /* 09C INTREQ */
- SW (adkcon); /* 09E ADKCON */
- /* 0A0 - 0DE Audio regs */
- for (i = 0; full && i < 32; i++)
- SW (0);
- for (i = 0; i < 8; i++)
- SL (bplpt[i]); /* 0E0-0FE BPLxPT */
- SW (bplcon0); /* 100 BPLCON0 */
- SW (bplcon1); /* 102 BPLCON1 */
- SW (bplcon2); /* 104 BPLCON2 */
- SW (bplcon3); /* 106 BPLCON3 */
- SW (bpl1mod); /* 108 BPL1MOD */
- SW (bpl2mod); /* 10A BPL2MOD */
- SW (bplcon4); /* 10C BPLCON4 */
- SW (clxcon2); /* 10E CLXCON2 */
- for (i = 0;i < 8; i++)
- SW (fetched[i]); /* 110 BPLxDAT */
- /* 120 - 17E Sprite regs */
- if (full) {
- for (i = 0; i < 8; i++) {
- SL (spr[i].pt); /* 120-13E SPRxPT */
+ SL(currprefs.chipset_mask);
+ SW(0); /* 000 BLTDDAT */
+ SW(dmacon); /* 002 DMACONR */
+ SW(VPOSR()); /* 004 VPOSR */
+ SW(VHPOSR()); /* 006 VHPOSR */
+ SW(0); /* 008 DSKDATR */
+ SW(JOYGET(0)); /* 00A JOY0DAT */
+ SW(JOYGET(1)); /* 00C JOY1DAT */
+ SW(clxdat | 0x8000); /* 00E CLXDAT */
+ SW(ADKCONR()); /* 010 ADKCONR */
+ SW(POT0DAT()); /* 012 POT0DAT */
+ SW(POT1DAT()); /* 014 POT1DAT */
+ SW(0); /* 016 POTINP * */
+ SW(0); /* 018 SERDATR * */
+ SW(dskbytr); /* 01A DSKBYTR */
+ SW(INTENAR()); /* 01C INTENAR */
+ SW(INTREQR()); /* 01E INTREQR */
+ SL(dskpt); /* 020-023 DSKPT */
+ SW(dsklen); /* 024 DSKLEN */
+ SW(0); /* 026 DSKDAT */
+ SW(refptr); /* 028 REFPTR */
+ SW((lof_store ? 0x8001 : 0) | (lol ? 0x0080 : 0));/* 02A VPOSW */
+ SW(0); /* 02C VHPOSW */
+ SW(copcon); /* 02E COPCON */
+ //SW(serdat); /* 030 SERDAT * */
+ //SW(serper); /* 032 SERPER * */
+ SW(potgo_value); /* 034 POTGO */
+ SW(0); /* 036 JOYTEST * */
+ SW(0); /* 038 STREQU */
+ SW(0); /* 03A STRVBL */
+ SW(0); /* 03C STRHOR */
+ SW(0); /* 03E STRLONG */
+ SW(bltcon0); /* 040 BLTCON0 */
+ SW(bltcon1); /* 042 BLTCON1 */
+ SW(blt_info.bltafwm); /* 044 BLTAFWM */
+ SW(blt_info.bltalwm); /* 046 BLTALWM */
+ SL(bltcpt); /* 048-04B BLTCPT */
+ SL(bltbpt); /* 04C-04F BLTCPT */
+ SL(bltapt); /* 050-053 BLTCPT */
+ SL(bltdpt); /* 054-057 BLTCPT */
+ SW(0); /* 058 BLTSIZE */
+ SW(0); /* 05A BLTCON0L (use BLTCON0 instead) */
+ SW(blt_info.vblitsize);/* 05C BLTSIZV */
+ SW(blt_info.hblitsize);/* 05E BLTSIZH */
+ SW(blt_info.bltcmod); /* 060 BLTCMOD */
+ SW(blt_info.bltbmod); /* 062 BLTBMOD */
+ SW(blt_info.bltamod); /* 064 BLTAMOD */
+ SW(blt_info.bltdmod); /* 066 BLTDMOD */
+ SW(0); /* 068 ? */
+ SW(0); /* 06A ? */
+ SW(0); /* 06C ? */
+ SW(0); /* 06E ? */
+ SW(blt_info.bltcdat); /* 070 BLTCDAT */
+ SW(blt_info.bltbdat); /* 072 BLTBDAT */
+ SW(blt_info.bltadat); /* 074 BLTADAT */
+ SW(0); /* 076 ? */
+ SW(0); /* 078 ? */
+ SW(0); /* 07A ? */
+ SW(DENISEID(&dummy)); /* 07C DENISEID/LISAID */
+ SW(dsksync); /* 07E DSKSYNC */
+ SL(cop1lc); /* 080-083 COP1LC */
+ SL(cop2lc); /* 084-087 COP2LC */
+ SW(0); /* 088 ? */
+ SW(0); /* 08A ? */
+ SW(0); /* 08C ? */
+ SW(diwstrt); /* 08E DIWSTRT */
+ SW(diwstop); /* 090 DIWSTOP */
+ SW(ddfstrt); /* 092 DDFSTRT */
+ SW(ddfstop); /* 094 DDFSTOP */
+ SW(dmacon); /* 096 DMACON */
+ SW(clxcon); /* 098 CLXCON */
+ SW(intena); /* 09A INTENA */
+ SW(intreq); /* 09C INTREQ */
+ SW(adkcon); /* 09E ADKCON */
+ for (i = 0; full && i < 32; i++)
+ SW(0);
+ for (i = 0; i < 8; i++)
+ SL(bplpt[i]); /* 0E0-0FE BPLxPT */
+ SW(bplcon0); /* 100 BPLCON0 */
+ SW(bplcon1); /* 102 BPLCON1 */
+ SW(bplcon2); /* 104 BPLCON2 */
+ SW(bplcon3); /* 106 BPLCON3 */
+ SW(bpl1mod); /* 108 BPL1MOD */
+ SW(bpl2mod); /* 10A BPL2MOD */
+ SW(bplcon4); /* 10C BPLCON4 */
+ SW(clxcon2); /* 10E CLXCON2 */
+ for (i = 0; i < 8; i++)
+ SW(fetched[i]); /* 110 BPLxDAT */
+ if (full) {
+ for (i = 0; i < 8; i++) {
+ SL(spr[i].pt); /* 120-13E SPRxPT */
}
for (i = 0; i < 8; i++) {
- SW (sprpos[i]); /* 1x0 SPRxPOS */
- SW (sprctl[i]); /* 1x2 SPRxPOS */
- SW (sprdata[i][0]); /* 1x4 SPRxDATA */
- SW (sprdatb[i][0]); /* 1x6 SPRxDATB */
- }
- }
- for ( i = 0; i < 32; i++)
- SW (current_colors.color_regs_ecs[i]); /* 180-1BE COLORxx */
- SW (htotal); /* 1C0 HTOTAL */
- SW (hsstop); /* 1C2 HSTOP */
- SW (hbstrt); /* 1C4 HBSTRT */
- SW (hbstop); /* 1C6 HBSTOP */
- SW (vtotal); /* 1C8 VTOTAL */
- SW (vsstop); /* 1CA VSSTOP */
- SW (vbstrt); /* 1CC VBSTRT */
- SW (vbstop); /* 1CE VBSTOP */
- SW (0); /* 1D0 */
- SW (0); /* 1D2 */
- SW (0); /* 1D4 */
- SW (0); /* 1D6 */
- SW (0); /* 1D8 */
- SW (0); /* 1DA */
- SW (beamcon0); /* 1DC BEAMCON0 */
- SW (hsstrt); /* 1DE HSSTRT */
- SW (vsstrt); /* 1E0 VSSTRT */
- SW (hcenter); /* 1E2 HCENTER */
- SW (diwhigh | (diwhigh_written ? 0x8000 : 0) | (hdiwstate == DIW_waiting_stop ? 0x4000 : 0)); /* 1E4 DIWHIGH */
- SW (0); /* 1E6 */
- SW (0); /* 1E8 */
- SW (0); /* 1EA */
- SW (0); /* 1EC */
- SW (0); /* 1EE */
- SW (0); /* 1F0 */
- SW (0); /* 1F2 */
- SW (0); /* 1F4 */
- SW (0); /* 1F6 */
- SW (0); /* 1F8 */
- SW (0x8000 | (currprefs.ntscmode ? 1 : 0)); /* 1FA (re-used for NTSC) */
- SW (fmode); /* 1FC FMODE */
- SW (last_custom_value1); /* 1FE */
+ SW(sprpos[i]); /* 1x0 SPRxPOS */
+ SW(sprctl[i]); /* 1x2 SPRxPOS */
+ SW(sprdata[i][0]); /* 1x4 SPRxDATA */
+ SW(sprdatb[i][0]); /* 1x6 SPRxDATB */
+ }
+ }
+ for (i = 0; i < 32; i++) {
+ if (currprefs.chipset_mask & CSMASK_AGA) {
+ uae_u32 v = current_colors.color_regs_aga[i];
+ uae_u16 v2;
+ v &= 0x00f0f0f0;
+ v2 = (v >> 4) & 15;
+ v2 |= ((v >> 12) & 15) << 4;
+ v2 |= ((v >> 20) & 15) << 8;
+ SW(v2);
+ }
+ else {
+ uae_u16 v = current_colors.color_regs_ecs[i];
+ if (color_regs_genlock[i])
+ v |= 0x8000;
+ SW(v); /* 180-1BE COLORxx */
+ }
+ }
+ SW(htotal); /* 1C0 HTOTAL */
+ SW(hsstop); /* 1C2 HSTOP*/
+ SW(hbstrt); /* 1C4 HBSTRT */
+ SW(hbstop); /* 1C6 HBSTOP */
+ SW(vtotal); /* 1C8 VTOTAL */
+ SW(vsstop); /* 1CA VSSTOP */
+ SW(vbstrt); /* 1CC VBSTRT */
+ SW(vbstop); /* 1CE VBSTOP */
+ SW(0); /* 1D0 */
+ SW(0); /* 1D2 */
+ SW(0); /* 1D4 */
+ SW(0); /* 1D6 */
+ SW(0); /* 1D8 */
+ SW(0); /* 1DA */
+ SW(beamcon0); /* 1DC BEAMCON0 */
+ SW(hsstrt); /* 1DE HSSTRT */
+ SW(vsstrt); /* 1E0 VSSTRT */
+ SW(hcenter); /* 1E2 HCENTER */
+ SW(diwhigh | (diwhigh_written ? 0x8000 : 0) | (hdiwstate == DIW_waiting_stop ? 0x4000 : 0)); /* 1E4 DIWHIGH */
+ SW(0); /* 1E6 */
+ SW(0); /* 1E8 */
+ SW(0); /* 1EA */
+ SW(0); /* 1EC */
+ SW(0); /* 1EE */
+ SW(0); /* 1F0 */
+ SW(0); /* 1F2 */
+ SW(0); /* 1F4 */
+ SW(0); /* 1F6 */
+ SW(0); /* 1F8 */
+ SW(0x8000 | (currprefs.ntscmode ? 1 : 0)); /* 1FA (re-used for NTSC) */
+ SW(fmode); /* 1FC FMODE */
+ SW(last_custom_value1); /* 1FE */
- *len = dst - dstbak;
- return dstbak;
+ *len = dst - dstbak;
+ return dstbak;
}
-uae_u8 *restore_custom_agacolors (uae_u8 *src)
-{
- int i;
+#endif /* SAVESTATE || DEBUGGER */
- for (i = 0; i < 256; i++) {
+#ifdef SAVESTATE
+
+uae_u8 *restore_custom_agacolors(uae_u8 *src)
+{
+ int i;
+
+ for (i = 0; i < 256; i++) {
+#ifdef AGA
uae_u32 v = RL;
- v &= 0x00ffffff;
- current_colors.color_regs_aga[i] = v;
- }
- return src;
-}
-
-uae_u8 *save_custom_agacolors (int *len, uae_u8 *dstptr)
-{
- uae_u8 *dstbak, *dst;
-
- if (dstptr)
- dstbak = dst = dstptr;
- else
- dstbak = dst = xmalloc (uae_u8, 256 * 4);
- for (int i = 0; i < 256; i++)
- SL (current_colors.color_regs_aga[i]);
- *len = dst - dstbak;
- return dstbak;
-}
-
-uae_u8 *restore_custom_sprite (int num, uae_u8 *src)
-{
- memset (&spr[num], 0, sizeof (struct sprite));
- spr[num].pt = RL; /* 120-13E SPRxPT */
- sprpos[num] = RW; /* 1x0 SPRxPOS */
- sprctl[num] = RW; /* 1x2 SPRxPOS */
- sprdata[num][0] = RW; /* 1x4 SPRxDATA */
- sprdatb[num][0] = RW; /* 1x6 SPRxDATB */
- sprdata[num][1] = RW;
- sprdatb[num][1] = RW;
- sprdata[num][2] = RW;
- sprdatb[num][2] = RW;
- sprdata[num][3] = RW;
- sprdatb[num][3] = RW;
- spr[num].armed = RB & 1;
- return src;
-}
-
-uae_u8 *save_custom_sprite(int num, int *len, uae_u8 *dstptr)
-{
- uae_u8 *dstbak, *dst;
-
- if (dstptr)
- dstbak = dst = dstptr;
- else
- dstbak = dst = xmalloc (uae_u8, 30);
- SL (spr[num].pt); /* 120-13E SPRxPT */
- SW (sprpos[num]); /* 1x0 SPRxPOS */
- SW (sprctl[num]); /* 1x2 SPRxPOS */
- SW (sprdata[num][0]); /* 1x4 SPRxDATA */
- SW (sprdatb[num][0]); /* 1x6 SPRxDATB */
- SW (sprdata[num][1]);
- SW (sprdatb[num][1]);
- SW (sprdata[num][2]);
- SW (sprdatb[num][2]);
- SW (sprdata[num][3]);
- SW (sprdatb[num][3]);
- SB (spr[num].armed ? 1 : 0);
- *len = dst - dstbak;
- return dstbak;
-}
-
-uae_u8 *restore_custom_extra (uae_u8 *src)
-{
- uae_u32 v = restore_u32 ();
-
- if (!(v & 1))
- v = 0;
- currprefs.cs_compatible = changed_prefs.cs_compatible = v >> 24;
- cia_set_overlay ((v & 2) != 0);
-
- currprefs.cs_rtc = changed_prefs.cs_rtc = RB;
-
- currprefs.cs_pcmcia = changed_prefs.cs_pcmcia = RBB;
- currprefs.cs_ciaatod = changed_prefs.cs_ciaatod = RB;
- currprefs.cs_ciaoverlay = changed_prefs.cs_ciaoverlay = RBB;
-
- currprefs.cs_fatgaryrev = changed_prefs.cs_fatgaryrev = SRB;
- currprefs.cs_ramseyrev = changed_prefs.cs_ramseyrev = SRB;
-
- currprefs.cs_cd32c2p = changed_prefs.cs_cd32c2p = RBB;
- currprefs.cs_cd32cd = changed_prefs.cs_cd32cd = RBB;
- currprefs.cs_cd32nvram = changed_prefs.cs_cd32nvram = RBB;
-
- currprefs.cs_df0idhw = changed_prefs.cs_df0idhw = RBB;
- currprefs.cs_ide = changed_prefs.cs_ide = RB;
- currprefs.cs_ksmirror_a8 = changed_prefs.cs_ksmirror_a8 = RBB;
- currprefs.cs_ksmirror_e0 = changed_prefs.cs_ksmirror_e0 = RBB;
- currprefs.cs_z3autoconfig = changed_prefs.cs_z3autoconfig = RBB;
-
+ color_regs_genlock[i] = 0;
+ if (v & 0x80000000)
+ color_regs_genlock[i] = 1;
+ v &= 0x80ffffff;
+ current_colors.color_regs_aga[i] = v;
+#else
+ RL;
+#endif
+ }
return src;
}
-uae_u8 *save_custom_extra (int *len, uae_u8 *dstptr)
+uae_u8 *save_custom_agacolors(int *len, uae_u8 *dstptr)
+{
+ uae_u8 *dstbak, *dst;
+ int i;
+
+ if (dstptr)
+ dstbak = dst = dstptr;
+ else
+ dstbak = dst = xmalloc(uae_u8, 256 * 4);
+ for (i = 0; i < 256; i++)
+#ifdef AGA
+ SL(current_colors.color_regs_aga[i] | (color_regs_genlock[i] ? 0x80000000 : 0));
+#else
+ SL(0);
+#endif
+ *len = dst - dstbak;
+ return dstbak;
+}
+
+uae_u8 *restore_custom_sprite(int num, uae_u8 *src)
+{
+ memset(&spr[num], 0, sizeof(struct sprite));
+ spr[num].pt = RL; /* 120-13E SPRxPT */
+ sprpos[num] = RW; /* 1x0 SPRxPOS */
+ sprctl[num] = RW; /* 1x2 SPRxPOS */
+ sprdata[num][0] = RW; /* 1x4 SPRxDATA */
+ sprdatb[num][0] = RW; /* 1x6 SPRxDATB */
+ sprdata[num][1] = RW;
+ sprdatb[num][1] = RW;
+ sprdata[num][2] = RW;
+ sprdatb[num][2] = RW;
+ sprdata[num][3] = RW;
+ sprdatb[num][3] = RW;
+ spr[num].armed = RB & 1;
+ return src;
+}
+
+uae_u8 *save_custom_sprite(int num, int *len, uae_u8 *dstptr)
{
uae_u8 *dstbak, *dst;
if (dstptr)
dstbak = dst = dstptr;
else
- dstbak = dst = xmalloc (uae_u8, 1000);
+ dstbak = dst = xmalloc(uae_u8, 30);
+ SL(spr[num].pt); /* 120-13E SPRxPT */
+ SW(sprpos[num]); /* 1x0 SPRxPOS */
+ SW(sprctl[num]); /* 1x2 SPRxPOS */
+ SW(sprdata[num][0]); /* 1x4 SPRxDATA */
+ SW(sprdatb[num][0]); /* 1x6 SPRxDATB */
+ SW(sprdata[num][1]);
+ SW(sprdatb[num][1]);
+ SW(sprdata[num][2]);
+ SW(sprdatb[num][2]);
+ SW(sprdata[num][3]);
+ SW(sprdatb[num][3]);
+ SB(spr[num].armed ? 1 : 0);
+ *len = dst - dstbak;
+ return dstbak;
+}
- SL ((currprefs.cs_compatible << 24) | (&get_mem_bank (0) != &chipmem_bank ? 2 : 0) | 1);
- SB (currprefs.cs_rtc);
+uae_u8 *restore_custom_extra(uae_u8 *src)
+{
+ uae_u32 v = restore_u32();
- SB (currprefs.cs_pcmcia ? 1 : 0);
- SB (currprefs.cs_ciaatod);
- SB (currprefs.cs_ciaoverlay ? 1 : 0);
+ if (!(v & 1))
+ v = 0;
+ currprefs.cs_compatible = changed_prefs.cs_compatible = v >> 24;
+ cia_set_overlay((v & 2) != 0);
- SB (currprefs.cs_fatgaryrev);
- SB (currprefs.cs_ramseyrev);
+ currprefs.genlock = changed_prefs.genlock = RBB;
+ currprefs.cs_rtc = changed_prefs.cs_rtc = RB;
+ currprefs.cs_rtc_adjust = changed_prefs.cs_rtc_adjust = RL;
- SB (currprefs.cs_cd32c2p);
- SB (currprefs.cs_cd32cd);
- SB (currprefs.cs_cd32nvram);
+ currprefs.cs_a1000ram = changed_prefs.cs_a1000ram = RBB;
+ currprefs.cs_slowmemisfast = changed_prefs.cs_slowmemisfast = RBB;
- SB (currprefs.cs_df0idhw ? 1 : 0);
- SB (currprefs.cs_ide);
- SB (currprefs.cs_ksmirror_a8 ? 1 : 0);
- SB (currprefs.cs_ksmirror_e0 ? 1 : 0);
- SB (currprefs.cs_z3autoconfig ? 1 : 0);
+ RBB;
+ RBB;
+ currprefs.cs_cdtvscsi = changed_prefs.cs_cdtvscsi = RBB;
+
+ currprefs.cs_pcmcia = changed_prefs.cs_pcmcia = RBB;
+ currprefs.cs_ciaatod = changed_prefs.cs_ciaatod = RB;
+ currprefs.cs_ciaoverlay = changed_prefs.cs_ciaoverlay = RBB;
+
+ currprefs.cs_agnusbltbusybug = changed_prefs.cs_agnusbltbusybug = RBB;
+ currprefs.cs_denisenoehb = changed_prefs.cs_denisenoehb = RBB;
+
+ currprefs.cs_agnusrev = changed_prefs.cs_agnusrev = SRB;
+ currprefs.cs_deniserev = changed_prefs.cs_deniserev = SRB;
+ currprefs.cs_fatgaryrev = changed_prefs.cs_fatgaryrev = SRB;
+ currprefs.cs_ramseyrev = changed_prefs.cs_ramseyrev = SRB;
+
+ currprefs.cs_cd32c2p = changed_prefs.cs_cd32c2p = RBB;
+ currprefs.cs_cd32cd = changed_prefs.cs_cd32cd = RBB;
+ currprefs.cs_cd32nvram = changed_prefs.cs_cd32nvram = RBB;
+ currprefs.cs_cdtvcd = changed_prefs.cs_cdtvcd = RBB;
+ currprefs.cs_cdtvram = changed_prefs.cs_cdtvram = RBB;
+ currprefs.cs_cdtvcard = changed_prefs.cs_cdtvcard = RB;
+
+ currprefs.cs_df0idhw = changed_prefs.cs_df0idhw = RBB;
+ currprefs.cs_dipagnus = changed_prefs.cs_dipagnus = RBB;
+ currprefs.cs_ide = changed_prefs.cs_ide = RB;
+ currprefs.cs_mbdmac = changed_prefs.cs_mbdmac = RB;
+ currprefs.cs_ksmirror_a8 = changed_prefs.cs_ksmirror_a8 = RBB;
+ currprefs.cs_ksmirror_e0 = changed_prefs.cs_ksmirror_e0 = RBB;
+ currprefs.cs_resetwarning = changed_prefs.cs_resetwarning = RBB;
+ currprefs.cs_z3autoconfig = changed_prefs.cs_z3autoconfig = RBB;
+ currprefs.cs_1mchipjumper = changed_prefs.cs_1mchipjumper = RBB;
+
+ return src;
+}
+
+uae_u8 *save_custom_extra(int *len, uae_u8 *dstptr)
+{
+ uae_u8 *dstbak, *dst;
+
+ if (dstptr)
+ dstbak = dst = dstptr;
+ else
+ dstbak = dst = xmalloc(uae_u8, 1000);
+
+ SL((currprefs.cs_compatible << 24) | 1);
+ SB(currprefs.genlock ? 1 : 0);
+ SB(currprefs.cs_rtc);
+ SL(currprefs.cs_rtc_adjust);
+
+ SB(currprefs.cs_a1000ram ? 1 : 0);
+ SB(currprefs.cs_slowmemisfast ? 1 : 0);
+
+ SB(is_board_enabled(&currprefs, ROMTYPE_A2091, 0) ? 1 : 0);
+ SB(is_board_enabled(&currprefs, ROMTYPE_A4091, 0) ? 1 : 0);
+ SB(currprefs.cs_cdtvscsi ? 1 : 0);
+
+ SB(currprefs.cs_pcmcia ? 1 : 0);
+ SB(currprefs.cs_ciaatod);
+ SB(currprefs.cs_ciaoverlay ? 1 : 0);
+
+ SB(currprefs.cs_agnusbltbusybug ? 1 : 0);
+ SB(currprefs.cs_denisenoehb ? 1 : 0);
+
+ SB(currprefs.cs_agnusrev);
+ SB(currprefs.cs_deniserev);
+ SB(currprefs.cs_fatgaryrev);
+ SB(currprefs.cs_ramseyrev);
+
+ SB(currprefs.cs_cd32c2p);
+ SB(currprefs.cs_cd32cd);
+ SB(currprefs.cs_cd32nvram);
+ SB(currprefs.cs_cdtvcd ? 1 : 0);
+ SB(currprefs.cs_cdtvram ? 1 : 0);
+ SB(currprefs.cs_cdtvcard);
+
+ SB(currprefs.cs_df0idhw ? 1 : 0);
+ SB(currprefs.cs_dipagnus ? 1 : 0);
+ SB(currprefs.cs_ide);
+ SB(currprefs.cs_mbdmac);
+ SB(currprefs.cs_ksmirror_a8 ? 1 : 0);
+ SB(currprefs.cs_ksmirror_e0 ? 1 : 0);
+ SB(currprefs.cs_resetwarning ? 1 : 0);
+ SB(currprefs.cs_z3autoconfig ? 1 : 0);
+ SB(currprefs.cs_1mchipjumper ? 1 : 0);
*len = dst - dstbak;
return dstbak;
}
+uae_u8 *restore_custom_event_delay(uae_u8 *src)
+{
+ if (restore_u32() != 1)
+ return src;
+ int cnt = restore_u8();
+ for (int i = 0; i < cnt; i++) {
+ uae_u8 type = restore_u8();
+ evt e = restore_u64();
+ uae_u32 data = restore_u32();
+ if (type == 1)
+ event2_newevent_xx(-1, e, data, send_interrupt_do);
+ }
+ return src;
+}
+uae_u8 *save_custom_event_delay(int *len, uae_u8 *dstptr)
+{
+ uae_u8 *dstbak, *dst;
+ int cnt = 0;
+
+ for (int i = ev2_misc; i < ev2_max; i++) {
+ struct ev2 *e = &eventtab2[i];
+ if (e->active && e->handler == send_interrupt_do) {
+ cnt++;
+ }
+ }
+ if (cnt == 0)
+ return NULL;
+
+ if (dstptr)
+ dstbak = dst = dstptr;
+ else
+ dstbak = dst = xmalloc(uae_u8, 1000);
+
+ save_u32(1);
+ save_u8(cnt);
+ for (int i = ev2_misc; i < ev2_max; i++) {
+ struct ev2 *e = &eventtab2[i];
+ if (e->active && e->handler == send_interrupt_do) {
+ save_u8(1);
+ save_u64(e->evtime - get_cycles());
+ save_u32(e->data);
+
+ }
+ }
+
+ *len = dst - dstbak;
+ return dstbak;
+}
+
+
+uae_u8 *save_cycles(int *len, uae_u8 *dstptr)
+{
+ uae_u8 *dstbak, *dst;
+ if (dstptr)
+ dstbak = dst = dstptr;
+ else
+ dstbak = dst = xmalloc(uae_u8, 1000);
+ save_u32(1);
+ save_u32(CYCLE_UNIT);
+ save_u64(get_cycles());
+ save_u32(extra_cycle);
+ write_log(_T("SAVECYCLES %08lX\n"), get_cycles());
+ *len = dst - dstbak;
+ return dstbak;
+}
+
+uae_u8 *restore_cycles(uae_u8 *src)
+{
+ if (restore_u32() != 1)
+ return src;
+ restore_u32();
+ start_cycles = restore_u64();
+ extra_cycle = restore_u32();
+ if (extra_cycle < 0 || extra_cycle >= 2 * CYCLE_UNIT)
+ extra_cycle = 0;
+ write_log(_T("RESTORECYCLES %08lX\n"), start_cycles);
+ return src;
+}
+
#endif /* SAVESTATE */
-void check_prefs_changed_custom (void)
+void check_prefs_changed_custom(void)
{
if (!config_changed)
return;
- currprefs.gfx_framerate = changed_prefs.gfx_framerate;
- if (inputdevice_config_change_test ())
- inputdevice_copyconfig (&changed_prefs, &currprefs);
- currprefs.immediate_blits = changed_prefs.immediate_blits;
+ currprefs.gfx_framerate = changed_prefs.gfx_framerate;
+ if (currprefs.turbo_emulation_limit != changed_prefs.turbo_emulation_limit) {
+ currprefs.turbo_emulation_limit = changed_prefs.turbo_emulation_limit;
+ if (changed_prefs.turbo_emulation) {
+ warpmode(changed_prefs.turbo_emulation);
+ }
+ }
+ if (currprefs.turbo_emulation != changed_prefs.turbo_emulation)
+ warpmode(changed_prefs.turbo_emulation);
+ if (inputdevice_config_change_test())
+ inputdevice_copyconfig(&changed_prefs, &currprefs);
+ currprefs.immediate_blits = changed_prefs.immediate_blits;
currprefs.waiting_blits = changed_prefs.waiting_blits;
- currprefs.collision_level = changed_prefs.collision_level;
- currprefs.fast_copper = changed_prefs.fast_copper;
+ currprefs.collision_level = changed_prefs.collision_level;
+ if (!currprefs.keyboard_connected && changed_prefs.keyboard_connected) {
+ // send powerup sync
+ keyboard_connected(true);
+ }
+ else if (currprefs.keyboard_connected && !changed_prefs.keyboard_connected) {
+ keyboard_connected(false);
+ }
+ currprefs.keyboard_connected = changed_prefs.keyboard_connected;
- currprefs.cs_ciaatod = changed_prefs.cs_ciaatod;
+ currprefs.cs_ciaatod = changed_prefs.cs_ciaatod;
currprefs.cs_rtc = changed_prefs.cs_rtc;
currprefs.cs_cd32cd = changed_prefs.cs_cd32cd;
currprefs.cs_cd32c2p = changed_prefs.cs_cd32c2p;
currprefs.cs_cd32nvram = changed_prefs.cs_cd32nvram;
+ currprefs.cs_cdtvcd = changed_prefs.cs_cdtvcd;
currprefs.cs_ide = changed_prefs.cs_ide;
currprefs.cs_pcmcia = changed_prefs.cs_pcmcia;
currprefs.cs_fatgaryrev = changed_prefs.cs_fatgaryrev;
currprefs.cs_ramseyrev = changed_prefs.cs_ramseyrev;
+ currprefs.cs_agnusrev = changed_prefs.cs_agnusrev;
+ currprefs.cs_deniserev = changed_prefs.cs_deniserev;
+ currprefs.cs_mbdmac = changed_prefs.cs_mbdmac;
currprefs.cs_df0idhw = changed_prefs.cs_df0idhw;
+ currprefs.cs_slowmemisfast = changed_prefs.cs_slowmemisfast;
+ currprefs.cs_dipagnus = changed_prefs.cs_dipagnus;
+ currprefs.cs_denisenoehb = changed_prefs.cs_denisenoehb;
currprefs.cs_z3autoconfig = changed_prefs.cs_z3autoconfig;
-
- if (currprefs.chipset_mask != changed_prefs.chipset_mask ||
- currprefs.ntscmode != changed_prefs.ntscmode) {
- currprefs.chipset_mask = changed_prefs.chipset_mask;
- if (currprefs.ntscmode != changed_prefs.ntscmode) {
- currprefs.ntscmode = changed_prefs.ntscmode;
- new_beamcon0 = currprefs.ntscmode ? 0x00 : 0x20;
- }
- init_custom ();
- }
+
+ if (currprefs.chipset_mask != changed_prefs.chipset_mask ||
+ currprefs.picasso96_nocustom != changed_prefs.picasso96_nocustom ||
+ currprefs.ntscmode != changed_prefs.ntscmode) {
+ currprefs.picasso96_nocustom = changed_prefs.picasso96_nocustom;
+ currprefs.chipset_mask = changed_prefs.chipset_mask;
+ if (currprefs.ntscmode != changed_prefs.ntscmode) {
+ currprefs.ntscmode = changed_prefs.ntscmode;
+ new_beamcon0 = currprefs.ntscmode ? 0x00 : 0x20;
+ }
+ init_custom();
+ }
+#ifdef GFXFILTER
+ struct gfx_filterdata *fd = &currprefs.gf[0];
+ struct gfx_filterdata *fdcp = &changed_prefs.gf[0];
+
+ fd->gfx_filter_horiz_zoom = fdcp->gfx_filter_horiz_zoom;
+ fd->gfx_filter_vert_zoom = fdcp->gfx_filter_vert_zoom;
+ fd->gfx_filter_horiz_offset = fdcp->gfx_filter_horiz_offset;
+ fd->gfx_filter_vert_offset = fdcp->gfx_filter_vert_offset;
+ fd->gfx_filter_scanlines = fdcp->gfx_filter_scanlines;
+
+ fd->gfx_filter_left_border = fdcp->gfx_filter_left_border;
+ fd->gfx_filter_right_border = fdcp->gfx_filter_right_border;
+ fd->gfx_filter_top_border = fdcp->gfx_filter_top_border;
+ fd->gfx_filter_bottom_border = fdcp->gfx_filter_bottom_border;
+#endif
+}
+
+#ifdef CPUEMU_13
+
+STATIC_INLINE void sync_copper(int hpos)
+{
+ if (copper_enabled_thisline)
+ update_copper(hpos);
+}
+
+STATIC_INLINE void decide_fetch_ce(int hpos)
+{
+ if ((line_cyclebased || blitter_dangerous_bpl) && vpos < current_maxvpos())
+ decide_fetch(hpos);
+}
+
+#define BLIT_NASTY 4
+
+// blitter not in nasty mode = CPU gets one cycle if it has been waiting
+// at least 4 cycles (all DMA cycles count, not just blitter cycles, even
+// blitter idle cycles do count!)
+
+extern int cpu_tracer;
+static int dma_cycle(void)
+{
+ int hpos, hpos_old;
+
+ blitter_nasty = 1;
+ if (cpu_tracer < 0)
+ return current_hpos_safe();
+ if (!currprefs.cpu_memory_cycle_exact)
+ return current_hpos_safe();
+ while (currprefs.cpu_memory_cycle_exact) {
+ int bpldma;
+ int blitpri = dmacon & DMA_BLITPRI;
+ hpos_old = current_hpos_safe();
+ hpos = hpos_old + 1;
+ decide_line(hpos);
+ sync_copper(hpos);
+ decide_fetch_ce(hpos);
+ bpldma = is_bitplane_dma(hpos_old);
+ if (bltstate != BLT_done) {
+ if (!blitpri && blitter_nasty >= BLIT_NASTY && (cycle_line[hpos_old] & CYCLE_MASK) == 0 && !bpldma) {
+ alloc_cycle(hpos_old, CYCLE_CPUNASTY);
+ break;
+ }
+ decide_blitter(hpos);
+ // copper may have been waiting for the blitter
+ sync_copper(hpos);
+ }
+ if ((cycle_line[hpos_old] & CYCLE_MASK) == 0 && !bpldma) {
+ alloc_cycle(hpos_old, CYCLE_CPU);
+ break;
+ }
+ do_cycles(1 * CYCLE_UNIT);
+ /* bus was allocated to dma channel, wait for next cycle.. */
+ }
+ return hpos_old;
+}
+
+STATIC_INLINE void checknasty(int hpos, int vpos)
+{
+ if (blitter_nasty >= BLIT_NASTY && !(dmacon & DMA_BLITPRI))
+ record_dma_event(DMA_EVENT_BLITNASTY, hpos, vpos);
+}
+
+static void sync_ce020(void)
+{
+ unsigned long c;
+ int extra;
+
+ c = get_cycles();
+ extra = c & (CYCLE_UNIT - 1);
+ if (extra) {
+ extra = CYCLE_UNIT - extra;
+ do_cycles(extra);
+ }
+}
+
+#define SETIFCHIP \
+ if (addr < 0xd80000) \
+ last_custom_value1 = v;
+
+uae_u32 wait_cpu_cycle_read(uaecptr addr, int mode)
+{
+ uae_u32 v = 0;
+ int hpos;
+
+ hpos = dma_cycle();
+ x_do_cycles_pre(CYCLE_UNIT);
+
+#ifdef DEBUGGER
+ struct dma_rec *dr = NULL;
+ if (debug_dma) {
+ int reg = 0x1000;
+ if (mode < 0)
+ reg |= 4;
+ else if (mode > 0)
+ reg |= 2;
+ else
+ reg |= 1;
+ dr = record_dma(reg, v, addr, hpos, vpos, mode == -2 || mode == 2 ? DMARECORD_CPU_I : DMARECORD_CPU_D);
+ checknasty(hpos, vpos);
+ }
+#endif
+ switch (mode)
+ {
+ case -1:
+ v = get_long(addr);
+ break;
+ case -2:
+ v = get_longi(addr);
+ break;
+ case 1:
+ v = get_word(addr);
+ break;
+ case 2:
+ v = get_wordi(addr);
+ break;
+ case 0:
+ v = get_byte(addr);
+ break;
+ }
+
+#ifdef DEBUGGER
+ if (debug_dma)
+ dr->dat = v;
+#endif
+
+ x_do_cycles_post(CYCLE_UNIT, v);
+
+ regs.chipset_latch_rw = regs.chipset_latch_read = v;
+ SETIFCHIP
+ return v;
+}
+
+uae_u32 wait_cpu_cycle_read_ce020(uaecptr addr, int mode)
+{
+ uae_u32 v = 0;
+ int hpos;
+
+ sync_ce020();
+ hpos = dma_cycle();
+ x_do_cycles_pre(CYCLE_UNIT);
+
+#ifdef DEBUGGER
+ struct dma_rec *dr = NULL;
+ if (debug_dma) {
+ int reg = 0x1000;
+ if (mode < 0)
+ reg |= 4;
+ else if (mode > 0)
+ reg |= 2;
+ else
+ reg |= 1;
+ dr = record_dma(reg, v, addr, hpos, vpos, mode == -2 || mode == 2 ? DMARECORD_CPU_I : DMARECORD_CPU_D);
+ checknasty(hpos, vpos);
+ }
+#endif
+ switch (mode) {
+ case -1:
+ v = get_long(addr);
+ break;
+ case -2:
+ v = get_longi(addr);
+ break;
+ case 1:
+ v = get_word(addr);
+ break;
+ case 2:
+ v = get_wordi(addr);
+ break;
+ case 0:
+ v = get_byte(addr);
+ break;
+ }
+
+#ifdef DEBUGGER
+ if (debug_dma)
+ dr->dat = v;
+#endif
+
+ x_do_cycles_post(CYCLE_UNIT, v);
+
+ regs.chipset_latch_rw = regs.chipset_latch_read = v;
+ SETIFCHIP
+ return v;
+}
+
+void wait_cpu_cycle_write(uaecptr addr, int mode, uae_u32 v)
+{
+ int hpos;
+
+ hpos = dma_cycle();
+ x_do_cycles_pre(CYCLE_UNIT);
+
+#ifdef DEBUGGER
+ if (debug_dma) {
+ int reg = 0x1100;
+ if (mode < 0)
+ reg |= 4;
+ else if (mode > 0)
+ reg |= 2;
+ else
+ reg |= 1;
+ record_dma(reg, v, addr, hpos, vpos, DMARECORD_CPU_D);
+ checknasty(hpos, vpos);
+ }
+#endif
+
+ if (mode < 0)
+ put_long(addr, v);
+ else if (mode > 0)
+ put_word(addr, v);
+ else if (mode == 0)
+ put_byte(addr, v);
+
+ x_do_cycles_post(CYCLE_UNIT, v);
+
+ regs.chipset_latch_rw = regs.chipset_latch_write = v;
+ SETIFCHIP
+}
+
+void wait_cpu_cycle_write_ce020(uaecptr addr, int mode, uae_u32 v)
+{
+ int hpos;
+
+ sync_ce020();
+ hpos = dma_cycle();
+ x_do_cycles_pre(CYCLE_UNIT);
+
+#ifdef DEBUGGER
+ if (debug_dma) {
+ int reg = 0x1100;
+ if (mode < 0)
+ reg |= 4;
+ else if (mode > 0)
+ reg |= 2;
+ else
+ reg |= 1;
+ record_dma(reg, v, addr, hpos, vpos, DMARECORD_CPU_D);
+ checknasty(hpos, vpos);
+ }
+#endif
+
+ if (mode < 0)
+ put_long(addr, v);
+ else if (mode > 0)
+ put_word(addr, v);
+ else if (mode == 0)
+ put_byte(addr, v);
+
+ x_do_cycles_post(CYCLE_UNIT, v);
+
+ regs.chipset_latch_rw = regs.chipset_latch_write = v;
+ SETIFCHIP
+}
+
+void do_cycles_ce(unsigned long cycles)
+{
+ cycles += extra_cycle;
+ while (cycles >= CYCLE_UNIT) {
+ int hpos = current_hpos() + 1;
+ decide_line(hpos);
+ sync_copper(hpos);
+ decide_fetch_ce(hpos);
+ if (bltstate != BLT_done)
+ decide_blitter(hpos);
+ do_cycles(1 * CYCLE_UNIT);
+ cycles -= CYCLE_UNIT;
+ }
+ extra_cycle = cycles;
+}
+
+void do_cycles_ce020(unsigned long cycles)
+{
+ unsigned long c;
+ int extra;
+
+ if (!cycles)
+ return;
+ c = get_cycles();
+ extra = c & (CYCLE_UNIT - 1);
+ if (extra) {
+ extra = CYCLE_UNIT - extra;
+ if (extra >= cycles) {
+ do_cycles(cycles);
+ return;
+ }
+ do_cycles(extra);
+ cycles -= extra;
+ }
+ c = cycles;
+ while (c) {
+ int hpos = current_hpos() + 1;
+ decide_line(hpos);
+ sync_copper(hpos);
+ decide_fetch_ce(hpos);
+ if (bltstate != BLT_done)
+ decide_blitter(hpos);
+ if (c < CYCLE_UNIT)
+ break;
+ do_cycles(1 * CYCLE_UNIT);
+ c -= CYCLE_UNIT;
+ }
+ if (c > 0)
+ do_cycles(c);
+}
+
+
+int is_cycle_ce(void)
+{
+ int hpos = current_hpos();
+ return cycle_line[hpos] & CYCLE_MASK;
+}
+
+#endif
+
+bool isvga(void)
+{
+ if (!(beamcon0 & 0x80))
+ return false;
+ if (hblank_hz >= 20000)
+ return true;
+ return false;
+}
+
+bool ispal(void)
+{
+ if (beamcon0 & 0x80)
+ return currprefs.ntscmode == 0;
+ return maxvpos_display >= MAXVPOS_NTSC + (MAXVPOS_PAL - MAXVPOS_NTSC) / 2;
}
diff --git a/src/disk.cpp b/src/disk.cpp
index 67db6ec2..28806651 100644
--- a/src/disk.cpp
+++ b/src/disk.cpp
@@ -1,4 +1,4 @@
- /*
+/*
* UAE - The Un*x Amiga Emulator
*
* Floppy disk emulation
@@ -14,34 +14,50 @@
#include "sysconfig.h"
#include "sysdeps.h"
+int disk_debug_logging = 0;
+int disk_debug_mode = 0;
+int disk_debug_track = -1;
+
+#define REVOLUTION_DEBUG 0
#define MFM_VALIDATOR 0
#include "uae.h"
#include "options.h"
#include "memory.h"
#include "custom.h"
+#include "ersatz.h"
#include "disk.h"
#include "gui.h"
#include "zfile.h"
#include "newcpu.h"
+#include "osemu.h"
#include "execlib.h"
#include "savestate.h"
#include "cia.h"
+#include "debug.h"
#ifdef FDI2RAW
#include "fdi2raw.h"
#endif
+#ifdef CAPS
+#include "caps/caps_win32.h"
+#endif
+#ifdef SCP
+#include "scp.h"
+#endif
#include "crc32.h"
+#ifdef RETROPLATFORM
+#include "rp.h"
+#endif
#include "fsdb.h"
-#include "rommgr.h"
+
+#undef CATWEASEL
static int longwritemode = 0;
/* support HD floppies */
#define FLOPPY_DRIVE_HD
/* writable track length with normal 2us bitcell/300RPM motor, 12667 PAL, 12797 NTSC */
-#define FLOPPY_WRITE_LEN_PAL 12668
-#define FLOPPY_WRITE_LEN_NTSC 12798
-#define FLOPPY_WRITE_LEN (currprefs.floppy_write_length > 256 ? currprefs.floppy_write_length / 2 : (currprefs.ntscmode ? (FLOPPY_WRITE_LEN_NTSC / 2) : (FLOPPY_WRITE_LEN_PAL / 2)))
+#define FLOPPY_WRITE_LEN (currprefs.floppy_write_length > 256 ? currprefs.floppy_write_length / 2 : (currprefs.ntscmode ? (12798 / 2) : (12668 / 2)))
#define FLOPPY_WRITE_MAXLEN 0x3800
/* This works out to 350 */
#define FLOPPY_GAP_LEN (FLOPPY_WRITE_LEN - 11 * 544)
@@ -67,8 +83,8 @@ static int longwritemode = 0;
* L track length in bits
*/
-static int side, direction, reserved_side;
-static uae_u8 selected = 15, disabled, reserved;
+static int side, direction;
+static uae_u8 selected = 15, disabled = 0;
static uae_u8 writebuffer[544 * MAX_SECTORS];
@@ -77,7 +93,7 @@ static uae_u8 writebuffer[544 * MAX_SECTORS];
#define DISK_REVOLUTION 4 /* 8,16,32,64 */
#define DSKREADY_UP_TIME 18
-#define DSKREADY_DOWN_TIME 24
+#define DSKREADY_DOWN_TIME 45
#define DSKDMA_OFF 0
#define DSKDMA_INIT 1
@@ -98,17 +114,27 @@ static unsigned long dsksync_cycles;
int disk_hpos;
static int disk_jitter;
static int indexdecay;
+
static uae_u8 prev_data;
static int prev_step;
-static struct diskinfo disk_info_data = { 0 };
-typedef enum { TRACK_AMIGADOS, TRACK_RAW, TRACK_RAW1, TRACK_PCDOS, TRACK_DISKSPARE, TRACK_NONE } image_tracktype;
-typedef struct {
- uae_u16 len;
- uae_u32 offs;
- int bitlen, track;
- uae_u16 sync;
- image_tracktype type;
+typedef enum
+{
+ TRACK_AMIGADOS,
+ TRACK_RAW,
+ TRACK_RAW1,
+ TRACK_PCDOS,
+ TRACK_DISKSPARE,
+ TRACK_NONE
+} image_tracktype;
+
+typedef struct
+{
+ uae_u16 len;
+ uae_u32 offs;
+ int bitlen, track;
+ uae_u16 sync;
+ image_tracktype type;
int revolutions;
} trackid;
@@ -129,72 +155,94 @@ typedef struct {
#define DRIVE_ID_35HD 0xAAAAAAAA
#define DRIVE_ID_525SD 0x55555555 /* 40 track 5.25 drive , kickstart does not recognize this */
-typedef enum { ADF_NONE = -1, ADF_NORMAL, ADF_EXT1, ADF_EXT2, ADF_FDI, ADF_SCP, ADF_PCDOS, ADF_KICK, ADF_SKICK } drive_filetype;
-typedef struct {
- struct zfile *diskfile;
- struct zfile *writediskfile;
- struct zfile *pcdecodedfile;
- drive_filetype filetype;
- trackid trackdata[MAX_TRACKS];
- trackid writetrackdata[MAX_TRACKS];
- int buffered_cyl, buffered_side;
- int cyl;
- bool motoroff;
- int motordelay; /* dskrdy needs some clock cycles before it changes after switching off motor */
- bool state;
- bool wrprot;
+typedef enum
+{
+ ADF_NONE = -1,
+ ADF_NORMAL,
+ ADF_EXT1,
+ ADF_EXT2,
+ ADF_FDI,
+ ADF_IPF,
+ ADF_SCP,
+ ADF_CATWEASEL,
+ ADF_PCDOS,
+ ADF_KICK,
+ ADF_SKICK
+} drive_filetype;
+
+typedef struct
+{
+ struct zfile* diskfile;
+ struct zfile* writediskfile;
+ drive_filetype filetype;
+ trackid trackdata[MAX_TRACKS];
+ trackid writetrackdata[MAX_TRACKS];
+ int buffered_cyl, buffered_side;
+ int cyl;
+ bool motoroff;
+ int motordelay; /* dskrdy needs some clock cycles before it changes after switching off motor */
+ bool state;
+ bool wrprot;
bool forcedwrprot;
- uae_u16 bigmfmbuf[0x4000 * DDHDMULT];
- uae_u16 tracktiming[0x4000 * DDHDMULT];
- int multi_revolution;
+ uae_u16 bigmfmbuf[0x4000 * DDHDMULT];
+ uae_u16 tracktiming[0x4000 * DDHDMULT];
+ int multi_revolution;
int revolution_check;
- int skipoffset;
- int mfmpos;
- int indexoffset;
- int tracklen;
- int revolutions;
- int prevtracklen;
- int trackspeed;
- int num_tracks, write_num_tracks, num_secs, num_heads;
- int hard_num_cyls;
- bool dskeject;
- bool dskchange;
- int dskchange_time;
- bool dskready;
- int dskready_up_time;
- int dskready_down_time;
- int writtento;
- int steplimit;
- frame_time_t steplimitcycle;
- int indexhack, indexhackmode;
- int ddhd; /* 1=DD 2=HD */
- int drive_id_scnt; /* drive id shift counter */
- int idbit;
- unsigned long drive_id; /* drive id to be reported */
- TCHAR newname[256]; /* storage space for new filename during eject delay */
+ int skipoffset;
+ int mfmpos;
+ int indexoffset;
+ int tracklen;
+ int revolutions;
+ int prevtracklen;
+ int trackspeed;
+ int num_tracks, write_num_tracks, num_secs;
+ int hard_num_cyls;
+ bool dskchange;
+ int dskchange_time;
+ bool dskready;
+ int dskready_up_time;
+ int dskready_down_time;
+ int writtento;
+ int steplimit;
+ frame_time_t steplimitcycle;
+ int indexhack, indexhackmode;
+ int ddhd; /* 1=DD 2=HD */
+ int drive_id_scnt; /* drive id shift counter */
+ int idbit;
+ unsigned long drive_id; /* drive id to be reported */
+ TCHAR newname[256]; /* storage space for new filename during eject delay */
bool newnamewriteprotected;
- uae_u32 crc32;
+ uae_u32 crc32;
#ifdef FDI2RAW
FDI *fdi;
#endif
- int useturbo;
- int floppybitcounter; /* number of bits left */
+ int useturbo;
+ int floppybitcounter; /* number of bits left */
+#ifdef CATWEASEL
+ catweasel_drive *catweasel;
+#else
+ int catweasel;
+ int amax;
+ int lastdataacesstrack;
+ int lastrev;
+ bool track_access_done;
+#endif
} drive;
#define MIN_STEPLIMIT_CYCLE (CYCLE_UNIT * 140)
static uae_u16 bigmfmbufw[0x4000 * DDHDMULT];
static drive floppy[MAX_FLOPPY_DRIVES];
-static TCHAR dfxhistory[HISTORY_MAX][MAX_PREVIOUS_IMAGES][MAX_DPATH];
+static TCHAR dfxhistory[2][MAX_PREVIOUS_FLOPPIES][MAX_DPATH];
-static uae_u8 exeheader[]={0x00,0x00,0x03,0xf3,0x00,0x00,0x00,0x00};
-static uae_u8 bootblock_ofs[]={
- 0x44,0x4f,0x53,0x00,0xc0,0x20,0x0f,0x19,0x00,0x00,0x03,0x70,0x43,0xfa,0x00,0x18,
- 0x4e,0xae,0xff,0xa0,0x4a,0x80,0x67,0x0a,0x20,0x40,0x20,0x68,0x00,0x16,0x70,0x00,
- 0x4e,0x75,0x70,0xff,0x60,0xfa,0x64,0x6f,0x73,0x2e,0x6c,0x69,0x62,0x72,0x61,0x72,
- 0x79
+static uae_u8 exeheader[] = {0x00,0x00,0x03,0xf3,0x00,0x00,0x00,0x00};
+static uae_u8 bootblock_ofs[] = {
+ 0x44,0x4f,0x53,0x00,0xc0,0x20,0x0f,0x19,0x00,0x00,0x03,0x70,0x43,0xfa,0x00,0x18,
+ 0x4e,0xae,0xff,0xa0,0x4a,0x80,0x67,0x0a,0x20,0x40,0x20,0x68,0x00,0x16,0x70,0x00,
+ 0x4e,0x75,0x70,0xff,0x60,0xfa,0x64,0x6f,0x73,0x2e,0x6c,0x69,0x62,0x72,0x61,0x72,
+ 0x79
};
-static uae_u8 bootblock_ffs[]={
+static uae_u8 bootblock_ffs[] = {
0x44, 0x4F, 0x53, 0x01, 0xE3, 0x3D, 0x0E, 0x72, 0x00, 0x00, 0x03, 0x70, 0x43, 0xFA, 0x00, 0x3E,
0x70, 0x25, 0x4E, 0xAE, 0xFD, 0xD8, 0x4A, 0x80, 0x67, 0x0C, 0x22, 0x40, 0x08, 0xE9, 0x00, 0x06,
0x00, 0x22, 0x4E, 0xAE, 0xFE, 0x62, 0x43, 0xFA, 0x00, 0x18, 0x4E, 0xAE, 0xFF, 0xA0, 0x4A, 0x80,
@@ -209,332 +257,366 @@ static uae_u8 bootblock_ffs[]={
#define FS_FLOPPY_TOTALBLOCKS 1760
#define FS_FLOPPY_RESERVED 2
-static void writeimageblock (struct zfile *dst, uae_u8 *sector, int offset)
+static void writeimageblock(struct zfile* dst, uae_u8* sector, int offset)
{
- zfile_fseek (dst, offset, SEEK_SET);
- zfile_fwrite (sector, FS_FLOPPY_BLOCKSIZE, 1, dst);
+ zfile_fseek(dst, offset, SEEK_SET);
+ zfile_fwrite(sector, FS_FLOPPY_BLOCKSIZE, 1, dst);
}
-static uae_u32 disk_checksum (uae_u8 *p, uae_u8 *c)
+static uae_u32 disk_checksum(uae_u8* p, uae_u8* c)
{
- uae_u32 cs = 0;
- int i;
- for (i = 0; i < FS_FLOPPY_BLOCKSIZE; i+= 4)
- cs += (p[i] << 24) | (p[i+1] << 16) | (p[i+2] << 8) | (p[i+3] << 0);
- cs = -cs;
- if (c) {
- c[0] = cs >> 24; c[1] = cs >> 16; c[2] = cs >> 8; c[3] = cs >> 0;
- }
+ uae_u32 cs = 0;
+ int i;
+ for (i = 0; i < FS_FLOPPY_BLOCKSIZE; i += 4)
+ cs += (p[i] << 24) | (p[i + 1] << 16) | (p[i + 2] << 8) | (p[i + 3] << 0);
+ cs = -cs;
+ if (c)
+ {
+ c[0] = cs >> 24;
+ c[1] = cs >> 16;
+ c[2] = cs >> 8;
+ c[3] = cs >> 0;
+ }
return cs;
}
-static int dirhash (const uae_char *name)
+static int dirhash(const uae_char* name)
{
- unsigned long hash;
- int i;
+ unsigned long hash;
+ int i;
- hash = strlen (name);
- for(i = 0; i < strlen (name); i++) {
- hash = hash * 13;
- hash = hash + toupper (name[i]);
- hash = hash & 0x7ff;
- }
- hash = hash % ((FS_FLOPPY_BLOCKSIZE / 4) - 56);
- return hash;
+ hash = strlen(name);
+ for (i = 0; i < strlen(name); i++)
+ {
+ hash = hash * 13;
+ hash = hash + toupper(name[i]);
+ hash = hash & 0x7ff;
+ }
+ hash = hash % ((FS_FLOPPY_BLOCKSIZE / 4) - 56);
+ return hash;
}
-static void disk_date (uae_u8 *p)
+static void disk_date(uae_u8* p)
{
static int pdays, pmins, pticks;
int days, mins, ticks;
struct timeval tv;
struct mytimeval mtv;
- gettimeofday (&tv, NULL);
+ gettimeofday(&tv, nullptr);
tv.tv_sec -= _timezone;
mtv.tv_sec = tv.tv_sec;
mtv.tv_usec = tv.tv_usec;
- timeval_to_amiga (&mtv, &days, &mins, &ticks, 50);
- if (days == pdays && mins == pmins && ticks == pticks) {
+ timeval_to_amiga(&mtv, &days, &mins, &ticks);
+ if (days == pdays && mins == pmins && ticks == pticks)
+ {
ticks++;
- if (ticks >= 50 * 60) {
+ if (ticks >= 50 * 60)
+ {
ticks = 0;
mins++;
if (mins >= 24 * 60)
days++;
- }
+ }
}
pdays = days;
pmins = mins;
pticks = ticks;
- p[0] = days >> 24; p[1] = days >> 16; p[2] = days >> 8; p[3] = days >> 0;
- p[4] = mins >> 24; p[5] = mins >> 16; p[6] = mins >> 8; p[7] = mins >> 0;
- p[8] = ticks >> 24; p[9] = ticks >> 16; p[10] = ticks >> 8; p[11] = ticks >> 0;
+ p[0] = days >> 24;
+ p[1] = days >> 16;
+ p[2] = days >> 8;
+ p[3] = days >> 0;
+ p[4] = mins >> 24;
+ p[5] = mins >> 16;
+ p[6] = mins >> 8;
+ p[7] = mins >> 0;
+ p[8] = ticks >> 24;
+ p[9] = ticks >> 16;
+ p[10] = ticks >> 8;
+ p[11] = ticks >> 0;
}
-static void createbootblock (uae_u8 *sector, int bootable)
+static void createbootblock(uae_u8* sector, int bootable)
{
- memset (sector, 0, FS_FLOPPY_BLOCKSIZE);
- memcpy (sector, "DOS", 3);
- if (bootable)
- memcpy (sector, bootblock_ofs, sizeof bootblock_ofs);
+ memset(sector, 0, FS_FLOPPY_BLOCKSIZE);
+ memcpy(sector, "DOS", 3);
+ if (bootable)
+ memcpy(sector, bootblock_ofs, sizeof bootblock_ofs);
}
-static void createrootblock (uae_u8 *sector, const TCHAR *disk_name)
+static void createrootblock(uae_u8* sector, const TCHAR* disk_name)
{
- char *dn = ua (disk_name);
- if (strlen (dn) >= 30)
- dn[30] = 0;
- const char *dn2 = dn;
+ char* dn = ua(disk_name);
+ char* dn2 = dn;
+ if (strlen(dn2) >= 30)
+ dn2[30] = 0;
if (dn2[0] == 0)
dn2 = "empty";
- memset (sector, 0, FS_FLOPPY_BLOCKSIZE);
- sector[0+3] = 2;
- sector[12+3] = 0x48;
- sector[312] = sector[313] = sector[314] = sector[315] = (uae_u8)0xff;
- sector[316+2] = 881 >> 8; sector[316+3] = 881 & 255;
- sector[432] = strlen (dn2);
- strcpy ((char*)sector + 433, dn2);
- sector[508 + 3] = 1;
- disk_date (sector + 420);
- memcpy (sector + 472, sector + 420, 3 * 4);
- memcpy (sector + 484, sector + 420, 3 * 4);
+ memset(sector, 0, FS_FLOPPY_BLOCKSIZE);
+ sector[0 + 3] = 2;
+ sector[12 + 3] = 0x48;
+ sector[312] = sector[313] = sector[314] = sector[315] = (uae_u8)0xff;
+ sector[316 + 2] = 881 >> 8;
+ sector[316 + 3] = 881 & 255;
+ sector[432] = strlen(dn2);
+ strcpy(reinterpret_cast(sector) + 433, dn2);
+ sector[508 + 3] = 1;
+ disk_date(sector + 420);
+ memcpy(sector + 472, sector + 420, 3 * 4);
+ memcpy(sector + 484, sector + 420, 3 * 4);
xfree (dn);
}
-static int getblock (uae_u8 *bitmap, int *prev)
+static int getblock(uae_u8* bitmap, int* prev)
{
int i = *prev;
- while (bitmap[i] != 0xff) {
- if (bitmap[i] == 0) {
- bitmap[i] = 1;
+ while (bitmap[i] != 0xff)
+ {
+ if (bitmap[i] == 0)
+ {
+ bitmap[i] = 1;
*prev = i;
return i;
}
i++;
}
i = 0;
- while (bitmap[i] != 0xff) {
- if (bitmap[i] == 0) {
+ while (bitmap[i] != 0xff)
+ {
+ if (bitmap[i] == 0)
+ {
bitmap[i] = 1;
*prev = i;
- return i;
- }
- i++;
- }
- return -1;
+ return i;
+ }
+ i++;
+ }
+ return -1;
}
-static void pl (uae_u8 *sector, int offset, uae_u32 v)
+static void pl(uae_u8* sector, int offset, uae_u32 v)
{
- sector[offset + 0] = v >> 24;
- sector[offset + 1] = v >> 16;
- sector[offset + 2] = v >> 8;
- sector[offset + 3] = v >> 0;
+ sector[offset + 0] = v >> 24;
+ sector[offset + 1] = v >> 16;
+ sector[offset + 2] = v >> 8;
+ sector[offset + 3] = v >> 0;
}
-static int createdirheaderblock (uae_u8 *sector, int parent, const char *filename, uae_u8 *bitmap, int *prevblock)
+static int createdirheaderblock(uae_u8* sector, int parent, const char* filename, uae_u8* bitmap, int* prevblock)
{
- int block = getblock (bitmap, prevblock);
+ int block = getblock(bitmap, prevblock);
- memset (sector, 0, FS_FLOPPY_BLOCKSIZE);
- pl (sector, 0, 2);
- pl (sector, 4, block);
- disk_date (sector + 512 - 92);
- sector[512 - 80] = strlen (filename);
- strcpy ((char *)sector + 512 - 79, filename);
- pl (sector, 512 - 12, parent);
- pl (sector, 512 - 4, 2);
- return block;
+ memset(sector, 0, FS_FLOPPY_BLOCKSIZE);
+ pl(sector, 0, 2);
+ pl(sector, 4, block);
+ disk_date(sector + 512 - 92);
+ sector[512 - 80] = strlen(filename);
+ strcpy(reinterpret_cast(sector) + 512 - 79, filename);
+ pl(sector, 512 - 12, parent);
+ pl(sector, 512 - 4, 2);
+ return block;
}
-static int createfileheaderblock (struct zfile *z,uae_u8 *sector, int parent, const char *filename, struct zfile *src, uae_u8 *bitmap, int *prevblock)
+static int createfileheaderblock(struct zfile* z, uae_u8* sector, int parent, const char* filename, struct zfile* src, uae_u8* bitmap, int* prevblock)
{
- uae_u8 sector2[FS_FLOPPY_BLOCKSIZE];
- uae_u8 sector3[FS_FLOPPY_BLOCKSIZE];
- int block = getblock (bitmap, prevblock);
- int datablock = getblock (bitmap, prevblock);
- int datasec = 1;
- int extensions;
- int extensionblock, extensioncounter, headerextension = 1;
- int size;
+ uae_u8 sector2[FS_FLOPPY_BLOCKSIZE];
+ uae_u8 sector3[FS_FLOPPY_BLOCKSIZE];
+ int block = getblock(bitmap, prevblock);
+ int datablock = getblock(bitmap, prevblock);
+ int datasec = 1;
+ int extensions;
+ int extensionblock, extensioncounter, headerextension = 1;
+ int size;
- zfile_fseek (src, 0, SEEK_END);
- size = zfile_ftell (src);
- zfile_fseek (src, 0, SEEK_SET);
- extensions = (size + FS_OFS_DATABLOCKSIZE - 1) / FS_OFS_DATABLOCKSIZE;
+ zfile_fseek(src, 0, SEEK_END);
+ size = zfile_ftell(src);
+ zfile_fseek(src, 0, SEEK_SET);
+ extensions = (size + FS_OFS_DATABLOCKSIZE - 1) / FS_OFS_DATABLOCKSIZE;
- memset (sector, 0, FS_FLOPPY_BLOCKSIZE);
- pl (sector, 0, 2);
- pl (sector, 4, block);
- pl (sector, 8, extensions > FS_EXTENSION_BLOCKS ? FS_EXTENSION_BLOCKS : extensions);
- pl (sector, 16, datablock);
- pl (sector, FS_FLOPPY_BLOCKSIZE - 188, size);
- disk_date (sector + FS_FLOPPY_BLOCKSIZE - 92);
- sector[FS_FLOPPY_BLOCKSIZE - 80] = strlen (filename);
- strcpy ((char *)sector + FS_FLOPPY_BLOCKSIZE - 79, filename);
- pl (sector, FS_FLOPPY_BLOCKSIZE - 12, parent);
- pl (sector, FS_FLOPPY_BLOCKSIZE - 4, -3);
- extensioncounter = 0;
- extensionblock = 0;
+ memset(sector, 0, FS_FLOPPY_BLOCKSIZE);
+ pl(sector, 0, 2);
+ pl(sector, 4, block);
+ pl(sector, 8, extensions > FS_EXTENSION_BLOCKS ? FS_EXTENSION_BLOCKS : extensions);
+ pl(sector, 16, datablock);
+ pl(sector, FS_FLOPPY_BLOCKSIZE - 188, size);
+ disk_date(sector + FS_FLOPPY_BLOCKSIZE - 92);
+ sector[FS_FLOPPY_BLOCKSIZE - 80] = strlen(filename);
+ strcpy(reinterpret_cast(sector) + FS_FLOPPY_BLOCKSIZE - 79, filename);
+ pl(sector, FS_FLOPPY_BLOCKSIZE - 12, parent);
+ pl(sector, FS_FLOPPY_BLOCKSIZE - 4, -3);
+ extensioncounter = 0;
+ extensionblock = 0;
- while (size > 0) {
- int datablock2 = datablock;
- int extensionblock2 = extensionblock;
- if (extensioncounter == FS_EXTENSION_BLOCKS) {
- extensioncounter = 0;
- extensionblock = getblock (bitmap, prevblock);
- if (datasec > FS_EXTENSION_BLOCKS + 1) {
- pl (sector3, 8, FS_EXTENSION_BLOCKS);
- pl (sector3, FS_FLOPPY_BLOCKSIZE - 8, extensionblock);
- pl (sector3, 4, extensionblock2);
- disk_checksum(sector3, sector3 + 20);
- writeimageblock (z, sector3, extensionblock2 * FS_FLOPPY_BLOCKSIZE);
- } else {
- pl (sector, 512 - 8, extensionblock);
- }
- memset (sector3, 0, FS_FLOPPY_BLOCKSIZE);
- pl (sector3, 0, 16);
- pl (sector3, FS_FLOPPY_BLOCKSIZE - 12, block);
- pl (sector3, FS_FLOPPY_BLOCKSIZE - 4, -3);
- }
- memset (sector2, 0, FS_FLOPPY_BLOCKSIZE);
- pl (sector2, 0, 8);
- pl (sector2, 4, block);
- pl (sector2, 8, datasec++);
- pl (sector2, 12, size > FS_OFS_DATABLOCKSIZE ? FS_OFS_DATABLOCKSIZE : size);
- zfile_fread (sector2 + 24, size > FS_OFS_DATABLOCKSIZE ? FS_OFS_DATABLOCKSIZE : size, 1, src);
- size -= FS_OFS_DATABLOCKSIZE;
- datablock = 0;
- if (size > 0) datablock = getblock (bitmap, prevblock);
- pl (sector2, 16, datablock);
- disk_checksum(sector2, sector2 + 20);
- writeimageblock (z, sector2, datablock2 * FS_FLOPPY_BLOCKSIZE);
- if (datasec <= FS_EXTENSION_BLOCKS + 1)
- pl (sector, 512 - 204 - extensioncounter * 4, datablock2);
- else
- pl (sector3, 512 - 204 - extensioncounter * 4, datablock2);
- extensioncounter++;
- }
- if (datasec > FS_EXTENSION_BLOCKS) {
- pl (sector3, 8, extensioncounter);
- disk_checksum(sector3, sector3 + 20);
- writeimageblock (z, sector3, extensionblock * FS_FLOPPY_BLOCKSIZE);
- }
- disk_checksum(sector, sector + 20);
- writeimageblock (z, sector, block * FS_FLOPPY_BLOCKSIZE);
- return block;
+ while (size > 0)
+ {
+ int datablock2 = datablock;
+ int extensionblock2 = extensionblock;
+ if (extensioncounter == FS_EXTENSION_BLOCKS)
+ {
+ extensioncounter = 0;
+ extensionblock = getblock(bitmap, prevblock);
+ if (datasec > FS_EXTENSION_BLOCKS + 1)
+ {
+ pl(sector3, 8, FS_EXTENSION_BLOCKS);
+ pl(sector3, FS_FLOPPY_BLOCKSIZE - 8, extensionblock);
+ pl(sector3, 4, extensionblock2);
+ disk_checksum(sector3, sector3 + 20);
+ writeimageblock(z, sector3, extensionblock2 * FS_FLOPPY_BLOCKSIZE);
+ }
+ else
+ {
+ pl(sector, 512 - 8, extensionblock);
+ }
+ memset(sector3, 0, FS_FLOPPY_BLOCKSIZE);
+ pl(sector3, 0, 16);
+ pl(sector3, FS_FLOPPY_BLOCKSIZE - 12, block);
+ pl(sector3, FS_FLOPPY_BLOCKSIZE - 4, -3);
+ }
+ memset(sector2, 0, FS_FLOPPY_BLOCKSIZE);
+ pl(sector2, 0, 8);
+ pl(sector2, 4, block);
+ pl(sector2, 8, datasec++);
+ pl(sector2, 12, size > FS_OFS_DATABLOCKSIZE ? FS_OFS_DATABLOCKSIZE : size);
+ zfile_fread(sector2 + 24, size > FS_OFS_DATABLOCKSIZE ? FS_OFS_DATABLOCKSIZE : size, 1, src);
+ size -= FS_OFS_DATABLOCKSIZE;
+ datablock = 0;
+ if (size > 0) datablock = getblock(bitmap, prevblock);
+ pl(sector2, 16, datablock);
+ disk_checksum(sector2, sector2 + 20);
+ writeimageblock(z, sector2, datablock2 * FS_FLOPPY_BLOCKSIZE);
+ if (datasec <= FS_EXTENSION_BLOCKS + 1)
+ pl(sector, 512 - 204 - extensioncounter * 4, datablock2);
+ else
+ pl(sector3, 512 - 204 - extensioncounter * 4, datablock2);
+ extensioncounter++;
+ }
+ if (datasec > FS_EXTENSION_BLOCKS)
+ {
+ pl(sector3, 8, extensioncounter);
+ disk_checksum(sector3, sector3 + 20);
+ writeimageblock(z, sector3, extensionblock * FS_FLOPPY_BLOCKSIZE);
+ }
+ disk_checksum(sector, sector + 20);
+ writeimageblock(z, sector, block * FS_FLOPPY_BLOCKSIZE);
+ return block;
}
-static void createbitmapblock (uae_u8 *sector, uae_u8 *bitmap)
+static void createbitmapblock(uae_u8* sector, uae_u8* bitmap)
{
- int i, j;
- memset (sector, 0, FS_FLOPPY_BLOCKSIZE);
+ int i, j;
+ memset(sector, 0, FS_FLOPPY_BLOCKSIZE);
i = 0;
- for (;;) {
+ for (;;)
+ {
uae_u32 mask = 0;
- for (j = 0; j < 32; j++) {
+ for (j = 0; j < 32; j++)
+ {
if (bitmap[2 + i * 32 + j] == 0xff)
break;
if (!bitmap[2 + i * 32 + j])
mask |= 1 << j;
- }
+ }
sector[4 + i * 4 + 0] = mask >> 24;
sector[4 + i * 4 + 1] = mask >> 16;
- sector[4 + i * 4 + 2] = mask >> 8;
- sector[4 + i * 4 + 3] = mask >> 0;
+ sector[4 + i * 4 + 2] = mask >> 8;
+ sector[4 + i * 4 + 3] = mask >> 0;
if (bitmap[2 + i * 32 + j] == 0xff)
break;
i++;
- }
- disk_checksum(sector, sector + 0);
+ }
+ disk_checksum(sector, sector + 0);
}
-static int createimagefromexe (struct zfile *src, struct zfile *dst)
+static int createimagefromexe(struct zfile* src, struct zfile* dst)
{
- uae_u8 sector1[FS_FLOPPY_BLOCKSIZE], sector2[FS_FLOPPY_BLOCKSIZE];
- uae_u8 bitmap[FS_FLOPPY_TOTALBLOCKS + 8];
- int exesize;
- int blocksize = FS_OFS_DATABLOCKSIZE;
- int blocks, extensionblocks;
- int totalblocks;
- int fblock1, dblock1;
- const char *fname1 = "runme.exe";
- const TCHAR *fname1b = _T("runme.adf");
- const char *fname2 = "startup-sequence";
- const char *dirname1 = "s";
- struct zfile *ss;
+ uae_u8 sector1[FS_FLOPPY_BLOCKSIZE], sector2[FS_FLOPPY_BLOCKSIZE];
+ uae_u8 bitmap[FS_FLOPPY_TOTALBLOCKS + 8];
+ int exesize;
+ int blocksize = FS_OFS_DATABLOCKSIZE;
+ int blocks, extensionblocks;
+ int totalblocks;
+ int fblock1, dblock1;
+ char* fname1 = "runme.exe";
+ TCHAR* fname1b = _T("runme.adf");
+ char* fname2 = "startup-sequence";
+ char* dirname1 = "s";
+ struct zfile* ss;
int prevblock;
- memset (bitmap, 0, sizeof bitmap);
- zfile_fseek (src, 0, SEEK_END);
- exesize = zfile_ftell (src);
- blocks = (exesize + blocksize - 1) / blocksize;
- extensionblocks = (blocks + FS_EXTENSION_BLOCKS - 1) / FS_EXTENSION_BLOCKS;
- /* bootblock=2, root=1, bitmap=1, startup-sequence=1+1, exefileheader=1 */
- totalblocks = 2 + 1 + 1 + 2 + 1 + blocks + extensionblocks;
- if (totalblocks > FS_FLOPPY_TOTALBLOCKS)
- return 0;
+ memset(bitmap, 0, sizeof bitmap);
+ zfile_fseek(src, 0, SEEK_END);
+ exesize = zfile_ftell(src);
+ blocks = (exesize + blocksize - 1) / blocksize;
+ extensionblocks = (blocks + FS_EXTENSION_BLOCKS - 1) / FS_EXTENSION_BLOCKS;
+ /* bootblock=2, root=1, bitmap=1, startup-sequence=1+1, exefileheader=1 */
+ totalblocks = 2 + 1 + 1 + 2 + 1 + blocks + extensionblocks;
+ if (totalblocks > FS_FLOPPY_TOTALBLOCKS)
+ return 0;
- bitmap[880] = 1;
- bitmap[881] = 1;
- bitmap[0] = 1;
- bitmap[1] = 1;
+ bitmap[880] = 1;
+ bitmap[881] = 1;
+ bitmap[0] = 1;
+ bitmap[1] = 1;
bitmap[1760] = -1;
prevblock = 880;
- dblock1 = createdirheaderblock (sector2, 880, dirname1, bitmap, &prevblock);
- ss = zfile_fopen_empty (src, fname1b, strlen(fname1));
- zfile_fwrite (fname1, strlen(fname1), 1, ss);
- fblock1 = createfileheaderblock (dst, sector1, dblock1, fname2, ss, bitmap, &prevblock);
- zfile_fclose (ss);
- pl (sector2, 24 + dirhash (fname2) * 4, fblock1);
- disk_checksum(sector2, sector2 + 20);
- writeimageblock (dst, sector2, dblock1 * FS_FLOPPY_BLOCKSIZE);
+ dblock1 = createdirheaderblock(sector2, 880, dirname1, bitmap, &prevblock);
+ ss = zfile_fopen_empty(src, fname1b, strlen(fname1));
+ zfile_fwrite(fname1, strlen(fname1), 1, ss);
+ fblock1 = createfileheaderblock(dst, sector1, dblock1, fname2, ss, bitmap, &prevblock);
+ zfile_fclose(ss);
+ pl(sector2, 24 + dirhash(fname2) * 4, fblock1);
+ disk_checksum(sector2, sector2 + 20);
+ writeimageblock(dst, sector2, dblock1 * FS_FLOPPY_BLOCKSIZE);
- fblock1 = createfileheaderblock (dst, sector1, 880, fname1, src, bitmap, &prevblock);
+ fblock1 = createfileheaderblock(dst, sector1, 880, fname1, src, bitmap, &prevblock);
- createrootblock (sector1, zfile_getfilename (src));
- pl (sector1, 24 + dirhash (fname1) * 4, fblock1);
- pl (sector1, 24 + dirhash (dirname1) * 4, dblock1);
- disk_checksum(sector1, sector1 + 20);
- writeimageblock (dst, sector1, 880 * FS_FLOPPY_BLOCKSIZE);
-
- createbitmapblock (sector1, bitmap);
- writeimageblock (dst, sector1, 881 * FS_FLOPPY_BLOCKSIZE);
+ createrootblock(sector1, zfile_getfilename(src));
+ pl(sector1, 24 + dirhash(fname1) * 4, fblock1);
+ pl(sector1, 24 + dirhash(dirname1) * 4, dblock1);
+ disk_checksum(sector1, sector1 + 20);
+ writeimageblock(dst, sector1, 880 * FS_FLOPPY_BLOCKSIZE);
- createbootblock (sector1, 1);
- writeimageblock (dst, sector1, 0 * FS_FLOPPY_BLOCKSIZE);
+ createbitmapblock(sector1, bitmap);
+ writeimageblock(dst, sector1, 881 * FS_FLOPPY_BLOCKSIZE);
- return 1;
+ createbootblock(sector1, 1);
+ writeimageblock(dst, sector1, 0 * FS_FLOPPY_BLOCKSIZE);
+
+ return 1;
}
-static int get_floppy_speed (void)
+static bool isfloppysound(drive* drv)
{
- int m = currprefs.floppy_speed;
- if (m <= 10)
- m = 100;
- m = NORMAL_FLOPPY_SPEED * 100 / m;
- return m;
+ return drv->useturbo == 0;
}
-static int get_floppy_speed2 (drive *drv)
+static int get_floppy_speed()
{
- int m = get_floppy_speed () * drv->tracklen / (2 * 8 * FLOPPY_WRITE_LEN * drv->ddhd);
- if (m <= 0)
- m = 1;
- return m;
+ int m = currprefs.floppy_speed;
+ if (m <= 10)
+ m = 100;
+ m = NORMAL_FLOPPY_SPEED * 100 / m;
+ return m;
}
-static const TCHAR *drive_id_name(drive *drv)
+static int get_floppy_speed2(drive* drv)
{
- switch (drv->drive_id)
- {
- case DRIVE_ID_35HD : return _T("3.5HD");
- case DRIVE_ID_525SD: return _T("5.25SD");
- case DRIVE_ID_35DD : return _T("3.5DD");
- case DRIVE_ID_NONE : return _T("NONE");
- }
+ int m = get_floppy_speed() * drv->tracklen / (2 * 8 * FLOPPY_WRITE_LEN * drv->ddhd);
+ if (m <= 0)
+ m = 1;
+ return m;
+}
+
+static TCHAR* drive_id_name(drive* drv)
+{
+ switch (drv->drive_id)
+ {
+ case DRIVE_ID_35HD: return _T("3.5HD");
+ case DRIVE_ID_525SD: return _T("5.25SD");
+ case DRIVE_ID_35DD: return _T("3.5DD");
+ case DRIVE_ID_NONE: return _T("NONE");
+ }
return _T("UNKNOWN");
}
@@ -543,1067 +625,1152 @@ static const TCHAR *drive_id_name(drive *drv)
* disk or a 3.5 DD disk is inserted. Only 3.5 HD drive id is reported
* when a real 3.5 HD disk is inserted. -Adil
*/
-static void drive_settype_id (drive *drv)
+static void drive_settype_id(drive* drv)
{
- int t = currprefs.floppyslots[drv - &floppy[0]].dfxtype;
+ int t = currprefs.floppyslots[drv - &floppy[0]].dfxtype;
- switch (t)
- {
- case DRV_35_HD:
+ switch (t)
+ {
+ case DRV_35_HD:
#ifdef FLOPPY_DRIVE_HD
- if (!drv->diskfile || drv->ddhd <= 1)
- drv->drive_id = DRIVE_ID_35DD;
- else
- drv->drive_id = DRIVE_ID_35HD;
+ if (!drv->diskfile || drv->ddhd <= 1)
+ drv->drive_id = DRIVE_ID_35DD;
+ else
+ drv->drive_id = DRIVE_ID_35HD;
#else
drv->drive_id = DRIVE_ID_35DD;
#endif
- break;
- case DRV_35_DD_ESCOM:
- case DRV_35_DD:
- default:
- drv->drive_id = DRIVE_ID_35DD;
- break;
- case DRV_525_SD:
- drv->drive_id = DRIVE_ID_525SD;
- break;
- case DRV_NONE:
- case DRV_PC_ONLY_40:
- case DRV_PC_ONLY_80:
- drv->drive_id = DRIVE_ID_NONE;
- break;
- }
+ break;
+ case DRV_35_DD_ESCOM:
+ case DRV_35_DD:
+ default:
+ drv->drive_id = DRIVE_ID_35DD;
+ break;
+ case DRV_525_SD:
+ drv->drive_id = DRIVE_ID_525SD;
+ break;
+ case DRV_NONE:
+ drv->drive_id = DRIVE_ID_NONE;
+ break;
+ }
}
-static void drive_image_free (drive *drv)
+static void drive_image_free(drive* drv)
{
switch (drv->filetype)
{
- case ADF_FDI:
-#ifdef FDI2RAW
- fdi2raw_header_free (drv->fdi);
- drv->fdi = 0;
+ case ADF_IPF:
+#ifdef CAPS
+ caps_unloadimage(drv - floppy);
#endif
- break;
- }
- drv->filetype = ADF_NONE;
- zfile_fclose (drv->diskfile);
- drv->diskfile = NULL;
- zfile_fclose (drv->writediskfile);
- drv->writediskfile = NULL;
- zfile_fclose(drv->pcdecodedfile);
- drv->pcdecodedfile = NULL;
+ break;
+ case ADF_SCP:
+#ifdef SCP
+ scp_close(drv - floppy);
+#endif
+ break;
+ case ADF_FDI:
+#ifdef FDI2RAW
+ fdi2raw_header_free(drv->fdi);
+ drv->fdi = 0;
+#endif
+ break;
+ }
+ drv->filetype = ADF_NONE;
+ zfile_fclose(drv->diskfile);
+ drv->diskfile = nullptr;
+ zfile_fclose(drv->writediskfile);
+ drv->writediskfile = nullptr;
}
-static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const TCHAR *fname, bool fake, bool writeprotected);
+static int drive_insert(drive* drv, struct uae_prefs* p, int dnum, const TCHAR* fname, bool fake, bool writeprotected);
static void reset_drive_gui(int num)
{
- gui_data.drive_disabled[num] = 0;
- gui_data.df[num][0] = 0;
- gui_data.crc32[num] = 0;
- if (currprefs.floppyslots[num].dfxtype < 0)
- gui_data.drive_disabled[num] = 1;
+ gui_data.drive_disabled[num] = 0;
+ gui_data.df[num][0] = 0;
+ gui_data.crc32[num] = 0;
+ if (currprefs.floppyslots[num].dfxtype < 0)
+ gui_data.drive_disabled[num] = 1;
+}
+
+static void setamax()
+{
+#ifdef AMAX
+ if (currprefs.amaxromfile[0]) {
+ /* Put A-Max as last drive in drive chain */
+ int j;
+ for (j = 0; j < MAX_FLOPPY_DRIVES; j++)
+ if (floppy[j].amax)
+ return;
+ for (j = 0; j < MAX_FLOPPY_DRIVES; j++) {
+ if ((1 << j) & disabled) {
+ floppy[j].amax = 1;
+ write_log(_T("AMAX: drive %d\n"), j);
+ return;
+ }
+ }
+ }
+#endif
}
static void reset_drive(int num)
{
- drive *drv = &floppy[num];
+ drive* drv = &floppy[num];
- drive_image_free (drv);
- drv->motoroff = 1;
- drv->idbit = 0;
- drv->drive_id = 0;
- drv->drive_id_scnt = 0;
- disabled &= ~(1 << num);
- reserved &= ~(1 << num);
- if (currprefs.floppyslots[num].dfxtype < 0 || currprefs.floppyslots[num].dfxtype >= DRV_PC_ONLY_40)
- disabled |= 1 << num;
- if (currprefs.floppyslots[num].dfxtype >= DRV_PC_ONLY_40)
- reserved |= 1 << num;
- reset_drive_gui(num);
- /* most internal Amiga floppy drives won't enable
- * diskready until motor is running at full speed
- * and next indexsync has been passed
- */
- drv->indexhackmode = 0;
- if (num == 0 && currprefs.floppyslots[num].dfxtype == 0)
- drv->indexhackmode = 1;
- drv->dskchange_time = 0;
- drv->dskchange = false;
- drv->dskready_down_time = 0;
- drv->dskready_up_time = 0;
- drv->buffered_cyl = -1;
- drv->buffered_side = -1;
- gui_led (num + LED_DF0, 0, -1);
- drive_settype_id (drv);
- _tcscpy (currprefs.floppyslots[num].df, changed_prefs.floppyslots[num].df);
- drv->newname[0] = 0;
+ drv->amax = 0;
+ drive_image_free(drv);
+ drv->motoroff = 1;
+ drv->idbit = 0;
+ drv->drive_id = 0;
+ drv->drive_id_scnt = 0;
+ drv->lastdataacesstrack = -1;
+ disabled &= ~(1 << num);
+ if (currprefs.floppyslots[num].dfxtype < 0)
+ disabled |= 1 << num;
+ reset_drive_gui(num);
+ /* most internal Amiga floppy drives won't enable
+ * diskready until motor is running at full speed
+ * and next indexsync has been passed
+ */
+ drv->indexhackmode = 0;
+ if (num == 0 && currprefs.floppyslots[num].dfxtype == 0)
+ drv->indexhackmode = 1;
+ drv->dskchange_time = 0;
+ drv->dskchange = false;
+ drv->dskready_down_time = 0;
+ drv->dskready_up_time = 0;
+ drv->buffered_cyl = -1;
+ drv->buffered_side = -1;
+ gui_led(num + LED_DF0, 0);
+ drive_settype_id(drv);
+ _tcscpy (currprefs.floppyslots[num].df, changed_prefs.floppyslots[num].df);
+ drv->newname[0] = 0;
drv->newnamewriteprotected = false;
- if (!drive_insert (drv, &currprefs, num, currprefs.floppyslots[num].df, false, false))
- disk_eject (num);
+ if (!drive_insert(drv, &currprefs, num, currprefs.floppyslots[num].df, false, false))
+ disk_eject(num);
}
/* code for track display */
-static void update_drive_gui (int num, bool force)
+static void update_drive_gui(int num, bool force)
{
- if (num >= currprefs.nr_floppies)
- return;
- drive *drv = floppy + num;
- bool writ = dskdmaen == DSKDMA_WRITE && drv->state && !((selected | disabled) & (1 << num));
+ if (num >= currprefs.nr_floppies)
+ return;
+ drive* drv = floppy + num;
+ bool writ = dskdmaen == DSKDMA_WRITE && drv->state && !((selected | disabled) & (1 << num));
if (!force && drv->state == gui_data.drive_motor[num]
- && drv->cyl == gui_data.drive_track[num]
- && side == gui_data.drive_side
- && drv->crc32 == gui_data.crc32[num]
- && writ == gui_data.drive_writing[num]
- && !_tcscmp (gui_data.df[num], currprefs.floppyslots[num].df))
- return;
- _tcscpy (gui_data.df[num], currprefs.floppyslots[num].df);
- gui_data.crc32[num] = drv->crc32;
- gui_data.drive_motor[num] = drv->state;
- gui_data.drive_track[num] = drv->cyl;
- if (reserved & (1 << num))
- gui_data.drive_side = reserved_side;
- else
- gui_data.drive_side = side;
- gui_data.drive_writing[num] = writ;
- gui_led (num + LED_DF0, (gui_data.drive_motor[num] ? 1 : 0) | (gui_data.drive_writing[num] ? 2 : 0), -1);
+ && drv->cyl == gui_data.drive_track[num]
+ && side == gui_data.drive_side
+ && drv->crc32 == gui_data.crc32[num]
+ && writ == gui_data.drive_writing[num]
+ && !_tcscmp (gui_data.df[num], currprefs.floppyslots[num].df))
+ return;
+ _tcscpy (gui_data.df[num], currprefs.floppyslots[num].df);
+ gui_data.crc32[num] = drv->crc32;
+ gui_data.drive_motor[num] = drv->state;
+ gui_data.drive_track[num] = drv->cyl;
+ gui_data.drive_side = side;
+ gui_data.drive_writing[num] = writ;
+ gui_led(num + LED_DF0, (gui_data.drive_motor[num] ? 1 : 0) | (gui_data.drive_writing[num] ? 2 : 0));
}
-static void drive_fill_bigbuf (drive *drv, int);
+static void drive_fill_bigbuf(drive* drv, int);
-int DISK_validate_filename (struct uae_prefs *p, const TCHAR *fname, int leave_open, bool *wrprot, uae_u32 *crc32, struct zfile **zf)
+int DISK_validate_filename(struct uae_prefs* p, const TCHAR* fname, int leave_open, bool* wrprot, uae_u32* crc32, struct zfile** zf)
{
if (zf)
- *zf = NULL;
- if (crc32)
- *crc32 = 0;
+ *zf = nullptr;
+ if (crc32)
+ *crc32 = 0;
if (wrprot)
- *wrprot = p->floppy_read_only ? 1 : 0;
- if (leave_open || !zf) {
- struct zfile *f = zfile_fopen (fname, _T("r+b"), ZFD_NORMAL | ZFD_DISKHISTORY);
- if (!f) {
- if (wrprot)
- *wrprot = 1;
- f = zfile_fopen (fname, _T("rb"), ZFD_NORMAL | ZFD_DISKHISTORY);
- }
- if (f && crc32)
- *crc32 = zfile_crc32 (f);
+ *wrprot = false;
+ if (leave_open || !zf)
+ {
+ struct zfile* f = zfile_fopen(fname, _T("r+b"), ZFD_NORMAL | ZFD_DISKHISTORY);
+ if (!f)
+ {
+ if (wrprot)
+ *wrprot = true;
+ f = zfile_fopen(fname, _T("rb"), ZFD_NORMAL | ZFD_DISKHISTORY);
+ }
+ if (f && crc32)
+ *crc32 = zfile_crc32(f);
if (!zf)
- zfile_fclose (f);
+ zfile_fclose(f);
else
*zf = f;
return f ? 1 : 0;
- } else {
- if (zfile_exists (fname)) {
- if (wrprot && !p->floppy_read_only)
- *wrprot = 0;
- if (crc32) {
- struct zfile *f = zfile_fopen (fname, _T("rb"), ZFD_NORMAL | ZFD_DISKHISTORY);
- if (f)
- *crc32 = zfile_crc32 (f);
- zfile_fclose (f);
- }
+ }
+ else
+ {
+ if (zfile_exists(fname))
+ {
+ if (wrprot)
+ *wrprot = false;
+ if (crc32)
+ {
+ struct zfile* f = zfile_fopen(fname, _T("rb"), ZFD_NORMAL | ZFD_DISKHISTORY);
+ if (f)
+ *crc32 = zfile_crc32(f);
+ zfile_fclose(f);
+ }
return 1;
- } else {
- if (wrprot)
- *wrprot = 1;
- return 0;
- }
- }
+ }
+ else
+ {
+ if (wrprot)
+ *wrprot = true;
+ return 0;
+ }
+ }
}
-static void updatemfmpos (drive *drv)
+static void updatemfmpos(drive* drv)
{
- if (drv->prevtracklen) {
- drv->mfmpos = drv->mfmpos * (drv->tracklen * 1000 / drv->prevtracklen) / 1000;
+ if (drv->prevtracklen)
+ {
+ drv->mfmpos = drv->mfmpos * (drv->tracklen * 1000 / drv->prevtracklen) / 1000;
if (drv->mfmpos >= drv->tracklen)
drv->mfmpos = drv->tracklen - 1;
}
- drv->mfmpos %= drv->tracklen;
- drv->prevtracklen = drv->tracklen;
+ drv->mfmpos %= drv->tracklen;
+ drv->prevtracklen = drv->tracklen;
}
-static void track_reset (drive *drv)
+static void track_reset(drive* drv)
{
- drv->tracklen = FLOPPY_WRITE_LEN * drv->ddhd * 2 * 8;
+ drv->tracklen = FLOPPY_WRITE_LEN * drv->ddhd * 2 * 8;
drv->revolutions = 1;
- drv->trackspeed = get_floppy_speed ();
- drv->buffered_side = -1;
- drv->skipoffset = -1;
- drv->tracktiming[0] = 0;
- memset (drv->bigmfmbuf, 0xaa, FLOPPY_WRITE_LEN * 2 * drv->ddhd);
- updatemfmpos (drv);
+ drv->trackspeed = get_floppy_speed();
+ drv->buffered_side = -1;
+ drv->skipoffset = -1;
+ drv->tracktiming[0] = 0;
+ memset(drv->bigmfmbuf, 0xaa, FLOPPY_WRITE_LEN * 2 * drv->ddhd);
+ updatemfmpos(drv);
}
-static int read_header_ext2 (struct zfile *diskfile, trackid *trackdata, int *num_tracks, int *ddhd)
-{
- uae_u8 buffer[2 + 2 + 4 + 4];
- trackid *tid;
- int offs;
- int i;
-
- zfile_fseek (diskfile, 0, SEEK_SET);
- zfile_fread (buffer, 1, 8, diskfile);
- if (strncmp ((char *)buffer, "UAE-1ADF", 8))
- return 0;
- zfile_fread (buffer, 1, 4, diskfile);
- *num_tracks = buffer[2] * 256 + buffer[3];
- offs = 8 + 2 + 2 + (*num_tracks) * (2 + 2 + 4 + 4);
-
- for (i = 0; i < (*num_tracks); i++) {
- tid = trackdata + i;
- zfile_fread (buffer, 2 + 2 + 4 + 4, 1, diskfile);
- tid->type = (image_tracktype)buffer[3];
- tid->revolutions = buffer[2] + 1;
- tid->len = buffer[5] * 65536 + buffer[6] * 256 + buffer[7];
- tid->bitlen = buffer[9] * 65536 + buffer[10] * 256 + buffer[11];
- tid->offs = offs;
- if (tid->len > 20000 && ddhd)
- *ddhd = 2;
- tid->track = i;
- offs += tid->len;
- }
- return 1;
-}
-
-static void saveimagecutpathpart(TCHAR *name)
+static int read_header_ext2(struct zfile* diskfile, trackid* trackdata, int* num_tracks, int* ddhd)
{
+ uae_u8 buffer[2 + 2 + 4 + 4];
+ trackid* tid;
+ int offs;
int i;
- i = _tcslen (name) - 1;
- while (i > 0) {
- if (name[i] == '/' || name[i] == '\\') {
- name[i] = 0;
- break;
- }
- if (name[i] == '.') {
- name[i] = 0;
- break;
- }
- i--;
- }
- while (i > 0) {
- if (name[i] == '/' || name[i] == '\\') {
- name[i] = 0;
- break;
- }
- i--;
+ zfile_fseek(diskfile, 0, SEEK_SET);
+ zfile_fread(buffer, 1, 8, diskfile);
+ if (strncmp(reinterpret_cast(buffer), "UAE-1ADF", 8))
+ return 0;
+ zfile_fread(buffer, 1, 4, diskfile);
+ *num_tracks = buffer[2] * 256 + buffer[3];
+ offs = 8 + 2 + 2 + (*num_tracks) * (2 + 2 + 4 + 4);
+
+ for (i = 0; i < (*num_tracks); i++)
+ {
+ tid = trackdata + i;
+ zfile_fread(buffer, 2 + 2 + 4 + 4, 1, diskfile);
+ tid->type = image_tracktype(buffer[3]);
+ tid->revolutions = buffer[2] + 1;
+ tid->len = buffer[5] * 65536 + buffer[6] * 256 + buffer[7];
+ tid->bitlen = buffer[9] * 65536 + buffer[10] * 256 + buffer[11];
+ tid->offs = offs;
+ if (tid->len > 20000 && ddhd)
+ *ddhd = 2;
+ tid->track = i;
+ offs += tid->len;
}
+ return 1;
}
-static void saveimagecutfilepart(TCHAR *name)
+TCHAR* DISK_get_saveimagepath(const TCHAR* name)
{
- TCHAR tmp[MAX_DPATH];
- int i;
-
- _tcscpy(tmp, name);
- i = _tcslen (tmp) - 1;
- while (i > 0) {
- if (tmp[i] == '/' || tmp[i] == '\\') {
- _tcscpy(name, tmp + i + 1);
- break;
- }
- if (tmp[i] == '.') {
- tmp[i] = 0;
- break;
- }
- i--;
- }
- while (i > 0) {
- if (tmp[i] == '/' || tmp[i] == '\\') {
- _tcscpy(name, tmp + i + 1);
- break;
- }
- i--;
- }
-}
-
-static void saveimageaddfilename(TCHAR *dst, const TCHAR *src, int type)
-{
- _tcscat(dst, src);
- if (type)
- _tcscat(dst, _T(".save_adf"));
- else
- _tcscat(dst, _T("_save.adf"));
-}
-
-static TCHAR *DISK_get_default_saveimagepath (const TCHAR *name)
-{
- TCHAR name1[MAX_DPATH];
+ static TCHAR name1[MAX_DPATH];
+ TCHAR name2[MAX_DPATH];
TCHAR path[MAX_DPATH];
- _tcscpy(name1, name);
- saveimagecutfilepart(name1);
- fetch_saveimagepath (path, sizeof path / sizeof (TCHAR), 1);
- saveimageaddfilename(path, name1, 0);
- return my_strdup(path);
-}
+ int i;
-// -2 = existing, if not, use 0.
-// -1 = as configured
-// 0 = saveimages-dir
-// 1 = image dir
-TCHAR *DISK_get_saveimagepath(const TCHAR *name, int type)
-{
- int typev = type;
-
- for (int i = 0; i < 2; i++) {
- if (typev == 1 || (typev == -2 && i == 1)) {
- TCHAR si_name[MAX_DPATH], si_path[MAX_DPATH];
- _tcscpy(si_name, name);
- _tcscpy(si_path, name);
- saveimagecutfilepart(si_name);
- saveimagecutpathpart(si_path);
- _tcscat(si_path, FSDB_DIR_SEPARATOR_S);
- saveimageaddfilename(si_path, si_name, 1);
- if (typev != -2 || (typev == -2 && zfile_exists(si_path)))
- return my_strdup(si_path);
- }
- if (typev == 2 || typev == -1 || typev == -2) {
- TCHAR *p = DISK_get_default_saveimagepath(name);
- if (typev != -2 || (typev == -2 && zfile_exists(p)))
- return p;
- xfree(p);
+ _tcscpy (name2, name);
+ i = _tcslen (name2) - 1;
+ while (i > 0)
+ {
+ if (name2[i] == '.')
+ {
+ name2[i] = 0;
+ break;
}
+ i--;
}
- return DISK_get_saveimagepath(name, -1);
+ while (i > 0)
+ {
+ if (name2[i] == '/' || name2[i] == '\\')
+ {
+ i++;
+ break;
+ }
+ i--;
+ }
+ fetch_saveimagepath(path, sizeof path / sizeof (TCHAR), 1);
+ _stprintf(name1, _T("%s%s_save.adf"), path, name2 + i);
+ return name1;
}
-static struct zfile *getexistingwritefile(struct uae_prefs *p, const TCHAR *name, bool *wrprot)
+static struct zfile* getwritefile(struct uae_prefs* p, const TCHAR* name, bool* wrprot)
{
- struct zfile *zf = NULL;
- TCHAR *path;
- path = DISK_get_saveimagepath(name, 0);
- DISK_validate_filename (p, path, 1, wrprot, NULL, &zf);
- xfree(path);
- if (zf)
- return zf;
- path = DISK_get_saveimagepath(name, -1);
- DISK_validate_filename (p, path, 1, wrprot, NULL, &zf);
- xfree(path);
+ struct zfile* zf;
+ DISK_validate_filename(p, DISK_get_saveimagepath(name), 1, wrprot, nullptr, &zf);
return zf;
}
-static int iswritefileempty (struct uae_prefs *p, const TCHAR *name)
+static int iswritefileempty(struct uae_prefs* p, const TCHAR* name)
{
- struct zfile *zf;
- bool wrprot;
- uae_char buffer[8];
- trackid td[MAX_TRACKS];
- int tracks, ddhd, i, ret;
+ struct zfile* zf;
+ bool wrprot;
+ uae_char buffer[8];
+ trackid td[MAX_TRACKS];
+ int tracks, ddhd, i, ret;
- zf = getexistingwritefile (p, name, &wrprot);
- if (!zf) return 1;
- zfile_fread (buffer, sizeof (char), 8, zf);
- if (strncmp ((uae_char*)buffer, "UAE-1ADF", 8))
- return 0;
- ret = read_header_ext2 (zf, td, &tracks, &ddhd);
- zfile_fclose (zf);
- if (!ret)
- return 1;
- for (i = 0; i < tracks; i++) {
- if (td[i].bitlen) return 0;
- }
- return 1;
+ zf = getwritefile(p, name, &wrprot);
+ if (!zf) return 1;
+ zfile_fread(buffer, sizeof (char), 8, zf);
+ if (strncmp(static_cast(buffer), "UAE-1ADF", 8))
+ return 0;
+ ret = read_header_ext2(zf, td, &tracks, &ddhd);
+ zfile_fclose(zf);
+ if (!ret)
+ return 1;
+ for (i = 0; i < tracks; i++)
+ {
+ if (td[i].bitlen) return 0;
+ }
+ return 1;
}
-static int openwritefile (struct uae_prefs *p, drive *drv, int create)
+static int openwritefile(struct uae_prefs* p, drive* drv, int create)
{
- bool wrprot = 0;
+ bool wrprot = false;
- drv->writediskfile = getexistingwritefile(p, currprefs.floppyslots[drv - &floppy[0]].df, &wrprot);
- if (drv->writediskfile) {
- drv->wrprot = wrprot;
- if (!read_header_ext2 (drv->writediskfile, drv->writetrackdata, &drv->write_num_tracks, 0)) {
- zfile_fclose (drv->writediskfile);
- drv->writediskfile = 0;
- drv->wrprot = 1;
- } else {
- if (drv->write_num_tracks > drv->num_tracks)
- drv->num_tracks = drv->write_num_tracks;
- }
- } else if (zfile_iscompressed (drv->diskfile)) {
- drv->wrprot = 1;
- }
- return drv->writediskfile ? 1 : 0;
+ drv->writediskfile = getwritefile(p, currprefs.floppyslots[drv - &floppy[0]].df, &wrprot);
+ if (drv->writediskfile)
+ {
+ drv->wrprot = wrprot;
+ if (!read_header_ext2(drv->writediskfile, drv->writetrackdata, &drv->write_num_tracks, nullptr))
+ {
+ zfile_fclose(drv->writediskfile);
+ drv->writediskfile = nullptr;
+ drv->wrprot = true;
+ }
+ else
+ {
+ if (drv->write_num_tracks > drv->num_tracks)
+ drv->num_tracks = drv->write_num_tracks;
+ }
+ }
+ else if (zfile_iscompressed(drv->diskfile))
+ {
+ drv->wrprot = true;
+ }
+ return drv->writediskfile ? 1 : 0;
}
-static bool diskfile_iswriteprotect (struct uae_prefs *p, const TCHAR *fname, int *needwritefile, drive_type *drvtype)
+static bool diskfile_iswriteprotect(struct uae_prefs* p, const TCHAR* fname, int* needwritefile, drive_type* drvtype)
{
- struct zfile *zf1, *zf2;
- bool wrprot1 = 0, wrprot2 = 1;
- uae_char buffer[25];
-
- *needwritefile = 0;
- *drvtype = DRV_35_DD;
- DISK_validate_filename (p, fname, 1, &wrprot1, NULL, &zf1);
- if (!zf1)
- return 1;
- if (zfile_iscompressed (zf1)) {
- wrprot1 = 1;
- *needwritefile = 1;
- }
- zf2 = getexistingwritefile(p, fname, &wrprot2);
- zfile_fclose (zf2);
- zfile_fread (buffer, sizeof (char), 25, zf1);
- zfile_fclose (zf1);
- if (strncmp ((uae_char *) buffer, "Formatted Disk Image file", 25) == 0) {
- *needwritefile = 1;
- return wrprot2;
- }
- if (strncmp ((uae_char *) buffer, "UAE-1ADF", 8) == 0) {
- if (wrprot1)
- return wrprot2;
- return wrprot1;
- }
- if (strncmp ((uae_char *) buffer, "UAE--ADF", 8) == 0) {
- *needwritefile = 1;
- return wrprot2;
- }
- if (memcmp (exeheader, buffer, sizeof exeheader) == 0)
- return 0;
- if (wrprot1)
- return wrprot2;
- return wrprot1;
+ struct zfile *zf1, *zf2;
+ bool wrprot1 = false, wrprot2 = true;
+ uae_char buffer[25];
+
+ *needwritefile = 0;
+ *drvtype = DRV_35_DD;
+ DISK_validate_filename(p, fname, 1, &wrprot1, nullptr, &zf1);
+ if (!zf1)
+ return true;
+ if (zfile_iscompressed(zf1))
+ {
+ wrprot1 = true;
+ *needwritefile = 1;
+ }
+ zf2 = getwritefile(p, fname, &wrprot2);
+ zfile_fclose(zf2);
+ zfile_fread(buffer, sizeof (char), 25, zf1);
+ zfile_fclose(zf1);
+ if (strncmp(static_cast(buffer), "CAPS", 4) == 0) {
+ *needwritefile = 1;
+ return wrprot2;
+ }
+ if (strncmp(static_cast(buffer), "SCP", 3) == 0) {
+ *needwritefile = 1;
+ return wrprot2;
+ }
+ if (strncmp(static_cast(buffer), "Formatted Disk Image file", 25) == 0)
+ {
+ *needwritefile = 1;
+ return wrprot2;
+ }
+ if (strncmp(static_cast(buffer), "UAE-1ADF", 8) == 0)
+ {
+ if (wrprot1)
+ return wrprot2;
+ return wrprot1;
+ }
+ if (strncmp(static_cast(buffer), "UAE--ADF", 8) == 0)
+ {
+ *needwritefile = 1;
+ return wrprot2;
+ }
+ if (memcmp(exeheader, buffer, sizeof exeheader) == 0)
+ return false;
+ if (wrprot1)
+ return wrprot2;
+ return wrprot1;
}
-static bool isrecognizedext (const TCHAR *name)
+static bool isrecognizedext(const TCHAR* name)
{
- const TCHAR *ext = _tcsrchr (name, '.');
- if (ext) {
- ext++;
- if (!_tcsicmp (ext, _T("adf")) || !_tcsicmp (ext, _T("adz")) || !_tcsicmp (ext, _T("st")) || !_tcsicmp (ext, _T("ima")) || !_tcsicmp (ext, _T("img")))
+ const TCHAR* ext = _tcsrchr (name, '.');
+ if (ext)
+ {
+ if (!_tcsicmp (ext + 1, _T("adf")) || !_tcsicmp (ext + 1, _T("adz")) || !_tcsicmp (ext + 1, _T("st")) || !_tcsicmp (ext + 1, _T("ima")) || !_tcsicmp (ext + 1, _T("img")))
return true;
- }
+ }
return false;
}
-static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const TCHAR *fname, bool fake, bool forcedwriteprotect)
+static int drive_insert(drive* drv, struct uae_prefs* p, int dnum, const TCHAR* fname, bool fake, bool forcedwriteprotect)
{
- uae_u8 buffer[2 + 2 + 4 + 4];
- trackid *tid;
- int num_tracks, size;
+ uae_u8 buffer[2 + 2 + 4 + 4];
+ trackid* tid;
+ int num_tracks, size;
int canauto;
- drive_image_free (drv);
- if (!fake)
- DISK_examine_image(p, dnum, &disk_info_data);
- DISK_validate_filename (p, fname, 1, &drv->wrprot, &drv->crc32, &drv->diskfile);
+ drive_image_free(drv);
+ DISK_validate_filename(p, fname, 1, &drv->wrprot, &drv->crc32, &drv->diskfile);
drv->forcedwrprot = forcedwriteprotect;
if (drv->forcedwrprot)
drv->wrprot = true;
- drv->ddhd = 1;
- drv->num_heads = 2;
- drv->num_secs = 0;
- drv->hard_num_cyls = p->floppyslots[dnum].dfxtype == DRV_525_SD ? 40 : 80;
- drv->tracktiming[0] = 0;
- drv->useturbo = 0;
- drv->indexoffset = 0;
- if (!fake) {
- drv->dskeject = false;
- }
+ drv->ddhd = 1;
+ drv->num_secs = 0;
+ drv->hard_num_cyls = p->floppyslots[dnum].dfxtype == DRV_525_SD ? 40 : 80;
+ drv->tracktiming[0] = 0;
+ drv->useturbo = 0;
+ drv->indexoffset = 0;
- if (!drv->motoroff) {
+ gui_disk_image_change(dnum, fname, drv->wrprot);
+
+ if (!drv->motoroff)
+ {
drv->dskready_up_time = DSKREADY_UP_TIME * 312 + (uaerand() & 511);
- drv->dskready_down_time = 0;
- }
-
- if (drv->diskfile == 0) {
- track_reset (drv);
- return 0;
- }
-
- if (!fake) {
- if (currprefs.floppyslots[dnum].df != fname) {
- _tcsncpy (currprefs.floppyslots[dnum].df, fname, 255);
- currprefs.floppyslots[dnum].df[255] = 0;
- }
- currprefs.floppyslots[dnum].forcedwriteprotect = forcedwriteprotect;
- _tcsncpy (changed_prefs.floppyslots[dnum].df, fname, 255);
- changed_prefs.floppyslots[dnum].df[255] = 0;
- changed_prefs.floppyslots[dnum].forcedwriteprotect = forcedwriteprotect;
- _tcscpy (drv->newname, fname);
- drv->newnamewriteprotected = forcedwriteprotect;
- gui_filename (dnum, fname);
+ drv->dskready_down_time = 0;
}
- memset (buffer, 0, sizeof buffer);
- size = 0;
- if (drv->diskfile) {
- zfile_fread (buffer, sizeof (char), 8, drv->diskfile);
- zfile_fseek (drv->diskfile, 0, SEEK_END);
- size = zfile_ftell (drv->diskfile);
- zfile_fseek (drv->diskfile, 0, SEEK_SET);
- }
+ if (drv->diskfile == nullptr && !drv->catweasel)
+ {
+ track_reset(drv);
+ return 0;
+ }
+
+ if (!fake)
+ {
+ //TODO: enable when we implement inputrecord.cpp
+ //inprec_recorddiskchange(dnum, fname, drv->wrprot);
+ _tcsncpy (currprefs.floppyslots[dnum].df, fname, 255);
+ currprefs.floppyslots[dnum].df[255] = 0;
+ currprefs.floppyslots[dnum].forcedwriteprotect = forcedwriteprotect;
+ _tcsncpy (changed_prefs.floppyslots[dnum].df, fname, 255);
+ changed_prefs.floppyslots[dnum].df[255] = 0;
+ changed_prefs.floppyslots[dnum].forcedwriteprotect = forcedwriteprotect;
+ _tcscpy (drv->newname, fname);
+ drv->newnamewriteprotected = forcedwriteprotect;
+ gui_filename(dnum, fname);
+ }
+
+ memset(buffer, 0, sizeof buffer);
+ size = 0;
+ if (drv->diskfile)
+ {
+ zfile_fread(buffer, sizeof (char), 8, drv->diskfile);
+ zfile_fseek(drv->diskfile, 0, SEEK_END);
+ size = zfile_ftell(drv->diskfile);
+ zfile_fseek(drv->diskfile, 0, SEEK_SET);
+ }
canauto = 0;
- if (isrecognizedext (fname))
+ if (isrecognizedext(fname))
canauto = 1;
- if (!canauto && drv->diskfile && isrecognizedext (zfile_getname (drv->diskfile)))
- canauto = 1;
- // if PC-only drive, make sure PC-like floppies are alwayss detected
- if (!canauto && currprefs.floppyslots[dnum].dfxtype >= DRV_PC_ONLY_40)
+ if (!canauto && drv->diskfile && isrecognizedext(zfile_getname(drv->diskfile)))
canauto = 1;
- if (0) {
-
-#ifdef FDI2RAW
- } else if ((drv->fdi = fdi2raw_header (drv->diskfile))) {
+ if (drv->catweasel) {
drv->wrprot = true;
- drv->num_tracks = fdi2raw_get_last_track (drv->fdi);
- drv->num_secs = fdi2raw_get_num_sector (drv->fdi);
+ drv->filetype = ADF_CATWEASEL;
+ drv->num_tracks = 80;
+ drv->ddhd = 1;
+
+#ifdef CAPS
+ }
+ else if (strncmp((char*)buffer, "CAPS", 4) == 0) {
+
+ drv->wrprot = true;
+ if (!caps_loadimage(drv->diskfile, drv - floppy, &num_tracks)) {
+ zfile_fclose(drv->diskfile);
+ drv->diskfile = 0;
+ return 0;
+ }
+ drv->num_tracks = num_tracks;
+ drv->filetype = ADF_IPF;
+#endif
+#ifdef SCP
+ }
+ else if (strncmp((char*)buffer, "SCP", 3) == 0) {
+ drv->wrprot = true;
+ if (!scp_open(drv->diskfile, drv - floppy, &num_tracks)) {
+ zfile_fclose(drv->diskfile);
+ drv->diskfile = 0;
+ return 0;
+ }
+ drv->num_tracks = num_tracks;
+ drv->filetype = ADF_SCP;
+#endif
+#ifdef FDI2RAW
+ }
+ else if (drv->fdi = fdi2raw_header(drv->diskfile)) {
+
+ drv->wrprot = true;
+ drv->num_tracks = fdi2raw_get_last_track(drv->fdi);
+ drv->num_secs = fdi2raw_get_num_sector(drv->fdi);
drv->filetype = ADF_FDI;
#endif
- } else if (strncmp ((char*)buffer, "UAE-1ADF", 8) == 0) {
-
- read_header_ext2 (drv->diskfile, drv->trackdata, &drv->num_tracks, &drv->ddhd);
- drv->filetype = ADF_EXT2;
- drv->num_secs = 11;
- if (drv->ddhd > 1)
- drv->num_secs = 22;
-
- } else if (strncmp ((char *) buffer, "UAE--ADF", 8) == 0) {
- int offs = 160 * 4 + 8;
- int i;
+ }
+ else if (strncmp(reinterpret_cast(buffer), "UAE-1ADF", 8) == 0)
+ {
+ read_header_ext2(drv->diskfile, drv->trackdata, &drv->num_tracks, &drv->ddhd);
+ drv->filetype = ADF_EXT2;
+ drv->num_secs = 11;
+ if (drv->ddhd > 1)
+ drv->num_secs = 22;
+ }
+ else if (strncmp(reinterpret_cast(buffer), "UAE--ADF", 8) == 0)
+ {
+ int offs = 160 * 4 + 8;
+ int i;
drv->wrprot = true;
- drv->filetype = ADF_EXT1;
- drv->num_tracks = 160;
- drv->num_secs = 11;
+ drv->filetype = ADF_EXT1;
+ drv->num_tracks = 160;
+ drv->num_secs = 11;
- zfile_fseek (drv->diskfile, 8, SEEK_SET);
- for (i = 0; i < 160; i++) {
- tid = &drv->trackdata[i];
- zfile_fread (buffer, 4, 1, drv->diskfile);
- tid->sync = buffer[0] * 256 + buffer[1];
- tid->len = buffer[2] * 256 + buffer[3];
- tid->offs = offs;
+ zfile_fseek(drv->diskfile, 8, SEEK_SET);
+ for (i = 0; i < 160; i++)
+ {
+ tid = &drv->trackdata[i];
+ zfile_fread(buffer, 4, 1, drv->diskfile);
+ tid->sync = buffer[0] * 256 + buffer[1];
+ tid->len = buffer[2] * 256 + buffer[3];
+ tid->offs = offs;
tid->revolutions = 1;
- if (tid->sync == 0) {
- tid->type = TRACK_AMIGADOS;
- tid->bitlen = 0;
- } else {
- tid->type = TRACK_RAW1;
- tid->bitlen = tid->len * 8;
- }
- offs += tid->len;
- }
-
- } else if (memcmp (exeheader, buffer, sizeof exeheader) == 0) {
- int i;
- struct zfile *z = zfile_fopen_empty (NULL, _T(""), 512 * 1760);
- createimagefromexe (drv->diskfile, z);
- drv->filetype = ADF_NORMAL;
- zfile_fclose (drv->diskfile);
- drv->diskfile = z;
- drv->num_tracks = 160;
- drv->num_secs = 11;
- for (i = 0; i < drv->num_tracks; i++) {
- tid = &drv->trackdata[i];
- tid->type = TRACK_AMIGADOS;
- tid->len = 512 * drv->num_secs;
- tid->bitlen = 0;
- tid->offs = i * 512 * drv->num_secs;
+ if (tid->sync == 0)
+ {
+ tid->type = TRACK_AMIGADOS;
+ tid->bitlen = 0;
+ }
+ else
+ {
+ tid->type = TRACK_RAW1;
+ tid->bitlen = tid->len * 8;
+ }
+ offs += tid->len;
+ }
+ }
+ else if (memcmp(exeheader, buffer, sizeof exeheader) == 0)
+ {
+ int i;
+ struct zfile* z = zfile_fopen_empty(nullptr, _T(""), 512 * 1760);
+ createimagefromexe(drv->diskfile, z);
+ drv->filetype = ADF_NORMAL;
+ zfile_fclose(drv->diskfile);
+ drv->diskfile = z;
+ drv->num_tracks = 160;
+ drv->num_secs = 11;
+ for (i = 0; i < drv->num_tracks; i++)
+ {
+ tid = &drv->trackdata[i];
+ tid->type = TRACK_AMIGADOS;
+ tid->len = 512 * drv->num_secs;
+ tid->bitlen = 0;
+ tid->offs = i * 512 * drv->num_secs;
tid->revolutions = 1;
- }
- drv->useturbo = 1;
+ }
+ drv->useturbo = 1;
+ }
+ else if (canauto && (
- } else if (canauto && (
-
- // 320k double sided
- size == 8 * 40 * 2 * 512 ||
- // 320k single sided
- size == 8 * 40 * 1 * 512 ||
-
- // 360k double sided
- size == 9 * 40 * 2 * 512 ||
- // 360k single sided
- size == 9 * 40 * 1 * 512 ||
-
- // 1.2M double sided
- size == 15 * 80 * 2 * 512 ||
-
- // 720k/1440k double sided
- size == 9 * 80 * 2 * 512 || size == 18 * 80 * 2 * 512 || size == 10 * 80 * 2 * 512 || size == 20 * 80 * 2 * 512 || size == 21 * 80 * 2 * 512 ||
- size == 9 * 81 * 2 * 512 || size == 18 * 81 * 2 * 512 || size == 10 * 81 * 2 * 512 || size == 20 * 81 * 2 * 512 || size == 21 * 81 * 2 * 512 ||
- size == 9 * 82 * 2 * 512 || size == 18 * 82 * 2 * 512 || size == 10 * 82 * 2 * 512 || size == 20 * 82 * 2 * 512 || size == 21 * 82 * 2 * 512 ||
- // 720k/1440k single sided
+ // double sided
+ size == 9 * 80 * 2 * 512 || size == 18 * 80 * 2 * 512 || size == 10 * 80 * 2 * 512 || size == 20 * 80 * 2 * 512 ||
+ size == 9 * 81 * 2 * 512 || size == 18 * 81 * 2 * 512 || size == 10 * 81 * 2 * 512 || size == 20 * 81 * 2 * 512 ||
+ size == 9 * 82 * 2 * 512 || size == 18 * 82 * 2 * 512 || size == 10 * 82 * 2 * 512 || size == 20 * 82 * 2 * 512 ||
+ // single sided
size == 9 * 80 * 1 * 512 || size == 18 * 80 * 1 * 512 || size == 10 * 80 * 1 * 512 || size == 20 * 80 * 1 * 512 ||
size == 9 * 81 * 1 * 512 || size == 18 * 81 * 1 * 512 || size == 10 * 81 * 1 * 512 || size == 20 * 81 * 1 * 512 ||
- size == 9 * 82 * 1 * 512 || size == 18 * 82 * 1 * 512 || size == 10 * 82 * 1 * 512 || size == 20 * 82 * 1 * 512)) {
- /* PC formatted image */
- int i, side;
+ size == 9 * 82 * 1 * 512 || size == 18 * 82 * 1 * 512 || size == 10 * 82 * 1 * 512 || size == 20 * 82 * 1 * 512))
+ {
+ /* PC formatted image */
+ int i, side;
- drv->num_secs = 9;
- drv->ddhd = 1;
+ for (side = 2; side > 0; side--)
+ {
+ if (size == 9 * 80 * side * 512 || size == 9 * 81 * side * 512 || size == 9 * 82 * side * 512)
+ {
+ drv->num_secs = 9;
+ drv->ddhd = 1;
+ break;
+ }
+ else if (size == 18 * 80 * side * 512 || size == 18 * 81 * side * 512 || size == 18 * 82 * side * 512)
+ {
+ drv->num_secs = 18;
+ drv->ddhd = 2;
+ break;
+ }
+ else if (size == 10 * 80 * side * 512 || size == 10 * 81 * side * 512 || size == 10 * 82 * side * 512)
+ {
+ drv->num_secs = 10;
+ drv->ddhd = 1;
+ break;
+ }
+ else if (size == 20 * 80 * side * 512 || size == 20 * 81 * side * 512 || size == 20 * 82 * side * 512)
+ {
+ drv->num_secs = 20;
+ drv->ddhd = 2;
+ break;
+ }
+ }
+ drv->num_tracks = size / (drv->num_secs * 512);
- for (side = 2; side > 0; side--) {
- if ( size == 9 * 80 * side * 512 || size == 9 * 81 * side * 512 || size == 9 * 82 * side * 512) {
- drv->num_secs = 9;
- drv->ddhd = 1;
- break;
- } else if (size == 18 * 80 * side * 512 || size == 18 * 81 * side * 512 || size == 18 * 82 * side * 512) {
- drv->num_secs = 18;
- drv->ddhd = 2;
- break;
- } else if (size == 10 * 80 * side * 512 || size == 10 * 81 * side * 512 || size == 10 * 82 * side * 512) {
- drv->num_secs = 10;
- drv->ddhd = 1;
- break;
- } else if (size == 20 * 80 * side * 512 || size == 20 * 81 * side * 512 || size == 20 * 82 * side * 512) {
- drv->num_secs = 20;
- drv->ddhd = 2;
- break;
- } else if (size == 21 * 80 * side * 512 || size == 21 * 81 * side * 512 || size == 21 * 82 * side * 512) {
- drv->num_secs = 21;
- drv->ddhd = 2;
- break;
- } else if (size == 9 * 40 * side * 512) {
- drv->num_secs = 9;
- drv->ddhd = 1;
- break;
- } else if (size == 8 * 40 * side * 512) {
- drv->num_secs = 8;
- drv->ddhd = 1;
- break;
- } else if (size == 15 * 80 * side * 512) {
- drv->num_secs = 15;
- drv->ddhd = 1;
- break;
- }
- }
-
- drv->num_tracks = size / (drv->num_secs * 512);
-
- drv->filetype = ADF_PCDOS;
- tid = &drv->trackdata[0];
- for (i = 0; i < drv->num_tracks; i++) {
- tid->type = TRACK_PCDOS;
- tid->len = 512 * drv->num_secs;
- tid->bitlen = 0;
- tid->offs = i * 512 * drv->num_secs;
- if (side == 1) {
- tid++;
- tid->type = TRACK_NONE;
- tid->len = 512 * drv->num_secs;
- }
- tid->revolutions = 1;
- tid++;
-
- }
- drv->num_heads = side;
- if (side == 1)
- drv->num_tracks *= 2;
-
- } else if ((size == 262144 || size == 524288) && buffer[0] == 0x11 && (buffer[1] == 0x11 || buffer[1] == 0x14)) {
-
- // 256k -> KICK disk, 512k -> SuperKickstart disk
- drv->filetype = size == 262144 ? ADF_KICK : ADF_SKICK;
- drv->num_tracks = 1760 / (drv->num_secs = 11);
- for (int i = 0; i < drv->num_tracks; i++) {
- tid = &drv->trackdata[i];
- tid->type = TRACK_AMIGADOS;
- tid->len = 512 * drv->num_secs;
- tid->bitlen = 0;
- tid->offs = i * 512 * drv->num_secs - (drv->filetype == ADF_KICK ? 512 : 262144 + 1024);
- tid->track = i;
- tid->revolutions = 1;
- }
-
- } else {
-
- int i, ds;
-
- ds = 0;
- drv->filetype = ADF_NORMAL;
-
- /* High-density or diskspare disk? */
- drv->num_tracks = 0;
- if (size > 160 * 11 * 512 + 511) { // larger than standard adf?
- for (i = 80; i <= 83; i++) {
- if (size == i * 22 * 512 * 2) { // HD
- drv->ddhd = 2;
- drv->num_tracks = size / (512 * (drv->num_secs = 22));
- break;
- }
- if (size == i * 11 * 512 * 2) { // >80 cyl DD
- drv->num_tracks = size / (512 * (drv->num_secs = 11));
- break;
- }
- if (size == i * 12 * 512 * 2) { // ds 12 sectors
- drv->num_tracks = size / (512 * (drv->num_secs = 12));
- ds = 1;
- break;
- }
- if (size == i * 24 * 512 * 2) { // ds 24 sectors
- drv->num_tracks = size / (512 * (drv->num_secs = 24));
- drv->ddhd = 2;
- ds = 1;
- break;
- }
- }
- if (drv->num_tracks == 0) {
- drv->num_tracks = size / (512 * (drv->num_secs = 22));
- drv->ddhd = 2;
- }
- } else {
- drv->num_tracks = size / (512 * (drv->num_secs = 11));
- }
-
- if (!ds &&drv->num_tracks > MAX_TRACKS)
- write_log (_T("Your diskfile is too big, %d bytes!\n"), size);
- for (i = 0; i < drv->num_tracks; i++) {
- tid = &drv->trackdata[i];
- tid->type = ds ? TRACK_DISKSPARE : TRACK_AMIGADOS;
- tid->len = 512 * drv->num_secs;
- tid->bitlen = 0;
- tid->offs = i * 512 * drv->num_secs;
+ drv->filetype = ADF_PCDOS;
+ tid = &drv->trackdata[0];
+ for (i = 0; i < drv->num_tracks; i++)
+ {
+ tid->type = TRACK_PCDOS;
+ tid->len = 512 * drv->num_secs;
+ tid->bitlen = 0;
+ tid->offs = i * 512 * drv->num_secs;
+ if (side == 1)
+ {
+ tid++;
+ tid->type = TRACK_NONE;
+ tid->len = 512 * drv->num_secs;
+ }
tid->revolutions = 1;
- }
- }
- openwritefile (p, drv, 0);
- drive_settype_id (drv); /* Set DD or HD drive */
- drive_fill_bigbuf (drv, 1);
- drv->mfmpos = uaerand ();
- drv->mfmpos |= (uaerand () << 16);
- drv->mfmpos %= drv->tracklen;
- drv->prevtracklen = 0;
- if (!fake) {
- update_drive_gui (drv - floppy, false);
+ tid++;
+ }
+ if (side == 1)
+ drv->num_tracks *= 2;
}
- return 1;
+ else if ((size == 262144 || size == 524288) && buffer[0] == 0x11 && (buffer[1] == 0x11 || buffer[1] == 0x14))
+ {
+ // 256k -> KICK disk, 512k -> SuperKickstart disk
+ drv->filetype = size == 262144 ? ADF_KICK : ADF_SKICK;
+ drv->num_tracks = 1760 / (drv->num_secs = 11);
+ for (int i = 0; i < drv->num_tracks; i++)
+ {
+ tid = &drv->trackdata[i];
+ tid->type = TRACK_AMIGADOS;
+ tid->len = 512 * drv->num_secs;
+ tid->bitlen = 0;
+ tid->offs = i * 512 * drv->num_secs - (drv->filetype == ADF_KICK ? 512 : 262144 + 1024);
+ tid->track = i;
+ tid->revolutions = 1;
+ }
+ }
+ else
+ {
+ int i, ds;
+
+ ds = 0;
+ drv->filetype = ADF_NORMAL;
+
+ /* High-density or diskspare disk? */
+ drv->num_tracks = 0;
+ if (size > 160 * 11 * 512 + 511)
+ { // larger than standard adf?
+ for (i = 80; i <= 83; i++)
+ {
+ if (size == i * 22 * 512 * 2)
+ { // HD
+ drv->ddhd = 2;
+ drv->num_tracks = size / (512 * (drv->num_secs = 22));
+ break;
+ }
+ if (size == i * 11 * 512 * 2)
+ { // >80 cyl DD
+ drv->num_tracks = size / (512 * (drv->num_secs = 11));
+ break;
+ }
+ if (size == i * 12 * 512 * 2)
+ { // ds 12 sectors
+ drv->num_tracks = size / (512 * (drv->num_secs = 12));
+ ds = 1;
+ break;
+ }
+ if (size == i * 24 * 512 * 2)
+ { // ds 24 sectors
+ drv->num_tracks = size / (512 * (drv->num_secs = 24));
+ drv->ddhd = 2;
+ ds = 1;
+ break;
+ }
+ }
+ if (drv->num_tracks == 0)
+ {
+ drv->num_tracks = size / (512 * (drv->num_secs = 22));
+ drv->ddhd = 2;
+ }
+ }
+ else
+ {
+ drv->num_tracks = size / (512 * (drv->num_secs = 11));
+ }
+
+ if (!ds && drv->num_tracks > MAX_TRACKS)
+ write_log (_T("Your diskfile is too big, %d bytes!\n"), size);
+ for (i = 0; i < drv->num_tracks; i++)
+ {
+ tid = &drv->trackdata[i];
+ tid->type = ds ? TRACK_DISKSPARE : TRACK_AMIGADOS;
+ tid->len = 512 * drv->num_secs;
+ tid->bitlen = 0;
+ tid->offs = i * 512 * drv->num_secs;
+ tid->revolutions = 1;
+ }
+ }
+ openwritefile(p, drv, 0);
+ drive_settype_id(drv); /* Set DD or HD drive */
+ drive_fill_bigbuf(drv, 1);
+ drv->mfmpos = uaerand ();
+ drv->mfmpos |= uaerand () << 16;
+ drv->mfmpos %= drv->tracklen;
+ drv->prevtracklen = 0;
+ if (!fake)
+ {
+#ifdef DRIVESOUND
+ if (isfloppysound(drv))
+ driveclick_insert(drv - floppy, 0);
+#endif
+ update_drive_gui(drv - floppy, false);
+ }
+ return 1;
}
-static void rand_shifter (drive *drv)
+static void rand_shifter(drive* drv)
{
- int r = ((uaerand () >> 4) & 7) + 1;
- while (r-- > 0) {
- word <<= 1;
- word |= (uaerand () & 0x1000) ? 1 : 0;
- bitoffset++;
- bitoffset &= 15;
- }
+ int r = (uaerand () >> 4 & 7) + 1;
+ while (r-- > 0)
+ {
+ word <<= 1;
+ word |= uaerand () & 0x1000 ? 1 : 0;
+ bitoffset++;
+ bitoffset &= 15;
+ }
}
-static void set_steplimit (drive *drv)
+static void set_steplimit(drive* drv)
{
// emulate step limit only if cycle-exact or approximate CPU speed
if (currprefs.m68k_speed != 0)
return;
drv->steplimit = 4;
- drv->steplimitcycle = get_cycles ();
+ drv->steplimitcycle = get_cycles();
}
-static int drive_empty (drive * drv)
+static int drive_empty(drive* drv)
{
- return drv->diskfile == 0 && drv->dskchange_time >= 0;
+#ifdef CATWEASEL
+ if (drv->catweasel)
+ return catweasel_disk_changed(drv->catweasel) == 0;
+#endif
+ return drv->diskfile == nullptr && drv->dskchange_time >= 0;
}
-static void drive_step (drive * drv, int step_direction)
+static void drive_step(drive* drv, int step_direction)
{
- if (!drive_empty (drv))
- drv->dskchange = 0;
- if (drv->steplimit && get_cycles() - drv->steplimitcycle < MIN_STEPLIMIT_CYCLE) {
- return;
- }
- /* A1200's floppy drive needs at least 30 raster lines between steps
- * but we'll use very small value for better compatibility with faster CPU emulation
- * (stupid trackloaders with CPU delay loops)
- */
- set_steplimit (drv);
- if (step_direction) {
- if (drv->cyl) {
- drv->cyl--;
- }
- } else {
- int maxtrack = drv->hard_num_cyls;
- if (drv->cyl < maxtrack + 3) {
- drv->cyl++;
- }
+#ifdef CATWEASEL
+ if (drv->catweasel) {
+ int dir = direction ? -1 : 1;
+ catweasel_step(drv->catweasel, dir);
+ drv->cyl += dir;
+ if (drv->cyl < 0)
+ drv->cyl = 0;
+ write_log(_T("%d -> %d\n"), dir, drv->cyl);
+ return;
+ }
+#endif
+ if (!drive_empty(drv))
+ drv->dskchange = false;
+ if (drv->steplimit && get_cycles() - drv->steplimitcycle < MIN_STEPLIMIT_CYCLE)
+ {
+ write_log(_T(" step ignored drive %d, %d\n"),
+ drv - floppy, (get_cycles() - drv->steplimitcycle) / CYCLE_UNIT);
+ return;
+ }
+ /* A1200's floppy drive needs at least 30 raster lines between steps
+ * but we'll use very small value for better compatibility with faster CPU emulation
+ * (stupid trackloaders with CPU delay loops)
+ */
+ set_steplimit(drv);
+ if (step_direction)
+ {
+ if (drv->cyl)
+ {
+ drv->cyl--;
+#ifdef DRIVESOUND
+ if (isfloppysound(drv))
+ driveclick_click(drv - floppy, drv->cyl);
+#endif
+ }
+ }
+ else
+ {
+ int maxtrack = drv->hard_num_cyls;
+ if (drv->cyl < maxtrack + 3)
+ {
+ drv->cyl++;
+#ifdef CATWEASEL
+ if (drv->catweasel)
+ catweasel_step(drv->catweasel, 1);
+#endif
+ }
if (drv->cyl >= maxtrack)
write_log (_T("program tried to step over track %d\n"), maxtrack);
- }
- rand_shifter (drv);
+#ifdef DRIVESOUND
+ if (isfloppysound(drv))
+ driveclick_click(drv - floppy, drv->cyl);
+#endif
+ }
+ rand_shifter(drv);
}
-static int drive_track0 (drive * drv)
+static int drive_track0(drive* drv)
{
- return drv->cyl == 0;
+#ifdef CATWEASEL
+ if (drv->catweasel)
+ return catweasel_track0(drv->catweasel);
+#endif
+ return drv->cyl == 0;
}
-static int drive_writeprotected (drive * drv)
+static int drive_writeprotected(drive* drv)
{
- return currprefs.floppy_read_only || drv->wrprot || drv->forcedwrprot || drv->diskfile == NULL;
+#ifdef CATWEASEL
+ if (drv->catweasel)
+ return 1;
+#endif
+ //TODO: enable when floppy_read_only is added in options.h
+ //return currprefs.floppy_read_only || drv->wrprot || drv->forcedwrprot || drv->diskfile == NULL;
+ return drv->wrprot || drv->forcedwrprot || drv->diskfile == nullptr;
}
-static int drive_running (drive * drv)
+static int drive_running(drive* drv)
{
- return !drv->motoroff;
+ return !drv->motoroff;
}
void DISK_motordelay_func(uae_u32 v)
{
- floppy[v].motordelay = 0;
+ floppy[v].motordelay = 0;
}
-static void drive_motor (drive * drv, bool off)
+static void motordelay_func(uae_u32 v)
{
- if (drv->motoroff && !off) {
+ floppy[v].motordelay = 0;
+}
+
+static void drive_motor(drive* drv, bool off)
+{
+ if (drv->motoroff && !off)
+ {
drv->dskready_up_time = DSKREADY_UP_TIME * 312 + (uaerand() & 511);
- rand_shifter (drv);
- }
- if (!drv->motoroff && off) {
- drv->drive_id_scnt = 0; /* Reset id shift reg counter */
- drv->dskready_down_time = DSKREADY_DOWN_TIME * 312 + (uaerand() & 511);
- if (currprefs.cpu_model <= 68010 && currprefs.m68k_speed == 0) {
- drv->motordelay = 1;
- event2_newevent(ev2_disk_motor0 + (drv - floppy), 30, drv - floppy);
- }
- }
- drv->motoroff = off;
- if (drv->motoroff) {
- drv->dskready = 0;
+ rand_shifter(drv);
+#ifdef DRIVESOUND
+ if (isfloppysound(drv))
+ driveclick_motor(drv - floppy, drv->dskready_down_time == 0 ? 2 : 1);
+#endif
+ }
+ if (!drv->motoroff && off)
+ {
+ drv->drive_id_scnt = 0; /* Reset id shift reg counter */
+ drv->dskready_down_time = DSKREADY_DOWN_TIME * 312 + (uaerand() & 511);
+#ifdef DRIVESOUND
+ driveclick_motor(drv - floppy, 0);
+#endif
+ if (currprefs.cpu_model <= 68010 && currprefs.m68k_speed == 0)
+ {
+ drv->motordelay = 1;
+ event2_newevent2(30, drv - floppy, motordelay_func);
+ }
+ }
+ drv->motoroff = off;
+ if (drv->motoroff)
+ {
+ drv->dskready = 0;
drv->dskready_up_time = 0;
- } else {
+ }
+ else
+ {
drv->dskready_down_time = 0;
- }
+ }
+#ifdef CATWEASEL
+ if (drv->catweasel)
+ catweasel_set_motor(drv->catweasel, !drv->motoroff);
+#endif
}
-static void read_floppy_data (struct zfile *diskfile, int type, trackid *tid, int offset, uae_u8 *dst, int len)
+static void read_floppy_data(struct zfile* diskfile, int type, trackid* tid, int offset, uae_u8* dst, int len)
{
- if (len == 0)
- return;
- if (tid->track == 0) {
- if (type == ADF_KICK) {
- memset (dst, 0, len > 512 ? 512 : len);
- if (offset == 0) {
- memcpy (dst, "KICK", 4);
+ if (len == 0)
+ return;
+ if (tid->track == 0)
+ {
+ if (type == ADF_KICK)
+ {
+ memset(dst, 0, len > 512 ? 512 : len);
+ if (offset == 0)
+ {
+ memcpy(dst, "KICK", 4);
len -= 512;
}
- } else if (type == ADF_SKICK) {
- memset (dst, 0, len > 512 ? 512 : len);
- if (offset == 0) {
- memcpy (dst, "KICKSUP0", 8);
+ }
+ else if (type == ADF_SKICK)
+ {
+ memset(dst, 0, len > 512 ? 512 : len);
+ if (offset == 0)
+ {
+ memcpy(dst, "KICKSUP0", 8);
len -= 1024;
- } else if (offset == 512) {
+ }
+ else if (offset == 512)
+ {
len -= 512;
}
}
}
int off = tid->offs + offset;
- if (off >= 0 && len > 0) {
- zfile_fseek (diskfile, off, SEEK_SET);
- zfile_fread (dst, 1, len, diskfile);
+ if (off >= 0 && len > 0)
+ {
+ zfile_fseek(diskfile, off, SEEK_SET);
+ zfile_fread(dst, 1, len, diskfile);
}
}
/* Megalomania does not like zero MFM words... */
-static void mfmcode (uae_u16 * mfm, int words)
+static void mfmcode(uae_u16* mfm, int words)
{
- uae_u32 lastword = 0;
- while (words--) {
+ uae_u32 lastword = 0;
+
+ while (words--)
+ {
uae_u32 v = (*mfm) & 0x55555555;
- uae_u32 lv = (lastword << 16) | v;
- uae_u32 nlv = 0x55555555 & ~lv;
- uae_u32 mfmbits = (nlv << 1) & (nlv >> 1);
- *mfm++ = v | mfmbits;
- lastword = v;
- }
+ uae_u32 lv = (lastword << 16) | v;
+ uae_u32 nlv = 0x55555555 & ~lv;
+ uae_u32 mfmbits = (nlv << 1) & (nlv >> 1);
+ *mfm++ = v | mfmbits;
+ lastword = v;
+ }
}
-static const uae_u8 mfmencodetable[16] = {
- 0x2a, 0x29, 0x24, 0x25, 0x12, 0x11, 0x14, 0x15,
- 0x4a, 0x49, 0x44, 0x45, 0x52, 0x51, 0x54, 0x55
+static uae_u8 mfmencodetable[16] = {
+ 0x2a, 0x29, 0x24, 0x25, 0x12, 0x11, 0x14, 0x15,
+ 0x4a, 0x49, 0x44, 0x45, 0x52, 0x51, 0x54, 0x55
};
static uae_u16 dos_encode_byte(uae_u8 byte)
-{
- uae_u8 b2, b1;
- uae_u16 word;
+{
+ uae_u8 b2, b1;
+ uae_u16 word;
- b1 = byte;
- b2 = b1 >> 4;
- b1 &= 15;
- word = mfmencodetable[b2] <<8 | mfmencodetable[b1];
- return (word | ((word & (256 | 64)) ? 0 : 128));
+ b1 = byte;
+ b2 = b1 >> 4;
+ b1 &= 15;
+ word = mfmencodetable[b2] << 8 | mfmencodetable[b1];
+ return (word | ((word & (256 | 64)) ? 0 : 128));
}
-static uae_u16 *mfmcoder(uae_u8 *src, uae_u16 *dest, int len)
+static uae_u16* mfmcoder(uae_u8* src, uae_u16* dest, int len)
{
- int i;
+ int i;
- for (i = 0; i < len; i++) {
- *dest = dos_encode_byte(*src++);
- *dest |= ((dest[-1] & 1)||(*dest & 0x4000)) ? 0: 0x8000;
- dest++;
- }
- return dest;
+ for (i = 0; i < len; i++)
+ {
+ *dest = dos_encode_byte(*src++);
+ *dest |= ((dest[-1] & 1) || (*dest & 0x4000)) ? 0 : 0x8000;
+ dest++;
+ }
+ return dest;
}
-static void decode_pcdos (drive *drv)
+static void decode_pcdos(drive* drv)
{
- int i, len;
- int tr = drv->cyl * 2 + side;
- uae_u16 *dstmfmbuf, *mfm2;
- uae_u8 secbuf[1000];
- uae_u16 crc16;
- trackid *ti = drv->trackdata + tr;
- int tracklen = 12500;
+ int i, len;
+ int tr = drv->cyl * 2 + side;
+ uae_u16 *dstmfmbuf, *mfm2;
+ uae_u8 secbuf[1000];
+ uae_u16 crc16;
+ trackid* ti = drv->trackdata + tr;
+ int tracklen = 12500;
- mfm2 = drv->bigmfmbuf;
- *mfm2++ = 0x9254;
- memset (secbuf, 0x4e, 40);
- memset (secbuf + 40, 0x00, 12);
- secbuf[52] = 0xc2;
- secbuf[53] = 0xc2;
- secbuf[54] = 0xc2;
- secbuf[55] = 0xfc;
- memset (secbuf + 56, 0x4e, 40);
- dstmfmbuf = mfmcoder (secbuf, mfm2, 96);
- mfm2[52] = 0x5224;
- mfm2[53] = 0x5224;
- mfm2[54] = 0x5224;
- for (i = 0; i < drv->num_secs; i++) {
- mfm2 = dstmfmbuf;
- memset (secbuf, 0x00, 12);
- secbuf[12] = 0xa1;
- secbuf[13] = 0xa1;
- secbuf[14] = 0xa1;
- secbuf[15] = 0xfe;
- secbuf[16] = drv->cyl;
- secbuf[17] = side;
- secbuf[18] = 1 + i;
- secbuf[19] = 2; // 128 << 2 = 512
- crc16 = get_crc16(secbuf + 12, 3 + 1 + 4);
- secbuf[20] = crc16 >> 8;
- secbuf[21] = crc16 & 0xff;
- memset(secbuf + 22, 0x4e, 22);
- memset(secbuf + 44, 0x00, 12);
- secbuf[56] = 0xa1;
- secbuf[57] = 0xa1;
- secbuf[58] = 0xa1;
- secbuf[59] = 0xfb;
- read_floppy_data (drv->diskfile, drv->filetype, ti, i * 512, &secbuf[60], 512);
- crc16 = get_crc16(secbuf + 56, 3 + 1 + 512);
- secbuf[60 + 512] = crc16 >> 8;
- secbuf[61 + 512] = crc16 & 0xff;
- len = (tracklen / 2 - 96) / drv->num_secs - 574 / drv->ddhd;
- if (len > 0)
- memset(secbuf + 512 + 62, 0x4e, len);
- dstmfmbuf = mfmcoder(secbuf, mfm2, 60 + 512 + 2 + 76 / drv->ddhd);
- mfm2[12] = 0x4489;
- mfm2[13] = 0x4489;
- mfm2[14] = 0x4489;
- mfm2[56] = 0x4489;
- mfm2[57] = 0x4489;
- mfm2[58] = 0x4489;
- }
- while (dstmfmbuf - drv->bigmfmbuf < tracklen / 2)
- *dstmfmbuf++ = 0x9254;
- drv->skipoffset = 0;
- drv->tracklen = (dstmfmbuf - drv->bigmfmbuf) * 16;
+ mfm2 = drv->bigmfmbuf;
+ *mfm2++ = 0x9254;
+ memset(secbuf, 0x4e, 40);
+ memset(secbuf + 40, 0x00, 12);
+ secbuf[52] = 0xc2;
+ secbuf[53] = 0xc2;
+ secbuf[54] = 0xc2;
+ secbuf[55] = 0xfc;
+ memset(secbuf + 56, 0x4e, 40);
+ dstmfmbuf = mfmcoder(secbuf, mfm2, 96);
+ mfm2[52] = 0x5224;
+ mfm2[53] = 0x5224;
+ mfm2[54] = 0x5224;
+ for (i = 0; i < drv->num_secs; i++)
+ {
+ mfm2 = dstmfmbuf;
+ memset(secbuf, 0x00, 12);
+ secbuf[12] = 0xa1;
+ secbuf[13] = 0xa1;
+ secbuf[14] = 0xa1;
+ secbuf[15] = 0xfe;
+ secbuf[16] = drv->cyl;
+ secbuf[17] = side;
+ secbuf[18] = 1 + i;
+ secbuf[19] = 2; // 128 << 2 = 512
+ crc16 = get_crc16(secbuf + 12, 3 + 1 + 4);
+ secbuf[20] = crc16 >> 8;
+ secbuf[21] = crc16 & 0xff;
+ memset(secbuf + 22, 0x4e, 22);
+ memset(secbuf + 44, 0x00, 12);
+ secbuf[56] = 0xa1;
+ secbuf[57] = 0xa1;
+ secbuf[58] = 0xa1;
+ secbuf[59] = 0xfb;
+ read_floppy_data(drv->diskfile, drv->filetype, ti, i * 512, &secbuf[60], 512);
+ crc16 = get_crc16(secbuf + 56, 3 + 1 + 512);
+ secbuf[60 + 512] = crc16 >> 8;
+ secbuf[61 + 512] = crc16 & 0xff;
+ len = (tracklen / 2 - 96) / drv->num_secs - 574 / drv->ddhd;
+ if (len > 0)
+ memset(secbuf + 512 + 62, 0x4e, len);
+ dstmfmbuf = mfmcoder(secbuf, mfm2, 60 + 512 + 2 + 76 / drv->ddhd);
+ mfm2[12] = 0x4489;
+ mfm2[13] = 0x4489;
+ mfm2[14] = 0x4489;
+ mfm2[56] = 0x4489;
+ mfm2[57] = 0x4489;
+ mfm2[58] = 0x4489;
+ }
+ while (dstmfmbuf - drv->bigmfmbuf < tracklen / 2)
+ *dstmfmbuf++ = 0x9254;
+ drv->skipoffset = 0;
+ drv->tracklen = (dstmfmbuf - drv->bigmfmbuf) * 16;
}
-static void decode_amigados (drive *drv)
+static void decode_amigados(drive* drv)
{
- /* Normal AmigaDOS format track */
- int tr = drv->cyl * 2 + side;
- int sec;
+ /* Normal AmigaDOS format track */
+ int tr = drv->cyl * 2 + side;
+ int sec;
int dstmfmoffset = 0;
- uae_u16 *dstmfmbuf = drv->bigmfmbuf;
- int len = drv->num_secs * 544 + FLOPPY_GAP_LEN;
+ uae_u16* dstmfmbuf = drv->bigmfmbuf;
+ int len = drv->num_secs * 544 + FLOPPY_GAP_LEN;
int prevbit;
- trackid *ti = drv->trackdata + tr;
- memset (dstmfmbuf, 0xaa, len * 2);
+ trackid* ti = drv->trackdata + tr;
+ memset(dstmfmbuf, 0xaa, len * 2);
dstmfmoffset += FLOPPY_GAP_LEN;
drv->skipoffset = (FLOPPY_GAP_LEN * 8) / 3 * 2;
drv->tracklen = len * 2 * 8;
prevbit = 0;
- for (sec = 0; sec < drv->num_secs; sec++) {
- uae_u8 secbuf[544];
- uae_u16 mfmbuf[544 + 1];
- int i;
- uae_u32 deven, dodd;
- uae_u32 hck = 0, dck = 0;
+ for (sec = 0; sec < drv->num_secs; sec++)
+ {
+ uae_u8 secbuf[544];
+ uae_u16 mfmbuf[544 + 1];
+ int i;
+ uae_u32 deven, dodd;
+ uae_u32 hck = 0, dck = 0;
- secbuf[0] = secbuf[1] = 0x00;
- secbuf[2] = secbuf[3] = 0xa1;
- secbuf[4] = 0xff;
- secbuf[5] = tr;
- secbuf[6] = sec;
- secbuf[7] = drv->num_secs - sec;
+ secbuf[0] = secbuf[1] = 0x00;
+ secbuf[2] = secbuf[3] = 0xa1;
+ secbuf[4] = 0xff;
+ secbuf[5] = tr;
+ secbuf[6] = sec;
+ secbuf[7] = drv->num_secs - sec;
- for (i = 8; i < 24; i++)
- secbuf[i] = 0;
+ for (i = 8; i < 24; i++)
+ secbuf[i] = 0;
- read_floppy_data (drv->diskfile, drv->filetype, ti, sec * 512, &secbuf[32], 512);
+ read_floppy_data(drv->diskfile, drv->filetype, ti, sec * 512, &secbuf[32], 512);
mfmbuf[0] = prevbit ? 0x2aaa : 0xaaaa;
mfmbuf[1] = 0xaaaa;
- mfmbuf[2] = mfmbuf[3] = 0x4489;
+ mfmbuf[2] = mfmbuf[3] = 0x4489;
- deven = ((secbuf[4] << 24) | (secbuf[5] << 16)
- | (secbuf[6] << 8) | (secbuf[7]));
- dodd = deven >> 1;
- deven &= 0x55555555;
- dodd &= 0x55555555;
+ deven = ((secbuf[4] << 24) | (secbuf[5] << 16)
+ | (secbuf[6] << 8) | (secbuf[7]));
+ dodd = deven >> 1;
+ deven &= 0x55555555;
+ dodd &= 0x55555555;
- mfmbuf[4] = dodd >> 16;
- mfmbuf[5] = dodd;
- mfmbuf[6] = deven >> 16;
- mfmbuf[7] = deven;
+ mfmbuf[4] = dodd >> 16;
+ mfmbuf[5] = dodd;
+ mfmbuf[6] = deven >> 16;
+ mfmbuf[7] = deven;
- for (i = 8; i < 48; i++)
- mfmbuf[i] = 0xaaaa;
- for (i = 0; i < 512; i += 4) {
- deven = ((secbuf[i + 32] << 24) | (secbuf[i + 33] << 16)
- | (secbuf[i + 34] << 8) | (secbuf[i + 35]));
- dodd = deven >> 1;
- deven &= 0x55555555;
- dodd &= 0x55555555;
- mfmbuf[(i >> 1) + 32] = dodd >> 16;
- mfmbuf[(i >> 1) + 33] = dodd;
- mfmbuf[(i >> 1) + 256 + 32] = deven >> 16;
- mfmbuf[(i >> 1) + 256 + 33] = deven;
- }
+ for (i = 8; i < 48; i++)
+ mfmbuf[i] = 0xaaaa;
+ for (i = 0; i < 512; i += 4)
+ {
+ deven = ((secbuf[i + 32] << 24) | (secbuf[i + 33] << 16)
+ | (secbuf[i + 34] << 8) | (secbuf[i + 35]));
+ dodd = deven >> 1;
+ deven &= 0x55555555;
+ dodd &= 0x55555555;
+ mfmbuf[(i >> 1) + 32] = dodd >> 16;
+ mfmbuf[(i >> 1) + 33] = dodd;
+ mfmbuf[(i >> 1) + 256 + 32] = deven >> 16;
+ mfmbuf[(i >> 1) + 256 + 33] = deven;
+ }
- for (i = 4; i < 24; i += 2)
- hck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1];
+ for (i = 4; i < 24; i += 2)
+ hck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1];
- deven = dodd = hck;
- dodd >>= 1;
- mfmbuf[24] = dodd >> 16;
- mfmbuf[25] = dodd;
- mfmbuf[26] = deven >> 16;
- mfmbuf[27] = deven;
+ deven = dodd = hck;
+ dodd >>= 1;
+ mfmbuf[24] = dodd >> 16;
+ mfmbuf[25] = dodd;
+ mfmbuf[26] = deven >> 16;
+ mfmbuf[27] = deven;
- for (i = 32; i < 544; i += 2)
- dck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1];
+ for (i = 32; i < 544; i += 2)
+ dck ^= (mfmbuf[i] << 16) | mfmbuf[i + 1];
- deven = dodd = dck;
- dodd >>= 1;
- mfmbuf[28] = dodd >> 16;
- mfmbuf[29] = dodd;
- mfmbuf[30] = deven >> 16;
- mfmbuf[31] = deven;
+ deven = dodd = dck;
+ dodd >>= 1;
+ mfmbuf[28] = dodd >> 16;
+ mfmbuf[29] = dodd;
+ mfmbuf[30] = deven >> 16;
+ mfmbuf[31] = deven;
mfmbuf[544] = 0;
- mfmcode (mfmbuf + 4, 544 - 4 + 1);
+ mfmcode(mfmbuf + 4, 544 - 4 + 1);
- for (i = 0; i < 544; i++) {
- dstmfmbuf[dstmfmoffset % len] = mfmbuf[i];
- dstmfmoffset++;
- }
+ for (i = 0; i < 544; i++)
+ {
+ dstmfmbuf[dstmfmoffset % len] = mfmbuf[i];
+ dstmfmoffset++;
+ }
prevbit = mfmbuf[i - 1] & 1;
// so that final word has correct MFM encoding
dstmfmbuf[dstmfmoffset % len] = mfmbuf[i];
- }
+ }
}
/*
@@ -1617,188 +1784,236 @@ static void decode_amigados (drive *drv)
*
*/
-static void decode_diskspare (drive *drv)
+static void decode_diskspare(drive* drv)
{
- int tr = drv->cyl * 2 + side;
- int sec;
- int dstmfmoffset = 0;
- int size = 512 + 8;
- uae_u16 *dstmfmbuf = drv->bigmfmbuf;
- int len = drv->num_secs * size + FLOPPY_GAP_LEN;
+ int tr = drv->cyl * 2 + side;
+ int sec;
+ int dstmfmoffset = 0;
+ int size = 512 + 8;
+ uae_u16* dstmfmbuf = drv->bigmfmbuf;
+ int len = drv->num_secs * size + FLOPPY_GAP_LEN;
- trackid *ti = drv->trackdata + tr;
- memset (dstmfmbuf, 0xaa, len * 2);
- dstmfmoffset += FLOPPY_GAP_LEN;
- drv->skipoffset = (FLOPPY_GAP_LEN * 8) / 3 * 2;
- drv->tracklen = len * 2 * 8;
+ trackid* ti = drv->trackdata + tr;
+ memset(dstmfmbuf, 0xaa, len * 2);
+ dstmfmoffset += FLOPPY_GAP_LEN;
+ drv->skipoffset = (FLOPPY_GAP_LEN * 8) / 3 * 2;
+ drv->tracklen = len * 2 * 8;
- for (sec = 0; sec < drv->num_secs; sec++) {
- uae_u8 secbuf[512 + 8];
- uae_u16 mfmbuf[512 + 8];
- int i;
- uae_u32 deven, dodd;
- uae_u16 chk;
+ for (sec = 0; sec < drv->num_secs; sec++)
+ {
+ uae_u8 secbuf[512 + 8];
+ uae_u16 mfmbuf[512 + 8];
+ int i;
+ uae_u32 deven, dodd;
+ uae_u16 chk;
- secbuf[0] = tr;
- secbuf[1] = sec;
- secbuf[2] = 0;
- secbuf[3] = 0;
+ secbuf[0] = tr;
+ secbuf[1] = sec;
+ secbuf[2] = 0;
+ secbuf[3] = 0;
- read_floppy_data (drv->diskfile, drv->filetype, ti, sec * 512, &secbuf[4], 512);
+ read_floppy_data(drv->diskfile, drv->filetype, ti, sec * 512, &secbuf[4], 512);
- mfmbuf[0] = 0xaaaa;
- mfmbuf[1] = 0x4489;
- mfmbuf[2] = 0x4489;
- mfmbuf[3] = 0x2aaa;
+ mfmbuf[0] = 0xaaaa;
+ mfmbuf[1] = 0x4489;
+ mfmbuf[2] = 0x4489;
+ mfmbuf[3] = 0x2aaa;
- for (i = 0; i < 512; i += 4) {
- deven = ((secbuf[i + 4] << 24) | (secbuf[i + 5] << 16)
- | (secbuf[i + 6] << 8) | (secbuf[i + 7]));
- dodd = deven >> 1;
- deven &= 0x55555555;
- dodd &= 0x55555555;
- mfmbuf[i + 8 + 0] = dodd >> 16;
- mfmbuf[i + 8 + 1] = dodd;
- mfmbuf[i + 8 + 2] = deven >> 16;
- mfmbuf[i + 8 + 3] = deven;
- }
- mfmcode (mfmbuf + 8, 512);
+ for (i = 0; i < 512; i += 4)
+ {
+ deven = ((secbuf[i + 4] << 24) | (secbuf[i + 5] << 16)
+ | (secbuf[i + 6] << 8) | (secbuf[i + 7]));
+ dodd = deven >> 1;
+ deven &= 0x55555555;
+ dodd &= 0x55555555;
+ mfmbuf[i + 8 + 0] = dodd >> 16;
+ mfmbuf[i + 8 + 1] = dodd;
+ mfmbuf[i + 8 + 2] = deven >> 16;
+ mfmbuf[i + 8 + 3] = deven;
+ }
+ mfmcode(mfmbuf + 8, 512);
- i = 8;
- chk = mfmbuf[i++] & 0x7fff;
- while (i < 512 + 8)
- chk ^= mfmbuf[i++];
- secbuf[2] = chk >> 8;
- secbuf[3] = chk;
+ i = 8;
+ chk = mfmbuf[i++] & 0x7fff;
+ while (i < 512 + 8)
+ chk ^= mfmbuf[i++];
+ secbuf[2] = chk >> 8;
+ secbuf[3] = chk;
- deven = ((secbuf[0] << 24) | (secbuf[1] << 16)
- | (secbuf[2] << 8) | (secbuf[3]));
- dodd = deven >> 1;
- deven &= 0x55555555;
- dodd &= 0x55555555;
+ deven = ((secbuf[0] << 24) | (secbuf[1] << 16)
+ | (secbuf[2] << 8) | (secbuf[3]));
+ dodd = deven >> 1;
+ deven &= 0x55555555;
+ dodd &= 0x55555555;
- mfmbuf[4] = dodd >> 16;
- mfmbuf[5] = dodd;
- mfmbuf[6] = deven >> 16;
- mfmbuf[7] = deven;
- mfmcode (mfmbuf + 4, 4);
+ mfmbuf[4] = dodd >> 16;
+ mfmbuf[5] = dodd;
+ mfmbuf[6] = deven >> 16;
+ mfmbuf[7] = deven;
+ mfmcode(mfmbuf + 4, 4);
- for (i = 0; i < 512 + 8; i++) {
- dstmfmbuf[dstmfmoffset % len] = mfmbuf[i];
- dstmfmoffset++;
- }
- }
+ for (i = 0; i < 512 + 8; i++)
+ {
+ dstmfmbuf[dstmfmoffset % len] = mfmbuf[i];
+ dstmfmoffset++;
+ }
+ }
}
-static void drive_fill_bigbuf (drive * drv, int force)
+static void drive_fill_bigbuf(drive* drv, int force)
{
- int tr = drv->cyl * 2 + side;
- trackid *ti = drv->trackdata + tr;
+ int tr = drv->cyl * 2 + side;
+ trackid* ti = drv->trackdata + tr;
+ bool retrytrack;
int rev = -1;
- if ((!drv->diskfile) || tr >= drv->num_tracks) {
- track_reset (drv);
- return;
- }
-
- if (!force && drv->buffered_cyl == drv->cyl && drv->buffered_side == side)
- return;
- drv->indexoffset = 0;
- drv->multi_revolution = 0;
- drv->tracktiming[0] = 0;
- drv->skipoffset = -1;
- drv->revolutions = 1;
+ if (!drv->diskfile || tr >= drv->num_tracks)
+ {
+ track_reset(drv);
+ return;
+ }
- if (drv->writediskfile && drv->writetrackdata[tr].bitlen > 0) {
- int i;
- trackid *wti = &drv->writetrackdata[tr];
- drv->tracklen = wti->bitlen;
- drv->revolutions = wti->revolutions;
- read_floppy_data (drv->writediskfile, drv->filetype, wti, 0, (uae_u8*)drv->bigmfmbuf, (wti->bitlen + 7) / 8);
- for (i = 0; i < (drv->tracklen + 15) / 16; i++) {
- uae_u16 *mfm = drv->bigmfmbuf + i;
- uae_u8 *data = (uae_u8 *) mfm;
- *mfm = 256 * *data + *(data + 1);
- }
+ if (!force && drv->catweasel) {
+ drv->buffered_cyl = -1;
+ return;
+ }
- } else if (drv->filetype == ADF_FDI) {
+ if (!force && drv->buffered_cyl == drv->cyl && drv->buffered_side == side)
+ return;
+ drv->indexoffset = 0;
+ drv->multi_revolution = 0;
+ drv->tracktiming[0] = 0;
+ drv->skipoffset = -1;
+ drv->revolutions = 1;
+ retrytrack = drv->lastdataacesstrack == drv->cyl * 2 + side;
+ if (!dskdmaen && !retrytrack)
+ drv->track_access_done = false;
+ //write_log (_T("%d:%d %d\n"), drv->cyl, side, retrytrack);
-#ifdef FDI2RAW
- fdi2raw_loadtrack (drv->fdi, drv->bigmfmbuf, drv->tracktiming, tr, &drv->tracklen, &drv->indexoffset, &drv->multi_revolution, 1);
+ if (drv->writediskfile && drv->writetrackdata[tr].bitlen > 0)
+ {
+ int i;
+ trackid* wti = &drv->writetrackdata[tr];
+ drv->tracklen = wti->bitlen;
+ drv->revolutions = wti->revolutions;
+ read_floppy_data(drv->writediskfile, drv->filetype, wti, 0, reinterpret_cast(drv->bigmfmbuf), (wti->bitlen + 7) / 8);
+ for (i = 0; i < (drv->tracklen + 15) / 16; i++)
+ {
+ uae_u16* mfm = drv->bigmfmbuf + i;
+ uae_u8* data = reinterpret_cast(mfm);
+ *mfm = 256 * *data + *(data + 1);
+ }
+ }
+ else if (drv->filetype == ADF_CATWEASEL) {
+#ifdef CATWEASEL
+ drv->tracklen = 0;
+ if (!catweasel_disk_changed(drv->catweasel)) {
+ drv->tracklen = catweasel_fillmfm(drv->catweasel, drv->bigmfmbuf, side, drv->ddhd, 0);
+ }
+ drv->buffered_cyl = -1;
+ if (!drv->tracklen) {
+ track_reset(drv);
+ return;
+ }
+#endif
+ }
+ else if (drv->filetype == ADF_IPF) {
+
+#ifdef CAPS
+ caps_loadtrack(drv->bigmfmbuf, drv->tracktiming, drv - floppy, tr, &drv->tracklen, &drv->multi_revolution, &drv->skipoffset, &drv->lastrev, retrytrack);
#endif
- } else if (ti->type == TRACK_PCDOS) {
+ }
+ else if (drv->filetype == ADF_SCP) {
- decode_pcdos(drv);
+#ifdef SCP
+ scp_loadtrack(drv->bigmfmbuf, drv->tracktiming, drv - floppy, tr, &drv->tracklen, &drv->multi_revolution, &drv->skipoffset, &drv->lastrev, retrytrack);
+#endif
- } else if (ti->type == TRACK_AMIGADOS) {
+ }
+ else if (drv->filetype == ADF_FDI) {
- decode_amigados(drv);
+#ifdef FDI2RAW
+ fdi2raw_loadtrack(drv->fdi, drv->bigmfmbuf, drv->tracktiming, tr, &drv->tracklen, &drv->indexoffset, &drv->multi_revolution, 1);
+#endif
+ }
+ else if (ti->type == TRACK_PCDOS)
+ {
+ decode_pcdos(drv);
+ }
+ else if (ti->type == TRACK_AMIGADOS)
+ {
+ decode_amigados(drv);
+ }
+ else if (ti->type == TRACK_DISKSPARE)
+ {
+ decode_diskspare(drv);
+ }
+ else if (ti->type == TRACK_NONE)
+ {
+ ;
+ }
+ else
+ {
+ int i;
+ int base_offset = ti->type == TRACK_RAW ? 0 : 1;
+ drv->tracklen = ti->bitlen + 16 * base_offset;
+ drv->bigmfmbuf[0] = ti->sync;
+ read_floppy_data(drv->diskfile, drv->filetype, ti, 0, reinterpret_cast(drv->bigmfmbuf + base_offset), (ti->bitlen + 7) / 8);
+ for (i = base_offset; i < (drv->tracklen + 15) / 16; i++)
+ {
+ uae_u16* mfm = drv->bigmfmbuf + i;
+ uae_u8* data = reinterpret_cast(mfm);
+ *mfm = 256 * *data + *(data + 1);
+ }
+ }
+ drv->buffered_side = side;
+ drv->buffered_cyl = drv->cyl;
+ if (drv->tracklen == 0)
+ {
+ drv->tracklen = FLOPPY_WRITE_LEN * drv->ddhd * 2 * 8;
+ memset(drv->bigmfmbuf, 0, FLOPPY_WRITE_LEN * 2 * drv->ddhd);
+ }
- } else if (ti->type == TRACK_DISKSPARE) {
-
- decode_diskspare (drv);
-
- } else if (ti->type == TRACK_NONE) {
-
- ;
-
- } else {
- int i;
- int base_offset = ti->type == TRACK_RAW ? 0 : 1;
- drv->tracklen = ti->bitlen + 16 * base_offset;
- drv->bigmfmbuf[0] = ti->sync;
- read_floppy_data (drv->diskfile, drv->filetype, ti, 0, (uae_u8*)(drv->bigmfmbuf + base_offset), (ti->bitlen + 7) / 8);
- for (i = base_offset; i < (drv->tracklen + 15) / 16; i++) {
- uae_u16 *mfm = drv->bigmfmbuf + i;
- uae_u8 *data = (uae_u8 *) mfm;
- *mfm = 256 * *data + *(data + 1);
- }
- }
- drv->buffered_side = side;
- drv->buffered_cyl = drv->cyl;
- if (drv->tracklen == 0) {
- drv->tracklen = FLOPPY_WRITE_LEN * drv->ddhd * 2 * 8;
- memset (drv->bigmfmbuf, 0, FLOPPY_WRITE_LEN * 2 * drv->ddhd);
- }
-
- drv->trackspeed = get_floppy_speed2 (drv);
- updatemfmpos (drv);
+ drv->trackspeed = get_floppy_speed2(drv);
+ updatemfmpos(drv);
}
/* Update ADF_EXT2 track header */
-static void diskfile_update (struct zfile *diskfile, trackid *ti, int len, image_tracktype type)
+static void diskfile_update(struct zfile* diskfile, trackid* ti, int len, image_tracktype type)
{
- uae_u8 buf[2 + 2 + 4 + 4], *zerobuf;
+ uae_u8 buf[2 + 2 + 4 + 4], *zerobuf;
- ti->revolutions = 1;
- ti->bitlen = len;
- zfile_fseek (diskfile, 8 + 4 + (2 + 2 + 4 + 4) * ti->track, SEEK_SET);
- memset (buf, 0, sizeof buf);
- ti->type = type;
- buf[2] = 0;
- buf[3] = ti->type;
- do_put_mem_long ((uae_u32 *) (buf + 4), ti->len);
- do_put_mem_long ((uae_u32 *) (buf + 8), ti->bitlen);
- zfile_fwrite (buf, sizeof buf, 1, diskfile);
- if (ti->len > (len + 7) / 8) {
- zerobuf = xmalloc (uae_u8, ti->len);
- memset (zerobuf, 0, ti->len);
- zfile_fseek (diskfile, ti->offs, SEEK_SET);
- zfile_fwrite (zerobuf, 1, ti->len, diskfile);
- free (zerobuf);
- }
+ ti->revolutions = 1;
+ ti->bitlen = len;
+ zfile_fseek(diskfile, 8 + 4 + (2 + 2 + 4 + 4) * ti->track, SEEK_SET);
+ memset(buf, 0, sizeof buf);
+ ti->type = type;
+ buf[2] = 0;
+ buf[3] = ti->type;
+ do_put_mem_long(reinterpret_cast(buf + 4), ti->len);
+ do_put_mem_long(reinterpret_cast(buf + 8), ti->bitlen);
+ zfile_fwrite(buf, sizeof buf, 1, diskfile);
+ if (ti->len > (len + 7) / 8)
+ {
+ zerobuf = xmalloc (uae_u8, ti->len);
+ memset(zerobuf, 0, ti->len);
+ zfile_fseek(diskfile, ti->offs, SEEK_SET);
+ zfile_fwrite(zerobuf, 1, ti->len, diskfile);
+ free(zerobuf);
+ }
}
#define MFMMASK 0x55555555
-static uae_u16 getmfmword (uae_u16 *mbuf, int shift)
+
+static uae_u16 getmfmword(uae_u16* mbuf, int shift)
{
- return (mbuf[0] << shift) | (mbuf[1] >> (16 - shift));
+ return (mbuf[0] << shift) | (mbuf[1] >> (16 - shift));
}
-static uae_u32 getmfmlong (uae_u16 *mbuf, int shift)
+static uae_u32 getmfmlong(uae_u16* mbuf, int shift)
{
- return ((getmfmword (mbuf, shift) << 16) | getmfmword (mbuf + 1, shift)) & MFMMASK;
+ return ((getmfmword(mbuf, shift) << 16) | getmfmword(mbuf + 1, shift)) & MFMMASK;
}
#if MFM_VALIDATOR
@@ -1814,302 +2029,321 @@ static void check_valid_mfm (uae_u16 *mbuf, int words, int sector)
int databit = w & (1 << (bitoffset + 0));
if ((clockbit && databit) || (clockbit && !databit && prevbit) || (!clockbit && !databit && !prevbit)) {
- write_log (_T("illegal mfm sector %d data %04x %04x, bit %d:%d\n"), sector, wp, w, wordoffset, bitoffset);
+ write_log (L"illegal mfm sector %d data %04x %04x, bit %d:%d\n", sector, wp, w, wordoffset, bitoffset);
}
prevbit = databit;
}
}
#endif
-static int decode_buffer (uae_u16 *mbuf, int cyl, int drvsec, int ddhd, int filetype, int *drvsecp, int *sectable, int checkmode)
+static int decode_buffer(uae_u16* mbuf, int cyl, int drvsec, int ddhd, int filetype, int* drvsecp, int* sectable, int checkmode)
{
- int i, secwritten = 0;
- int fwlen = FLOPPY_WRITE_LEN * ddhd;
- int length = 2 * fwlen;
- uae_u32 odd, even, chksum, id, dlong;
- uae_u8 *secdata;
- uae_u8 secbuf[544];
+ int i, secwritten = 0;
+ int fwlen = FLOPPY_WRITE_LEN * ddhd;
+ int length = 2 * fwlen;
+ uae_u32 odd, even, chksum, id, dlong;
+ uae_u8* secdata;
+ uae_u8 secbuf[544];
uae_u16 *mend = mbuf + length, *mstart;
uae_u32 sechead[4];
- int shift = 0;
+ int shift = 0;
bool issechead;
- memset (sectable, 0, MAX_SECTORS * sizeof (int));
+ memset(sectable, 0, MAX_SECTORS * sizeof (int));
mstart = mbuf;
- memcpy (mbuf + fwlen, mbuf, fwlen * sizeof (uae_u16));
- mend -= (4 + 16 + 8 + 512);
- while (secwritten < drvsec) {
- int trackoffs;
+ memcpy(mbuf + fwlen, mbuf, fwlen * sizeof (uae_u16));
+ mend -= (4 + 16 + 8 + 512);
+ while (secwritten < drvsec)
+ {
+ int trackoffs;
- while (getmfmword (mbuf, shift) != 0x4489) {
- if (mbuf >= mend)
- return 1;
- shift++;
- if (shift == 16) {
- shift = 0;
- mbuf++;
- }
- }
- while (getmfmword (mbuf, shift) == 0x4489) {
- if (mbuf >= mend)
- return 1;
- mbuf++;
- }
+ while (getmfmword(mbuf, shift) != 0x4489)
+ {
+ if (mbuf >= mend)
+ return 1;
+ shift++;
+ if (shift == 16)
+ {
+ shift = 0;
+ mbuf++;
+ }
+ }
+ while (getmfmword(mbuf, shift) == 0x4489)
+ {
+ if (mbuf >= mend)
+ return 1;
+ mbuf++;
+ }
- odd = getmfmlong (mbuf, shift);
- even = getmfmlong (mbuf + 2, shift);
- mbuf += 4;
- id = (odd << 1) | even;
+ odd = getmfmlong(mbuf, shift);
+ even = getmfmlong(mbuf + 2, shift);
+ mbuf += 4;
+ id = (odd << 1) | even;
- trackoffs = (id & 0xff00) >> 8;
- if (trackoffs + 1 > drvsec) {
- write_log (_T("Disk decode: weird sector number %d (%08x, %ld)\n"), trackoffs, id, mbuf - mstart);
- if (filetype == ADF_EXT2)
- return 2;
- continue;
- }
+ trackoffs = (id & 0xff00) >> 8;
+ if (trackoffs + 1 > drvsec)
+ {
+ write_log (_T("Disk decode: weird sector number %d (%08X, %d)\n"), trackoffs, id, mbuf - mstart);
+ if (filetype == ADF_EXT2)
+ return 2;
+ continue;
+ }
#if MFM_VALIDATOR
check_valid_mfm (mbuf - 4, 544 - 4 + 1, trackoffs);
#endif
issechead = false;
- chksum = odd ^ even;
- for (i = 0; i < 4; i++) {
- odd = getmfmlong (mbuf, shift);
- even = getmfmlong (mbuf + 8, shift);
- mbuf += 2;
+ chksum = odd ^ even;
+ for (i = 0; i < 4; i++)
+ {
+ odd = getmfmlong(mbuf, shift);
+ even = getmfmlong(mbuf + 8, shift);
+ mbuf += 2;
- dlong = (odd << 1) | even;
- if (dlong && !checkmode) {
+ dlong = (odd << 1) | even;
+ if (dlong && !checkmode)
+ {
issechead = true;
}
sechead[i] = dlong;
chksum ^= odd ^ even;
}
- if (issechead) {
- if (filetype == ADF_EXT2)
- return 6;
- }
- mbuf += 8;
- odd = getmfmlong (mbuf, shift);
- even = getmfmlong (mbuf + 2, shift);
- mbuf += 4;
- if (((odd << 1) | even) != chksum) {
+ if (issechead)
+ {
+ if (filetype == ADF_EXT2)
+ return 6;
+ }
+ mbuf += 8;
+ odd = getmfmlong(mbuf, shift);
+ even = getmfmlong(mbuf + 2, shift);
+ mbuf += 4;
+ if (((odd << 1) | even) != chksum)
+ {
write_log (_T("Disk decode: checksum error on sector %d header\n"), trackoffs);
- if (filetype == ADF_EXT2)
- return 3;
- continue;
- }
- if (((id & 0x00ff0000) >> 16) != cyl * 2 + side) {
+ if (filetype == ADF_EXT2)
+ return 3;
+ continue;
+ }
+ if (((id & 0x00ff0000) >> 16) != cyl * 2 + side)
+ {
write_log (_T("Disk decode: mismatched track (%d <> %d) on sector %d header (%08X)\n"), (id & 0x00ff0000) >> 16, cyl * 2 + side, trackoffs, id);
- if (filetype == ADF_EXT2)
- return 3;
- continue;
- }
- odd = getmfmlong (mbuf, shift);
- even = getmfmlong (mbuf + 2, shift);
- mbuf += 4;
- chksum = (odd << 1) | even;
- secdata = secbuf + 32;
- for (i = 0; i < 128; i++) {
- odd = getmfmlong (mbuf, shift);
- even = getmfmlong (mbuf + 256, shift);
- mbuf += 2;
- dlong = (odd << 1) | even;
- *secdata++ = dlong >> 24;
- *secdata++ = dlong >> 16;
- *secdata++ = dlong >> 8;
- *secdata++ = dlong;
- chksum ^= odd ^ even;
- }
- if (chksum) {
+ if (filetype == ADF_EXT2)
+ return 3;
+ continue;
+ }
+ odd = getmfmlong(mbuf, shift);
+ even = getmfmlong(mbuf + 2, shift);
+ mbuf += 4;
+ chksum = (odd << 1) | even;
+ secdata = secbuf + 32;
+ for (i = 0; i < 128; i++)
+ {
+ odd = getmfmlong(mbuf, shift);
+ even = getmfmlong(mbuf + 256, shift);
+ mbuf += 2;
+ dlong = (odd << 1) | even;
+ *secdata++ = dlong >> 24;
+ *secdata++ = dlong >> 16;
+ *secdata++ = dlong >> 8;
+ *secdata++ = dlong;
+ chksum ^= odd ^ even;
+ }
+ if (chksum)
+ {
write_log (_T("Disk decode: sector %d, data checksum error\n"), trackoffs);
- if (filetype == ADF_EXT2)
- return 4;
- continue;
- }
- mbuf += 256;
- sectable[trackoffs] = 1;
- secwritten++;
- memcpy (writebuffer + trackoffs * 512, secbuf + 32, 512);
- }
- if (filetype == ADF_EXT2 && (secwritten == 0 || secwritten < 0))
- return 5;
- if (secwritten == 0)
- write_log (_T("Disk decode: unsupported format\n"));
- if (secwritten < 0)
- write_log (_T("Disk decode: sector labels ignored\n"));
- *drvsecp = drvsec;
- return 0;
+ if (filetype == ADF_EXT2)
+ return 4;
+ continue;
+ }
+ mbuf += 256;
+ sectable[trackoffs] = 1;
+ secwritten++;
+ memcpy(writebuffer + trackoffs * 512, secbuf + 32, 512);
+ }
+ if (filetype == ADF_EXT2 && (secwritten == 0 || secwritten < 0))
+ return 5;
+ *drvsecp = drvsec;
+ return 0;
}
-static uae_u8 mfmdecode(uae_u16 **mfmp, int shift)
+static uae_u8 mfmdecode(uae_u16** mfmp, int shift)
{
- uae_u16 mfm = getmfmword (*mfmp, shift);
- uae_u8 out = 0;
- int i;
+ uae_u16 mfm = getmfmword(*mfmp, shift);
+ uae_u8 out = 0;
+ int i;
- (*mfmp)++;
- mfm &= 0x5555;
- for (i = 0; i < 8; i++) {
- out >>= 1;
- if (mfm & 1)
- out |= 0x80;
- mfm >>= 2;
- }
- return out;
+ (*mfmp)++;
+ mfm &= 0x5555;
+ for (i = 0; i < 8; i++)
+ {
+ out >>= 1;
+ if (mfm & 1)
+ out |= 0x80;
+ mfm >>= 2;
+ }
+ return out;
}
-static int drive_write_pcdos (drive *drv, struct zfile *zf, bool count)
+static int drive_write_pcdos(drive* drv)
{
- int i;
- int drvsec = drv->num_secs;
- int fwlen = FLOPPY_WRITE_LEN * drv->ddhd;
- int length = 2 * fwlen;
- uae_u16 *mbuf = drv->bigmfmbuf;
- uae_u16 *mend = mbuf + length;
- int secwritten = 0, seccnt = 0;
- int shift = 0, sector = -1;
- int sectable[24];
- uae_u8 secbuf[3 + 1 + 512];
- uae_u8 mark;
- uae_u16 crc;
+ int i;
+ int drvsec = drv->num_secs;
+ int fwlen = FLOPPY_WRITE_LEN * drv->ddhd;
+ int length = 2 * fwlen;
+ uae_u16* mbuf = drv->bigmfmbuf;
+ uae_u16* mend = mbuf + length;
+ int secwritten = 0, shift = 0, sector = -1;
+ int sectable[18];
+ uae_u8 secbuf[3 + 1 + 512];
+ uae_u8 mark;
+ uae_u16 crc;
- memset (sectable, 0, sizeof sectable);
- memcpy (mbuf + fwlen, mbuf, fwlen * sizeof (uae_u16));
- mend -= 518;
- secbuf[0] = secbuf[1] = secbuf[2] = 0xa1;
- secbuf[3] = 0xfb;
+ memset(sectable, 0, sizeof sectable);
+ memcpy(mbuf + fwlen, mbuf, fwlen * sizeof (uae_u16));
+ mend -= 518;
+ secbuf[0] = secbuf[1] = secbuf[2] = 0xa1;
+ secbuf[3] = 0xfb;
- while (seccnt < drvsec) {
+ while (secwritten < drvsec)
+ {
int mfmcount;
mfmcount = 0;
- while (getmfmword (mbuf, shift) != 0x4489) {
+ while (getmfmword(mbuf, shift) != 0x4489)
+ {
mfmcount++;
- if (mbuf >= mend)
- return -1;
- shift++;
- if (shift == 16) {
- shift = 0;
- mbuf++;
- }
+ if (mbuf >= mend)
+ return 1;
+ shift++;
+ if (shift == 16)
+ {
+ shift = 0;
+ mbuf++;
+ }
if (sector >= 0 && mfmcount / 16 >= 43)
sector = -1;
- }
+ }
mfmcount = 0;
- while (getmfmword (mbuf, shift) == 0x4489) {
+ while (getmfmword(mbuf, shift) == 0x4489)
+ {
mfmcount++;
- if (mbuf >= mend)
- return -1;
- mbuf++;
- }
+ if (mbuf >= mend)
+ return 1;
+ mbuf++;
+ }
if (mfmcount < 3) // ignore if less than 3 sync markers
continue;
- mark = mfmdecode(&mbuf, shift);
- if (mark == 0xfe) {
- uae_u8 tmp[8];
- uae_u8 cyl, head, size;
+ mark = mfmdecode(&mbuf, shift);
+ if (mark == 0xfe)
+ {
+ uae_u8 tmp[8];
+ uae_u8 cyl, head, size;
- cyl = mfmdecode(&mbuf, shift);
- head = mfmdecode(&mbuf, shift);
- sector = mfmdecode(&mbuf, shift);
- size = mfmdecode(&mbuf, shift);
- crc = (mfmdecode(&mbuf, shift) << 8) | mfmdecode(&mbuf, shift);
+ cyl = mfmdecode(&mbuf, shift);
+ head = mfmdecode(&mbuf, shift);
+ sector = mfmdecode(&mbuf, shift);
+ size = mfmdecode(&mbuf, shift);
+ crc = (mfmdecode(&mbuf, shift) << 8) | mfmdecode(&mbuf, shift);
- tmp[0] = 0xa1; tmp[1] = 0xa1; tmp[2] = 0xa1; tmp[3] = mark;
- tmp[4] = cyl; tmp[5] = head; tmp[6] = sector; tmp[7] = size;
+ tmp[0] = 0xa1;
+ tmp[1] = 0xa1;
+ tmp[2] = 0xa1;
+ tmp[3] = mark;
+ tmp[4] = cyl;
+ tmp[5] = head;
+ tmp[6] = sector;
+ tmp[7] = size;
// skip 28 bytes
for (i = 0; i < 28; i++)
- mfmdecode (&mbuf, shift);
+ mfmdecode(&mbuf, shift);
- if (get_crc16 (tmp, 8) != crc || cyl != drv->cyl || head != side || size != 2 || sector < 1 || sector > drv->num_secs || sector >= sizeof sectable) {
+ if (get_crc16(tmp, 8) != crc || cyl != drv->cyl || head != side || size != 2 || sector < 1 || sector > drv->num_secs)
+ {
write_log (_T("PCDOS: track %d, corrupted sector header\n"), drv->cyl * 2 + side);
- return -1;
- }
- sector--;
- continue;
- }
- if (mark != 0xfb && mark != 0xfa) {
+ return 1;
+ }
+ sector--;
+ continue;
+ }
+ if (mark != 0xfb && mark != 0xfa)
+ {
write_log (_T("PCDOS: track %d: unknown address mark %02X\n"), drv->cyl * 2 + side, mark);
- continue;
- }
- if (sector < 0)
- continue;
- for (i = 0; i < 512; i++)
- secbuf[i + 4] = mfmdecode(&mbuf, shift);
- crc = (mfmdecode(&mbuf, shift) << 8) | mfmdecode(&mbuf, shift);
- if (get_crc16(secbuf, 3 + 1 + 512) != crc) {
+ continue;
+ }
+ if (sector < 0)
+ continue;
+ for (i = 0; i < 512; i++)
+ secbuf[i + 4] = mfmdecode(&mbuf, shift);
+ crc = (mfmdecode(&mbuf, shift) << 8) | mfmdecode(&mbuf, shift);
+ if (get_crc16(secbuf, 3 + 1 + 512) != crc)
+ {
write_log (_T("PCDOS: track %d, sector %d data checksum error\n"),
drv->cyl * 2 + side, sector + 1);
- continue;
- }
- seccnt++;
- if (count && sectable[sector])
- break;
- if (!sectable[sector]) {
- secwritten++;
- sectable[sector] = 1;
- zfile_fseek (zf, drv->trackdata[drv->cyl * 2 + side].offs + sector * 512, SEEK_SET);
- zfile_fwrite (secbuf + 4, sizeof (uae_u8), 512, zf);
+ continue;
}
- sector = -1;
- }
- if (!count && secwritten != drv->num_secs)
- write_log (_T("PCDOS: track %d, %d corrupted sectors ignored\n"),
+ sectable[sector] = 1;
+ secwritten++;
+ zfile_fseek(drv->diskfile, drv->trackdata[drv->cyl * 2 + side].offs + sector * 512, SEEK_SET);
+ zfile_fwrite(secbuf + 4, sizeof (uae_u8), 512, drv->diskfile);
+ write_log (_T("PCDOS: track %d sector %d written\n"), drv->cyl * 2 + side, sector + 1);
+ sector = -1;
+ }
+ if (secwritten != drv->num_secs)
+ write_log (_T("PCDOS: track %d, %d corrupted sectors ignored\n"),
drv->cyl * 2 + side, drv->num_secs - secwritten);
- return secwritten;
+ return 0;
}
-static int drive_write_adf_amigados (drive * drv)
+static int drive_write_adf_amigados(drive* drv)
{
- int drvsec, i;
- int sectable[MAX_SECTORS];
+ int drvsec, i;
+ int sectable[MAX_SECTORS];
- if (decode_buffer (drv->bigmfmbuf, drv->cyl, drv->num_secs, drv->ddhd, drv->filetype, &drvsec, sectable, 0))
- return 2;
- if (!drvsec)
- return 2;
+ if (decode_buffer(drv->bigmfmbuf, drv->cyl, drv->num_secs, drv->ddhd, drv->filetype, &drvsec, sectable, 0))
+ return 2;
+ if (!drvsec)
+ return 2;
- if (drv->filetype == ADF_EXT2)
- diskfile_update (drv->diskfile, &drv->trackdata[drv->cyl * 2 + side], drvsec * 512 * 8, TRACK_AMIGADOS);
- for (i = 0; i < drvsec; i++) {
- zfile_fseek (drv->diskfile, drv->trackdata[drv->cyl * 2 + side].offs + i * 512, SEEK_SET);
- zfile_fwrite (writebuffer + i * 512, sizeof (uae_u8), 512, drv->diskfile);
- }
+ if (drv->filetype == ADF_EXT2)
+ diskfile_update(drv->diskfile, &drv->trackdata[drv->cyl * 2 + side], drvsec * 512 * 8, TRACK_AMIGADOS);
+ for (i = 0; i < drvsec; i++)
+ {
+ zfile_fseek(drv->diskfile, drv->trackdata[drv->cyl * 2 + side].offs + i * 512, SEEK_SET);
+ zfile_fwrite(writebuffer + i * 512, sizeof (uae_u8), 512, drv->diskfile);
+ }
- return 0;
+ return 0;
}
/* write raw track to disk file */
-static int drive_write_ext2 (uae_u16 *bigmfmbuf, struct zfile *diskfile, trackid *ti, int tracklen)
+static int drive_write_ext2(uae_u16* bigmfmbuf, struct zfile* diskfile, trackid* ti, int tracklen)
{
- int len, i, offset;
+ int len, i;
- offset = 0;
- len = (tracklen + 7) / 8;
- if (len > ti->len) {
+ len = (tracklen + 7) / 8;
+ if (len > ti->len)
+ {
write_log (_T("disk raw write: image file's track %d is too small (%d < %d)!\n"), ti->track, ti->len, len);
- offset = (len - ti->len) / 2;
- len = ti->len;
- }
- diskfile_update (diskfile, ti, tracklen, TRACK_RAW);
- for (i = 0; i < ti->len / 2; i++) {
- uae_u16 *mfm = bigmfmbuf + i + offset;
- uae_u16 *mfmw = bigmfmbufw + i + offset;
- uae_u8 *data = (uae_u8 *) mfm;
- *mfmw = 256 * *data + *(data + 1);
- }
- zfile_fseek (diskfile, ti->offs, SEEK_SET);
- zfile_fwrite (bigmfmbufw, 1, len, diskfile);
- return 1;
+ len = ti->len;
+ }
+ diskfile_update(diskfile, ti, tracklen, TRACK_RAW);
+ for (i = 0; i < ti->len / 2; i++)
+ {
+ uae_u16* mfm = bigmfmbuf + i;
+ uae_u16* mfmw = bigmfmbufw + i;
+ uae_u8* data = reinterpret_cast(mfm);
+ *mfmw = 256 * *data + *(data + 1);
+ }
+ zfile_fseek(diskfile, ti->offs, SEEK_SET);
+ zfile_fwrite(bigmfmbufw, 1, len, diskfile);
+ return 1;
}
-static void drive_write_data (drive * drv);
+static void drive_write_data(drive * drv);
-static bool convert_adf_to_ext2 (drive *drv, int mode)
+static bool convert_adf_to_ext2(drive *drv, int mode)
{
TCHAR name[MAX_DPATH];
bool hd = drv->ddhd == 2;
@@ -2117,480 +2351,570 @@ static bool convert_adf_to_ext2 (drive *drv, int mode)
if (drv->filetype != ADF_NORMAL)
return false;
- _tcscpy (name, currprefs.floppyslots[drv - floppy].df);
+ _tcscpy(name, currprefs.floppyslots[drv - floppy].df);
if (!name[0])
return false;
if (mode == 1) {
- TCHAR *p = _tcsrchr (name, '.');
+ TCHAR *p = _tcsrchr(name, '.');
if (!p)
- p = name + _tcslen (name);
- _tcscpy (p, _T(".extended.adf"));
- if (!disk_creatediskfile (&currprefs, name, 1, hd ? DRV_35_HD : DRV_35_DD, -1, NULL, false, false, drv->diskfile))
+ p = name + _tcslen(name);
+ _tcscpy(p, _T(".extended.adf"));
+ if (!disk_creatediskfile(name, 1, hd ? DRV_35_HD : DRV_35_DD, nullptr, false, false, drv->diskfile))
return false;
- } else if (mode == 2) {
- struct zfile *tmp = zfile_fopen_load_zfile (drv->diskfile);
+ }
+ else if (mode == 2) {
+ struct zfile *tmp = zfile_fopen_load_zfile(drv->diskfile);
if (!tmp)
return false;
- zfile_fclose (drv->diskfile);
- drv->diskfile = NULL;
- if (!disk_creatediskfile (&currprefs, name, 1, hd ? DRV_35_HD : DRV_35_DD, -1, NULL, false, false, tmp)) {
- zfile_fclose (tmp);
+ zfile_fclose(drv->diskfile);
+ drv->diskfile = nullptr;
+ if (!disk_creatediskfile(name, 1, hd ? DRV_35_HD : DRV_35_DD, nullptr, false, false, tmp)) {
+ zfile_fclose(tmp);
return false;
}
- } else {
+ }
+ else {
return false;
}
- f = zfile_fopen (name, _T("r+b"));
+ f = zfile_fopen(name, _T("r+b"));
if (!f)
return false;
- _tcscpy (currprefs.floppyslots[drv - floppy].df, name);
- _tcscpy (changed_prefs.floppyslots[drv - floppy].df, name);
- zfile_fclose (drv->diskfile);
+ _tcscpy(currprefs.floppyslots[drv - floppy].df, name);
+ _tcscpy(changed_prefs.floppyslots[drv - floppy].df, name);
+ zfile_fclose(drv->diskfile);
drv->diskfile = f;
drv->filetype = ADF_EXT2;
- read_header_ext2 (drv->diskfile, drv->trackdata, &drv->num_tracks, &drv->ddhd);
+ read_header_ext2(drv->diskfile, drv->trackdata, &drv->num_tracks, &drv->ddhd);
- drive_write_data (drv);
- drive_fill_bigbuf (drv, 1);
+ drive_write_data(drv);
+#ifdef RETROPLATFORM
+ rp_disk_image_change(drv - &floppy[0], name, false);
+#endif
+ drive_fill_bigbuf(drv, 1);
return true;
}
-static void drive_write_data (drive * drv)
+static void drive_write_data(drive* drv)
{
- int ret = -1;
+ int ret = -1;
int tr = drv->cyl * 2 + side;
- if (drive_writeprotected (drv) || drv->trackdata[tr].type == TRACK_NONE) {
- /* read original track back because we didn't really write anything */
- drv->buffered_side = 2;
- return;
- }
- if (drv->writediskfile) {
- drive_write_ext2 (drv->bigmfmbuf, drv->writediskfile, &drv->writetrackdata[tr],
- longwritemode ? dsklength2 * 8 : drv->tracklen);
- }
- switch (drv->filetype) {
- case ADF_NORMAL:
- if (drv->ddhd > 1 && currprefs.floppyslots[drv - &floppy[0]].dfxtype != DRV_35_HD) {
- // HD image in DD drive: ignore writing.
- drv->buffered_side = 2;
- } else {
- if (drive_write_adf_amigados (drv)) {
- if (currprefs.floppy_auto_ext2) {
- convert_adf_to_ext2 (drv, currprefs.floppy_auto_ext2);
- } else {
- static int warned;
- if (!warned)
- notify_user (NUMSG_NEEDEXT2);
- warned = 1;
- }
- }
+ if (drive_writeprotected(drv) || drv->trackdata[tr].type == TRACK_NONE)
+ {
+ /* read original track back because we didn't really write anything */
+ drv->buffered_side = 2;
+ return;
+ }
+ if (drv->writediskfile)
+ {
+ drive_write_ext2(drv->bigmfmbuf, drv->writediskfile, &drv->writetrackdata[tr],
+ longwritemode ? dsklength2 * 8 : drv->tracklen);
+ }
+ switch (drv->filetype)
+ {
+ case ADF_NORMAL:
+ if (drive_write_adf_amigados(drv))
+ {
+ static int warned;
+ if (!warned)
+ notify_user(NUMSG_NEEDEXT2);
+ warned = 1;
}
- return;
- case ADF_EXT1:
- break;
- case ADF_EXT2:
- if (!longwritemode)
- ret = drive_write_adf_amigados (drv);
- if (ret) {
- write_log (_T("not an amigados track %d (error %d), writing as raw track\n"), drv->cyl * 2 + side, ret);
- drive_write_ext2 (drv->bigmfmbuf, drv->diskfile, &drv->trackdata[drv->cyl * 2 + side],
- longwritemode ? dsklength2 * 8 : drv->tracklen);
- }
- return;
- case ADF_PCDOS:
- ret = drive_write_pcdos (drv, drv->diskfile, 0);
- if (ret < 0)
- write_log (_T("not a PC formatted track %d (error %d)\n"), drv->cyl * 2 + side, ret);
- break;
- }
- drv->tracktiming[0] = 0;
+ return;
+ case ADF_EXT1:
+ break;
+ case ADF_EXT2:
+ if (!longwritemode)
+ ret = drive_write_adf_amigados(drv);
+ if (ret)
+ {
+ write_log (_T("not an amigados track %d (error %d), writing as raw track\n"), drv->cyl * 2 + side, ret);
+ drive_write_ext2(drv->bigmfmbuf, drv->diskfile, &drv->trackdata[drv->cyl * 2 + side],
+ longwritemode ? dsklength2 * 8 : drv->tracklen);
+ }
+ return;
+ case ADF_IPF:
+ break;
+ case ADF_PCDOS:
+ ret = drive_write_pcdos(drv);
+ if (ret)
+ write_log (_T("not a PC formatted track %d (error %d)\n"), drv->cyl * 2 + side, ret);
+ break;
+ }
+ drv->tracktiming[0] = 0;
}
-static void drive_eject (drive * drv)
+static void drive_eject(drive* drv)
{
- drive_image_free (drv);
- drv->dskeject = false;
- drv->dskchange = true;
- drv->ddhd = 1;
- drv->dskchange_time = 0;
- drv->dskready = 0;
- drv->dskready_up_time = 0;
- drv->dskready_down_time = 0;
- drv->crc32 = 0;
- drive_settype_id (drv); /* Back to 35 DD */
+#ifdef DRIVESOUND
+ if (isfloppysound(drv))
+ driveclick_insert(drv - floppy, 1);
+#endif
+ gui_disk_image_change(drv - floppy, nullptr, drv->wrprot);
+ drive_image_free(drv);
+ drv->dskchange = true;
+ drv->ddhd = 1;
+ drv->dskchange_time = 0;
+ drv->dskready = false;
+ drv->dskready_up_time = 0;
+ drv->dskready_down_time = 0;
+ drv->crc32 = 0;
+ drive_settype_id(drv); /* Back to 35 DD */
+ //TODO: enable when inputrecording is implemented
+ //inprec_recorddiskchange(drv - floppy, NULL, false);
}
-static void floppy_get_bootblock (uae_u8 *dst, bool ffs, bool bootable)
+/* We use this function if we have no Kickstart ROM.
+ * No error checking - we trust our luck. */
+void DISK_ersatz_read(int tr, int sec, uaecptr dest)
{
- strcpy ((char*)dst, "DOS");
+ uae_u8* dptr = get_real_address(dest);
+ zfile_fseek(floppy[0].diskfile, floppy[0].trackdata[tr].offs + sec * 512, SEEK_SET);
+ zfile_fread(dptr, 1, 512, floppy[0].diskfile);
+}
+
+static void floppy_get_bootblock(uae_u8* dst, bool ffs, bool bootable)
+{
+ strcpy(reinterpret_cast(dst), "DOS");
dst[3] = ffs ? 1 : 0;
if (bootable)
- memcpy (dst, ffs ? bootblock_ffs : bootblock_ofs, ffs ? sizeof bootblock_ffs : sizeof bootblock_ofs);
+ memcpy(dst, ffs ? bootblock_ffs : bootblock_ofs, ffs ? sizeof bootblock_ffs : sizeof bootblock_ofs);
}
-static void floppy_get_rootblock (uae_u8 *dst, int block, const TCHAR *disk_name, bool hd)
+
+static void floppy_get_rootblock(uae_u8* dst, int block, const TCHAR* disk_name, drive_type adftype)
{
- dst[0+3] = 2; // primary type
- dst[12+3] = 0x48; // size of hash table
- dst[312] = dst[313] = dst[314] = dst[315] = (uae_u8)0xff; // bitmap valid
- dst[316+2] = (block + 1) >> 8; dst[316+3] = (block + 1) & 255; // bitmap pointer
- char *s = ua ((disk_name && _tcslen (disk_name) > 0) ? disk_name : _T("empty"));
- dst[432] = strlen (s); // name length
- strcpy ((char*)dst + 433, s); // name
+ dst[0 + 3] = 2;
+ dst[12 + 3] = 0x48;
+ dst[312] = dst[313] = dst[314] = dst[315] = uae_u8(0xff);
+ dst[316 + 2] = (block + 1) >> 8;
+ dst[316 + 3] = (block + 1) & 255;
+ char* s = ua((disk_name && _tcslen (disk_name) > 0) ? disk_name : _T("empty"));
+ dst[432] = strlen(s);
+ strcpy(reinterpret_cast(dst) + 433, s);
xfree (s);
- dst[508 + 3] = 1; // secondary type
- disk_date (dst + 420); // root modification date
- disk_date(dst + 484); // creation date
- disk_checksum (dst, dst + 20);
+ dst[508 + 3] = 1;
+ disk_date(dst + 420);
+ memcpy(dst + 472, dst + 420, 3 * 4);
+ memcpy(dst + 484, dst + 420, 3 * 4);
+ disk_checksum(dst, dst + 20);
/* bitmap block */
- memset (dst + 512 + 4, 0xff, 2 * block / 8);
- if (!hd)
+ memset(dst + 512 + 4, 0xff, 2 * block / 8);
+ if (adftype == 0)
dst[512 + 0x72] = 0x3f;
else
dst[512 + 0xdc] = 0x3f;
- disk_checksum (dst + 512, dst + 512);
+ disk_checksum(dst + 512, dst + 512);
}
/* type: 0=regular, 1=ext2adf */
-bool disk_creatediskfile (struct uae_prefs *p, const TCHAR *name, int type, drive_type adftype, int hd, const TCHAR *disk_name, bool ffs, bool bootable, struct zfile *copyfrom)
+/* adftype: 0=DD,1=HD,2=DD PC,3=HD PC,4=525SD */
+bool disk_creatediskfile(const TCHAR* name, int type, drive_type adftype, const TCHAR* disk_name, bool ffs, bool bootable, struct zfile* copyfrom)
{
int size = 32768;
- struct zfile *f;
- int i, l, file_size, tracks, track_len, sectors;
- uae_u8 *chunk = NULL;
+ struct zfile* f;
+ int i, l, file_size, tracks, track_len, sectors;
+ uae_u8* chunk = nullptr;
int ddhd = 1;
bool ok = false;
uae_u64 pos;
- if (type == 1)
- tracks = 2 * 83;
- else
- tracks = 2 * 80;
- file_size = 880 * 1024;
- sectors = 11;
- if (adftype == DRV_PC_ONLY_40 || adftype == DRV_PC_ONLY_80) {
- file_size = 720 * 1024;
- sectors = 9;
- }
- // largest needed
- track_len = FLOPPY_WRITE_LEN_NTSC;
- if (p->floppy_write_length > track_len && p->floppy_write_length < 2 * FLOPPY_WRITE_LEN_NTSC)
- track_len = p->floppy_write_length;
- if (adftype == DRV_35_HD || hd > 0) {
- file_size *= 2;
- track_len *= 2;
+ if (type == 1)
+ tracks = 2 * 83;
+ else
+ tracks = 2 * 80;
+ file_size = 880 * 1024;
+ sectors = 11;
+ if (adftype == 2 || adftype == 3)
+ {
+ file_size = 720 * 1024;
+ sectors = 9;
+ }
+ track_len = FLOPPY_WRITE_LEN * 2;
+ if (adftype == 1 || adftype == 3)
+ {
+ file_size *= 2;
+ track_len *= 2;
ddhd = 2;
- } else if (adftype == DRV_PC_ONLY_40) {
- file_size /= 2;
- tracks /= 2;
- }
-
- if (copyfrom) {
- pos = zfile_ftell (copyfrom);
- zfile_fseek (copyfrom, 0, SEEK_SET);
+ }
+ else if (adftype == 4)
+ {
+ file_size /= 2;
+ tracks /= 2;
}
- f = zfile_fopen (name, _T("wb"), 0);
- chunk = xmalloc (uae_u8, size);
- if (f && chunk) {
- int cylsize = sectors * 2 * 512;
- memset(chunk, 0 ,size);
- if (type == 0) {
- for (i = 0; i < file_size; i += cylsize) {
- memset(chunk, 0, cylsize);
- if (adftype == DRV_35_DD || adftype == DRV_35_HD) {
- if (i == 0) {
- /* boot block */
- floppy_get_bootblock (chunk, ffs, bootable);
- } else if (i == file_size / 2) {
- /* root block */
- floppy_get_rootblock (chunk, file_size / 1024, disk_name, ddhd > 1);
- }
- }
- zfile_fwrite (chunk, cylsize, 1, f);
- }
+ if (copyfrom)
+ {
+ pos = zfile_ftell(copyfrom);
+ zfile_fseek(copyfrom, 0, SEEK_SET);
+ }
+
+ f = zfile_fopen(name, _T("wb"), 0);
+ chunk = xmalloc (uae_u8, size);
+ if (f && chunk)
+ {
+ int cylsize = sectors * 2 * 512;
+ memset(chunk, 0, size);
+ if (type == 0)
+ {
+ for (i = 0; i < file_size; i += cylsize)
+ {
+ memset(chunk, 0, cylsize);
+ if (adftype <= 1)
+ {
+ if (i == 0)
+ {
+ /* boot block */
+ floppy_get_bootblock(chunk, ffs, bootable);
+ }
+ else if (i == file_size / 2)
+ {
+ /* root block */
+ floppy_get_rootblock(chunk, file_size / 1024, disk_name, adftype);
+ }
+ }
+ zfile_fwrite(chunk, cylsize, 1, f);
+ }
ok = true;
- } else {
+ }
+ else
+ {
uae_u8 root[4];
uae_u8 rawtrack[3 * 4], dostrack[3 * 4];
- l = track_len;
- zfile_fwrite ("UAE-1ADF", 8, 1, f);
- root[0] = 0; root[1] = 0; /* flags (reserved) */
- root[2] = 0; root[3] = tracks; /* number of tracks */
- zfile_fwrite (root, 4, 1, f);
- rawtrack[0] = 0; rawtrack[1] = 0; /* flags (reserved) */
- rawtrack[2] = 0; rawtrack[3] = 1; /* track type */
- rawtrack[4] = 0; rawtrack[5] = 0; rawtrack[6]=(uae_u8)(l >> 8); rawtrack[7] = (uae_u8)l;
- rawtrack[8] = 0; rawtrack[9] = 0; rawtrack[10] = 0; rawtrack[11] = 0;
- memcpy (dostrack, rawtrack, sizeof rawtrack);
+ l = track_len;
+ zfile_fwrite("UAE-1ADF", 8, 1, f);
+ root[0] = 0;
+ root[1] = 0; /* flags (reserved) */
+ root[2] = 0;
+ root[3] = tracks; /* number of tracks */
+ zfile_fwrite(root, 4, 1, f);
+ rawtrack[0] = 0;
+ rawtrack[1] = 0; /* flags (reserved) */
+ rawtrack[2] = 0;
+ rawtrack[3] = 1; /* track type */
+ rawtrack[4] = 0;
+ rawtrack[5] = 0;
+ rawtrack[6] = uae_u8(l >> 8);
+ rawtrack[7] = uae_u8(l);
+ rawtrack[8] = 0;
+ rawtrack[9] = 0;
+ rawtrack[10] = 0;
+ rawtrack[11] = 0;
+ memcpy(dostrack, rawtrack, sizeof rawtrack);
dostrack[3] = 0;
- dostrack[9] = (l * 8) >> 16; dostrack[10] = (l * 8) >> 8; dostrack[11] = (l * 8) >> 0;
+ dostrack[9] = (l * 8) >> 16;
+ dostrack[10] = (l * 8) >> 8;
+ dostrack[11] = (l * 8) >> 0;
bool dodos = ffs || bootable || (disk_name && _tcslen (disk_name) > 0);
- for (i = 0; i < tracks; i++) {
+ for (i = 0; i < tracks; i++)
+ {
uae_u8 tmp[3 * 4];
- memcpy (tmp, rawtrack, sizeof rawtrack);
+ memcpy(tmp, rawtrack, sizeof rawtrack);
if (dodos || copyfrom)
- memcpy (tmp, dostrack, sizeof dostrack);
- zfile_fwrite (tmp, sizeof tmp, 1, f);
+ memcpy(tmp, dostrack, sizeof dostrack);
+ zfile_fwrite(tmp, sizeof tmp, 1, f);
}
- for (i = 0; i < tracks; i++) {
- memset (chunk, 0, size);
- if (copyfrom) {
- zfile_fread (chunk, 11 * ddhd, 512, copyfrom);
- } else {
- if (dodos) {
- if (i == 0)
- floppy_get_bootblock (chunk, ffs, bootable);
- else if (i == 80)
- floppy_get_rootblock (chunk, 80 * 11 * ddhd, disk_name, adftype == DRV_35_HD);
- }
+ for (i = 0; i < tracks; i++)
+ {
+ memset(chunk, 0, size);
+ if (copyfrom)
+ {
+ zfile_fread(chunk, 11 * ddhd, 512, copyfrom);
}
- zfile_fwrite (chunk, l, 1, f);
+ else
+ {
+ if (dodos)
+ {
+ if (i == 0)
+ floppy_get_bootblock(chunk, ffs, bootable);
+ else if (i == 80)
+ floppy_get_rootblock(chunk, 80 * 11 * ddhd, disk_name, adftype);
+ }
+ }
+ zfile_fwrite(chunk, l, 1, f);
}
ok = true;
- }
- }
- xfree (chunk);
- zfile_fclose (f);
+ }
+ }
+ xfree (chunk);
+ zfile_fclose(f);
if (copyfrom)
- zfile_fseek (copyfrom, pos, SEEK_SET);
+ zfile_fseek(copyfrom, pos, SEEK_SET);
return ok;
}
-int disk_getwriteprotect (struct uae_prefs *p, const TCHAR *name)
+int disk_getwriteprotect(struct uae_prefs* p, const TCHAR* name)
{
- int needwritefile;
- drive_type drvtype;
- return diskfile_iswriteprotect (p, name, &needwritefile, &drvtype);
+ int needwritefile;
+ drive_type drvtype;
+ return diskfile_iswriteprotect(p, name, &needwritefile, &drvtype);
}
-static void diskfile_readonly (const TCHAR *name, bool readonly)
+static void diskfile_readonly(const TCHAR* name, bool readonly)
{
struct mystat st;
- int mode, oldmode;
-
- if (!my_stat (name, &st)) {
+ int mode, oldmode;
+
+ if (!my_stat(name, &st))
+ {
write_log (_T("failed to access '%s'\n"), name);
- return;
+ return;
}
- write_log(_T("'%s': old mode = %x\n"), name, st.mode);
oldmode = mode = st.mode;
- mode &= ~FILEFLAG_WRITE;
- if (!readonly)
- mode |= FILEFLAG_WRITE;
- if (mode != oldmode) {
- if (!my_chmod (name, mode))
- write_log(_T("chmod failed!\n"));
- }
- write_log(_T("'%s': new mode = %x\n"), name, mode);
+ mode &= ~FILEFLAG_WRITE;
+ if (!readonly)
+ mode |= FILEFLAG_WRITE;
+ if (mode != oldmode)
+ {
+ if (!my_chmod(name, mode))
+ write_log(_T("chmod failed!\n"));
+ }
}
-static void setdskchangetime(drive *drv, int dsktime)
+static void setdskchangetime(drive* drv, int dsktime)
{
- int i;
- /* prevent multiple disk insertions at the same time */
- if (drv->dskchange_time > 0)
- return;
- for (i = 0; i < MAX_FLOPPY_DRIVES; i++) {
- if (&floppy[i] != drv && floppy[i].dskchange_time > 0 && floppy[i].dskchange_time + 1 >= dsktime) {
- dsktime = floppy[i].dskchange_time + 1;
- }
- }
- drv->dskchange_time = dsktime;
+ int i;
+ /* prevent multiple disk insertions at the same time */
+ if (drv->dskchange_time > 0)
+ return;
+ for (i = 0; i < MAX_FLOPPY_DRIVES; i++)
+ {
+ if (&floppy[i] != drv && floppy[i].dskchange_time > 0 && floppy[i].dskchange_time + 1 >= dsktime)
+ {
+ dsktime = floppy[i].dskchange_time + 1;
+ }
+ }
+ drv->dskchange_time = dsktime;
}
-void DISK_reinsert (int num)
+void DISK_reinsert(int num)
{
- drive_eject (&floppy[num]);
- setdskchangetime (&floppy[num], 2 * 50 * 312);
+ drive_eject(&floppy[num]);
+ setdskchangetime(&floppy[num], 2 * 50 * 312);
}
-int disk_setwriteprotect (struct uae_prefs *p, int num, const TCHAR *name, bool writeprotected)
+int disk_setwriteprotect(struct uae_prefs* p, int num, const TCHAR* name, bool writeprotected)
{
- int needwritefile, oldprotect;
- struct zfile *zf1, *zf2;
- bool wrprot1, wrprot2;
- int i;
- TCHAR *name2;
- drive_type drvtype;
+ int needwritefile, oldprotect;
+ struct zfile *zf1, *zf2;
+ bool wrprot1, wrprot2;
+ int i;
+ TCHAR* name2;
+ drive_type drvtype;
write_log(_T("disk_setwriteprotect %d '%s' %d\n"), num, name, writeprotected);
- oldprotect = diskfile_iswriteprotect (p, name, &needwritefile, &drvtype);
- DISK_validate_filename (p, name, 1, &wrprot1, NULL, &zf1);
- if (!zf1)
- return 0;
-
- write_log(_T("old = %d writeprot = %d master = %d\n"), oldprotect, wrprot1, p->floppy_read_only);
-
- if (wrprot1 && p->floppy_read_only)
+ oldprotect = diskfile_iswriteprotect(p, name, &needwritefile, &drvtype);
+ DISK_validate_filename(p, name, 1, &wrprot1, NULL, &zf1);
+ if (!zf1)
return 0;
- if (zfile_iscompressed (zf1))
- wrprot1 = 1;
- zfile_fclose (zf1);
- zf2 = getexistingwritefile(p, name, &wrprot2);
- name2 = DISK_get_saveimagepath(name, -2);
- if (needwritefile && zf2 == 0)
- disk_creatediskfile (p, name2, 1, drvtype, -1, NULL, false, false, NULL);
- zfile_fclose (zf2);
- if (writeprotected && iswritefileempty (p, name)) {
- for (i = 0; i < MAX_FLOPPY_DRIVES; i++) {
- if (!_tcscmp (name, floppy[i].newname))
- drive_eject (&floppy[i]);
- }
- _wunlink (name2);
- }
+ write_log(_T("old = %d writeprot = %d\n"), oldprotect, wrprot1);
- if (!needwritefile)
- diskfile_readonly (name, writeprotected);
- diskfile_readonly (name2, writeprotected);
- return 1;
+ //TODO: Enable when floppy_read_only is implemented in options
+ //if (wrprot1 && p->floppy_read_only)
+ // return 0;
+ if (zfile_iscompressed(zf1))
+ wrprot1 = true;
+ zfile_fclose(zf1);
+ zf2 = getwritefile(p, name, &wrprot2);
+ name2 = DISK_get_saveimagepath(name);
+
+ if (needwritefile && zf2 == 0)
+ disk_creatediskfile(name2, 1, drvtype, nullptr, false, false, nullptr);
+ zfile_fclose(zf2);
+ if (writeprotected && iswritefileempty(p, name))
+ {
+ for (i = 0; i < MAX_FLOPPY_DRIVES; i++)
+ {
+ if (!_tcscmp (name, floppy[i].newname))
+ drive_eject(&floppy[i]);
+ }
+ _wunlink (name2);
+ }
+
+ if (!needwritefile)
+ diskfile_readonly(name, writeprotected);
+ diskfile_readonly(name2, writeprotected);
+ DISK_reinsert(num);
+ return 1;
}
-void disk_eject (int num)
+void disk_eject(int num)
{
- set_config_changed ();
- gui_filename (num, _T(""));
- drive_eject (floppy + num);
- *currprefs.floppyslots[num].df = *changed_prefs.floppyslots[num].df = 0;
- floppy[num].newname[0] = 0;
- update_drive_gui (num, true);
+ set_config_changed();
+ gui_filename(num, _T(""));
+ drive_eject(floppy + num);
+ *currprefs.floppyslots[num].df = *changed_prefs.floppyslots[num].df = 0;
+ floppy[num].newname[0] = 0;
+ update_drive_gui(num, true);
}
-int DISK_history_add (const TCHAR *name, int idx, int type, int donotcheck)
+int DISK_history_add(const TCHAR* name, int idx, int type, int donotcheck)
{
- int i;
+ int i;
- if (idx >= MAX_PREVIOUS_IMAGES)
- return 0;
- if (name == NULL) {
- if (idx < 0)
+ if (idx >= MAX_PREVIOUS_FLOPPIES)
+ return 0;
+ if (name == nullptr)
+ {
+ dfxhistory[type][idx][0] = 0;
+ return 1;
+ }
+ if (name[0] == 0)
+ return 0;
+ if (!donotcheck)
+ {
+ if (!zfile_exists(name))
+ {
+ for (i = 0; i < MAX_PREVIOUS_FLOPPIES; i++)
+ {
+ if (!_tcsicmp (dfxhistory[type][i], name))
+ {
+ while (i < MAX_PREVIOUS_FLOPPIES - 1)
+ {
+ _tcscpy (dfxhistory[type][i], dfxhistory[type][i + 1]);
+ i++;
+ }
+ dfxhistory[type][MAX_PREVIOUS_FLOPPIES - 1][0] = 0;
+ break;
+ }
+ }
+ return 0;
+ }
+ }
+ if (idx >= 0)
+ {
+ if (idx >= MAX_PREVIOUS_FLOPPIES)
return 0;
dfxhistory[type][idx][0] = 0;
- return 1;
- }
- if (name[0] == 0)
- return 0;
- if (idx >= 0) {
- if (idx >= MAX_PREVIOUS_IMAGES)
- return 0;
- dfxhistory[type][idx][0] = 0;
- for (i = 0; i < MAX_PREVIOUS_IMAGES; i++) {
+ for (i = 0; i < MAX_PREVIOUS_FLOPPIES; i++)
+ {
if (!_tcsicmp (dfxhistory[type][i], name))
- return 0;
- }
+ return 0;
+ }
_tcscpy (dfxhistory[type][idx], name);
- return 1;
- }
- for (i = 0; i < MAX_PREVIOUS_IMAGES; i++) {
- if (!_tcscmp (dfxhistory[type][i], name)) {
- while (i < MAX_PREVIOUS_IMAGES - 1) {
+ return 1;
+ }
+ for (i = 0; i < MAX_PREVIOUS_FLOPPIES; i++)
+ {
+ if (!_tcscmp (dfxhistory[type][i], name))
+ {
+ while (i < MAX_PREVIOUS_FLOPPIES - 1)
+ {
_tcscpy (dfxhistory[type][i], dfxhistory[type][i + 1]);
- i++;
- }
- dfxhistory[type][MAX_PREVIOUS_IMAGES - 1][0] = 0;
- break;
- }
- }
- for (i = MAX_PREVIOUS_IMAGES - 2; i >= 0; i--)
- _tcscpy (dfxhistory[type][i + 1], dfxhistory[type][i]);
+ i++;
+ }
+ dfxhistory[type][MAX_PREVIOUS_FLOPPIES - 1][0] = 0;
+ break;
+ }
+ }
+ for (i = MAX_PREVIOUS_FLOPPIES - 2; i >= 0; i--)
+ _tcscpy (dfxhistory[type][i + 1], dfxhistory[type][i]);
_tcscpy (dfxhistory[type][0], name);
- return 1;
+ return 1;
}
-TCHAR *DISK_history_get (int idx, int type)
+TCHAR* DISK_history_get(int idx, int type)
{
- if (idx >= MAX_PREVIOUS_IMAGES)
+ if (idx >= MAX_PREVIOUS_FLOPPIES)
return NULL;
return dfxhistory[type][idx];
}
-static void disk_insert_2 (int num, const TCHAR *name, bool forced, bool forcedwriteprotect)
+static void disk_insert_2(int num, const TCHAR* name, bool forced, bool forcedwriteprotect)
{
- drive *drv = floppy + num;
+ drive* drv = floppy + num;
- if (forced) {
- drive_insert (drv, &currprefs, num, name, false, forcedwriteprotect);
- return;
- }
- if (!_tcscmp (currprefs.floppyslots[num].df, name))
- return;
- drv->dskeject = false;
- _tcscpy (drv->newname, name);
+ if (forced)
+ {
+ drive_insert(drv, &currprefs, num, name, false, forcedwriteprotect);
+ return;
+ }
+ if (!_tcscmp (currprefs.floppyslots[num].df, name))
+ return;
+ _tcscpy (drv->newname, name);
drv->newnamewriteprotected = forcedwriteprotect;
- _tcscpy (currprefs.floppyslots[num].df, name);
+ _tcscpy (currprefs.floppyslots[num].df, name);
currprefs.floppyslots[num].forcedwriteprotect = forcedwriteprotect;
- DISK_history_add (name, -1, HISTORY_FLOPPY, 0);
- if (name[0] == 0) {
- disk_eject (num);
- } else if (!drive_empty(drv) || drv->dskchange_time > 0) {
- // delay eject so that it is always called when emulation is active
- drv->dskeject = true;
- } else {
- setdskchangetime (drv, 1 * 312);
+ DISK_history_add(name, -1, HISTORY_FLOPPY, 0);
+ if (name[0] == 0)
+ {
+ disk_eject(num);
+ }
+ else if (!drive_empty(drv) || drv->dskchange_time > 0)
+ {
+ drive_eject(drv);
+ /* set dskchange_time, disk_insert() will be
+ * called from DISK_check_change() after 2 second delay
+ * this makes sure that all programs detect disk change correctly
+ */
+ setdskchangetime(drv, 2 * 50 * 312);
+ }
+ else
+ {
+ setdskchangetime(drv, 1 * 312);
}
}
-void disk_insert (int num, const TCHAR *name, bool forcedwriteprotect)
+void disk_insert(int num, const TCHAR* name, bool forcedwriteprotect)
{
- set_config_changed ();
- target_addtorecent (name, 0);
- disk_insert_2 (num, name, 0, forcedwriteprotect);
+ set_config_changed();
+ //target_addtorecent(name, 0);
+ disk_insert_2(num, name, false, forcedwriteprotect);
}
-void disk_insert (int num, const TCHAR *name)
+void disk_insert(int num, const TCHAR* name)
{
- set_config_changed ();
- target_addtorecent (name, 0);
- disk_insert_2 (num, name, 0, false);
-}
-void disk_insert_force (int num, const TCHAR *name, bool forcedwriteprotect)
-{
- disk_insert_2 (num, name, 1, forcedwriteprotect);
+ set_config_changed();
+ //target_addtorecent(name, 0);
+ disk_insert_2(num, name, false, false);
}
-static void DISK_check_change (void)
+void disk_insert_force(int num, const TCHAR* name, bool forcedwriteprotect)
{
- if (currprefs.floppy_speed != changed_prefs.floppy_speed)
- currprefs.floppy_speed = changed_prefs.floppy_speed;
- if (currprefs.floppy_read_only != changed_prefs.floppy_read_only)
- currprefs.floppy_read_only = changed_prefs.floppy_read_only;
- for (int i = 0; i < MAX_FLOPPY_DRIVES; i++) {
- drive *drv = floppy + i;
- if (drv->dskeject) {
- drive_eject(drv);
- /* set dskchange_time, disk_insert() will be
- * called from DISK_check_change() after 2 second delay
- * this makes sure that all programs detect disk change correctly
- */
- setdskchangetime(drv, 2 * 50 * 312);
+ disk_insert_2(num, name, true, forcedwriteprotect);
+}
+
+static void DISK_check_change()
+{
+ if (currprefs.floppy_speed != changed_prefs.floppy_speed)
+ currprefs.floppy_speed = changed_prefs.floppy_speed;
+ //TODO: enable when floppy_read_only
+ /*if (currprefs.floppy_read_only != changed_prefs.floppy_read_only)
+ currprefs.floppy_read_only = changed_prefs.floppy_read_only;*/
+ for (int i = 0; i < MAX_FLOPPY_DRIVES; i++)
+ {
+ drive* drv = floppy + i;
+ if (currprefs.floppyslots[i].dfxtype != changed_prefs.floppyslots[i].dfxtype)
+ {
+ currprefs.floppyslots[i].dfxtype = changed_prefs.floppyslots[i].dfxtype;
+ reset_drive(i);
+#ifdef RETROPLATFORM
+ rp_floppy_device_enable(i, currprefs.floppyslots[i].dfxtype >= 0);
+#endif
}
- if (currprefs.floppyslots[i].dfxtype != changed_prefs.floppyslots[i].dfxtype) {
- currprefs.floppyslots[i].dfxtype = changed_prefs.floppyslots[i].dfxtype;
- reset_drive (i);
- }
}
}
-void DISK_vsync (void)
+void DISK_vsync()
{
- DISK_check_change ();
- for (int i = 0; i < MAX_FLOPPY_DRIVES; i++) {
- drive *drv = floppy + i;
- if (drv->dskchange_time == 0 && _tcscmp (currprefs.floppyslots[i].df, changed_prefs.floppyslots[i].df))
- disk_insert (i, changed_prefs.floppyslots[i].df, changed_prefs.floppyslots[i].forcedwriteprotect);
- }
+ DISK_check_change();
+ for (int i = 0; i < MAX_FLOPPY_DRIVES; i++)
+ {
+ drive* drv = floppy + i;
+ if (drv->dskchange_time == 0 && _tcscmp (currprefs.floppyslots[i].df, changed_prefs.floppyslots[i].df))
+ disk_insert(i, changed_prefs.floppyslots[i].df, changed_prefs.floppyslots[i].forcedwriteprotect);
+ }
}
-int disk_empty (int num)
+int disk_empty(int num)
{
- return drive_empty (floppy + num);
+ return drive_empty(floppy + num);
}
-static TCHAR *tobin (uae_u8 v)
+static TCHAR* tobin(uae_u8 v)
{
static TCHAR buf[9];
for (int i = 7; i >= 0; i--)
@@ -2605,350 +2929,481 @@ static void fetch_DISK_select(uae_u8 data)
direction = (data >> 1) & 1;
}
-void DISK_select_set (uae_u8 data)
+void DISK_select_set(uae_u8 data)
{
prev_data = data;
prev_step = data & 1;
- fetch_DISK_select (data);
+ fetch_DISK_select(data);
}
-void DISK_select (uae_u8 data)
+void DISK_select(uae_u8 data)
{
- int step_pulse, prev_selected, dr;
+ int step_pulse, prev_selected, dr;
- prev_selected = selected;
+ prev_selected = selected;
- fetch_DISK_select (data);
- step_pulse = data & 1;
+ fetch_DISK_select(data);
+ step_pulse = data & 1;
- if ((prev_data & 0x80) != (data & 0x80)) {
- for (dr = 0; dr < 4; dr++) {
- if (floppy[dr].indexhackmode > 1 && !((selected | disabled) & (1 << dr))) {
- floppy[dr].indexhack = 1;
- }
- }
- }
+#ifdef AMAX
+ if (currprefs.amaxromfile[0])
+ amax_disk_select(data, prev_data);
+#endif
+
+ if ((prev_data & 0x80) != (data & 0x80))
+ {
+ for (dr = 0; dr < 4; dr++)
+ {
+ if (floppy[dr].indexhackmode > 1 && !(selected & (1 << dr)))
+ {
+ floppy[dr].indexhack = 1;
+ }
+ }
+ }
// step goes high and drive was selected when step pulse changes: step
- if (prev_step != step_pulse) {
- prev_step = step_pulse;
- if (prev_step && !savestate_state) {
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- if (!((prev_selected | disabled) & (1 << dr))) {
- drive_step (floppy + dr, direction);
- if (floppy[dr].indexhackmode > 1 && (data & 0x80))
- floppy[dr].indexhack = 1;
- }
- }
- }
- }
+ if (prev_step != step_pulse)
+ {
+ prev_step = step_pulse;
+ if (prev_step && !savestate_state)
+ {
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ if (!((prev_selected | disabled) & (1 << dr)))
+ {
+ drive_step(floppy + dr, direction);
+ if (floppy[dr].indexhackmode > 1 && (data & 0x80))
+ floppy[dr].indexhack = 1;
+ }
+ }
+ }
+ }
- if (!savestate_state) {
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- drive *drv = floppy + dr;
- /* motor on/off workings tested with small assembler code on real Amiga 1200. */
- /* motor/id flipflop is set only when drive select goes from high to low */
- if (!((selected | disabled) & (1 << dr)) && (prev_selected & (1 << dr)) ) {
- drv->drive_id_scnt++;
- drv->drive_id_scnt &= 31;
- drv->idbit = (drv->drive_id & (1L << (31 - drv->drive_id_scnt))) ? 1 : 0;
- if (!(disabled & (1 << dr))) {
- if ((prev_data & 0x80) == 0 || (data & 0x80) == 0) {
- /* motor off: if motor bit = 0 in prevdata or data -> turn motor on */
- drive_motor (drv, 0);
- } else if (prev_data & 0x80) {
- /* motor on: if motor bit = 1 in prevdata only (motor flag state in data has no effect)
- -> turn motor off */
- drive_motor (drv, 1);
- }
- }
- if (!currprefs.cs_df0idhw && dr == 0)
- drv->idbit = 0;
- }
- }
- }
+ if (!savestate_state)
+ {
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = floppy + dr;
+ /* motor on/off workings tested with small assembler code on real Amiga 1200. */
+ /* motor/id flipflop is set only when drive select goes from high to low */
+ if (!(selected & (1 << dr)) && (prev_selected & (1 << dr)))
+ {
+ drv->drive_id_scnt++;
+ drv->drive_id_scnt &= 31;
+ drv->idbit = (drv->drive_id & (1L << (31 - drv->drive_id_scnt))) ? 1 : 0;
+ if (!(disabled & (1 << dr)))
+ {
+ if ((prev_data & 0x80) == 0 || (data & 0x80) == 0)
+ {
+ /* motor off: if motor bit = 0 in prevdata or data -> turn motor on */
+ drive_motor(drv, false);
+ }
+ else if (prev_data & 0x80)
+ {
+ /* motor on: if motor bit = 1 in prevdata only (motor flag state in data has no effect)
+ -> turn motor off */
+ drive_motor(drv, 1);
+ }
+ }
+ //TODO: uncomment when cs_df0idhw is added in options
+ if (/*!currprefs.cs_df0idhw &&*/ dr == 0)
+ drv->idbit = 0;
+ }
+ }
+ }
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- floppy[dr].state = (!(selected & (1 << dr))) | !floppy[dr].motoroff;
- update_drive_gui (dr, false);
- }
- prev_data = data;
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ floppy[dr].state = (!(selected & (1 << dr))) | !floppy[dr].motoroff;
+ update_drive_gui(dr, false);
+ }
+ prev_data = data;
}
-uae_u8 DISK_status_ciaa(void)
+uae_u8 DISK_status()
{
- uae_u8 st = 0x3c;
+ uae_u8 st = 0x3c;
+ int dr;
- for (int dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- drive *drv = floppy + dr;
- if (!((selected | disabled) & (1 << dr))) {
- if (drive_running (drv)) {
- if (drv->dskready && !drv->indexhack && currprefs.floppyslots[dr].dfxtype != DRV_35_DD_ESCOM)
- st &= ~0x20;
- } else {
- if (currprefs.cs_df0idhw || dr > 0) {
- /* report drive ID */
- if (drv->idbit && currprefs.floppyslots[dr].dfxtype != DRV_35_DD_ESCOM)
- st &= ~0x20;
- } else {
- /* non-ID internal drive: mirror real dskready */
- if (drv->dskready)
- st &= ~0x20;
- }
- /* dskrdy needs some cycles after switching the motor off.. (Pro Tennis Tour) */
- if (!currprefs.cs_df0idhw && dr == 0 && drv->motordelay)
- st &= ~0x20;
- }
- if (drive_track0 (drv))
- st &= ~0x10;
- if (drive_writeprotected (drv))
- st &= ~8;
- if (drv->dskchange && currprefs.floppyslots[dr].dfxtype != DRV_525_SD) {
- st &= ~4;
- }
- } else if (!((selected | disabled) & (1 << dr))) {
- if (drv->idbit)
- st &= ~0x20;
- }
- }
-
- return st;
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = floppy + dr;
+ if (drv->amax) {
+ //TODO: enable when amax is implemented
+ //st = amax_disk_status();
+ }
+ else if (!((selected | disabled) & (1 << dr)))
+ {
+ if (drive_running(drv))
+ {
+ if (drv->catweasel) {
+#ifdef CATWEASEL
+ if (catweasel_diskready(drv->catweasel))
+ st &= ~0x20;
+#endif
+ }
+ else
+ {
+ if (drv->dskready && !drv->indexhack && currprefs.floppyslots[dr].dfxtype != DRV_35_DD_ESCOM)
+ st &= ~0x20;
+ }
+ }
+ else
+ {
+ if (/*currprefs.cs_df0idhw ||*/ dr > 0)
+ {
+ /* report drive ID */
+ if (drv->idbit && currprefs.floppyslots[dr].dfxtype != DRV_35_DD_ESCOM)
+ st &= ~0x20;
+ }
+ else
+ {
+ /* non-ID internal drive: mirror real dskready */
+ if (drv->dskready)
+ st &= ~0x20;
+ }
+ /* dskrdy needs some cycles after switching the motor off.. (Pro Tennis Tour) */
+ if (/*!currprefs.cs_df0idhw &&*/ dr == 0 && drv->motordelay)
+ st &= ~0x20;
+ }
+ if (drive_track0(drv))
+ st &= ~0x10;
+ if (drive_writeprotected(drv))
+ st &= ~8;
+ if (drv->catweasel) {
+#ifdef CATWEASEL
+ if (catweasel_disk_changed(drv->catweasel))
+ st &= ~4;
+#endif
+ }
+ else if (drv->dskchange && currprefs.floppyslots[dr].dfxtype != DRV_525_SD)
+ {
+ st &= ~4;
+ }
+ }
+ else if (!(selected & (1 << dr)))
+ {
+ if (drv->idbit)
+ st &= ~0x20;
+ }
+ }
+ return st;
}
-static bool unformatted (drive *drv)
+static bool unformatted(drive* drv)
{
- int tr = drv->cyl * 2 + side;
- if (tr >= drv->num_tracks)
- return true;
- if (drv->filetype == ADF_EXT2 && drv->trackdata[tr].bitlen == 0 && drv->trackdata[tr].type != TRACK_AMIGADOS)
- return true;
+ int tr = drv->cyl * 2 + side;
+ if (tr >= drv->num_tracks)
+ return true;
+ if (drv->filetype == ADF_EXT2 && drv->trackdata[tr].bitlen == 0 && drv->trackdata[tr].type != TRACK_AMIGADOS)
+ return true;
if (drv->trackdata[tr].type == TRACK_NONE)
return true;
- return false;
+ return false;
}
/* get one bit from MFM bit stream */
-STATIC_INLINE uae_u32 getonebit (uae_u16 * mfmbuf, int mfmpos)
+STATIC_INLINE uae_u32 getonebit(uae_u16* mfmbuf, int mfmpos)
{
- uae_u16 *buf;
+ uae_u16* buf;
- buf = &mfmbuf[mfmpos >> 4];
- return (buf[0] & (1 << (15 - (mfmpos & 15)))) ? 1 : 0;
+ buf = &mfmbuf[mfmpos >> 4];
+ return (buf[0] & (1 << (15 - (mfmpos & 15)))) ? 1 : 0;
}
-static void disk_dmafinished (void)
+void dumpdisk()
{
- INTREQ (0x8000 | 0x0002);
- longwritemode = 0;
- dskdmaen = DSKDMA_OFF;
+ int i, j, k;
+ uae_u16 w;
+
+ for (i = 0; i < MAX_FLOPPY_DRIVES; i++) {
+ drive *drv = &floppy[i];
+ if (!(disabled & (1 << i))) {
+ console_out(_T("Drive %d: motor %s cylinder %2d sel %s %s mfmpos %d/%d\n"),
+ i, drv->motoroff ? _T("off") : _T(" on"), drv->cyl, (selected & (1 << i)) ? _T("no") : _T("yes"),
+ drive_writeprotected(drv) ? _T("ro") : _T("rw"), drv->mfmpos, drv->tracklen);
+ if (drv->motoroff == 0) {
+ w = word;
+ for (j = 0; j < 15; j++) {
+ console_out(_T("%04X "), w);
+ for (k = 0; k < 16; k++) {
+ w <<= 1;
+ w |= getonebit(drv->bigmfmbuf, drv->mfmpos + j * 16 + k);
+ }
+ }
+ console_out(_T("\n"));
+ }
+ }
+ }
+ console_out(_T("side %d dma %d off %d word %04X pt %08X len %04X bytr %04X adk %04X sync %04X\n"),
+ side, dskdmaen, bitoffset, word, dskpt, dsklen, dskbytr_val, adkcon, dsksync);
+}
+
+static void disk_dmafinished()
+{
+ INTREQ(0x8000 | 0x0002);
+ longwritemode = 0;
+ dskdmaen = DSKDMA_OFF;
dsklength = 0;
- dsklen = 0;
}
-static void fetchnextrevolution (drive *drv)
+static void fetchnextrevolution(drive* drv)
{
if (drv->revolution_check)
return;
- drv->trackspeed = get_floppy_speed2 (drv);
+ drv->trackspeed = get_floppy_speed2(drv);
drv->revolution_check = 2;
- if (!drv->multi_revolution)
- return;
+ if (!drv->multi_revolution)
+ return;
switch (drv->filetype)
{
- case ADF_FDI:
-#ifdef FDI2RAW
- fdi2raw_loadrevolution(drv->fdi, drv->bigmfmbuf, drv->tracktiming, drv->cyl * 2 + side, &drv->tracklen, 1);
+ case ADF_IPF:
+#ifdef CAPS
+ caps_loadrevolution(drv->bigmfmbuf, drv->tracktiming, drv - floppy, drv->cyl * 2 + side, &drv->tracklen, &drv->lastrev, drv->track_access_done);
#endif
- break;
+ break;
+ case ADF_SCP:
+#ifdef SCP
+ scp_loadrevolution(drv->bigmfmbuf, drv - floppy, drv->tracktiming, &drv->tracklen);
+#endif
+ break;
+ case ADF_FDI:
+#ifdef FDI2RAW
+ fdi2raw_loadrevolution(drv->fdi, drv->bigmfmbuf, drv->tracktiming, drv->cyl * 2 + side, &drv->tracklen, 1);
+#endif
+ break;
}
}
-static void do_disk_index (void)
+static void do_disk_index()
{
- if (!indexdecay) {
+ if (!indexdecay)
+ {
indexdecay = 2;
- cia_diskindex ();
+ cia_diskindex();
}
}
-void DISK_handler (uae_u32 data)
+void DISK_handler(uae_u32 data)
{
int flag = data & 255;
int disk_sync_cycle = data >> 8;
- int hpos = current_hpos ();
+ int hpos = current_hpos();
- event2_remevent(ev2_disk);
- DISK_update (disk_sync_cycle);
- if (!dskdmaen) {
- if (flag & (DISK_REVOLUTION << 0))
- fetchnextrevolution (&floppy[0]);
- if (flag & (DISK_REVOLUTION << 1))
- fetchnextrevolution (&floppy[1]);
- if (flag & (DISK_REVOLUTION << 2))
- fetchnextrevolution (&floppy[2]);
- if (flag & (DISK_REVOLUTION << 3))
- fetchnextrevolution (&floppy[3]);
+ event2_remevent(ev2_disk);
+ DISK_update(disk_sync_cycle);
+ if (!dskdmaen)
+ {
+ if (flag & (DISK_REVOLUTION << 0))
+ fetchnextrevolution(&floppy[0]);
+ if (flag & (DISK_REVOLUTION << 1))
+ fetchnextrevolution(&floppy[1]);
+ if (flag & (DISK_REVOLUTION << 2))
+ fetchnextrevolution(&floppy[2]);
+ if (flag & (DISK_REVOLUTION << 3))
+ fetchnextrevolution(&floppy[3]);
}
- if (flag & DISK_WORDSYNC)
- INTREQ (0x8000 | 0x1000);
+ if (flag & DISK_WORDSYNC)
+ INTREQ(0x8000 | 0x1000);
if (flag & DISK_INDEXSYNC)
- do_disk_index ();
+ do_disk_index();
}
-static void disk_doupdate_write (drive * drv, int floppybits)
+static void disk_doupdate_write(drive* drv, int floppybits)
{
- int dr;
- int drives[4];
-
- for (dr = 0; dr < MAX_FLOPPY_DRIVES ; dr++) {
- drive *drv2 = &floppy[dr];
- drives[dr] = 0;
- if (drv2->motoroff)
- continue;
- if ((selected | disabled) & (1 << dr))
- continue;
- drives[dr] = 1;
- }
+ int dr;
+ int drives[4];
- while (floppybits >= drv->trackspeed) {
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- if (drives[dr]) {
- floppy[dr].mfmpos++;
- floppy[dr].mfmpos %= drv->tracklen;
- }
- }
- if (dmaen (DMA_DISK) && dskdmaen == DSKDMA_WRITE && dsklength > 0 && fifo_filled) {
- bitoffset++;
- bitoffset &= 15;
- if (!bitoffset) {
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv2 = &floppy[dr];
+ drives[dr] = 0;
+ if (drv2->motoroff)
+ continue;
+ if (selected & (1 << dr))
+ continue;
+ drives[dr] = 1;
+ }
+
+ while (floppybits >= drv->trackspeed)
+ {
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ if (drives[dr])
+ {
+ floppy[dr].mfmpos++;
+ floppy[dr].mfmpos %= drv->tracklen;
+ }
+ }
+ if (dmaen(DMA_DISK) && dskdmaen == DSKDMA_WRITE && dsklength > 0 && fifo_filled)
+ {
+ bitoffset++;
+ bitoffset &= 15;
+ if (!bitoffset)
+ {
// fast disk modes, fill the fifo instantly
- if (currprefs.floppy_speed > 100 && !fifo_inuse[0] && !fifo_inuse[1] && !fifo_inuse[2]) {
- while (!fifo_inuse[2]) {
- uae_u16 w = chipmem_wget_indirect (dskpt);
- DSKDAT (w);
+ if (currprefs.floppy_speed > 100 && !fifo_inuse[0] && !fifo_inuse[1] && !fifo_inuse[2])
+ {
+ while (!fifo_inuse[2])
+ {
+ uae_u16 w = chipmem_wget_indirect(dskpt);
+ DSKDAT(w);
dskpt += 2;
}
}
- if (disk_fifostatus () >= 0) {
- uae_u16 w = DSKDATR ();
- for (dr = 0; dr < MAX_FLOPPY_DRIVES ; dr++) {
- drive *drv2 = &floppy[dr];
- if (drives[dr]) {
- drv2->bigmfmbuf[drv2->mfmpos >> 4] = w;
- drv2->bigmfmbuf[(drv2->mfmpos >> 4) + 1] = 0x5555;
- drv2->writtento = 1;
- }
- }
- dsklength--;
- if (dsklength <= 0) {
- disk_dmafinished ();
- for (int dr = 0; dr < MAX_FLOPPY_DRIVES ; dr++) {
- drive *drv = &floppy[dr];
- drv->writtento = 0;
- if (drv->motoroff)
- continue;
- if ((selected | disabled) & (1 << dr))
- continue;
- drive_write_data (drv);
- }
- }
- }
- }
- }
- floppybits -= drv->trackspeed;
- }
+ if (disk_fifostatus() >= 0)
+ {
+ uae_u16 w = DSKDATR();
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv2 = &floppy[dr];
+ if (drives[dr])
+ {
+ drv2->bigmfmbuf[drv2->mfmpos >> 4] = w;
+ drv2->bigmfmbuf[(drv2->mfmpos >> 4) + 1] = 0x5555;
+ drv2->writtento = 1;
+ }
+#ifdef AMAX
+ if (currprefs.amaxromfile[0])
+ amax_diskwrite(w);
+#endif
+ }
+ dsklength--;
+ if (dsklength <= 0)
+ {
+ disk_dmafinished();
+ for (int dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = &floppy[dr];
+ drv->writtento = 0;
+ if (drv->motoroff)
+ continue;
+ if (selected & (1 << dr))
+ continue;
+ drive_write_data(drv);
+ }
+ }
+ }
+ }
+ }
+ floppybits -= drv->trackspeed;
+ }
}
-static void update_jitter (void)
+static void update_jitter()
{
disk_jitter = ((uaerand () >> 4) % 3) + 1;
+ //TODO: enable the below when the relevant options are implemented
+ //if (currprefs.floppy_random_bits_max > 0)
+ // disk_jitter = ((uaerand() >> 4) % (currprefs.floppy_random_bits_max - currprefs.floppy_random_bits_min + 1)) + currprefs.floppy_random_bits_min;
+ //else
+ // disk_jitter = 0;
}
-static void updatetrackspeed (drive *drv, int mfmpos)
+static void updatetrackspeed(drive* drv, int mfmpos)
{
- if (dskdmaen < DSKDMA_WRITE) {
+ if (dskdmaen < DSKDMA_WRITE)
+ {
int t = drv->tracktiming[mfmpos / 8];
- int ts = get_floppy_speed2 (drv) * t / 1000;
- if (ts < 700 || ts > 3000) {
- } else {
+ int ts = get_floppy_speed2(drv) * t / 1000;
+ if (ts < 700 || ts > 3000)
+ {
+ static int warned;
+ warned++;
+ if (warned < 50)
+ write_log(_T("corrupted trackspeed value %d %d (%d/%d)\n"), t, ts, mfmpos, drv->tracklen);
+ }
+ else
+ {
drv->trackspeed = ts;
}
- }
+ }
}
-static void disk_doupdate_predict (int startcycle)
+static void disk_doupdate_predict(int startcycle)
{
int finaleventcycle = maxhpos << 8;
int finaleventflag = 0;
- for (int dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- drive *drv = &floppy[dr];
+ for (int dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = &floppy[dr];
if (drv->motoroff)
continue;
if (!drv->trackspeed)
continue;
- if ((selected | disabled) & (1 << dr))
+ if (selected & (1 << dr))
continue;
int mfmpos = drv->mfmpos;
if (drv->tracktiming[0])
- updatetrackspeed (drv, mfmpos);
+ updatetrackspeed(drv, mfmpos);
int diskevent_flag = 0;
- uae_u32 tword = word;
+ uae_u32 tword = word;
//int diff = drv->floppybitcounter % drv->trackspeed;
int countcycle = startcycle; // + (diff ? drv->trackspeed - diff : 0);
- while (countcycle < (maxhpos << 8)) {
- if (drv->tracktiming[0])
- updatetrackspeed (drv, mfmpos);
+ while (countcycle < (maxhpos << 8))
+ {
+ if (drv->tracktiming[0])
+ updatetrackspeed(drv, mfmpos);
countcycle += drv->trackspeed;
- if (dskdmaen != DSKDMA_WRITE || (dskdmaen == DSKDMA_WRITE && !dma_enable)) {
- tword <<= 1;
- if (!drive_empty (drv)) {
- if (unformatted (drv))
- tword |= (uaerand() & 0x1000) ? 1 : 0;
- else
- tword |= getonebit (drv->bigmfmbuf, mfmpos);
- }
+ if (dskdmaen != DSKDMA_WRITE || (dskdmaen == DSKDMA_WRITE && !dma_enable))
+ {
+ tword <<= 1;
+ if (!drive_empty(drv))
+ {
+ if (unformatted(drv))
+ tword |= (uaerand() & 0x1000) ? 1 : 0;
+ else
+ tword |= getonebit(drv->bigmfmbuf, mfmpos);
+ }
if (dskdmaen != DSKDMA_READ && (tword & 0xffff) == dsksync && dsksync != 0)
- diskevent_flag |= DISK_WORDSYNC;
- }
- mfmpos++;
- mfmpos %= drv->tracklen;
- if (!dskdmaen) {
- if (mfmpos == 0)
- diskevent_flag |= DISK_REVOLUTION << (drv - floppy);
- if (mfmpos == drv->indexoffset)
- diskevent_flag |= DISK_INDEXSYNC;
+ diskevent_flag |= DISK_WORDSYNC;
}
- if (dskdmaen != DSKDMA_WRITE && mfmpos == drv->skipoffset) {
- int skipcnt = disk_jitter;
- while (skipcnt-- > 0) {
- mfmpos++;
- mfmpos %= drv->tracklen;
- if (!dskdmaen) {
- if (mfmpos == 0)
- diskevent_flag |= DISK_REVOLUTION << (drv - floppy);
- if (mfmpos == drv->indexoffset)
- diskevent_flag |= DISK_INDEXSYNC;
- }
- }
+ mfmpos++;
+ mfmpos %= drv->tracklen;
+ if (!dskdmaen)
+ {
+ if (mfmpos == 0)
+ diskevent_flag |= DISK_REVOLUTION << (drv - floppy);
+ if (mfmpos == drv->indexoffset)
+ diskevent_flag |= DISK_INDEXSYNC;
+ }
+ if (dskdmaen != DSKDMA_WRITE && mfmpos == drv->skipoffset)
+ {
+ update_jitter();
+ int skipcnt = disk_jitter;
+ while (skipcnt-- > 0)
+ {
+ mfmpos++;
+ mfmpos %= drv->tracklen;
+ if (!dskdmaen)
+ {
+ if (mfmpos == 0)
+ diskevent_flag |= DISK_REVOLUTION << (drv - floppy);
+ if (mfmpos == drv->indexoffset)
+ diskevent_flag |= DISK_INDEXSYNC;
+ }
+ }
}
if (diskevent_flag)
break;
- }
- if (drv->tracktiming[0])
- updatetrackspeed (drv, drv->mfmpos);
- if (diskevent_flag && countcycle < finaleventcycle) {
+ }
+ if (drv->tracktiming[0])
+ updatetrackspeed(drv, drv->mfmpos);
+ if (diskevent_flag && countcycle < finaleventcycle)
+ {
finaleventcycle = countcycle;
finaleventflag = diskevent_flag;
}
}
- if (finaleventflag && (finaleventcycle >> 8) < maxhpos) {
- event2_newevent (ev2_disk, (finaleventcycle - startcycle) >> 8, ((finaleventcycle >> 8) << 8) | finaleventflag);
- }
+ if (finaleventflag && (finaleventcycle >> 8) < maxhpos)
+ {
+ event2_newevent(ev2_disk, (finaleventcycle - startcycle) >> 8, ((finaleventcycle >> 8) << 8) | finaleventflag);
+ }
}
-int disk_fifostatus (void)
+int disk_fifostatus()
{
if (fifo_inuse[0] && fifo_inuse[1] && fifo_inuse[2])
return 1;
@@ -2957,527 +3412,559 @@ int disk_fifostatus (void)
return 0;
}
-static int doreaddma (void)
+static int doreaddma()
{
- if (dmaen (DMA_DISK) && bitoffset == 15 && dma_enable && dskdmaen == DSKDMA_READ && dsklength >= 0) {
- if (dsklength > 0) {
+ if (dmaen(DMA_DISK) && bitoffset == 15 && dma_enable && dskdmaen == DSKDMA_READ && dsklength >= 0)
+ {
+ if (dsklength > 0)
+ {
// DSKLEN == 1: finish without DMA transfer.
- if (dsklength == 1 && dsklength2 == 1) {
- disk_dmafinished ();
+ if (dsklength == 1 && dsklength2 == 1)
+ {
+ disk_dmafinished();
return 0;
}
// fast disk modes, just flush the fifo
- if (currprefs.floppy_speed > 100 && fifo_inuse[0] && fifo_inuse[1] && fifo_inuse[2]) {
- while (fifo_inuse[0]) {
- uae_u16 w = DSKDATR ();
- chipmem_wput_indirect (dskpt, w);
+ if (currprefs.floppy_speed > 100 && fifo_inuse[0] && fifo_inuse[1] && fifo_inuse[2])
+ {
+ while (fifo_inuse[0])
+ {
+ uae_u16 w = DSKDATR();
+ chipmem_wput_indirect(dskpt, w);
dskpt += 2;
}
}
- if (disk_fifostatus () > 0) {
+ if (disk_fifostatus() > 0)
+ {
write_log (_T("doreaddma() fifo overflow detected, retrying..\n"));
return -1;
- } else {
- DSKDAT (word);
- dsklength--;
- }
- }
+ }
+ else
+ {
+ DSKDAT(word);
+ dsklength--;
+ }
+ }
return 1;
}
return 0;
}
-static void disk_doupdate_read_nothing (int floppybits)
+static void disk_doupdate_read_nothing(int floppybits)
{
- while (floppybits >= get_floppy_speed()) {
- word <<= 1;
- doreaddma ();
- if ((bitoffset & 7) == 7) {
- dskbytr_val = word & 0xff;
- dskbytr_val |= 0x8000;
- }
- bitoffset++;
- bitoffset &= 15;
- floppybits -= get_floppy_speed();
- }
-}
+ int j = 0, k = 1, l = 0;
-static void wordsync_detected(bool startup)
-{
- dsksync_cycles = get_cycles () + WORDSYNC_TIME * CYCLE_UNIT;
- if (dskdmaen != DSKDMA_OFF) {
- if (!startup)
- dma_enable = 1;
- INTREQ (0x8000 | 0x1000);
- }
- if (adkcon & 0x0400) {
- bitoffset = 15;
+ while (floppybits >= get_floppy_speed())
+ {
+ word <<= 1;
+ doreaddma();
+ if ((bitoffset & 7) == 7)
+ {
+ dskbytr_val = word & 0xff;
+ dskbytr_val |= 0x8000;
+ }
+ bitoffset++;
+ bitoffset &= 15;
+ floppybits -= get_floppy_speed();
}
}
-static void disk_doupdate_read (drive * drv, int floppybits)
+static void disk_doupdate_read(drive* drv, int floppybits)
{
- /*
- uae_u16 *mfmbuf = drv->bigmfmbuf;
- dsksync = 0x4444;
- adkcon |= 0x400;
- drv->mfmpos = 0;
- memset (mfmbuf, 0, 1000);
- cycles = 0x1000000;
- // 4444 4444 4444 aaaa aaaaa 4444 4444 4444
- // 4444 aaaa aaaa 4444
- mfmbuf[0] = 0x4444;
- mfmbuf[1] = 0x4444;
- mfmbuf[2] = 0x4444;
- mfmbuf[3] = 0xaaaa;
- mfmbuf[4] = 0xaaaa;
- mfmbuf[5] = 0x4444;
- mfmbuf[6] = 0x4444;
- mfmbuf[7] = 0x4444;
- */
- while (floppybits >= drv->trackspeed) {
- if (drv->tracktiming[0])
- updatetrackspeed (drv, drv->mfmpos);
- word <<= 1;
+ int j = 0, k = 1, l = 0;
- if (!drive_empty (drv)) {
- if (unformatted (drv))
- word |= (uaerand() & 0x1000) ? 1 : 0;
- else
- word |= getonebit (drv->bigmfmbuf, drv->mfmpos);
- }
- if (doreaddma () < 0) {
+ while (floppybits >= drv->trackspeed)
+ {
+ if (drv->tracktiming[0])
+ updatetrackspeed(drv, drv->mfmpos);
+ word <<= 1;
+ if (!drive_empty(drv))
+ {
+ if (unformatted(drv))
+ word |= (uaerand() & 0x1000) ? 1 : 0;
+ else
+ word |= getonebit(drv->bigmfmbuf, drv->mfmpos);
+ }
+ if (doreaddma() < 0)
+ {
word >>= 1;
return;
}
- drv->mfmpos++;
- drv->mfmpos %= drv->tracklen;
- if (drv->mfmpos == drv->indexoffset) {
- drv->indexhack = 0;
- do_disk_index ();
- }
- if (drv->mfmpos == 0) {
- fetchnextrevolution (drv);
- if (drv->tracktiming[0])
- updatetrackspeed (drv, drv->mfmpos);
+ drv->mfmpos++;
+ drv->mfmpos %= drv->tracklen;
+ if (drv->mfmpos == drv->indexoffset)
+ {
+ drv->indexhack = 0;
+ do_disk_index();
}
- if (drv->mfmpos == drv->skipoffset) {
+ if (drv->mfmpos == 0)
+ {
+ fetchnextrevolution(drv);
+ if (drv->tracktiming[0])
+ updatetrackspeed(drv, drv->mfmpos);
+ }
+ if (drv->mfmpos == drv->skipoffset)
+ {
+ update_jitter();
int skipcnt = disk_jitter;
- while (skipcnt-- > 0) {
+ while (skipcnt-- > 0)
+ {
drv->mfmpos++;
- drv->mfmpos %= drv->tracklen;
- if (drv->mfmpos == drv->indexoffset) {
+ drv->mfmpos %= drv->tracklen;
+ if (drv->mfmpos == drv->indexoffset)
+ {
drv->indexhack = 0;
- do_disk_index ();
- }
- if (drv->mfmpos == 0) {
- fetchnextrevolution (drv);
+ do_disk_index();
+ }
+ if (drv->mfmpos == 0)
+ {
+ fetchnextrevolution(drv);
if (drv->tracktiming[0])
- updatetrackspeed (drv, drv->mfmpos);
+ updatetrackspeed(drv, drv->mfmpos);
}
}
- }
- if ((bitoffset & 7) == 7) {
- dskbytr_val = word & 0xff;
- dskbytr_val |= 0x8000;
- }
+ }
+ if ((bitoffset & 7) == 7)
+ {
+ dskbytr_val = word & 0xff;
+ dskbytr_val |= 0x8000;
+ }
if (word == dsksync)
- wordsync_detected(false);
- bitoffset++;
- bitoffset &= 15;
- floppybits -= drv->trackspeed;
- }
+ {
+ dsksync_cycles = get_cycles() + WORDSYNC_TIME * CYCLE_UNIT;
+ if (dskdmaen != DSKDMA_OFF)
+ {
+ dma_enable = 1;
+ INTREQ(0x8000 | 0x1000);
+ }
+ if (adkcon & 0x400)
+ {
+ bitoffset = 15;
+ }
+ }
+ bitoffset++;
+ bitoffset &= 15;
+ floppybits -= drv->trackspeed;
+ }
+}
+
+static void disk_dma_debugmsg(void)
+{
+ write_log(_T("LEN=%04X (%d) SYNC=%04X PT=%08X ADKCON=%04X INTREQ=%04X PC=%08X\n"),
+ dsklength, dsklength, (adkcon & 0x400) ? dsksync : 0xffff, dskpt, adkcon, intreq, M68K_GETPC);
}
/* this is very unoptimized. DSKBYTR is used very rarely, so it should not matter. */
-uae_u16 DSKBYTR (int hpos)
+uae_u16 DSKBYTR(int hpos)
{
- uae_u16 v;
+ uae_u16 v;
+
+ DISK_update(hpos);
+ v = dskbytr_val;
+ dskbytr_val &= ~0x8000;
+ if (word == dsksync && cycles_in_range(dsksync_cycles))
+ v |= 0x1000;
+ if (dskdmaen != DSKDMA_OFF && dmaen(DMA_DISK))
+ v |= 0x4000;
+ if (dsklen & 0x4000)
+ v |= 0x2000;
- DISK_update (hpos);
- v = dskbytr_val;
- dskbytr_val &= ~0x8000;
- if (word == dsksync && cycles_in_range (dsksync_cycles)) {
- v |= 0x1000;
- }
- if (dskdmaen != DSKDMA_OFF && dmaen (DMA_DISK))
- v |= 0x4000;
- if (dsklen & 0x4000)
- v |= 0x2000;
for (int dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
drive *drv = &floppy[dr];
if (drv->motoroff)
continue;
+ if (!(selected & (1 << dr))) {
+ drv->lastdataacesstrack = drv->cyl * 2 + side;
+ drv->track_access_done = true;
+ }
}
- return v;
+ return v;
}
-static void DISK_start (void)
+static void DISK_start()
{
- int dr;
+ int dr;
for (int i = 0; i < 3; i++)
fifo_inuse[i] = false;
- fifo_filled = 0;
+ fifo_filled = false;
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = &floppy[dr];
+ if (!(selected & (1 << dr)))
+ {
+ int tr = drv->cyl * 2 + side;
+ trackid* ti = drv->trackdata + tr;
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- drive *drv = &floppy[dr];
- if (!((selected | disabled) & (1 << dr))) {
- int tr = drv->cyl * 2 + side;
- trackid *ti = drv->trackdata + tr;
-
- if (dskdmaen == DSKDMA_WRITE) {
- word = 0;
- drv->tracklen = longwritemode ? FLOPPY_WRITE_MAXLEN : FLOPPY_WRITE_LEN * drv->ddhd * 8 * 2;
- drv->trackspeed = get_floppy_speed();
- drv->skipoffset = -1;
- updatemfmpos (drv);
- }
- /* Ugh. A nasty hack. Assume ADF_EXT1 tracks are always read
- from the start. */
- if (ti->type == TRACK_RAW1) {
- drv->mfmpos = 0;
- bitoffset = 0;
- word = 0;
+ if (dskdmaen == DSKDMA_WRITE)
+ {
+ drv->tracklen = longwritemode ? FLOPPY_WRITE_MAXLEN : FLOPPY_WRITE_LEN * drv->ddhd * 8 * 2;
+ drv->trackspeed = get_floppy_speed();
+ drv->skipoffset = -1;
+ updatemfmpos(drv);
}
- }
- drv->floppybitcounter = 0;
- }
-
+ /* Ugh. A nasty hack. Assume ADF_EXT1 tracks are always read
+ from the start. */
+ if (ti->type == TRACK_RAW1)
+ {
+ drv->mfmpos = 0;
+ bitoffset = 0;
+ }
+ if (drv->catweasel)
+ drive_fill_bigbuf(drv, 1);
+ }
+ drv->floppybitcounter = 0;
+ }
dma_enable = (adkcon & 0x400) ? 0 : 1;
- if (word == dsksync)
- wordsync_detected(true);
}
static int linecounter;
-void DISK_hsync (void)
+void DISK_hsync()
{
- int dr;
+ int dr;
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- drive *drv = &floppy[dr];
- if (drv->steplimit)
- drv->steplimit--;
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = &floppy[dr];
+ if (drv->steplimit)
+ drv->steplimit--;
if (drv->revolution_check)
drv->revolution_check--;
if (drv->dskready_down_time > 0)
drv->dskready_down_time--;
/* emulate drive motor turn on time */
- if (drv->dskready_up_time > 0 && !drive_empty (drv)) {
+ if (drv->dskready_up_time > 0 && !drive_empty(drv))
+ {
drv->dskready_up_time--;
if (drv->dskready_up_time == 0 && !drv->motoroff)
drv->dskready = true;
}
/* delay until new disk image is inserted */
- if (drv->dskchange_time > 0) {
+ if (drv->dskchange_time > 0)
+ {
drv->dskchange_time--;
- if (drv->dskchange_time == 0) {
- drive_insert (drv, &currprefs, dr, drv->newname, false, drv->newnamewriteprotected);
- update_drive_gui (dr, false);
+ if (drv->dskchange_time == 0)
+ {
+ drive_insert(drv, &currprefs, dr, drv->newname, false, drv->newnamewriteprotected);
+ update_drive_gui(dr, false);
}
}
- }
+ }
if (indexdecay)
indexdecay--;
- if (linecounter) {
- linecounter--;
- if (! linecounter)
- disk_dmafinished ();
- return;
- }
- DISK_update (maxhpos);
+ if (linecounter)
+ {
+ linecounter--;
+ if (! linecounter)
+ disk_dmafinished();
+ return;
+ }
+ DISK_update(maxhpos);
}
-void DISK_update (int tohpos)
+void DISK_update(int tohpos)
{
- int dr;
+ int dr;
int cycles;
+ int startcycle = disk_hpos;
- if (disk_hpos < 0) {
+ if (disk_hpos < 0)
+ {
disk_hpos = - disk_hpos;
return;
}
cycles = (tohpos << 8) - disk_hpos;
- if (cycles <= 0)
- return;
- disk_hpos += cycles;
- if (disk_hpos >= (maxhpos << 8))
+ if (cycles <= 0)
+ return;
+ disk_hpos += cycles;
+ if (disk_hpos >= (maxhpos << 8))
disk_hpos %= 1 << 8;
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- drive *drv = &floppy[dr];
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = &floppy[dr];
- if (drv->motoroff || !drv->tracklen || !drv->trackspeed)
- continue;
- drv->floppybitcounter += cycles;
- if ((selected | disabled) & (1 << dr)) {
- drv->mfmpos += drv->floppybitcounter / drv->trackspeed;
- drv->mfmpos %= drv->tracklen;
- drv->floppybitcounter %= drv->trackspeed;
- continue;
- }
- if (drv->diskfile)
- drive_fill_bigbuf (drv, 0);
- drv->mfmpos %= drv->tracklen;
- }
- int didaccess = 0;
- bool done_jitter = false;
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- drive *drv = &floppy[dr];
- if (drv->motoroff || !drv->trackspeed)
- continue;
- if ((selected | disabled) & (1 << dr))
- continue;
- if (!done_jitter) {
- update_jitter();
- done_jitter = true;
+ if (drv->motoroff || !drv->tracklen || !drv->trackspeed)
+ continue;
+ drv->floppybitcounter += cycles;
+ if (selected & (1 << dr))
+ {
+ drv->mfmpos += drv->floppybitcounter / drv->trackspeed;
+ drv->mfmpos %= drv->tracklen;
+ drv->floppybitcounter %= drv->trackspeed;
+ continue;
}
+ if (drv->diskfile)
+ drive_fill_bigbuf(drv, 0);
+ drv->mfmpos %= drv->tracklen;
+ }
+ int didaccess = 0;
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = &floppy[dr];
+ if (drv->motoroff || !drv->trackspeed)
+ continue;
+ if (selected & (1 << dr))
+ continue;
/* write dma and wordsync enabled: read until wordsync match found */
if (dskdmaen == DSKDMA_WRITE && dma_enable)
- disk_doupdate_write (drv, drv->floppybitcounter);
- else
- disk_doupdate_read (drv, drv->floppybitcounter);
-
- drv->floppybitcounter %= drv->trackspeed;
+ disk_doupdate_write(drv, drv->floppybitcounter);
+ else
+ disk_doupdate_read(drv, drv->floppybitcounter);
+ drv->floppybitcounter %= drv->trackspeed;
didaccess = 1;
- }
- /* no floppy selected but read dma */
- if (!didaccess && dskdmaen == DSKDMA_READ) {
- disk_doupdate_read_nothing (cycles);
- }
+ }
+ /* no floppy selected but read dma */
+ if (!didaccess && dskdmaen == DSKDMA_READ)
+ {
+ disk_doupdate_read_nothing(cycles);
+ }
/* instantly finish dma if dsklen==0 and wordsync detected */
if (dskdmaen != DSKDMA_OFF && dma_enable && dsklength2 == 0 && dsklength == 0)
- disk_dmafinished ();
+ disk_dmafinished();
- if (!done_jitter) {
- update_jitter();
- done_jitter = true;
- }
- disk_doupdate_predict (disk_hpos);
+ disk_doupdate_predict(disk_hpos);
}
-void DSKLEN (uae_u16 v, int hpos)
+void DSKLEN(uae_u16 v, int hpos)
{
- int dr, prev = dsklen;
- int noselected = 0;
- int motormask;
+ int dr, prev = dsklen;
+ int noselected = 0;
+ int motormask;
- DISK_update (hpos);
+ DISK_update(hpos);
+ if ((v & 0x8000) && (dsklen & 0x8000))
+ {
+ dskdmaen = DSKDMA_READ;
+ DISK_start();
+ }
+ if (!(v & 0x8000))
+ {
+ if (dskdmaen != DSKDMA_OFF)
+ {
+ /* Megalomania and Knightmare does this */
+ if (dskdmaen == DSKDMA_WRITE)
+ {
+ write_log (_T("warning: Disk write DMA aborted, %d words left PC=%x\n"), dsklength, M68K_GETPC);
+ // did program write something that needs to be stored to file?
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv2 = &floppy[dr];
+ if (!drv2->writtento)
+ continue;
+ drive_write_data(drv2);
+ }
+ }
+ dskdmaen = DSKDMA_OFF;
+ }
+ }
dsklen = v;
dsklength2 = dsklength = dsklen & 0x3fff;
- if ((v & 0x8000) && (prev & 0x8000)) {
- if (dskdmaen == DSKDMA_READ) {
- // update only currently active DMA length, don't change DMA state
- write_log(_T("warning: Disk read DMA length rewrite %d -> %d. (%04x) PC=%08x\n"), prev & 0x3fff, v & 0x3fff, v, M68K_GETPC);
- return;
- }
- dskdmaen = DSKDMA_READ;
- DISK_start ();
- }
- if (!(v & 0x8000)) {
- if (dskdmaen != DSKDMA_OFF) {
- /* Megalomania and Knightmare does this */
- if (dskdmaen == DSKDMA_WRITE) {
- write_log (_T("warning: Disk write DMA aborted, %d words left PC=%x\n"), dsklength, M68K_GETPC);
- // did program write something that needs to be stored to file?
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- drive *drv2 = &floppy[dr];
- if (!drv2->writtento)
- continue;
- drive_write_data (drv2);
- }
- }
- dskdmaen = DSKDMA_OFF;
- }
- }
-
if (dskdmaen == DSKDMA_OFF)
- return;
+ return;
- if (dsklength == 0 && dma_enable) {
- disk_dmafinished ();
- return;
- }
+ if (dsklength == 0 && dma_enable)
+ {
+ disk_dmafinished();
+ return;
+ }
- if ((v & 0x4000) && (prev & 0x4000)) {
- if (dsklength == 0)
- return;
- if (dsklength == 1) {
- disk_dmafinished();
- return;
- }
- if (dskdmaen == DSKDMA_WRITE) {
- write_log(_T("warning: Disk write DMA length rewrite %d -> %d\n"), prev & 0x3fff, v & 0x3fff);
+ if ((v & 0x4000) && (prev & 0x4000))
+ {
+ if (dsklength == 0)
+ return;
+ if (dsklength == 1)
+ {
+ disk_dmafinished();
return;
}
dskdmaen = DSKDMA_WRITE;
- DISK_start ();
- }
+ DISK_start();
+ }
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- drive *drv = &floppy[dr];
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = &floppy[dr];
if (drv->motoroff)
continue;
if (selected & (1 << dr))
continue;
+ if (dskdmaen == DSKDMA_READ)
+ {
+ drv->lastdataacesstrack = drv->cyl * 2 + side;
+ drv->track_access_done = true;
+ }
}
- motormask = 0;
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- drive *drv = &floppy[dr];
- drv->writtento = 0;
- if (drv->motoroff)
- continue;
- motormask |= 1 << dr;
- if ((selected & (1 << dr)) == 0)
- break;
- }
- if (dr == 4) {
- noselected = 1;
- }
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
- update_drive_gui (dr, false);
+ motormask = 0;
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = &floppy[dr];
+ drv->writtento = 0;
+ if (drv->motoroff)
+ continue;
+ motormask |= 1 << dr;
+ if ((selected & (1 << dr)) == 0)
+ break;
+ }
+ if (dr == 4)
+ {
+ write_log (_T("disk %s DMA started, drvmask=%x motormask=%x PC=%08x\n"),
+ dskdmaen == DSKDMA_WRITE ? _T("write") : _T("read"), selected ^ 15, motormask, M68K_GETPC);
+ noselected = 1;
+ }
- /* Try to make floppy access from Kickstart faster. */
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ update_drive_gui(dr, false);
+
+ /* Try to make floppy access from Kickstart faster. */
if (dskdmaen != DSKDMA_READ && dskdmaen != DSKDMA_WRITE)
- return;
+ return;
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- drive *drv = &floppy[dr];
- if (selected & (1 << dr))
- continue;
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = &floppy[dr];
+ if (selected & (1 << dr))
+ continue;
if (drv->filetype != ADF_NORMAL && drv->filetype != ADF_KICK && drv->filetype != ADF_SKICK)
- break;
- }
- if (dr < MAX_FLOPPY_DRIVES) /* no turbo mode if any selected drive has non-standard ADF */
- return;
- {
- int done = 0;
- for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- drive *drv = &floppy[dr];
- bool floppysupported = (drv->ddhd < 2) || (drv->ddhd > 1 && currprefs.floppyslots[dr].dfxtype == DRV_35_HD);
- int pos, i;
+ break;
+ }
+ if (dr < MAX_FLOPPY_DRIVES) /* no turbo mode if any selected drive has non-standard ADF */
+ return;
+ {
+ int done = 0;
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = &floppy[dr];
+ int pos, i;
- if (drv->motoroff)
- continue;
- if (!drv->useturbo && currprefs.floppy_speed > 0)
- continue;
- if (selected & (1 << dr))
- continue;
+ if (drv->motoroff)
+ continue;
+ if (!drv->useturbo && currprefs.floppy_speed > 0)
+ continue;
+ if (selected & (1 << dr))
+ continue;
- pos = drv->mfmpos & ~15;
- drive_fill_bigbuf (drv, 0);
+ pos = drv->mfmpos & ~15;
+ drive_fill_bigbuf(drv, 0);
- if (dskdmaen == DSKDMA_READ) { /* TURBO read */
-
- if ((adkcon & 0x400) && floppysupported) {
- for (i = 0; i < drv->tracklen; i += 16) {
- pos += 16;
- pos %= drv->tracklen;
- if (drv->bigmfmbuf[pos >> 4] == dsksync) {
- /* must skip first disk sync marker */
- pos += 16;
- pos %= drv->tracklen;
- break;
- }
- }
- if (i >= drv->tracklen)
- return;
- }
- // read nothing if not supported and MFMSYNC is on.
- if ((floppysupported) || (!floppysupported && !(adkcon & 0x400))) {
- while (dsklength-- > 0) {
- chipmem_wput_indirect (dskpt, floppysupported ? drv->bigmfmbuf[pos >> 4] : uaerand());
- dskpt += 2;
- pos += 16;
+ if (dskdmaen == DSKDMA_READ)
+ { /* TURBO read */
+ if (adkcon & 0x400)
+ {
+ for (i = 0; i < drv->tracklen; i += 16)
+ {
+ pos += 16;
pos %= drv->tracklen;
+ if (drv->bigmfmbuf[pos >> 4] == dsksync)
+ {
+ /* must skip first disk sync marker */
+ pos += 16;
+ pos %= drv->tracklen;
+ break;
+ }
}
- } else {
- pos += uaerand();
- pos %= drv->tracklen;
- }
- drv->mfmpos = pos;
- if (floppysupported)
- INTREQ (0x8000 | 0x1000);
- done = 2;
-
- } else if (dskdmaen == DSKDMA_WRITE) { /* TURBO write */
-
- if (floppysupported) {
- for (i = 0; i < dsklength; i++) {
- uae_u16 w = chipmem_wget_indirect (dskpt + i * 2);
- drv->bigmfmbuf[pos >> 4] = w;
- pos += 16;
- pos %= drv->tracklen;
- }
- drv->mfmpos = pos;
- drive_write_data (drv);
- done = 2;
- } else {
- pos += uaerand();
- pos %= drv->tracklen;
- drv->mfmpos = pos;
- done = 2;
+ if (i >= drv->tracklen)
+ return;
}
- }
- }
- if (!done && noselected) {
- while (dsklength-- > 0) {
- if (dskdmaen == DSKDMA_WRITE) {
- uae_u16 w = chipmem_wget_indirect (dskpt);
- } else {
- chipmem_wput_indirect (dskpt, 0);
- }
- dskpt += 2;
- }
- INTREQ (0x8000 | 0x1000);
- done = 2;
- }
+ while (dsklength-- > 0)
+ {
+ chipmem_wput_indirect(dskpt, drv->bigmfmbuf[pos >> 4]);
+ dskpt += 2;
+ pos += 16;
+ pos %= drv->tracklen;
+ }
+ drv->mfmpos = pos;
+ INTREQ(0x8000 | 0x1000);
+ done = 1;
+ }
+ else if (dskdmaen == DSKDMA_WRITE)
+ { /* TURBO write */
- if (done) {
- linecounter = done;
+ for (i = 0; i < dsklength; i++)
+ {
+ uae_u16 w = chipmem_wget_indirect(dskpt + i * 2);
+ drv->bigmfmbuf[pos >> 4] = w;
+#ifdef AMAX
+ if (currprefs.amaxromfile[0])
+ amax_diskwrite(w);
+#endif
+ pos += 16;
+ pos %= drv->tracklen;
+ }
+ drv->mfmpos = pos;
+ drive_write_data(drv);
+ done = 1;
+ }
+ }
+ if (!done && noselected)
+ {
+ while (dsklength-- > 0)
+ {
+ if (dskdmaen == DSKDMA_WRITE)
+ {
+ uae_u16 w = chipmem_wget_indirect(dskpt);
+#ifdef AMAX
+ if (currprefs.amaxromfile[0])
+ amax_diskwrite(w);
+#endif
+ }
+ else
+ {
+ chipmem_wput_indirect(dskpt, 0);
+ }
+ dskpt += 2;
+ }
+ INTREQ(0x8000 | 0x1000);
+ done = 1;
+ }
+
+ if (done)
+ {
+ linecounter = 2;
dskdmaen = DSKDMA_OFF;
- return;
- }
- }
+ return;
+ }
+ }
}
-void DISK_update_adkcon (int hpos, uae_u16 v)
+void DISK_update_adkcon(int hpos, uae_u16 v)
{
uae_u16 vold = adkcon;
uae_u16 vnew = adkcon;
if (v & 0x8000)
- vnew |= v & 0x7FFF;
+ vnew |= v & 0x7FFF;
else
vnew &= ~v;
if ((vnew & 0x400) && !(vold & 0x400))
bitoffset = 0;
}
-void DSKSYNC (int hpos, uae_u16 v)
+void DSKSYNC(int hpos, uae_u16 v)
{
- if (v == dsksync)
- return;
- DISK_update (hpos);
- dsksync = v;
+ if (v == dsksync)
+ return;
+ DISK_update(hpos);
+ dsksync = v;
}
-STATIC_INLINE bool iswrite (void)
+STATIC_INLINE bool iswrite()
{
- return dskdmaen == DSKDMA_WRITE;
+ return dskdmaen == 3;
}
-void DSKDAT (uae_u16 v)
+void DSKDAT(uae_u16 v)
{
- if (fifo_inuse[2]) {
+ if (fifo_inuse[2])
+ {
write_log (_T("DSKDAT: FIFO overflow!\n"));
return;
}
@@ -3485,199 +3972,229 @@ void DSKDAT (uae_u16 v)
fifo[2] = fifo[1];
fifo_inuse[1] = fifo_inuse[0];
fifo[1] = fifo[0];
- fifo_inuse[0] = iswrite () ? 2 : 1;
+ fifo_inuse[0] = iswrite() ? 2 : 1;
fifo[0] = v;
- fifo_filled = 1;
+ fifo_filled = true;
}
-uae_u16 DSKDATR (void)
+
+uae_u16 DSKDATR()
{
int i;
uae_u16 v = 0;
- for (i = 2; i >= 0; i--) {
- if (fifo_inuse[i]) {
+ for (i = 2; i >= 0; i--)
+ {
+ if (fifo_inuse[i])
+ {
fifo_inuse[i] = 0;
v = fifo[i];
break;
}
}
- if (i < 0) {
+ if (i < 0)
+ {
write_log (_T("DSKDATR: FIFO underflow!\n"));
- } else if (dskdmaen > 0 && dskdmaen < 3 && dsklength <= 0 && disk_fifostatus () < 0) {
- disk_dmafinished ();
+ }
+ else if (dskdmaen > 0 && dskdmaen < 3 && dsklength <= 0 && disk_fifostatus() < 0)
+ {
+ disk_dmafinished();
}
return v;
}
-uae_u16 disk_dmal (void)
+uae_u16 disk_dmal()
{
uae_u16 dmal = 0;
- if (dskdmaen) {
- if (dskdmaen == 3) {
+ if (dskdmaen)
+ {
+ if (dskdmaen == 3)
+ {
dmal = (1 + 2) * (fifo_inuse[0] ? 1 : 0) + (4 + 8) * (fifo_inuse[1] ? 1 : 0) + (16 + 32) * (fifo_inuse[2] ? 1 : 0);
dmal ^= 63;
if (dsklength == 2)
dmal &= ~(16 + 32);
if (dsklength == 1)
dmal &= ~(16 + 32 + 4 + 8);
- } else {
+ }
+ else
+ {
dmal = 16 * (fifo_inuse[0] ? 1 : 0) + 4 * (fifo_inuse[1] ? 1 : 0) + 1 * (fifo_inuse[2] ? 1 : 0);
}
}
return dmal;
}
-uaecptr disk_getpt (void)
+
+uaecptr disk_getpt()
{
uaecptr pt = dskpt;
dskpt += 2;
return pt;
}
-void DSKPTH (uae_u16 v)
+
+void DSKPTH(uae_u16 v)
{
- dskpt = (dskpt & 0xffff) | ((uae_u32) v << 16);
+ dskpt = (dskpt & 0xffff) | (uae_u32(v) << 16);
}
-void DSKPTL (uae_u16 v)
+void DSKPTL(uae_u16 v)
{
- dskpt = (dskpt & ~0xffff) | (v);
+ dskpt = (dskpt & ~0xffff) | (v);
}
-void DISK_free (void)
+void DISK_free()
{
- for (int dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
- drive *drv = &floppy[dr];
- drive_image_free (drv);
- }
-}
-
-void DISK_init (void)
-{
- for (int dr = MAX_FLOPPY_DRIVES - 1; dr >= 0; dr--) {
- drive *drv = &floppy[dr];
- /* reset all drive types to 3.5 DD */
- drive_settype_id (drv);
- if (!drive_insert (drv, &currprefs, dr, currprefs.floppyslots[dr].df, false, currprefs.floppyslots[dr].forcedwriteprotect))
- disk_eject (dr);
- }
- if (disk_empty (0))
- write_log (_T("No disk in drive 0.\n"));
-}
-
-void DISK_reset (void)
-{
- if (savestate_state)
- return;
-
- disk_hpos = 0;
- dskdmaen = 0;
- disabled = 0;
- memset(&disk_info_data, 0, sizeof disk_info_data);
- for (int dr = MAX_FLOPPY_DRIVES - 1; dr >= 0; dr--) {
- reset_drive (dr);
+ int dr;
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = &floppy[dr];
+ drive_image_free(drv);
}
}
-static void load_track (int num, int cyl, int side, int *sectable)
+void DISK_init()
+{
+ int dr;
+
+ for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
+ {
+ drive* drv = &floppy[dr];
+ /* reset all drive types to 3.5 DD */
+ drive_settype_id(drv);
+ if (!drive_insert(drv, &currprefs, dr, currprefs.floppyslots[dr].df, false, currprefs.floppyslots[dr].forcedwriteprotect))
+ disk_eject(dr);
+ }
+ if (disk_empty(0))
+ write_log (_T("No disk in drive 0.\n"));
+ //TODO: enable when AMAX is implemented
+ //amax_init();
+}
+
+void DISK_reset()
+{
+ int i;
+
+ if (savestate_state)
+ return;
+
+ disk_hpos = 0;
+ dskdmaen = 0;
+ disabled = 0;
+ for (i = 0; i < MAX_FLOPPY_DRIVES; i++)
+ reset_drive(i);
+ setamax();
+}
+
+static void load_track(int num, int cyl, int side, int* sectable)
{
int oldcyl, oldside, drvsec;
- drive *drv = &floppy[num];
+ drive* drv = &floppy[num];
oldcyl = drv->cyl;
oldside = side;
drv->cyl = cyl;
side = 0;
drv->buffered_cyl = -1;
- drive_fill_bigbuf (drv, 1);
- decode_buffer (drv->bigmfmbuf, drv->cyl, 11, drv->ddhd, drv->filetype, &drvsec, sectable, 1);
+ drive_fill_bigbuf(drv, 1);
+ decode_buffer(drv->bigmfmbuf, drv->cyl, 11, drv->ddhd, drv->filetype, &drvsec, sectable, 1);
drv->cyl = oldcyl;
side = oldside;
drv->buffered_cyl = -1;
}
-int DISK_examine_image (struct uae_prefs *p, int num, struct diskinfo *di)
+int DISK_examine_image(struct uae_prefs* p, int num, struct diskinfo* di)
{
- int drvsec;
- int ret, i;
- drive *drv = &floppy[num];
- uae_u32 dos, crc, crc2;
- int wasdelayed = drv->dskchange_time;
- int sectable[MAX_SECTORS];
+ int drvsec;
+ int ret, i;
+ drive* drv = &floppy[num];
+ uae_u32 dos, crc, crc2;
+ int wasdelayed = drv->dskchange_time;
+ int sectable[MAX_SECTORS];
int oldcyl, oldside;
- uae_u32 v = 0;
+ uae_u32 v;
- ret = 0;
- memset (di, 0, sizeof (struct diskinfo));
+ ret = 0;
+ memset(di, 0, sizeof (struct diskinfo));
di->unreadable = true;
oldcyl = drv->cyl;
oldside = side;
- drv->cyl = 0;
- side = 0;
- if (!drive_insert (drv, p, num, p->floppyslots[num].df, true, true) || !drv->diskfile) {
+ drv->cyl = 0;
+ side = 0;
+ if (!drive_insert(drv, p, num, p->floppyslots[num].df, true, true) || !drv->diskfile)
+ {
drv->cyl = oldcyl;
side = oldside;
- return 1;
+ return 1;
}
- di->crc32 = zfile_crc32 (drv->diskfile);
+ di->crc32 = zfile_crc32(drv->diskfile);
di->unreadable = false;
- decode_buffer (drv->bigmfmbuf, drv->cyl, 11, drv->ddhd, drv->filetype, &drvsec, sectable, 1);
- di->hd = drv->ddhd == 2;
+ decode_buffer(drv->bigmfmbuf, drv->cyl, 11, drv->ddhd, drv->filetype, &drvsec, sectable, 1);
+ di->hd = drvsec == 22;
drv->cyl = oldcyl;
side = oldside;
- if (sectable[0] == 0 || sectable[1] == 0) {
- ret = 2;
+ if (sectable[0] == 0 || sectable[1] == 0)
+ {
+ ret = 2;
goto end2;
- }
- crc = crc2 = 0;
- for (i = 0; i < 1024; i += 4) {
+ }
+ crc = crc2 = 0;
+ for (i = 0; i < 1024; i += 4)
+ {
di->bootblock[i + 0] = writebuffer[i + 0];
di->bootblock[i + 1] = writebuffer[i + 1];
di->bootblock[i + 2] = writebuffer[i + 2];
di->bootblock[i + 3] = writebuffer[i + 3];
- v = (writebuffer[i] << 24) | (writebuffer[i + 1] << 16) | (writebuffer[i + 2] << 8) | writebuffer[i + 3];
- if (i == 0)
- dos = v;
- if (i == 4) {
- crc2 = v;
- v = 0;
- }
- if (crc + v < crc)
- crc++;
- crc += v;
- }
- if (dos == 0x4b49434b) { /* KICK */
- ret = 10;
- goto end;
- }
- crc ^= 0xffffffff;
- if (crc != crc2) {
- ret = 3;
- goto end;
- }
+ v = (writebuffer[i] << 24) | (writebuffer[i + 1] << 16) | (writebuffer[i + 2] << 8) | writebuffer[i + 3];
+ if (i == 0)
+ dos = v;
+ if (i == 4)
+ {
+ crc2 = v;
+ v = 0;
+ }
+ if (crc + v < crc)
+ crc++;
+ crc += v;
+ }
+ if (dos == 0x4b49434b)
+ { /* KICK */
+ ret = 10;
+ goto end;
+ }
+ crc ^= 0xffffffff;
+ if (crc != crc2)
+ {
+ ret = 3;
+ goto end;
+ }
di->bb_crc_valid = true;
writebuffer[4] = writebuffer[5] = writebuffer[6] = writebuffer[7] = 0;
- if (get_crc32 (writebuffer, 0x31) == 0xae5e282c) {
+ if (get_crc32(writebuffer, 0x31) == 0xae5e282c)
+ {
di->bootblocktype = 1;
}
- if (dos == 0x444f5300)
- ret = 10;
- else if (dos == 0x444f5301 || dos == 0x444f5302 || dos == 0x444f5303)
- ret = 11;
- else if (dos == 0x444f5304 || dos == 0x444f5305 || dos == 0x444f5306 || dos == 0x444f5307)
- ret = 12;
- else
- ret = 4;
- v = get_crc32 (writebuffer + 8, 0x5c - 8);
- if (ret >= 10 && v == 0xe158ca4b) {
+ if (dos == 0x444f5300)
+ ret = 10;
+ else if (dos == 0x444f5301 || dos == 0x444f5302 || dos == 0x444f5303)
+ ret = 11;
+ else if (dos == 0x444f5304 || dos == 0x444f5305 || dos == 0x444f5306 || dos == 0x444f5307)
+ ret = 12;
+ else
+ ret = 4;
+ v = get_crc32(writebuffer + 8, 0x5c - 8);
+ if (ret >= 10 && v == 0xe158ca4b)
+ {
di->bootblocktype = 2;
}
end:
- load_track (num, 40, 0, sectable);
- if (sectable[0]) {
- if (!disk_checksum (writebuffer, NULL) &&
+ load_track(num, 40, 0, sectable);
+ if (sectable[0])
+ {
+ if (!disk_checksum(writebuffer, nullptr) &&
writebuffer[0] == 0 && writebuffer[1] == 0 && writebuffer[2] == 0 && writebuffer[3] == 2 &&
- writebuffer[508] == 0 && writebuffer[509] == 0 && writebuffer[510] == 0 && writebuffer[511] == 1) {
+ writebuffer[508] == 0 && writebuffer[509] == 0 && writebuffer[510] == 0 && writebuffer[511] == 1)
+ {
writebuffer[512 - 20 * 4 + 1 + writebuffer[512 - 20 * 4]] = 0;
- TCHAR *n = au ((const char*)(writebuffer + 512 - 20 * 4 + 1));
+ TCHAR* n = au(reinterpret_cast(writebuffer + 512 - 20 * 4 + 1));
if (_tcslen (n) >= sizeof (di->diskname))
n[sizeof (di->diskname) - 1] = 0;
_tcscpy (di->diskname, n);
@@ -3685,165 +4202,179 @@ end:
}
}
end2:
- drive_image_free (drv);
- if (wasdelayed > 1) {
- drive_eject (drv);
- currprefs.floppyslots[num].df[0] = 0;
- drv->dskchange_time = wasdelayed;
- disk_insert (num, drv->newname);
- }
- return ret;
+ drive_image_free(drv);
+ if (wasdelayed > 1)
+ {
+ drive_eject(drv);
+ currprefs.floppyslots[num].df[0] = 0;
+ drv->dskchange_time = wasdelayed;
+ disk_insert(num, drv->newname);
+ }
+ return ret;
}
/* Disk save/restore code */
-#if defined SAVESTATE
+#if defined SAVESTATE || defined DEBUGGER
-void DISK_save_custom (uae_u32 *pdskpt, uae_u16 *pdsklength, uae_u16 *pdsksync, uae_u16 *pdskbytr)
+void DISK_save_custom(uae_u32* pdskpt, uae_u16* pdsklength, uae_u16* pdsksync, uae_u16* pdskbytr)
{
- if (pdskpt)
- *pdskpt = dskpt;
- if (pdsklength)
- *pdsklength = dsklen;
- if (pdsksync)
- *pdsksync = dsksync;
- if(pdskbytr)
- *pdskbytr = dskbytr_val;
+ if (pdskpt)
+ *pdskpt = dskpt;
+ if (pdsklength)
+ *pdsklength = dsklen;
+ if (pdsksync)
+ *pdsksync = dsksync;
+ if (pdskbytr)
+ *pdskbytr = dskbytr_val;
}
-#endif /* SAVESTATE */
+#endif /* SAVESTATE || DEBUGGER */
-static uae_u32 getadfcrc (drive *drv)
+static uae_u32 getadfcrc(drive* drv)
{
- uae_u8 *b;
+ uae_u8* b;
uae_u32 crc32;
int size;
if (!drv->diskfile)
return 0;
- zfile_fseek (drv->diskfile, 0, SEEK_END);
- size = zfile_ftell (drv->diskfile);
+ zfile_fseek(drv->diskfile, 0, SEEK_END);
+ size = zfile_ftell(drv->diskfile);
b = xmalloc (uae_u8, size);
if (!b)
return 0;
- zfile_fseek (drv->diskfile, 0, SEEK_SET);
- zfile_fread (b, 1, size, drv->diskfile);
- crc32 = get_crc32 (b, size);
- free (b);
+ zfile_fseek(drv->diskfile, 0, SEEK_SET);
+ zfile_fread(b, 1, size, drv->diskfile);
+ crc32 = get_crc32(b, size);
+ free(b);
return crc32;
}
#ifdef SAVESTATE
-void DISK_restore_custom (uae_u32 pdskpt, uae_u16 pdsklength, uae_u16 pdskbytr)
+void DISK_restore_custom(uae_u32 pdskpt, uae_u16 pdsklength, uae_u16 pdskbytr)
{
- dskpt = pdskpt;
- dsklen = pdsklength;
- dskbytr_val = pdskbytr;
+ dskpt = pdskpt;
+ dsklen = pdsklength;
+ dskbytr_val = pdskbytr;
}
-void restore_disk_finish (void)
+void restore_disk_finish()
{
int cnt = 0;
- for (int i = 0; i < MAX_FLOPPY_DRIVES; i++) {
- if (currprefs.floppyslots[i].dfxtype >= 0) {
- update_drive_gui (i, true);
+ for (int i = 0; i < MAX_FLOPPY_DRIVES; i++)
+ {
+ if (currprefs.floppyslots[i].dfxtype >= 0)
+ {
+ update_drive_gui(i, true);
cnt++;
}
}
currprefs.nr_floppies = changed_prefs.nr_floppies = cnt;
- DISK_check_change ();
+ DISK_check_change();
+ setamax();
}
-uae_u8 *restore_disk(int num,uae_u8 *src)
+uae_u8* restore_disk(int num, uae_u8* src)
{
- drive *drv;
- int state;
- TCHAR old[MAX_DPATH];
- TCHAR *s;
- int newis;
- drive_type dfxtype;
+ drive* drv;
+ int state, dfxtype;
+ TCHAR old[MAX_DPATH];
+ TCHAR* s;
+ int newis;
- drv = &floppy[num];
- disabled &= ~(1 << num);
- drv->drive_id = restore_u32 ();
- drv->motoroff = 1;
- drv->idbit = 0;
- state = restore_u8 ();
- if (state & 2) {
- disabled |= 1 << num;
- if (changed_prefs.nr_floppies > num)
- changed_prefs.nr_floppies = num;
- changed_prefs.floppyslots[num].dfxtype = -1;
- } else {
- drv->motoroff = (state & 1) ? 0 : 1;
+ drv = &floppy[num];
+ disabled &= ~(1 << num);
+ drv->drive_id = restore_u32 ();
+ drv->motoroff = true;
+ drv->idbit = 0;
+ state = restore_u8 ();
+ if (state & 2)
+ {
+ disabled |= 1 << num;
+ if (changed_prefs.nr_floppies > num)
+ changed_prefs.nr_floppies = num;
+ changed_prefs.floppyslots[num].dfxtype = -1;
+ }
+ else
+ {
+ drv->motoroff = (state & 1) ? 0 : 1;
drv->idbit = (state & 4) ? 1 : 0;
- switch (drv->drive_id)
- {
- case DRIVE_ID_35HD:
- dfxtype = DRV_35_HD;
- break;
- case DRIVE_ID_525SD:
- dfxtype = DRV_525_SD;
- break;
- default:
- dfxtype = DRV_35_DD;
- break;
- }
- currprefs.floppyslots[num].dfxtype = changed_prefs.floppyslots[num].dfxtype = dfxtype;
+ switch (drv->drive_id)
+ {
+ case DRIVE_ID_35HD:
+ dfxtype = DRV_35_HD;
+ break;
+ case DRIVE_ID_525SD:
+ dfxtype = DRV_525_SD;
+ break;
+ default:
+ dfxtype = DRV_35_DD;
+ break;
+ }
+ currprefs.floppyslots[num].dfxtype = changed_prefs.floppyslots[num].dfxtype = dfxtype;
}
drv->dskchange = (state & 8) != 0;
- side = (state & 16) ? 1 : 0;
- drv->indexhackmode = 0;
- if (num == 0 && currprefs.floppyslots[num].dfxtype == 0)
- drv->indexhackmode = 1;
- drv->buffered_cyl = -1;
- drv->buffered_side = -1;
- drv->cyl = restore_u8 ();
- drv->dskready = restore_u8 () != 0;
- drv->drive_id_scnt = restore_u8 ();
- int mfmpos = restore_u32 ();
- drv->dskchange_time = 0;
- restore_u32 ();
- s = restore_path (SAVESTATE_PATH_FLOPPY);
- _tcscpy (old, currprefs.floppyslots[num].df);
- _tcsncpy(changed_prefs.floppyslots[num].df, s,255);
- xfree (s);
- int dskready_up_time = restore_u16 ();
- int dskready_down_time = restore_u16 ();
- newis = changed_prefs.floppyslots[num].df[0] ? 1 : 0;
- if (!(disabled & (1 << num))) {
- if (!newis && old[0]) {
+ side = (state & 16) ? 1 : 0;
+ drv->indexhackmode = 0;
+ if (num == 0 && currprefs.floppyslots[num].dfxtype == 0)
+ drv->indexhackmode = 1;
+ drv->buffered_cyl = -1;
+ drv->buffered_side = -1;
+ drv->cyl = restore_u8 ();
+ drv->dskready = restore_u8 () != 0;
+ drv->drive_id_scnt = restore_u8 ();
+ int mfmpos = restore_u32 ();
+ drv->dskchange_time = 0;
+ restore_u32 ();
+ s = restore_path (SAVESTATE_PATH_FLOPPY);
+ _tcscpy (old, currprefs.floppyslots[num].df);
+ _tcsncpy(changed_prefs.floppyslots[num].df, s,255);
+ xfree (s);
+ int dskready_up_time = restore_u16 ();
+ int dskready_down_time = restore_u16 ();
+ newis = changed_prefs.floppyslots[num].df[0] ? 1 : 0;
+ if (!(disabled & (1 << num)))
+ {
+ if (!newis && old[0])
+ {
*currprefs.floppyslots[num].df = *changed_prefs.floppyslots[num].df = 0;
drv->dskchange = false;
- } else if (newis) {
- drive_insert (floppy + num, &currprefs, num, changed_prefs.floppyslots[num].df, false, false);
- if (drive_empty (floppy + num)) {
- if (newis && old[0]) {
- _tcscpy (changed_prefs.floppyslots[num].df, old);
- drive_insert (floppy + num, &currprefs, num, changed_prefs.floppyslots[num].df, false, false);
- if (drive_empty (floppy + num))
+ }
+ else if (newis)
+ {
+ drive_insert(floppy + num, &currprefs, num, changed_prefs.floppyslots[num].df, false, false);
+ if (drive_empty(floppy + num))
+ {
+ if (newis && old[0])
+ {
+ _tcscpy (changed_prefs.floppyslots[num].df, old);
+ drive_insert(floppy + num, &currprefs, num, changed_prefs.floppyslots[num].df, false, false);
+ if (drive_empty(floppy + num))
drv->dskchange = true;
- } else {
+ }
+ else
+ {
drv->dskchange_time = -1;
- _tcscpy(drv->newname, changed_prefs.floppyslots[num].df);
- }
- }
- }
- }
+ }
+ }
+ }
+ }
drv->mfmpos = mfmpos;
drv->prevtracklen = drv->tracklen;
drv->dskready_up_time = dskready_up_time;
drv->dskready_down_time = dskready_down_time;
- reset_drive_gui(num);
- return src;
+ reset_drive_gui(num);
+ return src;
}
-uae_u8 *restore_disk2 (int num,uae_u8 *src)
+uae_u8* restore_disk2(int num, uae_u8* src)
{
- drive *drv = &floppy[num];
+ drive* drv = &floppy[num];
uae_u32 m = restore_u32 ();
- if (m) {
+ if (m)
+ {
drv->floppybitcounter = restore_u16 ();
drv->tracklen = restore_u32 ();
drv->trackspeed = restore_u16 ();
@@ -3851,32 +4382,33 @@ uae_u8 *restore_disk2 (int num,uae_u8 *src)
drv->indexoffset = restore_u32 ();
drv->buffered_cyl = drv->cyl;
drv->buffered_side = side;
- for (int j = 0; j < (drv->tracklen + 15) / 16; j++) {
+ for (int j = 0; j < (drv->tracklen + 15) / 16; j++)
+ {
drv->bigmfmbuf[j] = restore_u16 ();
if (m & 2)
drv->tracktiming[j] = restore_u16 ();
}
drv->revolutions = restore_u16 ();
}
- return src;
+ return src;
}
-uae_u8 *save_disk (int num, int *len, uae_u8 *dstptr, bool usepath)
+uae_u8* save_disk(int num, int* len, uae_u8* dstptr, bool usepath)
{
- uae_u8 *dstbak,*dst;
- drive *drv = &floppy[num];
+ uae_u8 *dstbak, *dst;
+ drive* drv = &floppy[num];
- if (dstptr)
- dstbak = dst = dstptr;
- else
- dstbak = dst = xmalloc (uae_u8, 2 + 1 + 1 + 1 + 1 + 4 + 4 + 256);
- save_u32 (drv->drive_id); /* drive type ID */
+ if (dstptr)
+ dstbak = dst = dstptr;
+ else
+ dstbak = dst = xmalloc (uae_u8, 2 + 1 + 1 + 1 + 1 + 4 + 4 + 256);
+ save_u32 (drv->drive_id); /* drive type ID */
save_u8 ((drv->motoroff ? 0 : 1) | ((disabled & (1 << num)) ? 2 : 0) | (drv->idbit ? 4 : 0) | (drv->dskchange ? 8 : 0) | (side ? 16 : 0) | (drv->wrprot ? 32 : 0));
- save_u8 (drv->cyl); /* cylinder */
- save_u8 (drv->dskready); /* dskready */
- save_u8 (drv->drive_id_scnt); /* id mode position */
- save_u32 (drv->mfmpos); /* disk position */
- save_u32 (getadfcrc (drv)); /* CRC of disk image */
+ save_u8 (drv->cyl); /* cylinder */
+ save_u8 (drv->dskready); /* dskready */
+ save_u8 (drv->drive_id_scnt); /* id mode position */
+ save_u32 (drv->mfmpos); /* disk position */
+ save_u32 (getadfcrc (drv)); /* CRC of disk image */
save_path (usepath ? currprefs.floppyslots[num].df : _T(""), SAVESTATE_PATH_FLOPPY);/* image name */
save_u16 (drv->dskready_up_time);
save_u16 (drv->dskready_down_time);
@@ -3884,26 +4416,27 @@ uae_u8 *save_disk (int num, int *len, uae_u8 *dstptr, bool usepath)
return dstbak;
}
-uae_u8 *save_disk2 (int num, int *len, uae_u8 *dstptr)
+uae_u8* save_disk2(int num, int* len, uae_u8* dstptr)
{
- uae_u8 *dstbak,*dst;
- drive *drv = &floppy[num];
+ uae_u8 *dstbak, *dst;
+ drive* drv = &floppy[num];
int m = 0;
int size = 0;
- if (drv->motoroff == 0 && drv->buffered_side >= 0 && drv->tracklen > 0) {
+ if (drv->motoroff == 0 && drv->buffered_side >= 0 && drv->tracklen > 0)
+ {
m = 1;
if (drv->tracktiming[0])
m |= 2;
size += ((drv->tracklen + 15) * 2) / 8;
}
if (!m)
- return NULL;
+ return nullptr;
if (dstptr)
dstbak = dst = dstptr;
else
- dstbak = dst = xmalloc (uae_u8, 4 + 2 + 4 + 2 + 4 + 4 + size + 2);
+ dstbak = dst = xmalloc(uae_u8, 2 + 4 + 2 + 4 + 4 + size);
save_u32 (m);
save_u16 (drv->floppybitcounter);
@@ -3911,27 +4444,29 @@ uae_u8 *save_disk2 (int num, int *len, uae_u8 *dstptr)
save_u16 (drv->trackspeed);
save_u32 (drv->skipoffset);
save_u32 (drv->indexoffset);
- for (int j = 0; j < (drv->tracklen + 15) / 16; j++) {
+ for (int j = 0; j < (drv->tracklen + 15) / 16; j++)
+ {
save_u16 (drv->bigmfmbuf[j]);
if (drv->tracktiming[0])
save_u16 (drv->tracktiming[j]);
}
save_u16 (drv->revolutions);
- *len = dst - dstbak;
- return dstbak;
+ *len = dst - dstbak;
+ return dstbak;
}
/* internal floppy controller variables */
-uae_u8 *restore_floppy(uae_u8 *src)
+uae_u8* restore_floppy(uae_u8* src)
{
- word = restore_u16();
- bitoffset = restore_u8();
- dma_enable = restore_u8();
+ word = restore_u16();
+ bitoffset = restore_u8();
+ dma_enable = restore_u8();
disk_hpos = restore_u8 () & 0xff;
- dskdmaen = restore_u8();
- for (int i = 0; i < 3; i++) {
+ dskdmaen = restore_u8();
+ for (int i = 0; i < 3; i++)
+ {
fifo[i] = restore_u16 ();
fifo_inuse[i] = restore_u8 ();
if (dskdmaen == 0)
@@ -3939,30 +4474,212 @@ uae_u8 *restore_floppy(uae_u8 *src)
}
fifo_filled = fifo_inuse[0] || fifo_inuse[1] || fifo_inuse[2];
dsklength = restore_u16 ();
- return src;
+ return src;
}
-uae_u8 *save_floppy(int *len, uae_u8 *dstptr)
+uae_u8* save_floppy(int* len, uae_u8* dstptr)
{
- uae_u8 *dstbak, *dst;
+ uae_u8 *dstbak, *dst;
- if (dstptr)
- dstbak = dst = dstptr;
- else
+ if (dstptr)
+ dstbak = dst = dstptr;
+ else
dstbak = dst = xmalloc (uae_u8, 100);
- save_u16 (word); /* shift register */
- save_u8 (bitoffset); /* dma bit offset */
- save_u8 (dma_enable); /* disk sync found */
- save_u8 (disk_hpos & 0xff); /* next bit read position */
- save_u8 (dskdmaen); /* dma status */
- for (int i = 0; i < 3; i++) {
+ save_u16 (word); /* shift register */
+ save_u8 (bitoffset); /* dma bit offset */
+ save_u8 (dma_enable); /* disk sync found */
+ save_u8 (disk_hpos & 0xff); /* next bit read position */
+ save_u8 (dskdmaen); /* dma status */
+ for (int i = 0; i < 3; i++)
+ {
save_u16 (fifo[i]);
save_u8 (fifo_inuse[i]);
}
save_u16 (dsklength);
- *len = dst - dstbak;
- return dstbak;
+ *len = dst - dstbak;
+ return dstbak;
}
#endif /* SAVESTATE */
+
+#define MAX_DISKENTRIES 4
+int disk_prevnext_name(TCHAR *imgp, int dir)
+{
+ TCHAR img[MAX_DPATH], *ext, *p, *p2, *ps, *dst[MAX_DISKENTRIES];
+ int num = -1;
+ int cnt, i;
+ TCHAR imgl[MAX_DPATH];
+ int ret, gotone, wrapped;
+ TCHAR *old;
+
+ old = my_strdup(imgp);
+
+ struct zfile *zf = zfile_fopen(imgp, _T("rb"), ZFD_NORMAL);
+ if (zf) {
+ _tcscpy(img, zfile_getname(zf));
+ zfile_fclose(zf);
+ zf = zfile_fopen(img, _T("rb"), ZFD_NORMAL);
+ if (!zf) // oops, no directory support in this archive type
+ _tcscpy(img, imgp);
+ zfile_fclose(zf);
+ }
+ else {
+ _tcscpy(img, imgp);
+ }
+
+ wrapped = 0;
+retry:
+ _tcscpy(imgl, img);
+ to_lower(imgl, sizeof imgl / sizeof(TCHAR));
+ gotone = 0;
+ ret = 0;
+ ps = imgl;
+ cnt = 0;
+ dst[cnt] = nullptr;
+ for (;;) {
+ // disk x of y
+ p = _tcsstr(ps, _T("(disk "));
+ if (p && _istdigit(p[6])) {
+ p2 = p - imgl + img;
+ num = _tstoi(p + 6);
+ dst[cnt++] = p2 + 6;
+ if (cnt >= MAX_DISKENTRIES - 1)
+ break;
+ gotone = 1;
+ ps = p + 6;
+ continue;
+ }
+ if (gotone)
+ break;
+ p = _tcsstr(ps, _T("disk"));
+ if (p && _istdigit(p[4])) {
+ p2 = p - imgl + img;
+ num = _tstoi(p + 4);
+ dst[cnt++] = p2 + 4;
+ if (cnt >= MAX_DISKENTRIES - 1)
+ break;
+ gotone = 1;
+ ps = p + 4;
+ continue;
+ }
+ if (gotone)
+ break;
+ ext = _tcsrchr(ps, '.');
+ if (!ext || ext - ps < 4)
+ break;
+ TCHAR *ext2 = ext - imgl + img;
+ // name_x.ext
+ if (ext[-3] == '_' && !_istdigit(ext[-2]) && _istdigit(ext[-1])) {
+ num = _tstoi(ext - 1);
+ dst[cnt++] = ext2 - 1;
+ // name_x.ext, name-x.ext, name x.ext
+ }
+ else if ((ext[-2] == '_' || ext[-2] == '-' || ext[-2] == ' ') && _istdigit(ext[-1])) {
+ num = _tstoi(ext - 1);
+ dst[cnt++] = ext2 - 1;
+ // name_a.ext, name-a.ext, name a .ext
+ }
+ else if ((ext[-2] == '_' || ext[-2] == '-' || ext[-2] == ' ') && ext[-1] >= 'a' && ext[-1] <= 'z') {
+ num = ext[-1] - 'a' + 1;
+ dst[cnt++] = ext2 - 1;
+ // nameA.ext
+ }
+ else if (ext2[-2] >= 'a' && ext2[-2] <= 'z' && ext2[-1] >= 'A' && ext2[-1] <= 'Z') {
+ num = ext[-1] - 'a' + 1;
+ dst[cnt++] = ext2 - 1;
+ // namex.ext
+ }
+ else if (!_istdigit(ext2[-2]) && _istdigit(ext[-1])) {
+ num = ext[-1] - '0';
+ dst[cnt++] = ext2 - 1;
+ }
+ break;
+ }
+ dst[cnt] = nullptr;
+ if (num <= 0 || num >= 19)
+ goto end;
+ num += dir;
+ if (num > 9)
+ goto end;
+ if (num == 9)
+ num = 1;
+ else if (num == 0)
+ num = 9;
+ for (i = 0; i < cnt; i++) {
+ if (!_istdigit(dst[i][0])) {
+ int capital = dst[i][0] >= 'A' && dst[i][0] <= 'Z';
+ dst[i][0] = (num - 1) + (capital ? 'A' : 'a');
+ }
+ else {
+ dst[i][0] = num + '0';
+ }
+ }
+ if (zfile_exists(img)) {
+ ret = 1;
+ goto end;
+ }
+ if (gotone) { // was (disk x but no match, perhaps there are extra tags..
+ TCHAR *old2 = my_strdup(img);
+ for (;;) {
+ ext = _tcsrchr(img, '.');
+ if (!ext)
+ break;
+ if (ext == img)
+ break;
+ if (ext[-1] != ']')
+ break;
+ TCHAR *t = _tcsrchr(img, '[');
+ if (!t)
+ break;
+ t[0] = 0;
+ if (zfile_exists(img)) {
+ ret = 1;
+ goto end;
+ }
+ }
+ _tcscpy(img, old2);
+ xfree(old2);
+ }
+ if (!wrapped) {
+ for (i = 0; i < cnt; i++) {
+ if (!_istdigit(dst[i][0]))
+ dst[i][0] = dst[i][0] >= 'A' && dst[i][0] <= 'Z' ? 'A' : 'a';
+ else
+ dst[i][0] = '1';
+ if (dir < 0)
+ dst[i][0] += 8;
+ }
+ wrapped++;
+ }
+ if (zfile_exists(img)) {
+ ret = -1;
+ goto end;
+ }
+ if (dir < 0 && wrapped < 2)
+ goto retry;
+ _tcscpy(img, old);
+
+end:
+ _tcscpy(imgp, img);
+ xfree(old);
+ return ret;
+}
+
+int disk_prevnext(int drive, int dir)
+{
+ TCHAR img[MAX_DPATH];
+
+ _tcscpy(img, currprefs.floppyslots[drive].df);
+
+ if (!img[0])
+ return 0;
+ disk_prevnext_name(img, dir);
+ _tcscpy(changed_prefs.floppyslots[drive].df, img);
+ return 1;
+}
+
+int getdebug()
+{
+ return floppy[0].mfmpos;
+}
diff --git a/src/drawing.cpp b/src/drawing.cpp
index aa0de19d..099c5729 100644
--- a/src/drawing.cpp
+++ b/src/drawing.cpp
@@ -1,4 +1,4 @@
- /*
+/*
* UAE - The Un*x Amiga Emulator
*
* Screen drawing functions
@@ -8,6 +8,7 @@
* Copyright 2000-2008 Toni Wilen
*/
+
/* There are a couple of concepts of "coordinates" in this file.
- DIW coordinates
- DDF coordinates (essentially cycles, resolution lower than lores by a factor of 2)
@@ -45,40 +46,41 @@
#include "drawing.h"
#include "savestate.h"
#include "statusline.h"
-#include "cd32_fmv.h"
-#include "audio.h"
-#include "devices.h"
-
-#define VERTICAL_OFFSET 18;
-
-#define RENDER_SIGNAL_PARTIAL 1
-#define RENDER_SIGNAL_FRAME_DONE 2
-#define RENDER_SIGNAL_QUIT 3
-static uae_thread_id render_tid = 0;
-static smp_comm_pipe *volatile render_pipe = 0;
-static uae_sem_t render_sem = 0;
-static bool volatile render_thread_busy = false;
+#include "amiberry_gfx.h"
extern int sprite_buffer_res;
+static int lores_factor;
int lores_shift;
static void pfield_set_linetoscr(void);
+int debug_bpl_mask = 0xff, debug_bpl_mask_one;
+
static void lores_set(int lores)
{
- int old = lores_shift;
+ int old = lores;
lores_shift = lores;
if (lores_shift != old)
pfield_set_linetoscr();
}
-static void lores_reset (void)
+static void lores_reset(void)
{
+ lores_factor = currprefs.gfx_resolution ? 2 : 1;
lores_set(currprefs.gfx_resolution);
+ if (doublescan > 0) {
+ if (lores_shift < 2)
+ lores_shift++;
+ lores_factor = 2;
+ lores_set(lores_shift);
+ }
sprite_buffer_res = currprefs.gfx_resolution;
+ if (doublescan > 0 && sprite_buffer_res < RES_SUPERHIRES)
+ sprite_buffer_res++;
}
bool aga_mode; /* mirror of chipset_mask & CSMASK_AGA */
+bool direct_rgb;
/* The shift factor to apply when converting between Amiga coordinates and window
coordinates. Zero if the resolution is the same, positive if window coordinates
@@ -86,7 +88,17 @@ bool aga_mode; /* mirror of chipset_mask & CSMASK_AGA */
coordinates have a lower resolution (i.e. we're shrinking the image). */
static int res_shift;
+static int linedbl, linedbld;
+
int interlace_seen;
+int detected_screen_resolution;
+
+#define AUTO_LORES_FRAMES 10
+static int can_use_lores = 0, frame_res, frame_res_lace;
+static int resolution_count[RES_MAX + 1], lines_count;
+static bool center_reset;
+static bool init_genlock_data;
+bool need_genlock_data;
/* Lookup tables for dual playfields. The dblpf_*1 versions are for the case
that playfield 1 has the priority, dbplpf_*2 are used if playfield 2 has
@@ -96,39 +108,47 @@ int interlace_seen;
foreground being at bit offset 0, the one used if pf2 is in front being at
offset 16. */
-static int dblpf_ms1[256], dblpf_ms2[256];
+static int dblpf_ms1[256], dblpf_ms2[256], dblpf_ms[256];
static int dblpf_ind1[256], dblpf_ind2[256];
static int dblpf_2nd1[256], dblpf_2nd2[256];
static const int dblpfofs[] = { 0, 2, 4, 8, 16, 32, 64, 128 };
-static int sprite_col_nat[65536];
-static int sprite_col_at[65536];
-static int sprite_bit[65536];
+static int sprite_offs[256];
+
static uae_u32 clxtab[256];
/* Video buffer description structure. Filled in by the graphics system
* dependent code. */
+
struct vidbuf_description gfxvidinfo;
/* OCS/ECS color lookup table. */
xcolnr xcolors[4096];
-struct spritepixelsbuf {
+struct spritepixelsbuf
+{
uae_u8 attach;
uae_u8 stdata;
uae_u16 data;
};
+
static struct spritepixelsbuf spritepixels_buffer[MAX_PIXELS_PER_LINE];
static struct spritepixelsbuf *spritepixels;
static int sprite_first_x, sprite_last_x;
+#ifdef AGA
/* AGA mode color lookup tables */
-#ifndef ARMV6_ASSEMBLY
unsigned int xredcolors[256], xgreencolors[256], xbluecolors[256];
-#endif
static int dblpf_ind1_aga[256], dblpf_ind2_aga[256];
+#else
+static uae_u8 spriteagadpfpixels[1];
+static int dblpf_ind1_aga[1], dblpf_ind2_aga[1];
+#endif
+int xredcolor_s, xredcolor_b, xredcolor_m;
+int xgreencolor_s, xgreencolor_b, xgreencolor_m;
+int xbluecolor_s, xbluecolor_b, xbluecolor_m;
struct color_entry colors_for_drawing;
static struct color_entry direct_colors_for_drawing;
@@ -137,110 +157,553 @@ static xcolnr *p_acolors;
static xcolnr *p_xcolors;
/* The size of these arrays is pretty arbitrary; it was chosen to be "more
- than enough". The coordinates used for indexing into these arrays are
- almost, but not quite, Amiga coordinates (there's a constant offset). */
-static union pixdata_u {
- uae_u8 apixels[MAX_PIXELS_PER_LINE * 2];
- uae_u16 apixels_w[MAX_PIXELS_PER_LINE * 2 / sizeof (uae_u16)];
- uae_u32 apixels_l[MAX_PIXELS_PER_LINE * 2 / sizeof (uae_u32)];
+than enough". The coordinates used for indexing into these arrays are
+almost, but not quite, Amiga coordinates (there's a constant offset). */
+static union {
+ /* Let's try to align this thing. */
+ double uupzuq;
+ long int cruxmedo;
+ uae_u8 apixels[MAX_PIXELS_PER_LINE * 2];
+ uae_u16 apixels_w[MAX_PIXELS_PER_LINE * 2 / sizeof(uae_u16)];
+ uae_u32 apixels_l[MAX_PIXELS_PER_LINE * 2 / sizeof(uae_u32)];
} pixdata;
+static uae_u8 *refresh_indicator_buffer;
+static uae_u8 *refresh_indicator_changed, *refresh_indicator_changed_prev;
+static int refresh_indicator_height;
+
uae_u16 spixels[2 * MAX_SPR_PIXELS];
/* Eight bits for every pixel. */
union sps_union spixstate;
-static uae_u16 ham_linebuf[MAX_PIXELS_PER_LINE * 2];
+static uae_u32 ham_linebuf[MAX_PIXELS_PER_LINE * 2];
+static uae_u8 *real_bplpt[8];
-static uae_u8 *xlinebuffer;
+static uae_u8 all_ones[MAX_PIXELS_PER_LINE];
+static uae_u8 all_zeros[MAX_PIXELS_PER_LINE];
-#define MAX_VIDHEIGHT 270
+uae_u8 *xlinebuffer, *xlinebuffer_genlock;
-static int *native2amiga_line_map;
-static uae_u8 *row_map[MAX_VIDHEIGHT + 1];
+static int *amiga2aspect_line_map, *native2amiga_line_map;
+static uae_u8 **row_map;
+static uae_u8 *row_map_genlock_buffer;
static uae_u8 row_tmp[MAX_PIXELS_PER_LINE * 32 / 8];
+static int max_drawn_amiga_line;
+uae_u8 **row_map_genlock;
+uae_u8 *row_map_color_burst_buffer;
/* line_draw_funcs: pfield_do_linetoscr, pfield_do_fill_line, decode_ham */
-typedef void (*line_draw_func)(int, int, bool);
+typedef void(*line_draw_func)(int, int, bool);
-static bool screenlocked = false;
-static int next_line_to_render = 0;
-static int linestate_first_undecided = 0;
+#define LINE_UNDECIDED 1
+#define LINE_DECIDED 2
+#define LINE_DECIDED_DOUBLE 3
+#define LINE_AS_PREVIOUS 4
+#define LINE_BLACK 5
+#define LINE_REMEMBERED_AS_BLACK 6
+#define LINE_DONE 7
+#define LINE_DONE_AS_PREVIOUS 8
+#define LINE_REMEMBERED_AS_PREVIOUS 9
+
+#define LINESTATE_SIZE ((MAXVPOS + 2) * 2 + 1)
+
+static uae_u8 linestate[LINESTATE_SIZE];
uae_u8 line_data[(MAXVPOS + 2) * 2][MAX_PLANES * MAX_WORDS_PER_LINE * 2];
+/* Centering variables. */
+static int min_diwstart, max_diwstop;
/* The visible window: VISIBLE_LEFT_BORDER contains the left border of the visible
- area, VISIBLE_RIGHT_BORDER the right border. These are in window coordinates. */
-static int visible_left_border, visible_right_border;
+area, VISIBLE_RIGHT_BORDER the right border. These are in window coordinates. */
+int visible_left_border, visible_right_border;
+/* Pixels outside of visible_start and visible_stop are always black */
+static int visible_left_start, visible_right_stop;
+static int visible_top_start, visible_bottom_stop;
+/* same for hblank */
+static int hblank_left_start, hblank_right_stop;
static int linetoscr_x_adjust_pixbytes, linetoscr_x_adjust_pixels;
-static int thisframe_y_adjust_real, max_ypos_thisframe;
+static int thisframe_y_adjust;
+static int thisframe_y_adjust_real, max_ypos_thisframe, min_ypos_for_screen;
+int thisframe_first_drawn_line, thisframe_last_drawn_line;
+
+/* A frame counter that forces a redraw after at least one skipped frame in
+interlace mode. */
+static int last_redraw_point;
#define MAX_STOP 30000
+static int first_drawn_line, last_drawn_line;
+static int first_block_line, last_block_line;
+
+#define NO_BLOCK -3
/* These are generated by the drawing code from the line_decisions array for
- each line that needs to be drawn. These are basically extracted out of
- bit fields in the hardware registers. */
+each line that needs to be drawn. These are basically extracted out of
+bit fields in the hardware registers. */
static int bplehb, bplham, bpldualpf, bpldualpfpri, bpldualpf2of, bplplanecnt, ecsshres;
-static int bplbypass;
+static int bplbypass, bplcolorburst, bplcolorburst_field;
+static bool issprites;
static int bplres;
-static int plf1pri, plf2pri, bplxor, bpland;
+static int plf1pri, plf2pri, bplxor, bpland, bpldelay_sh;
static uae_u32 plf_sprite_mask;
-static uae_u32 plf_sprite_mask_n16;
static int sbasecol[2] = { 16, 16 };
static int hposblank;
+static bool specialmonitoron;
+static bool ecs_genlock_features_active;
+static uae_u8 ecs_genlock_features_mask;
+static bool ecs_genlock_features_colorkey;
+static int hsync_shift_hack;
bool picasso_requested_on, picasso_requested_forced_on, picasso_on;
int inhibit_frame;
-int framecnt = 0;
+int framecnt;
+int custom_frame_redraw_necessary;
+static int frame_redraw_necessary;
+static int picasso_redraw_necessary;
-STATIC_INLINE void count_frame (void)
+/* Calculate idle time (time to wait for vsync) */
+int idletime_percent = 0;
+
+#define xlinecheck(start, end)
+
+static void clearbuffer(struct vidbuffer *dst)
{
- framecnt++;
- if (framecnt > currprefs.gfx_framerate)
+ if (!dst->bufmem_allocated)
+ return;
+ uae_u8 *p = dst->bufmem_allocated;
+ for (int y = 0; y < dst->height_allocated; y++) {
+ memset(p, 0, dst->width_allocated * dst->pixbytes);
+ p += dst->rowbytes;
+ }
+}
+
+static void reset_decision_table(void)
+{
+ for (int i = 0; i < sizeof linestate / sizeof *linestate; i++) {
+ linestate[i] = LINE_UNDECIDED;
+ }
+}
+
+STATIC_INLINE void count_frame()
+{
+ framecnt++;
+ if (framecnt > currprefs.gfx_framerate)
framecnt = 0;
- if (inhibit_frame)
- framecnt = 1;
+ if (inhibit_frame)
+ framecnt = 1;
}
-STATIC_INLINE int xshift (int x, int shift)
+STATIC_INLINE int xshift(int x, int shift)
{
- if (shift < 0)
- return x >> (-shift);
- else
- return x << shift;
+ if (shift < 0)
+ return x >> (-shift);
+ return x << shift;
}
-int coord_native_to_amiga_x (int x)
+int coord_native_to_amiga_x(int x)
{
- x += visible_left_border;
- x = xshift (x, 1 - lores_shift);
- return x + 2*DISPLAY_LEFT_SHIFT - 2*DIW_DDF_OFFSET;
+ x += visible_left_border;
+ x = xshift(x, 1 - lores_shift);
+ return x + 2 * DISPLAY_LEFT_SHIFT - 2 * DIW_DDF_OFFSET;
}
-int coord_native_to_amiga_y (int y)
+int coord_native_to_amiga_y(int y)
{
- return native2amiga_line_map[y];
+ return native2amiga_line_map[y] + thisframe_y_adjust - minfirstline;
}
-STATIC_INLINE int res_shift_from_window (int x)
+STATIC_INLINE int res_shift_from_window(int x)
{
- if (res_shift >= 0)
+ if (res_shift >= 0)
return x >> res_shift;
- return x << -res_shift;
+ return x << -res_shift;
}
-STATIC_INLINE int res_shift_from_amiga (int x)
+STATIC_INLINE int res_shift_from_amiga(int x)
{
- if (res_shift >= 0)
+ if (res_shift >= 0)
return x >> res_shift;
- return x << -res_shift;
+ return x << -res_shift;
}
-static struct decision *dp_for_drawing;
-static struct draw_info *dip_for_drawing;
+void notice_screen_contents_lost(void)
+{
+ picasso_redraw_necessary = 1;
+ frame_redraw_necessary = 2;
+}
+
+bool isnativevidbuf(void)
+{
+ // we always use the SDL surface as the drawbuffer
+ return true;
+}
+
+extern int plffirstline_total, plflastline_total;
+extern int first_planes_vpos, last_planes_vpos;
+extern int diwfirstword_total, diwlastword_total;
+extern int ddffirstword_total, ddflastword_total;
+extern bool vertical_changed, horizontal_changed;
+extern int firstword_bplcon1;
+extern int lof_store;
+
+#define MIN_DISPLAY_W 256
+#define MIN_DISPLAY_H 192
+#define MAX_DISPLAY_W 362
+#define MAX_DISPLAY_H 283
+
+static int gclow, gcloh, gclox, gcloy, gclorealh;
+static int stored_left_start, stored_top_start, stored_width, stored_height;
+
+void get_custom_topedge(int *xp, int *yp, bool max)
+{
+ if (isnativevidbuf() && !max) {
+ int x, y;
+ x = visible_left_border + (DISPLAY_LEFT_SHIFT << currprefs.gfx_resolution);
+ y = minfirstline << currprefs.gfx_vresolution;
+
+ *xp = x;
+ *yp = y;
+ }
+ else {
+ *xp = 0;
+ *yp = 0;
+ }
+}
+
+static void reset_custom_limits(void)
+{
+ gclow = gcloh = gclox = gcloy = 0;
+ gclorealh = -1;
+ center_reset = true;
+}
+
+static void set_blanking_limits(void)
+{
+ hblank_left_start = visible_left_start;
+ hblank_right_stop = visible_right_stop;
+
+ //if (programmedmode) {
+ // if (hblank_left_start < coord_hw_to_window_x(hsyncendpos * 2))
+ // hblank_left_start = coord_hw_to_window_x(hsyncendpos * 2);
+ // if (hblank_right_stop > coord_hw_to_window_x(hsyncstartpos * 2))
+ // hblank_right_stop = coord_hw_to_window_x(hsyncstartpos * 2);
+ //}
+}
+
+void get_custom_raw_limits(int *pw, int *ph, int *pdx, int *pdy)
+{
+ if (stored_width > 0) {
+ *pw = stored_width;
+ *ph = stored_height;
+ *pdx = stored_left_start;
+ *pdy = stored_top_start;
+ }
+ else {
+ int x = visible_left_border;
+ if (x < visible_left_start)
+ x = visible_left_start;
+ *pdx = x;
+ int x2 = visible_right_border;
+ if (x2 > visible_right_stop)
+ x2 = visible_right_stop;
+ *pw = x2 - x;
+ int y = min_ypos_for_screen;
+ if (y < visible_top_start)
+ y = visible_top_start;
+ *pdy = y;
+ int y2 = max_ypos_thisframe;
+ if (y2 > visible_bottom_stop)
+ y2 = visible_bottom_stop;
+ *ph = y2 - y;
+ }
+}
+
+void set_custom_limits(int w, int h, int dx, int dy)
+{
+ int vls = visible_left_start;
+ int vrs = visible_right_stop;
+ int vts = visible_top_start;
+ int vbs = visible_bottom_stop;
+
+ if (w <= 0 || dx < 0) {
+ visible_left_start = 0;
+ visible_right_stop = MAX_STOP;
+ }
+ else {
+ visible_left_start = visible_left_border + dx;
+ visible_right_stop = visible_left_start + w;
+ }
+ if (h <= 0 || dy < 0) {
+ visible_top_start = 0;
+ visible_bottom_stop = MAX_STOP;
+ }
+ else {
+ visible_top_start = min_ypos_for_screen + dy;
+ visible_bottom_stop = visible_top_start + h;
+ }
+ if (vls != visible_left_start || vrs != visible_right_stop ||
+ vts != visible_top_start || vbs != visible_bottom_stop)
+ notice_screen_contents_lost();
+
+ set_blanking_limits();
+}
+
+void store_custom_limits(int w, int h, int x, int y)
+{
+ stored_left_start = x;
+ stored_top_start = y;
+ stored_width = w;
+ stored_height = h;
+}
+
+int get_custom_limits(int *pw, int *ph, int *pdx, int *pdy, int *prealh)
+{
+ int w, h, dx, dy, y1, y2, dbl1, dbl2;
+ int ret = 0;
+
+ if (!pw || !ph || !pdx || !pdy) {
+ reset_custom_limits();
+ return 0;
+ }
+
+ if (!isnativevidbuf()) {
+ *pw = gfxvidinfo.outwidth;
+ *ph = gfxvidinfo.outheight;
+ *pdx = 0;
+ *pdy = 0;
+ *prealh = -1;
+ return 1;
+ }
+
+ *pw = gclow;
+ *ph = gcloh;
+ *pdx = gclox;
+ *pdy = gcloy;
+ *prealh = gclorealh;
+
+ if (gclow > 0 && gcloh > 0)
+ ret = -1;
+
+ if (interlace_seen) {
+ static int interlace_count;
+ // interlace = only use long frames
+ if (lof_store && (interlace_count & 1) == 0)
+ interlace_count++;
+ if (!lof_store && (interlace_count & 1) != 0)
+ interlace_count++;
+ if (interlace_count < 3)
+ return ret;
+ if (!lof_store)
+ return ret;
+ interlace_count = 0;
+ /* program may have set last visible line as last possible line (CD32 boot screen) */
+ if (last_planes_vpos < maxvpos)
+ last_planes_vpos++;
+ if (plflastline_total < maxvpos)
+ plflastline_total++;
+ }
+
+ if (plflastline_total < 4)
+ plflastline_total = last_planes_vpos;
+
+ ddffirstword_total = coord_hw_to_window_x(ddffirstword_total * 2 + DIW_DDF_OFFSET);
+ ddflastword_total = coord_hw_to_window_x(ddflastword_total * 2 + DIW_DDF_OFFSET);
+
+ if (doublescan <= 0 && !programmedmode) {
+ int min = coord_diw_to_window_x(92);
+ int max = coord_diw_to_window_x(460);
+ if (diwfirstword_total < min)
+ diwfirstword_total = min;
+ if (diwlastword_total > max)
+ diwlastword_total = max;
+ if (ddffirstword_total < min)
+ ddffirstword_total = min;
+ if (ddflastword_total > max)
+ ddflastword_total = max;
+ }
+
+ w = diwlastword_total - diwfirstword_total;
+ dx = diwfirstword_total - visible_left_border;
+
+ y2 = plflastline_total;
+ if (y2 > last_planes_vpos)
+ y2 = last_planes_vpos;
+ y1 = plffirstline_total;
+ if (first_planes_vpos > y1)
+ y1 = first_planes_vpos;
+ if (minfirstline > y1)
+ y1 = minfirstline;
+
+ dbl2 = dbl1 = currprefs.gfx_vresolution;
+ if (doublescan > 0 && interlace_seen <= 0) {
+ dbl1--;
+ dbl2--;
+ }
+
+ h = y2 - y1;
+ dy = y1 - minfirstline;
+
+ if (first_planes_vpos == 0) {
+ // no planes enabled during frame
+ if (ret < 0)
+ return 1;
+ h = currprefs.ntscmode ? 200 : 240;
+ w = 320 << currprefs.gfx_resolution;
+ dy = 36 / 2;
+ dx = 58;
+ }
+
+ if (dx < 0)
+ dx = 0;
+
+ *prealh = -1;
+ if (!programmedmode && first_planes_vpos) {
+ int th = (maxvpos - minfirstline) * 95 / 100;
+ if (th > h) {
+ th = xshift(th, dbl1);
+ *prealh = th;
+ }
+ }
+
+ dy = xshift(dy, dbl2);
+ h = xshift(h, dbl1);
+
+ if (w == 0 || h == 0)
+ return 0;
+
+ if (doublescan <= 0 && !programmedmode) {
+ if ((w >> currprefs.gfx_resolution) < MIN_DISPLAY_W) {
+ dx += (w - (MIN_DISPLAY_W << currprefs.gfx_resolution)) / 2;
+ w = MIN_DISPLAY_W << currprefs.gfx_resolution;
+ }
+ if ((h >> dbl1) < MIN_DISPLAY_H) {
+ dy += (h - (MIN_DISPLAY_H << dbl1)) / 2;
+ h = MIN_DISPLAY_H << dbl1;
+ }
+ if ((w >> currprefs.gfx_resolution) > MAX_DISPLAY_W) {
+ dx += (w - (MAX_DISPLAY_W << currprefs.gfx_resolution)) / 2;
+ w = MAX_DISPLAY_W << currprefs.gfx_resolution;
+ }
+ if ((h >> dbl1) > MAX_DISPLAY_H) {
+ dy += (h - (MAX_DISPLAY_H << dbl1)) / 2;
+ h = MAX_DISPLAY_H << dbl1;
+ }
+ }
+
+ if (gclow == w && gcloh == h && gclox == dx && gcloy == dy)
+ return ret;
+
+ if (w <= 0 || h <= 0 || dx < 0 || dy < 0)
+ return ret;
+ if (doublescan <= 0 && !programmedmode) {
+ if (dx > gfxvidinfo.outwidth / 3)
+ return ret;
+ if (dy > gfxvidinfo.outheight / 3)
+ return ret;
+ }
+
+ gclow = w;
+ gcloh = h;
+ gclox = dx;
+ gcloy = dy;
+ gclorealh = *prealh;
+ *pw = w;
+ *ph = h;
+ *pdx = dx;
+ *pdy = dy;
+#if 1
+ write_log(_T("Display Size: %dx%d Offset: %dx%d\n"), w, h, dx, dy);
+ write_log(_T("First: %d Last: %d MinV: %d MaxV: %d Min: %d\n"),
+ plffirstline_total, plflastline_total,
+ first_planes_vpos, last_planes_vpos, minfirstline);
+#endif
+ center_reset = true;
+ return 1;
+}
+
+void get_custom_mouse_limits(int *pw, int *ph, int *pdx, int *pdy, int dbl)
+{
+ int delay1, delay2;
+ int w, h, dx, dy, dbl1, dbl2, y1, y2;
+
+ w = diwlastword_total - diwfirstword_total;
+ dx = diwfirstword_total - visible_left_border;
+
+ y2 = plflastline_total;
+ if (y2 > last_planes_vpos)
+ y2 = last_planes_vpos;
+ y1 = plffirstline_total;
+ if (first_planes_vpos > y1)
+ y1 = first_planes_vpos;
+ if (minfirstline > y1)
+ y1 = minfirstline;
+
+ h = y2 - y1;
+ dy = y1 - minfirstline;
+
+ if (*pw > 0)
+ w = *pw;
+
+ w = xshift(w, res_shift);
+
+ if (*ph > 0)
+ h = *ph;
+
+ delay1 = (firstword_bplcon1 & 0x0f) | ((firstword_bplcon1 & 0x0c00) >> 6);
+ delay2 = ((firstword_bplcon1 >> 4) & 0x0f) | (((firstword_bplcon1 >> 4) & 0x0c00) >> 6);
+ // if (delay1 == delay2)
+ // dx += delay1;
+
+ dx = xshift(dx, res_shift);
+
+ dbl2 = dbl1 = currprefs.gfx_vresolution;
+ if ((doublescan > 0 || interlace_seen > 0) && !dbl) {
+ dbl1--;
+ dbl2--;
+ }
+ if (interlace_seen > 0)
+ dbl2++;
+ if (interlace_seen <= 0 && dbl)
+ dbl2--;
+ h = xshift(h, dbl1);
+ dy = xshift(dy, dbl2);
+
+ if (w < 1)
+ w = 1;
+ if (h < 1)
+ h = 1;
+ if (dx < 0)
+ dx = 0;
+ if (dy < 0)
+ dy = 0;
+ *pw = w; *ph = h;
+ *pdx = dx; *pdy = dy;
+}
+
+static struct decision* dp_for_drawing;
+static struct draw_info* dip_for_drawing;
+
+/* Record DIW of the current line for use by centering code. */
+void record_diw_line(int plfstrt, int first, int last)
+{
+ if (last > max_diwstop)
+ max_diwstop = last;
+ if (first < min_diwstart) {
+ min_diwstart = first;
+ }
+}
+
+STATIC_INLINE int get_shdelay_add(void)
+{
+ if (bplres == RES_SUPERHIRES)
+ return 0;
+ int add = bpldelay_sh;
+ add >>= RES_MAX - currprefs.gfx_resolution;
+ return add;
+}
/*
* Screen update macros/functions
@@ -254,6 +717,7 @@ static int playfield_start, playfield_end;
static int real_playfield_start, real_playfield_end;
static int sprite_playfield_start;
static bool may_require_hard_way;
+static int linetoscr_diw_start, linetoscr_diw_end;
static int native_ddf_left, native_ddf_right;
static int pixels_offset;
@@ -261,7 +725,7 @@ static int src_pixel;
/* How many pixels in window coordinates which are to the left of the left border. */
static int unpainted;
-STATIC_INLINE xcolnr getbgc (bool blank)
+STATIC_INLINE xcolnr getbgc(bool blank)
{
return (blank || hposblank || ce_is_borderblank(colors_for_drawing.extra)) ? 0 : colors_for_drawing.acolors[0];
}
@@ -275,31 +739,35 @@ static void set_res_shift(int shift)
}
/* Initialize the variables necessary for drawing a line.
- * This involves setting up start/stop positions and display window
- * borders. */
-static void pfield_init_linetoscr (bool border)
+* This involves setting up start/stop positions and display window
+* borders. */
+static void pfield_init_linetoscr(bool border)
{
/* First, get data fetch start/stop in DIW coordinates. */
int ddf_left = dp_for_drawing->plfleft * 2 + DIW_DDF_OFFSET;
int ddf_right = dp_for_drawing->plfright * 2 + DIW_DDF_OFFSET;
int leftborderhidden;
- bool expanded = false;
+ int native_ddf_left2;
+
+ hsync_shift_hack = 0;
if (border)
ddf_left = DISPLAY_LEFT_SHIFT;
/* Compute datafetch start/stop in pixels; native display coordinates. */
- native_ddf_left = coord_hw_to_window_x (ddf_left);
- native_ddf_right = coord_hw_to_window_x (ddf_right);
+ native_ddf_left = coord_hw_to_window_x(ddf_left);
+ native_ddf_right = coord_hw_to_window_x(ddf_right);
+ // Blerkenwiegel/Scoopex workaround
+ native_ddf_left2 = native_ddf_left;
if (native_ddf_left < 0)
native_ddf_left = 0;
if (native_ddf_right < native_ddf_left)
native_ddf_right = native_ddf_left;
- int linetoscr_diw_start = dp_for_drawing->diwfirstword;
- int linetoscr_diw_end = dp_for_drawing->diwlastword;
+ linetoscr_diw_start = dp_for_drawing->diwfirstword;
+ linetoscr_diw_end = dp_for_drawing->diwlastword;
/* Perverse cases happen. */
if (linetoscr_diw_end < linetoscr_diw_start)
@@ -334,30 +802,25 @@ static void pfield_init_linetoscr (bool border)
if (dip_for_drawing->nr_sprites) {
if (!ce_is_borderblank(colors_for_drawing.extra)) {
/* bordersprite off or not supported: sprites are visible until diw_end */
- if (playfield_end < linetoscr_diw_end && MAX_STOP > playfield_end) {
+ if (playfield_end < linetoscr_diw_end && hblank_right_stop > playfield_end) {
playfield_end = linetoscr_diw_end;
}
- int left = coord_hw_to_window_x (dp_for_drawing->plfleft * 2);
+ int left = coord_hw_to_window_x(dp_for_drawing->plfleft * 2);
if (left < visible_left_border)
left = visible_left_border;
if (left < playfield_start && left >= linetoscr_diw_start) {
playfield_start = left;
}
- } else {
+ }
+ else {
sprite_playfield_start = 0;
- if (playfield_end < linetoscr_diw_end && MAX_STOP > playfield_end) {
+ if (playfield_end < linetoscr_diw_end && hblank_right_stop > playfield_end) {
playfield_end = linetoscr_diw_end;
}
}
}
- // if BPLCON4 is non-zero: it will affect background color until end of DIW.
- if (dp_for_drawing->xor_seen) {
- if (playfield_end < linetoscr_diw_end && MAX_STOP > playfield_end) {
- playfield_end = linetoscr_diw_end;
- expanded = true;
- }
- }
+#ifdef AGA
may_require_hard_way = false;
if (dp_for_drawing->bordersprite_seen && !ce_is_borderblank(colors_for_drawing.extra) && dip_for_drawing->nr_sprites) {
int min = visible_right_border, max = visible_left_border, i;
@@ -371,8 +834,8 @@ static void pfield_init_linetoscr (bool border)
if (x > max)
max = x;
}
- min = coord_hw_to_window_x (min >> sprite_buffer_res) + (DIW_DDF_OFFSET << lores_shift);
- max = coord_hw_to_window_x (max >> sprite_buffer_res) + (DIW_DDF_OFFSET << lores_shift);
+ min = coord_hw_to_window_x(min >> sprite_buffer_res) + (DIW_DDF_OFFSET << lores_shift);
+ max = coord_hw_to_window_x(max >> sprite_buffer_res) + (DIW_DDF_OFFSET << lores_shift);
if (min < playfield_start)
playfield_start = min;
@@ -385,9 +848,10 @@ static void pfield_init_linetoscr (bool border)
sprite_playfield_start = 0;
may_require_hard_way = true;
}
+#endif
unpainted = visible_left_border < playfield_start ? 0 : visible_left_border - playfield_start;
- unpainted = res_shift_from_window (unpainted);
+ unpainted = res_shift_from_window(unpainted);
int first_x = sprite_first_x;
int last_x = sprite_last_x;
@@ -403,87 +867,107 @@ static void pfield_init_linetoscr (bool border)
if (last_x > MAX_PIXELS_PER_LINE - 2)
last_x = MAX_PIXELS_PER_LINE - 2;
if (first_x < last_x)
- memset (spritepixels + first_x, 0, sizeof (struct spritepixelsbuf) * (last_x - first_x + 1));
+ memset(spritepixels + first_x, 0, sizeof(struct spritepixelsbuf) * (last_x - first_x + 1));
}
- sprite_last_x = 0;
- sprite_first_x = MAX_PIXELS_PER_LINE - 1;
+ sprite_last_x = 0;
+ sprite_first_x = MAX_PIXELS_PER_LINE - 1;
/* Now, compute some offsets. */
ddf_left -= DISPLAY_LEFT_SHIFT;
- if (ddf_left < 0)
- ddf_left = 0;
pixels_offset = MAX_PIXELS_PER_LINE - (ddf_left << bplres);
ddf_left <<= bplres;
- leftborderhidden = playfield_start - native_ddf_left;
- src_pixel = MAX_PIXELS_PER_LINE + res_shift_from_window (leftborderhidden);
+ leftborderhidden = playfield_start - native_ddf_left2;
+ if (hblank_left_start > playfield_start)
+ leftborderhidden += hblank_left_start - playfield_start;
+ src_pixel = MAX_PIXELS_PER_LINE + res_shift_from_window(leftborderhidden);
- if (dip_for_drawing->nr_sprites == 0 && !expanded)
+ if (dip_for_drawing->nr_sprites == 0)
return;
+ if (aga_mode) {
+ int add = get_shdelay_add();
+ if (add) {
+ if (sprite_playfield_start > 0) {
+ sprite_playfield_start -= add;
+ }
+ else {
+ ;// this is most likely wrong: playfield_start -= add;
+ }
+ }
+ }
+
/* We need to clear parts of apixels. */
if (linetoscr_diw_start < native_ddf_left) {
- int size = res_shift_from_window (native_ddf_left - linetoscr_diw_start);
+ int size = res_shift_from_window(native_ddf_left - linetoscr_diw_start);
linetoscr_diw_start = native_ddf_left;
- memset (pixdata.apixels + MAX_PIXELS_PER_LINE - size, 0, size);
+ memset(pixdata.apixels + MAX_PIXELS_PER_LINE - size, 0, size);
}
if (linetoscr_diw_end > native_ddf_right) {
- int pos = res_shift_from_window (native_ddf_right - native_ddf_left);
- int size = res_shift_from_window (linetoscr_diw_end - native_ddf_right);
- if (pos + size > MAX_PIXELS_PER_LINE)
- size = MAX_PIXELS_PER_LINE - pos;
- if (size > 0)
- memset (pixdata.apixels + MAX_PIXELS_PER_LINE + pos, 0, size);
+ int pos = res_shift_from_window(native_ddf_right - native_ddf_left);
+ int size = res_shift_from_window(linetoscr_diw_end - native_ddf_right);
linetoscr_diw_start = native_ddf_left;
+ memset(pixdata.apixels + MAX_PIXELS_PER_LINE + pos, 0, size);
}
}
// erase sprite graphics in pixdata if they were outside of ddf
-static void pfield_erase_hborder_sprites (void)
+static void pfield_erase_hborder_sprites(void)
{
if (sprite_first_x < native_ddf_left) {
- int size = res_shift_from_window (native_ddf_left - sprite_first_x);
- memset (pixdata.apixels + MAX_PIXELS_PER_LINE - size, 0, size);
+ int size = res_shift_from_window(native_ddf_left - sprite_first_x);
+ memset(pixdata.apixels + MAX_PIXELS_PER_LINE - size, 0, size);
}
if (sprite_last_x > native_ddf_right) {
- int pos = res_shift_from_window (native_ddf_right - native_ddf_left);
- int size = res_shift_from_window (sprite_last_x - native_ddf_right);
- if (pos + size > MAX_PIXELS_PER_LINE)
- size = MAX_PIXELS_PER_LINE - pos;
- if (size > 0)
- memset (pixdata.apixels + MAX_PIXELS_PER_LINE + pos, 0, size);
+ int pos = res_shift_from_window(native_ddf_right - native_ddf_left);
+ int size = res_shift_from_window(sprite_last_x - native_ddf_right);
+ memset(pixdata.apixels + MAX_PIXELS_PER_LINE + pos, 0, size);
}
}
// erase whole viewable area if sprite in upper or lower border
-static void pfield_erase_vborder_sprites (void)
+static void pfield_erase_vborder_sprites(void)
{
if (visible_right_border <= visible_left_border)
return;
int pos = 0;
int size = 0;
if (visible_left_border < native_ddf_left) {
- size = res_shift_from_window (native_ddf_left - visible_left_border);
+ size = res_shift_from_window(native_ddf_left - visible_left_border);
pos = -size;
}
if (visible_right_border > native_ddf_left)
- size += res_shift_from_window (visible_right_border - native_ddf_left);
- memset (pixdata.apixels + MAX_PIXELS_PER_LINE - pos, 0, size);
+ size += res_shift_from_window(visible_right_border - native_ddf_left);
+ memset(pixdata.apixels + MAX_PIXELS_PER_LINE - pos, 0, size);
}
+STATIC_INLINE uae_u16 merge_2pixel16(uae_u16 p1, uae_u16 p2)
+{
+ uae_u16 v = ((((p1 >> xredcolor_s) & xredcolor_m) + ((p2 >> xredcolor_s) & xredcolor_m)) / 2) << xredcolor_s;
+ v |= ((((p1 >> xbluecolor_s) & xbluecolor_m) + ((p2 >> xbluecolor_s) & xbluecolor_m)) / 2) << xbluecolor_s;
+ v |= ((((p1 >> xgreencolor_s) & xgreencolor_m) + ((p2 >> xgreencolor_s) & xgreencolor_m)) / 2) << xgreencolor_s;
+ return v;
+}
+STATIC_INLINE uae_u32 merge_2pixel32(uae_u32 p1, uae_u32 p2)
+{
+ uae_u32 v = ((((p1 >> 16) & 0xff) + ((p2 >> 16) & 0xff)) / 2) << 16;
+ v |= ((((p1 >> 8) & 0xff) + ((p2 >> 8) & 0xff)) / 2) << 8;
+ v |= ((((p1 >> 0) & 0xff) + ((p2 >> 0) & 0xff)) / 2) << 0;
+ return v;
+}
-STATIC_INLINE void fill_line_16 (uae_u8 *buf, int start, int stop, bool blank)
+STATIC_INLINE void fill_line_16(uae_u8 *buf, int start, int stop, bool blank)
{
uae_u16 *b = (uae_u16 *)buf;
unsigned int i;
unsigned int rem = 0;
- xcolnr col = getbgc (blank);
- if (((uintptr_t)&b[start]) & 3)
- b[start++] = (uae_u16) col;
+ xcolnr col = getbgc(blank);
+ if (((uintptr_t)&b[start]) & 1)
+ b[start++] = (uae_u16)col;
if (start >= stop)
return;
- if (((uintptr_t)&b[stop]) & 3) {
+ if (((uintptr_t)&b[stop]) & 1) {
rem++;
stop--;
}
@@ -495,36 +979,55 @@ STATIC_INLINE void fill_line_16 (uae_u8 *buf, int start, int stop, bool blank)
b[stop] = (uae_u16)col;
}
-static void pfield_do_fill_line (int start, int stop, bool blank)
+STATIC_INLINE void fill_line_32(uae_u8 *buf, int start, int stop, bool blank)
+{
+ uae_u32 *b = (uae_u32 *)buf;
+ unsigned int i;
+ xcolnr col = getbgc(blank);
+ for (i = start; i < stop; i++)
+ b[i] = col;
+}
+
+static void pfield_do_fill_line(int start, int stop, bool blank)
{
if (stop <= start)
return;
- fill_line_16 (xlinebuffer, start, stop, blank);
+ switch (gfxvidinfo.pixbytes) {
+ case 2: fill_line_16(xlinebuffer, start, stop, blank); break;
+ case 4: fill_line_32(xlinebuffer, start, stop, blank); break;
+ }
+ if (need_genlock_data) {
+ memset(xlinebuffer_genlock + start, 0, stop - start);
+ }
}
-static void fill_line2 (int startpos, int len)
+static void fill_line2(int startpos, int len)
{
int shift;
int nints, nrem;
int *start;
xcolnr val;
+ shift = 0;
+ if (gfxvidinfo.pixbytes == 2)
shift = 1;
+ if (gfxvidinfo.pixbytes == 4)
+ shift = 2;
nints = len >> (2 - shift);
nrem = nints & 7;
nints &= ~7;
start = (int *)(((uae_u8*)xlinebuffer) + (startpos << shift));
- val = getbgc (false);
+ val = getbgc(false);
for (; nints > 0; nints -= 8, start += 8) {
*start = val;
- *(start+1) = val;
- *(start+2) = val;
- *(start+3) = val;
- *(start+4) = val;
- *(start+5) = val;
- *(start+6) = val;
- *(start+7) = val;
+ *(start + 1) = val;
+ *(start + 2) = val;
+ *(start + 3) = val;
+ *(start + 4) = val;
+ *(start + 5) = val;
+ *(start + 6) = val;
+ *(start + 7) = val;
}
switch (nrem) {
@@ -545,72 +1048,126 @@ static void fill_line2 (int startpos, int len)
}
}
-STATIC_INLINE void fill_line_border (int lineno)
+static void fill_line_border(int lineno)
{
int lastpos = visible_left_border;
- int endpos = visible_left_border + gfxvidinfo.drawbuffer.outwidth;
+ int endpos = visible_left_border + gfxvidinfo.outwidth;
+
+ if (lineno < visible_top_start || lineno >= visible_bottom_stop) {
+ int b = hposblank;
+ hposblank = 3;
+ fill_line2(lastpos, gfxvidinfo.outwidth);
+ if (need_genlock_data) {
+ memset(xlinebuffer_genlock + lastpos, 0, gfxvidinfo.outwidth);
+ }
+ hposblank = b;
+ return;
+ }
// full hblank
if (hposblank) {
hposblank = 3;
- fill_line2(lastpos, gfxvidinfo.drawbuffer.outwidth);
+ fill_line2(lastpos, gfxvidinfo.outwidth);
+ if (need_genlock_data) {
+ memset(xlinebuffer_genlock + lastpos, 0, gfxvidinfo.outwidth);
+ }
return;
}
-
// hblank not visible
- if (0 <= lastpos && MAX_STOP >= endpos) {
- fill_line2(lastpos, gfxvidinfo.drawbuffer.outwidth);
+ if (hblank_left_start <= lastpos && hblank_right_stop >= endpos) {
+ fill_line2(lastpos, gfxvidinfo.outwidth);
+ if (need_genlock_data) {
+ memset(xlinebuffer_genlock + lastpos, 0, gfxvidinfo.outwidth);
+ }
return;
}
+ // left, right or both hblanks visible
+ if (lastpos < hblank_left_start) {
+ int t = hblank_left_start < endpos ? hblank_left_start : endpos;
+ pfield_do_fill_line(lastpos, t, true);
+ lastpos = t;
+ }
+ if (lastpos < hblank_right_stop) {
+ int t = hblank_right_stop < endpos ? hblank_right_stop : endpos;
+ pfield_do_fill_line(lastpos, t, false);
+ lastpos = t;
+ }
if (lastpos < endpos) {
pfield_do_fill_line(lastpos, endpos, true);
}
}
-static uae_u8 render_sprites (int pos, int dualpf, uae_u8 apixel, int aga)
+static int sprite_shdelay;
+#define SPRITE_DEBUG 0
+static uae_u8 render_sprites(int pos, int dualpf, uae_u8 apixel, int aga)
{
struct spritepixelsbuf *spb = &spritepixels[pos];
unsigned int v = spb->data;
- int *shift_lookup = bpldualpfpri ? dblpf_ms2 : dblpf_ms1;
+ int *shift_lookup = dualpf ? (bpldualpfpri ? dblpf_ms2 : dblpf_ms1) : dblpf_ms;
int maskshift, plfmask;
+ // shdelay hack, above &spritepixels[pos] is correct.
+ pos += sprite_shdelay;
/* The value in the shift lookup table is _half_ the shift count we
need. This is because we can't shift 32 bits at once (undefined
behaviour in C). */
-
- if(dualpf) {
- maskshift = shift_lookup[apixel];
- plfmask = (plf_sprite_mask >> maskshift) >> maskshift;
- v &= ~plfmask;
- } else {
- if(apixel)
- v &= plf_sprite_mask_n16;
- }
-
+ maskshift = shift_lookup[apixel];
+ plfmask = (plf_sprite_mask >> maskshift) >> maskshift;
+ v &= ~plfmask;
/* Extra 1 sprite pixel at DDFSTRT is only possible if at least 1 plane is active */
- if ((bplplanecnt > 0 || pos >= sprite_playfield_start) && (v != 0)) {
- unsigned int col;
+ if ((bplplanecnt > 0 || pos >= sprite_playfield_start) && (v != 0 || SPRITE_DEBUG)) {
+ unsigned int vlo, vhi, col;
+ unsigned int v1 = v & 255;
+ /* OFFS determines the sprite pair with the highest priority that has
+ any bits set. E.g. if we have 0xFF00 in the buffer, we have sprite
+ pairs 01 and 23 cleared, and pairs 45 and 67 set, so OFFS will
+ have a value of 4.
+ 2 * OFFS is the bit number in V of the sprite pair, and it also
+ happens to be the color offset for that pair.
+ */
+ int offs;
+ if (v1 == 0)
+ offs = 4 + sprite_offs[v >> 8];
+ else
+ offs = sprite_offs[v1];
- if (spb->attach) {
- int offs = sprite_bit[v];
- if (spb->stdata & offs) {
- if (aga)
- col = sprite_col_at[v] + sbasecol[1];
- else
- col = sprite_col_at[v] + 16;
- return col;
- }
- }
-
- if (aga) {
- int offs = sprite_bit[v];
- if (offs & 0x55)
- col = sprite_col_nat[v] + sbasecol[0];
+ /* Shift highest priority sprite pair down to bit zero. */
+ v >>= offs * 2;
+ v &= 15;
+#if SPRITE_DEBUG > 0
+ v ^= 8;
+#endif
+ if (spb->attach && (spb->stdata & (3 << offs))) {
+ col = v;
+ if (aga)
+ col += sbasecol[1];
else
- col = sprite_col_nat[v] + sbasecol[1];
- } else {
- col = sprite_col_nat[v] + 16;
+ col += 16;
+ }
+ else {
+ /* This sequence computes the correct color value. We have to select
+ either the lower-numbered or the higher-numbered sprite in the pair.
+ We have to select the high one if the low one has all bits zero.
+ If the lower-numbered sprite has any bits nonzero, (VLO - 1) is in
+ the range of 0..2, and with the mask and shift, VHI will be zero.
+ If the lower-numbered sprite is zero, (VLO - 1) is a mask of
+ 0xFFFFFFFF, and we select the bits of the higher numbered sprite
+ in VHI.
+ This is _probably_ more efficient than doing it with branches. */
+ vlo = v & 3;
+ vhi = (v & (vlo - 1)) >> 2;
+ col = (vlo | vhi);
+ if (aga) {
+ if (vhi > 0)
+ col += sbasecol[1];
+ else
+ col += sbasecol[0];
+ }
+ else {
+ col += 16;
+ }
+ col += offs * 2;
}
return col;
@@ -619,22 +1176,58 @@ static uae_u8 render_sprites (int pos, int dualpf, uae_u8 apixel, int aga)
return 0;
}
+static bool get_genlock_very_rare_and_complex_case(uae_u8 v)
+{
+ // border color without BRDNTRAN bit set = transparent
+ if (v == 0 && !ce_is_borderntrans(colors_for_drawing.extra))
+ return false;
+ if (ecs_genlock_features_colorkey) {
+ // color key match?
+ if (currprefs.chipset_mask & CSMASK_AGA) {
+ if (colors_for_drawing.color_regs_aga[v] & 0x80000000)
+ return false;
+ }
+ else {
+ if (colors_for_drawing.color_regs_ecs[v] & 0x8000)
+ return false;
+ }
+ }
+ // plane mask match?
+ if (v & ecs_genlock_features_mask)
+ return false;
+ return true;
+}
+// false = transparent
+STATIC_INLINE bool get_genlock_transparency(uae_u8 v)
+{
+ if (!ecs_genlock_features_active) {
+ if (v == 0)
+ return false;
+ return true;
+ }
+ else {
+ return get_genlock_very_rare_and_complex_case(v);
+ }
+}
+
#include "linetoscr.cpp"
+#define LTPARMS src_pixel, start, stop
+
/* ECS SuperHires special cases */
#define PUTBPIX(x) buf[dpix] = (x);
-STATIC_INLINE uae_u32 shsprite (int dpix, uae_u32 spix_val, uae_u32 v, int spr)
+STATIC_INLINE uae_u32 shsprite(int dpix, uae_u32 spix_val, uae_u32 v, int spr)
{
uae_u8 sprcol;
uae_u16 scol;
if (!spr)
return v;
- sprcol = render_sprites (dpix, 0, spix_val, 0);
+ sprcol = render_sprites(dpix, 0, spix_val, 0);
if (!sprcol)
return v;
- /* good enough for now.. */
+ /* good enough for now.. */
scol = colors_for_drawing.color_regs_ecs[sprcol] & 0xccc;
scol |= scol >> 2;
return xcolors[scol];
@@ -642,7 +1235,7 @@ STATIC_INLINE uae_u32 shsprite (int dpix, uae_u32 spix_val, uae_u32 v, int spr)
static int NOINLINE linetoscr_16_sh_func(int spix, int dpix, int stoppos, int spr)
{
- uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u16 *buf = (uae_u16 *)xlinebuffer;
while (dpix < stoppos) {
uae_u16 spix_val1, spix_val2;
@@ -651,13 +1244,13 @@ static int NOINLINE linetoscr_16_sh_func(int spix, int dpix, int stoppos, int sp
spix_val1 = pixdata.apixels[spix++];
spix_val2 = pixdata.apixels[spix++];
off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
- v = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;
+ v = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;
v |= v >> 2;
- PUTBPIX(shsprite (dpix, spix_val1, xcolors[v], spr));
+ PUTBPIX(shsprite(dpix, spix_val1, xcolors[v], spr));
dpix++;
- v = (colors_for_drawing.color_regs_ecs[off] & 0x333) << 2;
+ v = (colors_for_drawing.color_regs_ecs[off] & 0x333) << 2;
v |= v >> 2;
- PUTBPIX(shsprite (dpix, spix_val2, xcolors[v], spr));
+ PUTBPIX(shsprite(dpix, spix_val2, xcolors[v], spr));
dpix++;
}
return spix;
@@ -670,20 +1263,106 @@ static int linetoscr_16_sh(int spix, int dpix, int stoppos)
{
return linetoscr_16_sh_func(spix, dpix, stoppos, false);
}
+static int NOINLINE linetoscr_32_sh_func(int spix, int dpix, int stoppos, int spr)
+{
+ uae_u32 *buf = (uae_u32 *)xlinebuffer;
+
+ while (dpix < stoppos) {
+ uae_u32 spix_val1, spix_val2;
+ uae_u16 v;
+ int off;
+ spix_val1 = pixdata.apixels[spix++];
+ spix_val2 = pixdata.apixels[spix++];
+ off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
+ v = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;
+ v |= v >> 2;
+ PUTBPIX(shsprite(dpix, spix_val1, xcolors[v], spr));
+ dpix++;
+ v = (colors_for_drawing.color_regs_ecs[off] & 0x333) << 2;
+ v |= v >> 2;
+ PUTBPIX(shsprite(dpix, spix_val2, xcolors[v], spr));
+ dpix++;
+ }
+ return spix;
+}
+static int linetoscr_32_sh_spr(int spix, int dpix, int stoppos)
+{
+ return linetoscr_32_sh_func(spix, dpix, stoppos, true);
+}
+static int linetoscr_32_sh(int spix, int dpix, int stoppos)
+{
+ return linetoscr_32_sh_func(spix, dpix, stoppos, false);
+}
+static int NOINLINE linetoscr_32_shrink1_sh_func(int spix, int dpix, int stoppos, int spr)
+{
+ uae_u32 *buf = (uae_u32 *)xlinebuffer;
+
+ while (dpix < stoppos) {
+ uae_u32 spix_val1, spix_val2;
+ uae_u16 v;
+ int off;
+ spix_val1 = pixdata.apixels[spix++];
+ spix_val2 = pixdata.apixels[spix++];
+ off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
+ v = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;
+ v |= v >> 2;
+ PUTBPIX(shsprite(dpix, spix_val1, xcolors[v], spr));
+ dpix++;
+ }
+ return spix;
+}
+static int linetoscr_32_shrink1_sh_spr(int spix, int dpix, int stoppos)
+{
+ return linetoscr_32_shrink1_sh_func(spix, dpix, stoppos, true);
+}
+static int linetoscr_32_shrink1_sh(int spix, int dpix, int stoppos)
+{
+ return linetoscr_32_shrink1_sh_func(spix, dpix, stoppos, false);
+}
+static int NOINLINE linetoscr_32_shrink1f_sh_func(int spix, int dpix, int stoppos, int spr)
+{
+ uae_u32 *buf = (uae_u32 *)xlinebuffer;
+
+ while (dpix < stoppos) {
+ uae_u32 spix_val1, spix_val2, dpix_val1, dpix_val2;
+ uae_u16 v;
+ int off;
+ spix_val1 = pixdata.apixels[spix++];
+ spix_val2 = pixdata.apixels[spix++];
+ off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
+ v = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;
+ v |= v >> 2;
+ dpix_val1 = xcolors[v];
+ v = (colors_for_drawing.color_regs_ecs[off] & 0x333) << 2;
+ v |= v >> 2;
+ dpix_val2 = xcolors[v];
+ PUTBPIX(shsprite(dpix, spix_val1, merge_2pixel32(dpix_val1, dpix_val2), spr));
+ dpix++;
+ }
+ return spix;
+}
+static int linetoscr_32_shrink1f_sh_spr(int spix, int dpix, int stoppos)
+{
+ return linetoscr_32_shrink1f_sh_func(spix, dpix, stoppos, true);
+}
+static int linetoscr_32_shrink1f_sh(int spix, int dpix, int stoppos)
+{
+ return linetoscr_32_shrink1f_sh_func(spix, dpix, stoppos, false);
+}
static int NOINLINE linetoscr_16_shrink1_sh_func(int spix, int dpix, int stoppos, int spr)
{
- uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u16 *buf = (uae_u16 *)xlinebuffer;
while (dpix < stoppos) {
uae_u16 spix_val1, spix_val2;
uae_u16 v;
int off;
- spix_val1 = pixdata.apixels[spix++];
- spix_val2 = pixdata.apixels[spix++];
- off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
- v = (colors_for_drawing.color_regs_ecs[off] & 0xccc);
- v |= v >> 2;
- PUTBPIX(shsprite (dpix, spix_val1, xcolors[v], spr));
+ spix_val1 = pixdata.apixels[spix++];
+ spix_val2 = pixdata.apixels[spix++];
+ off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
+ v = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;
+ v |= v >> 2;
+ PUTBPIX(shsprite(dpix, spix_val1, xcolors[v], spr));
dpix++;
}
return spix;
@@ -696,21 +1375,119 @@ static int linetoscr_16_shrink1_sh(int spix, int dpix, int stoppos)
{
return linetoscr_16_shrink1_sh_func(spix, dpix, stoppos, false);
}
+static int NOINLINE linetoscr_16_shrink1f_sh_func(int spix, int dpix, int stoppos, int spr)
+{
+ uae_u16 *buf = (uae_u16 *)xlinebuffer;
+
+ while (dpix < stoppos) {
+ uae_u16 spix_val1, spix_val2, dpix_val1, dpix_val2;
+ uae_u16 v;
+ int off;
+ spix_val1 = pixdata.apixels[spix++];
+ spix_val2 = pixdata.apixels[spix++];
+ off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
+ v = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;
+ v |= v >> 2;
+ dpix_val1 = xcolors[v];
+ v = (colors_for_drawing.color_regs_ecs[off] & 0x333) << 2;
+ v |= v >> 2;
+ dpix_val2 = xcolors[v];
+ PUTBPIX(shsprite(dpix, spix_val1, merge_2pixel16(dpix_val1, dpix_val2), spr));
+ dpix++;
+ }
+ return spix;
+}
+static int linetoscr_16_shrink1f_sh_spr(int spix, int dpix, int stoppos)
+{
+ return linetoscr_16_shrink1f_sh_func(spix, dpix, stoppos, true);
+}
+static int linetoscr_16_shrink1f_sh(int spix, int dpix, int stoppos)
+{
+ return linetoscr_16_shrink1f_sh_func(spix, dpix, stoppos, false);
+}
+static int NOINLINE linetoscr_32_shrink2_sh_func(int spix, int dpix, int stoppos, int spr)
+{
+ uae_u32 *buf = (uae_u32 *)xlinebuffer;
+
+ while (dpix < stoppos) {
+ uae_u32 spix_val1, spix_val2;
+ uae_u16 v;
+ int off;
+ spix_val1 = pixdata.apixels[spix++];
+ spix_val2 = pixdata.apixels[spix++];
+ off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
+ v = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;
+ v |= v >> 2;
+ PUTBPIX(shsprite(dpix, spix_val1, xcolors[v], spr));
+ spix += 2;
+ dpix++;
+ }
+ return spix;
+}
+static int linetoscr_32_shrink2_sh_spr(int spix, int dpix, int stoppos)
+{
+ return linetoscr_32_shrink2_sh_func(spix, dpix, stoppos, true);
+}
+static int linetoscr_32_shrink2_sh(int spix, int dpix, int stoppos)
+{
+ return linetoscr_32_shrink2_sh_func(spix, dpix, stoppos, false);
+}
+static int NOINLINE linetoscr_32_shrink2f_sh_func(int spix, int dpix, int stoppos, int spr)
+{
+ uae_u32 *buf = (uae_u32 *)xlinebuffer;
+
+ while (dpix < stoppos) {
+ uae_u32 spix_val1, spix_val2, dpix_val1, dpix_val2, dpix_val3, dpix_val4;
+ uae_u16 v;
+ int off;
+ spix_val1 = pixdata.apixels[spix++];
+ spix_val2 = pixdata.apixels[spix++];
+ off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
+ v = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;
+ v |= v >> 2;
+ dpix_val1 = xcolors[v];
+ v = (colors_for_drawing.color_regs_ecs[off] & 0x333) << 2;
+ v |= v >> 2;
+ dpix_val2 = xcolors[v];
+ dpix_val3 = merge_2pixel32(dpix_val1, dpix_val2);
+ spix_val1 = pixdata.apixels[spix++];
+ spix_val2 = pixdata.apixels[spix++];
+ off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
+ v = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;
+ v |= v >> 2;
+ dpix_val1 = xcolors[v];
+ v = (colors_for_drawing.color_regs_ecs[off] & 0x333) << 2;
+ v |= v >> 2;
+ dpix_val2 = xcolors[v];
+ dpix_val4 = merge_2pixel32(dpix_val1, dpix_val2);
+ PUTBPIX(shsprite(dpix, spix_val1, merge_2pixel32(dpix_val3, dpix_val4), spr));
+ dpix++;
+ }
+ return spix;
+}
+static int linetoscr_32_shrink2f_sh_spr(int spix, int dpix, int stoppos)
+{
+ return linetoscr_32_shrink2f_sh_func(spix, dpix, stoppos, true);
+}
+static int linetoscr_32_shrink2f_sh(int spix, int dpix, int stoppos)
+{
+ return linetoscr_32_shrink2f_sh_func(spix, dpix, stoppos, false);
+}
static int NOINLINE linetoscr_16_shrink2_sh_func(int spix, int dpix, int stoppos, int spr)
{
- uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u16 *buf = (uae_u16 *)xlinebuffer;
while (dpix < stoppos) {
uae_u16 spix_val1, spix_val2;
uae_u16 v;
int off;
- spix_val1 = pixdata.apixels[spix++];
- spix_val2 = pixdata.apixels[spix++];
- off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
- v = (colors_for_drawing.color_regs_ecs[off] & 0xccc);
+ spix_val1 = pixdata.apixels[spix++];
+ spix_val2 = pixdata.apixels[spix++];
+ off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
+ v = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;
v |= v >> 2;
- PUTBPIX(shsprite (dpix, spix_val1, xcolors[v], spr));
- spix+=2;
+ PUTBPIX(shsprite(dpix, spix_val1, xcolors[v], spr));
+ spix += 2;
dpix++;
}
return spix;
@@ -723,6 +1500,47 @@ static int linetoscr_16_shrink2_sh(int spix, int dpix, int stoppos)
{
return linetoscr_16_shrink2_sh_func(spix, dpix, stoppos, false);
}
+static int NOINLINE linetoscr_16_shrink2f_sh_func(int spix, int dpix, int stoppos, int spr)
+{
+ uae_u16 *buf = (uae_u16 *)xlinebuffer;
+
+ while (dpix < stoppos) {
+ uae_u16 spix_val1, spix_val2, dpix_val1, dpix_val2, dpix_val3, dpix_val4;
+ uae_u16 v;
+ int off;
+ spix_val1 = pixdata.apixels[spix++];
+ spix_val2 = pixdata.apixels[spix++];
+ off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
+ v = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;
+ v |= v >> 2;
+ dpix_val1 = xcolors[v];
+ v = (colors_for_drawing.color_regs_ecs[off] & 0x333) << 2;
+ v |= v >> 2;
+ dpix_val2 = xcolors[v];
+ dpix_val3 = merge_2pixel32(dpix_val1, dpix_val2);
+ spix_val1 = pixdata.apixels[spix++];
+ spix_val2 = pixdata.apixels[spix++];
+ off = ((spix_val2 & 3) * 4) + (spix_val1 & 3) + ((spix_val1 | spix_val2) & 16);
+ v = (colors_for_drawing.color_regs_ecs[off] & 0xccc) << 0;
+ v |= v >> 2;
+ dpix_val1 = xcolors[v];
+ v = (colors_for_drawing.color_regs_ecs[off] & 0x333) << 2;
+ v |= v >> 2;
+ dpix_val2 = xcolors[v];
+ dpix_val4 = merge_2pixel32(dpix_val1, dpix_val2);
+ PUTBPIX(shsprite(dpix, spix_val1, merge_2pixel16(dpix_val3, dpix_val4), spr));
+ dpix++;
+ }
+ return spix;
+}
+static int linetoscr_16_shrink2f_sh_spr(int spix, int dpix, int stoppos)
+{
+ return linetoscr_16_shrink2f_sh_func(spix, dpix, stoppos, true);
+}
+static int linetoscr_16_shrink2f_sh(int spix, int dpix, int stoppos)
+{
+ return linetoscr_16_shrink2f_sh_func(spix, dpix, stoppos, false);
+}
typedef int(*call_linetoscr)(int spix, int dpix, int dpix_end);
@@ -743,8 +1561,57 @@ static int pfield_do_nothing(int a, int b, int c)
return a;
}
-static void pfield_set_linetoscr (void)
+/* AGA subpixel delay hack */
+static call_linetoscr pfield_do_linetoscr_shdelay_normal;
+static call_linetoscr pfield_do_linetoscr_shdelay_sprite;
+
+static int pfield_do_linetoscr_normal_shdelay(int spix, int dpix, int dpix_end)
{
+ int add = get_shdelay_add();
+ int add2 = add * gfxvidinfo.pixbytes;
+ if (add) {
+ // Clear skipped pixel(s).
+ pfield_do_linetoscr_shdelay_sprite(spix, dpix, dpix + add);
+ }
+ xlinebuffer += add2;
+ int out = pfield_do_linetoscr_shdelay_normal(spix, dpix, dpix_end);
+ xlinebuffer -= add2;
+ return out;
+}
+static int pfield_do_linetoscr_sprite_shdelay(int spix, int dpix, int dpix_end)
+{
+ int out = spix;
+ if (dpix < real_playfield_start && dpix_end > real_playfield_start) {
+ // Crosses real_playfield_start.
+ // Render only from dpix to real_playfield_start.
+ int len = real_playfield_start - dpix;
+ out = pfield_do_linetoscr_spriteonly(out, dpix, dpix + len);
+ dpix = real_playfield_start;
+ }
+ else if (dpix_end <= real_playfield_start) {
+ // Does not cross real_playfield_start, nothing special needed.
+ out = pfield_do_linetoscr_spriteonly(out, dpix, dpix_end);
+ return out;
+ }
+ // Render bitplane with subpixel scroll, from real_playfield_start to end.
+ int add = get_shdelay_add();
+ int add2 = add * gfxvidinfo.pixbytes;
+ if (add) {
+ pfield_do_linetoscr_shdelay_sprite(out, dpix, dpix + add);
+ }
+ sprite_shdelay = add;
+ spritepixels += add;
+ xlinebuffer += add2;
+ out = pfield_do_linetoscr_shdelay_sprite(out, dpix, dpix_end);
+ xlinebuffer -= add2;
+ spritepixels -= add;
+ sprite_shdelay = 0;
+ return out;
+}
+
+static void pfield_set_linetoscr(void)
+{
+ xlinecheck(start, stop);
p_acolors = colors_for_drawing.acolors;
p_xcolors = xcolors;
bpland = 0xff;
@@ -753,268 +1620,535 @@ static void pfield_set_linetoscr (void)
}
spritepixels = spritepixels_buffer;
pfield_do_linetoscr_spriteonly = pfield_do_nothing;
-
+#ifdef AGA
if (currprefs.chipset_mask & CSMASK_AGA) {
if (res_shift == 0) {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
pfield_do_linetoscr_normal = linetoscr_16_aga;
pfield_do_linetoscr_sprite = linetoscr_16_aga_spr;
pfield_do_linetoscr_spriteonly = linetoscr_16_aga_spronly;
- } else if (res_shift == 2) {
- } else if (res_shift == 1) {
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_aga;
+ pfield_do_linetoscr_sprite = linetoscr_32_aga_spr;
+ pfield_do_linetoscr_spriteonly = linetoscr_32_aga_spronly;
+ break;
+ }
+ }
+ else if (res_shift == 2) {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
+ pfield_do_linetoscr_normal = linetoscr_16_stretch2_aga;
+ pfield_do_linetoscr_sprite = linetoscr_16_stretch2_aga_spr;
+ pfield_do_linetoscr_spriteonly = linetoscr_16_stretch2_aga_spronly;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_stretch2_aga;
+ pfield_do_linetoscr_sprite = linetoscr_32_stretch2_aga_spr;
+ pfield_do_linetoscr_spriteonly = linetoscr_32_stretch2_aga_spronly;
+ break;
+ }
+ }
+ else if (res_shift == 1) {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
pfield_do_linetoscr_normal = linetoscr_16_stretch1_aga;
pfield_do_linetoscr_sprite = linetoscr_16_stretch1_aga_spr;
pfield_do_linetoscr_spriteonly = linetoscr_16_stretch1_aga_spronly;
- } else if (res_shift == -1) {
- pfield_do_linetoscr_normal = linetoscr_16_shrink1_aga;
- pfield_do_linetoscr_sprite = linetoscr_16_shrink1_aga_spr;
- pfield_do_linetoscr_spriteonly = linetoscr_16_shrink1_aga_spronly;
- } else if (res_shift == -2) {
- pfield_do_linetoscr_normal = linetoscr_16_shrink2_aga;
- pfield_do_linetoscr_sprite = linetoscr_16_shrink2_aga_spr;
- pfield_do_linetoscr_spriteonly = linetoscr_16_shrink2_aga_spronly;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_stretch1_aga;
+ pfield_do_linetoscr_sprite = linetoscr_32_stretch1_aga_spr;
+ pfield_do_linetoscr_spriteonly = linetoscr_32_stretch1_aga_spronly;
+ break;
+ }
+ }
+ else if (res_shift == -1) {
+ if (currprefs.gfx_lores_mode) {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
+ pfield_do_linetoscr_normal = linetoscr_16_shrink1f_aga;
+ pfield_do_linetoscr_sprite = linetoscr_16_shrink1f_aga_spr;
+ pfield_do_linetoscr_spriteonly = linetoscr_16_shrink1f_aga_spronly;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_shrink1f_aga;
+ pfield_do_linetoscr_sprite = linetoscr_32_shrink1f_aga_spr;
+ pfield_do_linetoscr_spriteonly = linetoscr_32_shrink1f_aga_spronly;
+ break;
+ }
+ }
+ else {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
+ pfield_do_linetoscr_normal = linetoscr_16_shrink1_aga;
+ pfield_do_linetoscr_sprite = linetoscr_16_shrink1_aga_spr;
+ pfield_do_linetoscr_spriteonly = linetoscr_16_shrink1_aga_spronly;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_shrink1_aga;
+ pfield_do_linetoscr_sprite = linetoscr_32_shrink1_aga_spr;
+ pfield_do_linetoscr_spriteonly = linetoscr_32_shrink1_aga_spronly;
+ break;
+ }
+ }
+ }
+ else if (res_shift == -2) {
+ if (currprefs.gfx_lores_mode) {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
+ pfield_do_linetoscr_normal = linetoscr_16_shrink2f_aga;
+ pfield_do_linetoscr_sprite = linetoscr_16_shrink2f_aga_spr;
+ pfield_do_linetoscr_spriteonly = linetoscr_16_shrink2f_aga_spronly;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_shrink2f_aga;
+ pfield_do_linetoscr_sprite = linetoscr_32_shrink2f_aga_spr;
+ pfield_do_linetoscr_spriteonly = linetoscr_32_shrink2f_aga_spronly;
+ break;
+ }
+ }
+ else {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
+ pfield_do_linetoscr_normal = linetoscr_16_shrink2_aga;
+ pfield_do_linetoscr_sprite = linetoscr_16_shrink2_aga_spr;
+ pfield_do_linetoscr_spriteonly = linetoscr_16_shrink2_aga_spronly;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_shrink2_aga;
+ pfield_do_linetoscr_sprite = linetoscr_32_shrink2_aga_spr;
+ pfield_do_linetoscr_spriteonly = linetoscr_32_shrink2_aga_spronly;
+ break;
+ }
+ }
+ }
+ if (get_shdelay_add()) {
+ pfield_do_linetoscr_shdelay_normal = pfield_do_linetoscr_normal;
+ pfield_do_linetoscr_shdelay_sprite = pfield_do_linetoscr_sprite;
+ pfield_do_linetoscr_normal = pfield_do_linetoscr_normal_shdelay;
+ pfield_do_linetoscr_sprite = pfield_do_linetoscr_sprite_shdelay;
}
}
-
+#endif
+#ifdef ECS_DENISE
if (!(currprefs.chipset_mask & CSMASK_AGA) && ecsshres) {
+ // TODO: genlock support
if (res_shift == 0) {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
pfield_do_linetoscr_normal = linetoscr_16_sh;
pfield_do_linetoscr_sprite = linetoscr_16_sh_spr;
- } else if (res_shift == -1) {
- pfield_do_linetoscr_normal = linetoscr_16_shrink1_sh;
- pfield_do_linetoscr_sprite = linetoscr_16_shrink1_sh_spr;
- } else if (res_shift == -2) {
- pfield_do_linetoscr_normal = linetoscr_16_shrink2_sh;
- pfield_do_linetoscr_sprite = linetoscr_16_shrink2_sh_spr;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_sh;
+ pfield_do_linetoscr_sprite = linetoscr_32_sh_spr;
+ break;
+ }
+ }
+ else if (res_shift == -1) {
+ if (currprefs.gfx_lores_mode) {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
+ pfield_do_linetoscr_normal = linetoscr_16_shrink1f_sh;
+ pfield_do_linetoscr_sprite = linetoscr_16_shrink1f_sh_spr;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_shrink1f_sh;
+ pfield_do_linetoscr_sprite = linetoscr_32_shrink1f_sh_spr;
+ break;
+ }
+ }
+ else {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
+ pfield_do_linetoscr_normal = linetoscr_16_shrink1_sh;
+ pfield_do_linetoscr_sprite = linetoscr_16_shrink1_sh_spr;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_shrink1_sh;
+ pfield_do_linetoscr_sprite = linetoscr_32_shrink1_sh_spr;
+ break;
+ }
+ }
+ }
+ else if (res_shift == -2) {
+ if (currprefs.gfx_lores_mode) {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
+ pfield_do_linetoscr_normal = linetoscr_16_shrink2f_sh;
+ pfield_do_linetoscr_sprite = linetoscr_16_shrink2f_sh_spr;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_shrink2f_sh;
+ pfield_do_linetoscr_sprite = linetoscr_32_shrink2f_sh_spr;
+ break;
+ }
+ }
+ else {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
+ pfield_do_linetoscr_normal = linetoscr_16_shrink2_sh;
+ pfield_do_linetoscr_sprite = linetoscr_16_shrink2_sh_spr;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_shrink2_sh;
+ pfield_do_linetoscr_sprite = linetoscr_32_shrink2_sh_spr;
+ break;
+ }
+ }
}
}
-
+#endif
if (!(currprefs.chipset_mask & CSMASK_AGA) && !ecsshres) {
if (res_shift == 0) {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
pfield_do_linetoscr_normal = linetoscr_16;
pfield_do_linetoscr_sprite = linetoscr_16_spr;
- } else if (res_shift == 2) {
- } else if (res_shift == 1) {
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32;
+ pfield_do_linetoscr_sprite = linetoscr_32_spr;
+ break;
+ }
+ }
+ else if (res_shift == 2) {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
+ pfield_do_linetoscr_normal = linetoscr_16_stretch2;
+ pfield_do_linetoscr_sprite = linetoscr_16_stretch2_spr;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_stretch2;
+ pfield_do_linetoscr_sprite = linetoscr_32_stretch2_spr;
+ break;
+ }
+ }
+ else if (res_shift == 1) {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
pfield_do_linetoscr_normal = linetoscr_16_stretch1;
pfield_do_linetoscr_sprite = linetoscr_16_stretch1_spr;
- } else if (res_shift == -1) {
- pfield_do_linetoscr_normal = linetoscr_16_shrink1;
- pfield_do_linetoscr_sprite = linetoscr_16_shrink1_spr;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_stretch1;
+ pfield_do_linetoscr_sprite = linetoscr_32_stretch1_spr;
+ break;
+ }
+ }
+ else if (res_shift == -1) {
+ if (currprefs.gfx_lores_mode) {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
+ pfield_do_linetoscr_normal = linetoscr_16_shrink1f;
+ pfield_do_linetoscr_sprite = linetoscr_16_shrink1f_spr;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_shrink1f;
+ pfield_do_linetoscr_sprite = linetoscr_32_shrink1f_spr;
+ break;
+ }
+ }
+ else {
+ switch (gfxvidinfo.pixbytes) {
+ case 2:
+ pfield_do_linetoscr_normal = linetoscr_16_shrink1;
+ pfield_do_linetoscr_sprite = linetoscr_16_shrink1_spr;
+ break;
+ case 4:
+ pfield_do_linetoscr_normal = linetoscr_32_shrink1;
+ pfield_do_linetoscr_sprite = linetoscr_32_shrink1_spr;
+ break;
+ }
+ }
}
}
}
// left or right AGA border sprite
-static void pfield_do_linetoscr_bordersprite_aga (int start, int stop, bool blank)
+static void pfield_do_linetoscr_bordersprite_aga(int start, int stop, bool blank)
{
if (blank) {
- pfield_do_fill_line (start, stop, blank);
+ pfield_do_fill_line(start, stop, blank);
return;
}
pfield_do_linetoscr_spriteonly(src_pixel, start, stop);
}
-static void dummy_worker (int start, int stop, bool blank)
+static void dummy_worker(int start, int stop, bool blank)
{
}
#ifdef ARMV6T2
STATIC_INLINE int DECODE_HAM8_1(int col, int pv)
{
- __asm__ (
- "ubfx %[pv], %[pv], #3, #5 \n\t"
- "bfi %[col], %[pv], #0, #5 \n\t"
- : [col] "+r" (col) , [pv] "+r" (pv) );
- return col;
+ __asm__(
+ "ubfx %[pv], %[pv], #3, #5 \n\t"
+ "bfi %[col], %[pv], #0, #5 \n\t"
+ : [col] "+r"(col),
+ [pv] "+r"(pv));
+ return col;
}
+
STATIC_INLINE int DECODE_HAM8_2(int col, int pv)
{
- __asm__ (
- "ubfx %[pv], %[pv], #3, #5 \n\t"
- "bfi %[col], %[pv], #11, #5 \n\t"
- : [col] "+r" (col) , [pv] "+r" (pv) );
- return col;
+ __asm__(
+ "ubfx %[pv], %[pv], #3, #5 \n\t"
+ "bfi %[col], %[pv], #11, #5 \n\t"
+ : [col] "+r"(col),
+ [pv] "+r"(pv));
+ return col;
}
+
STATIC_INLINE int DECODE_HAM8_3(int col, int pv)
{
- __asm__ (
- "ubfx %[pv], %[pv], #2, #6 \n\t"
- "bfi %[col], %[pv], #5, #6 \n\t"
- : [col] "+r" (col) , [pv] "+r" (pv) );
- return col;
+ __asm__(
+ "ubfx %[pv], %[pv], #2, #6 \n\t"
+ "bfi %[col], %[pv], #5, #6 \n\t"
+ : [col] "+r"(col),
+ [pv] "+r"(pv));
+ return col;
}
STATIC_INLINE int DECODE_HAM6_1(int col, int pv)
{
- __asm__ (
- "bfi %[col], %[pv], #1, #4 \n\t"
- : [col] "+r" (col) : [pv] "r" (pv) );
- return (col);
+ __asm__(
+ "lsl %[pv], %[pv], #1 \n\t"
+ "bfi %[col], %[pv], #0, #5 \n\t"
+ : [col] "+r"(col),
+ [pv] "+r"(pv));
+ return (col);
}
+
STATIC_INLINE int DECODE_HAM6_2(int col, int pv)
{
- __asm__ (
- "bfi %[col], %[pv], #12, #4 \n\t"
- : [col] "+r" (col) : [pv] "r" (pv) );
- return (col);
+ __asm__(
+ "lsl %[pv], %[pv], #1 \n\t"
+ "bfi %[col], %[pv], #11, #5 \n\t"
+ : [col] "+r"(col),
+ [pv] "+r"(pv));
+ return (col);
}
+
STATIC_INLINE int DECODE_HAM6_3(int col, int pv)
{
- __asm__ (
- "bfi %[col], %[pv], #7, #4 \n\t"
- : [col] "+r" (col) : [pv] "r" (pv) );
- return (col);
+ __asm__(
+ "lsl %[pv], %[pv], #2 \n\t"
+ "bfi %[col], %[pv], #5, #6 \n\t"
+ : [col] "+r"(col),
+ [pv] "+r"(pv));
+ return (col);
}
#endif
static int ham_decode_pixel;
-static uae_u16 ham_lastcolor;
+static unsigned int ham_lastcolor;
/* Decode HAM in the invisible portion of the display (left of VISIBLE_LEFT_BORDER),
* but don't draw anything in. This is done to prepare HAM_LASTCOLOR for later,
* when decode_ham runs.
*
*/
-static void init_ham_decoding (void)
+static void init_ham_decoding(void)
{
- int unpainted_amiga = unpainted;
+ int unpainted_amiga = unpainted;
+
+ ham_decode_pixel = src_pixel;
+ ham_lastcolor = color_reg_get(&colors_for_drawing, 0);
- ham_decode_pixel = src_pixel;
- ham_lastcolor = colors_for_drawing.acolors[0];
-
if (!bplham) {
if (unpainted_amiga > 0) {
int pv = pixdata.apixels[ham_decode_pixel + unpainted_amiga - 1];
- if (aga_mode)
- ham_lastcolor = colors_for_drawing.acolors[pv ^ bplxor];
+#ifdef AGA
+ if (currprefs.chipset_mask & CSMASK_AGA)
+ ham_lastcolor = colors_for_drawing.color_regs_aga[pv ^ bplxor] & 0xffffff;
else
- ham_lastcolor = colors_for_drawing.acolors[pv];
- }
- } else if (aga_mode) {
- if (bplplanecnt >= 7) { /* AGA mode HAM8 */
- while (unpainted_amiga-- > 0) {
- int pv = pixdata.apixels[ham_decode_pixel++] ^ bplxor;
- switch (pv & 0x3)
- {
- case 0x0: ham_lastcolor = colors_for_drawing.acolors[pv >> 2]; break;
-#ifdef ARMV6T2
- case 0x1: ham_lastcolor = DECODE_HAM8_1(ham_lastcolor, pv); break;
- case 0x2: ham_lastcolor = DECODE_HAM8_2(ham_lastcolor, pv); break;
- case 0x3: ham_lastcolor = DECODE_HAM8_3(ham_lastcolor, pv); break;
-#else
- case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pv & 0xFC); break;
- case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pv & 0xFC) << 16; break;
- case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pv & 0xFC) << 8; break;
#endif
- }
- }
- } else { /* AGA mode HAM6 */
- while (unpainted_amiga-- > 0) {
- int pv = pixdata.apixels[ham_decode_pixel++] ^ bplxor;
- uae_u32 pc = ((pv & 0xf) << 0) | ((pv & 0xf) << 4);
- switch (pv & 0x30)
- {
- case 0x00: ham_lastcolor = colors_for_drawing.acolors[pv]; break;
-#ifdef ARMV6T2
- case 0x10: ham_lastcolor = DECODE_HAM8_1(ham_lastcolor, pc); break;
- case 0x20: ham_lastcolor = DECODE_HAM8_2(ham_lastcolor, pc); break;
- case 0x30: ham_lastcolor = DECODE_HAM8_3(ham_lastcolor, pc); break;
+ ham_lastcolor = colors_for_drawing.color_regs_ecs[pv] & 0xfff;
+ }
+ }
+ else if (currprefs.chipset_mask & CSMASK_AGA)
+ {
+ if (bplplanecnt >= 7)
+ { /* AGA mode HAM8 */
+ while (unpainted_amiga-- > 0)
+ {
+ int pw = pixdata.apixels[ham_decode_pixel++];
+ int pv = pw ^ bplxor;
+ int pc = pv >> 2;
+ switch (pv & 0x3)
+ {
+ case 0x0: ham_lastcolor = colors_for_drawing.color_regs_aga[pc] & 0xffffff; break;
+ break;
+#ifdef NO_ARMV6T2
+ case 0x1: ham_lastcolor = DECODE_HAM8_1(ham_lastcolor, pv);
+ break;
+ case 0x2: ham_lastcolor = DECODE_HAM8_2(ham_lastcolor, pv);
+ break;
+ case 0x3: ham_lastcolor = DECODE_HAM8_3(ham_lastcolor, pv);
+ break;
#else
- case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= (pc & 0xF) << 4; break;
- case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pc & 0xF) << 20; break;
- case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pc & 0xF) << 12; break;
+ case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pw & 0xFC); break;
+ case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pw & 0xFC) << 16; break;
+ case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pw & 0xFC) << 8; break;
#endif
}
}
}
- } else {
+ else
+ { /* AGA mode HAM6 */
+ while (unpainted_amiga-- > 0)
+ {
+ int pw = pixdata.apixels[ham_decode_pixel++];
+ int pv = pw ^ bplxor;
+ uae_u32 pc = ((pw & 0xf) << 0) | ((pw & 0xf) << 4);
+ switch (pv & 0x30)
+ {
+ case 0x00: ham_lastcolor = colors_for_drawing.color_regs_aga[pv & 0x0f] & 0xffffff; break;
+ break;
+#ifdef NO_ARMV6T2
+ case 0x10: ham_lastcolor = DECODE_HAM6_1(ham_lastcolor, pv);
+ break;
+ case 0x20: ham_lastcolor = DECODE_HAM6_2(ham_lastcolor, pv);
+ break;
+ case 0x30: ham_lastcolor = DECODE_HAM6_3(ham_lastcolor, pv);
+ break;
+#else
+ case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= pc << 0; break;
+ case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= pc << 16; break;
+ case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= pc << 8; break;
+#endif
+ }
+ }
+ }
+ }
+ else
+ {
/* OCS/ECS mode HAM6 */
- while (unpainted_amiga-- > 0) {
+ while (unpainted_amiga-- > 0)
+ {
int pv = pixdata.apixels[ham_decode_pixel++];
- switch (pv & 0x30)
- {
- case 0x00: ham_lastcolor = colors_for_drawing.acolors[pv]; break;
-#ifdef ARMV6T2
- case 0x10: ham_lastcolor = DECODE_HAM6_1(ham_lastcolor, pv); break;
- case 0x20: ham_lastcolor = DECODE_HAM6_2(ham_lastcolor, pv); break;
- case 0x30: ham_lastcolor = DECODE_HAM6_3(ham_lastcolor, pv); break;
+ switch (pv & 0x30)
+ {
+ case 0x00: ham_lastcolor = colors_for_drawing.color_regs_ecs[pv] & 0xfff; break;
+ break;
+#ifdef NO_ARMV6T2
+ case 0x10: ham_lastcolor = DECODE_HAM6_1(ham_lastcolor, pv);
+ break;
+ case 0x20: ham_lastcolor = DECODE_HAM6_2(ham_lastcolor, pv);
+ break;
+ case 0x30: ham_lastcolor = DECODE_HAM6_3(ham_lastcolor, pv);
+ break;
#else
- case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break;
- case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break;
- case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break;
+ case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break;
+ case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break;
+ case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break;
#endif
}
}
}
}
-static void decode_ham (int pix, int stoppos, bool blank)
+static void decode_ham(int pix, int stoppos, bool blank)
{
- int todraw_amiga = res_shift_from_window (stoppos - pix);
-
- if (!bplham) {
- while (todraw_amiga-- > 0) {
+ int todraw_amiga = res_shift_from_window(stoppos - pix);
+ int hdp = ham_decode_pixel;
+
+ if (!bplham)
+ {
+ while (todraw_amiga-- > 0)
+ {
int pv = pixdata.apixels[ham_decode_pixel];
- if (aga_mode)
- ham_lastcolor = colors_for_drawing.acolors[pv ^ bplxor];
+#ifdef AGA
+ if (currprefs.chipset_mask & CSMASK_AGA)
+ ham_lastcolor = colors_for_drawing.color_regs_aga[pv ^ bplxor] & 0xffffff;
else
- ham_lastcolor = colors_for_drawing.acolors[pv];
-
+#endif
+ ham_lastcolor = colors_for_drawing.color_regs_ecs[pv] & 0xfff;
+
ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
}
- } else if (aga_mode) {
- if (bplplanecnt >= 7) { /* AGA mode HAM8 */
- while (todraw_amiga-- > 0) {
- int pv = pixdata.apixels[ham_decode_pixel] ^ bplxor;
- switch (pv & 0x3)
- {
- case 0x0: ham_lastcolor = colors_for_drawing.acolors[pv >> 2]; break;
-#ifdef ARMV6T2
- case 0x1: ham_lastcolor = DECODE_HAM8_1(ham_lastcolor, pv); break;
- case 0x2: ham_lastcolor = DECODE_HAM8_2(ham_lastcolor, pv); break;
- case 0x3: ham_lastcolor = DECODE_HAM8_3(ham_lastcolor, pv); break;
+ }
+ else if (currprefs.chipset_mask & CSMASK_AGA)
+ {
+ if (bplplanecnt >= 7)
+ { /* AGA mode HAM8 */
+ while (todraw_amiga-- > 0)
+ {
+ int pw = pixdata.apixels[ham_decode_pixel];
+ int pv = pw ^ bplxor;
+ int pc = pv >> 2;
+ switch (pv & 0x3)
+ {
+ case 0x0: ham_lastcolor = colors_for_drawing.color_regs_aga[pc] & 0xffffff; break;
+ break;
+#ifdef NO_ARMV6T2
+ case 0x1: ham_lastcolor = DECODE_HAM8_1(ham_lastcolor, pv);
+ break;
+ case 0x2: ham_lastcolor = DECODE_HAM8_2(ham_lastcolor, pv);
+ break;
+ case 0x3: ham_lastcolor = DECODE_HAM8_3(ham_lastcolor, pv);
+ break;
#else
- case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pv & 0xFC); break;
- case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pv & 0xFC) << 16; break;
- case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pv & 0xFC) << 8; break;
-#endif
- }
- ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
- }
- } else { /* AGA mode HAM6 */
- while (todraw_amiga-- > 0) {
- int pv = pixdata.apixels[ham_decode_pixel] ^ bplxor;
- uae_u32 pc = ((pv & 0xf) << 0) | ((pv & 0xf) << 4);
- switch (pv & 0x30)
- {
- case 0x00: ham_lastcolor = colors_for_drawing.acolors[pv]; break;
-#ifdef ARMV6T2
- case 0x10: ham_lastcolor = DECODE_HAM8_1(ham_lastcolor, pc); break;
- case 0x20: ham_lastcolor = DECODE_HAM8_2(ham_lastcolor, pc); break;
- case 0x30: ham_lastcolor = DECODE_HAM8_3(ham_lastcolor, pc); break;
-#else
- case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= (pc & 0xF) << 4; break;
- case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pc & 0xF) << 20; break;
- case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pc & 0xF) << 12; break;
+ case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pw & 0xFC); break;
+ case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pw & 0xFC) << 16; break;
+ case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pw & 0xFC) << 8; break;
#endif
}
ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
}
}
- } else {
- /* OCS/ECS mode HAM6 */
- while (todraw_amiga-- > 0) {
- int pv = pixdata.apixels[ham_decode_pixel];
- switch (pv & 0x30)
- {
- case 0x00: ham_lastcolor = colors_for_drawing.acolors[pv]; break;
-#ifdef ARMV6T2
- case 0x10: ham_lastcolor = DECODE_HAM6_1(ham_lastcolor, pv); break;
- case 0x20: ham_lastcolor = DECODE_HAM6_2(ham_lastcolor, pv); break;
- case 0x30: ham_lastcolor = DECODE_HAM6_3(ham_lastcolor, pv); break;
+ else
+ { /* AGA mode HAM6 */
+ while (todraw_amiga-- > 0)
+ {
+ int pw = pixdata.apixels[ham_decode_pixel];
+ int pv = pw ^ bplxor;
+ uae_u32 pc = ((pw & 0xf) << 0) | ((pw & 0xf) << 4);
+ switch (pv & 0x30)
+ {
+ case 0x00: ham_lastcolor = colors_for_drawing.color_regs_aga[pv & 0x0f] & 0xffffff; break;
+ break;
+#ifdef NO_ARMV6T2
+ case 0x10: ham_lastcolor = DECODE_HAM6_1(ham_lastcolor, pv);
+ break;
+ case 0x20: ham_lastcolor = DECODE_HAM6_2(ham_lastcolor, pv);
+ break;
+ case 0x30: ham_lastcolor = DECODE_HAM6_3(ham_lastcolor, pv);
+ break;
#else
- case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break;
- case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break;
- case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break;
+ case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= pc << 0; break;
+ case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= pc << 16; break;
+ case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= pc << 8; break;
+#endif
+ }
+ ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
+ }
+ }
+ }
+ else
+ {
+ /* OCS/ECS mode HAM6 */
+ while (todraw_amiga-- > 0)
+ {
+ int pv = pixdata.apixels[ham_decode_pixel];
+ switch (pv & 0x30)
+ {
+ case 0x00: ham_lastcolor = colors_for_drawing.color_regs_ecs[pv] & 0xfff; break;
+ break;
+#ifdef NO_ARMV6T2
+ case 0x10: ham_lastcolor = DECODE_HAM6_1(ham_lastcolor, pv);
+ break;
+ case 0x20: ham_lastcolor = DECODE_HAM6_2(ham_lastcolor, pv);
+ break;
+ case 0x30: ham_lastcolor = DECODE_HAM6_3(ham_lastcolor, pv);
+ break;
+#else
+ case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break;
+ case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break;
+ case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break;
#endif
}
ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
@@ -1022,7 +2156,18 @@ static void decode_ham (int pix, int stoppos, bool blank)
}
}
-static void gen_pfield_tables (void)
+static void erase_ham_right_border(int pix, int stoppos, bool blank)
+{
+ if (stoppos < playfield_end)
+ return;
+ // erase right border in HAM modes or old HAM data may be visible
+ // if DDFSTOP < DIWSTOP (Uridium II title screen)
+ int todraw_amiga = res_shift_from_window(stoppos - pix);
+ while (todraw_amiga-- > 0)
+ ham_linebuf[ham_decode_pixel++] = 0;
+}
+
+static void gen_pfield_tables(void)
{
int i;
@@ -1032,12 +2177,16 @@ static void gen_pfield_tables (void)
dblpf_2nd1[i] = plane1 == 0 && plane2 != 0;
dblpf_2nd2[i] = plane2 != 0;
-
+
+#ifdef AGA
dblpf_ind1_aga[i] = plane1 == 0 ? plane2 : plane1;
dblpf_ind2_aga[i] = plane2 == 0 ? plane1 : plane2;
-
+#endif
+
dblpf_ms1[i] = plane1 == 0 ? (plane2 == 0 ? 16 : 8) : 0;
dblpf_ms2[i] = plane2 == 0 ? (plane1 == 0 ? 16 : 0) : 8;
+ dblpf_ms[i] = i == 0 ? 16 : 8;
+
if (plane2 > 0)
plane2 += 8;
dblpf_ind1[i] = i >= 128 ? i & 0x7F : (plane1 == 0 ? plane2 : plane1);
@@ -1051,69 +2200,48 @@ static void gen_pfield_tables (void)
dblpf_ind1[i] = 0;
}
+ sprite_offs[i] = (i & 15) ? 0 : 2;
+
clxtab[i] = ((((i & 3) && (i & 12)) << 9)
- | (((i & 3) && (i & 48)) << 10)
- | (((i & 3) && (i & 192)) << 11)
- | (((i & 12) && (i & 48)) << 12)
- | (((i & 12) && (i & 192)) << 13)
- | (((i & 48) && (i & 192)) << 14));
+ | (((i & 3) && (i & 48)) << 10)
+ | (((i & 3) && (i & 192)) << 11)
+ | (((i & 12) && (i & 48)) << 12)
+ | (((i & 12) && (i & 192)) << 13)
+ | (((i & 48) && (i & 192)) << 14));
+
}
- for(i=0; i<65536; ++i)
- {
- sprite_col_nat[i] =
- (i & 0x0003) ? ((i >> 0) & 3) + 0 :
- (i & 0x000C) ? ((i >> 2) & 3) + 0 :
- (i & 0x0030) ? ((i >> 4) & 3) + 4 :
- (i & 0x00C0) ? ((i >> 6) & 3) + 4 :
- (i & 0x0300) ? ((i >> 8) & 3) + 8 :
- (i & 0x0C00) ? ((i >> 10) & 3) + 8 :
- (i & 0x3000) ? ((i >> 12) & 3) + 12 :
- (i & 0xC000) ? ((i >> 14) & 3) + 12 : 0;
- sprite_col_at[i] =
- (i & 0x000F) ? ((i >> 0) & 0x000F) :
- (i & 0x00F0) ? ((i >> 4) & 0x000F) :
- (i & 0x0F00) ? ((i >> 8) & 0x000F) :
- (i & 0xF000) ? ((i >> 12) & 0x000F) : 0;
- sprite_bit[i] =
- (i & 0x0003) ? 0x01 :
- (i & 0x000C) ? 0x02 :
- (i & 0x0030) ? 0x04 :
- (i & 0x00C0) ? 0x08 :
- (i & 0x0300) ? 0x10 :
- (i & 0x0C00) ? 0x20 :
- (i & 0x3000) ? 0x40 :
- (i & 0xC000) ? 0x80 : 0;
- }
+ memset(all_ones, 0xff, MAX_PIXELS_PER_LINE);
+
}
/* When looking at this function and the ones that inline it, bear in mind
- what an optimizing compiler will do with this code. All callers of this
- function only pass in constant arguments (except for E). This means
- that many of the if statements will go away completely after inlining. */
-STATIC_INLINE void draw_sprites_1 (struct sprite_entry *e, const int dualpf, const int has_attach)
+what an optimizing compiler will do with this code. All callers of this
+function only pass in constant arguments (except for E). This means
+that many of the if statements will go away completely after inlining. */
+STATIC_INLINE void draw_sprites_1(struct sprite_entry *e, int dualpf, int has_attach)
{
- uae_u16 *buf = spixels + e->first_pixel;
- uae_u8 *stbuf = spixstate.bytes + e->first_pixel;
- int spr_pos, pos;
+ uae_u16 *buf = spixels + e->first_pixel;
+ uae_u8 *stbuf = spixstate.bytes + e->first_pixel;
+ int spr_pos, pos;
int epos = e->pos;
int emax = e->max;
- buf -= epos;
- stbuf -= epos;
+ buf -= epos;
+ stbuf -= epos;
- spr_pos = epos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) << sprite_buffer_res);
+ spr_pos = epos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) << sprite_buffer_res);
if (spr_pos < sprite_first_x)
sprite_first_x = spr_pos;
- for (pos = epos; pos < emax; pos++, spr_pos++) {
+ for (pos = epos; pos < emax; pos++, spr_pos++) {
if (spr_pos >= 0 && spr_pos < MAX_PIXELS_PER_LINE) {
spritepixels[spr_pos].data = buf[pos];
spritepixels[spr_pos].stdata = stbuf[pos];
spritepixels[spr_pos].attach = has_attach;
}
- }
+ }
if (spr_pos > sprite_last_x)
sprite_last_x = spr_pos;
@@ -1122,34 +2250,38 @@ STATIC_INLINE void draw_sprites_1 (struct sprite_entry *e, const int dualpf, con
/* See comments above. Do not touch if you don't know what's going on.
* (We do _not_ want the following to be inlined themselves). */
/* lores bitplane, lores sprites */
-static void NOINLINE draw_sprites_normal_sp_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0); }
-static void NOINLINE draw_sprites_normal_dp_nat (struct sprite_entry *e) { draw_sprites_1 (e, 1, 0); }
-static void NOINLINE draw_sprites_normal_sp_at (struct sprite_entry *e) { draw_sprites_1 (e, 0, 1); }
-static void NOINLINE draw_sprites_normal_dp_at (struct sprite_entry *e) { draw_sprites_1 (e, 1, 1); }
+static void NOINLINE draw_sprites_normal_sp_nat(struct sprite_entry *e) { draw_sprites_1(e, 0, 0); }
+static void NOINLINE draw_sprites_normal_dp_nat(struct sprite_entry *e) { draw_sprites_1(e, 1, 0); }
+static void NOINLINE draw_sprites_normal_sp_at(struct sprite_entry *e) { draw_sprites_1(e, 0, 1); }
+static void NOINLINE draw_sprites_normal_dp_at(struct sprite_entry *e) { draw_sprites_1(e, 1, 1); }
+#ifdef AGA
/* not very optimized */
-STATIC_INLINE void draw_sprites_aga (struct sprite_entry *e, int aga)
+STATIC_INLINE void draw_sprites_aga(struct sprite_entry *e, int aga)
{
- draw_sprites_1 (e, bpldualpf, e->has_attached);
+ draw_sprites_1(e, bpldualpf, e->has_attached);
}
+#endif
-STATIC_INLINE void draw_sprites_ecs (struct sprite_entry *e)
+STATIC_INLINE void draw_sprites_ecs(struct sprite_entry *e)
{
if (e->has_attached) {
if (bpldualpf)
- draw_sprites_normal_dp_at (e);
+ draw_sprites_normal_dp_at(e);
else
- draw_sprites_normal_sp_at (e);
- } else {
+ draw_sprites_normal_sp_at(e);
+ }
+ else {
if (bpldualpf)
- draw_sprites_normal_dp_nat (e);
+ draw_sprites_normal_dp_nat(e);
else
- draw_sprites_normal_sp_nat (e);
+ draw_sprites_normal_sp_nat(e);
}
}
+#ifdef AGA
/* clear possible bitplane data outside DIW area */
-static void clear_bitplane_border_aga (void)
+static void clear_bitplane_border_aga(void)
{
int len, shift = res_shift;
uae_u8 v = 0;
@@ -1157,18 +2289,20 @@ static void clear_bitplane_border_aga (void)
if (shift < 0) {
shift = -shift;
len = (real_playfield_start - playfield_start) << shift;
- memset (pixdata.apixels + pixels_offset + (playfield_start << shift), v, len);
+ memset(pixdata.apixels + pixels_offset + (playfield_start << shift), v, len);
len = (playfield_end - real_playfield_end) << shift;
- memset (pixdata.apixels + pixels_offset + (real_playfield_end << shift), v, len);
- } else {
+ memset(pixdata.apixels + pixels_offset + (real_playfield_end << shift), v, len);
+ }
+ else {
len = (real_playfield_start - playfield_start) >> shift;
- memset (pixdata.apixels + pixels_offset + (playfield_start >> shift), v, len);
+ memset(pixdata.apixels + pixels_offset + (playfield_start >> shift), v, len);
len = (playfield_end - real_playfield_end) >> shift;
- memset (pixdata.apixels + pixels_offset + (real_playfield_end >> shift), v, len);
+ memset(pixdata.apixels + pixels_offset + (real_playfield_end >> shift), v, len);
}
}
+#endif
-static void weird_bitplane_fix (int start, int end)
+static void weird_bitplane_fix(int start, int end)
{
int sh = lores_shift;
uae_u8 *p = pixdata.apixels + pixels_offset;
@@ -1181,13 +2315,15 @@ static void weird_bitplane_fix (int start, int end)
if (p[i] & 16)
p[i] = 16;
}
- } else if (bpldualpf && bpldualpfpri) {
+ }
+ else if (bpldualpf && bpldualpfpri) {
/* in dualplayfield mode this feature is even more strange.. */
for (int i = start; i < end; i++) {
if (p[i] & (2 | 8 | 32))
p[i] |= 0x40;
}
- } else if (bpldualpf && !bpldualpfpri) {
+ }
+ else if (bpldualpf && !bpldualpfpri) {
for (int i = start; i < end; i++) {
p[i] &= ~(2 | 8 | 32);
}
@@ -1208,23 +2344,24 @@ Don't touch this if you don't know what you are doing. */
#define DATA_POINTER(n) (line_data[lineno] + (n) * MAX_WORDS_PER_LINE * 2)
-#if defined(USE_ARMNEON) && !defined(ANDROID)
-// FIXME: these neon helper functions caused text rel problem on android
+//TODO Test if this is actually faster
+#ifdef NO_USE_ARMNEON
#ifdef __cplusplus
- extern "C" {
+extern "C"
+{
#endif
- void ARM_doline_n1(uae_u32 *pixels, int wordcount, int lineno);
- void NEON_doline_n2(uae_u32 *pixels, int wordcount, int lineno);
- void NEON_doline_n3(uae_u32 *pixels, int wordcount, int lineno);
- void NEON_doline_n4(uae_u32 *pixels, int wordcount, int lineno);
- void NEON_doline_n6(uae_u32 *pixels, int wordcount, int lineno);
- void NEON_doline_n8(uae_u32 *pixels, int wordcount, int lineno);
+ void ARM_doline_n1(uae_u32* pixels, int wordcount, int lineno);
+ void NEON_doline_n2(uae_u32* pixels, int wordcount, int lineno);
+ void NEON_doline_n3(uae_u32* pixels, int wordcount, int lineno);
+ void NEON_doline_n4(uae_u32* pixels, int wordcount, int lineno);
+ void NEON_doline_n6(uae_u32* pixels, int wordcount, int lineno);
+ void NEON_doline_n8(uae_u32* pixels, int wordcount, int lineno);
#ifdef __cplusplus
- }
+}
#endif
-static void pfield_doline_n0 (uae_u32 *pixels, int wordcount, int lineno)
+static void pfield_doline_n0(uae_u32* pixels, int wordcount, int lineno)
{
memset(pixels, 0, wordcount << 5);
}
@@ -1235,308 +2372,457 @@ static void pfield_doline_n0 (uae_u32 *pixels, int wordcount, int lineno)
b ^= (tmp << shift); \
}
-static void pfield_doline_n5 (uae_u32 *pixels, int wordcount, int lineno)
+static void pfield_doline_n5(uae_u32* pixels, int wordcount, int lineno)
{
- uae_u8 *real_bplpt[5];
+ uae_u8* real_bplpt[5];
- real_bplpt[0] = DATA_POINTER (0);
- real_bplpt[1] = DATA_POINTER (1);
- real_bplpt[2] = DATA_POINTER (2);
- real_bplpt[3] = DATA_POINTER (3);
- real_bplpt[4] = DATA_POINTER (4);
+ real_bplpt[0] = DATA_POINTER(0);
+ real_bplpt[1] = DATA_POINTER(1);
+ real_bplpt[2] = DATA_POINTER(2);
+ real_bplpt[3] = DATA_POINTER(3);
+ real_bplpt[4] = DATA_POINTER(4);
- while (wordcount-- > 0) {
- uae_u32 b0,b1,b2,b3,b4,b5,b6,b7;
- b3 = GETLONG ((uae_u32 *)real_bplpt[4]); real_bplpt[4] += 4;
- b4 = GETLONG ((uae_u32 *)real_bplpt[3]); real_bplpt[3] += 4;
- b5 = GETLONG ((uae_u32 *)real_bplpt[2]); real_bplpt[2] += 4;
- b6 = GETLONG ((uae_u32 *)real_bplpt[1]); real_bplpt[1] += 4;
- b7 = GETLONG ((uae_u32 *)real_bplpt[0]); real_bplpt[0] += 4;
+ while (wordcount-- > 0)
+ {
+ uae_u32 b0, b1, b2, b3, b4, b5, b6, b7;
+ b3 = GETLONG(reinterpret_cast(real_bplpt[4]));
+ real_bplpt[4] += 4;
+ b4 = GETLONG(reinterpret_cast(real_bplpt[3]));
+ real_bplpt[3] += 4;
+ b5 = GETLONG(reinterpret_cast(real_bplpt[2]));
+ real_bplpt[2] += 4;
+ b6 = GETLONG(reinterpret_cast(real_bplpt[1]));
+ real_bplpt[1] += 4;
+ b7 = GETLONG(reinterpret_cast(real_bplpt[0]));
+ real_bplpt[0] += 4;
- MERGE_0(b2, b3, 0x55555555, 1);
- MERGE (b4, b5, 0x55555555, 1);
- MERGE (b6, b7, 0x55555555, 1);
+ MERGE_0(b2, b3, 0x55555555, 1);
+ MERGE(b4, b5, 0x55555555, 1);
+ MERGE(b6, b7, 0x55555555, 1);
- MERGE_0(b0, b2, 0x33333333, 2);
- MERGE_0(b1, b3, 0x33333333, 2);
- MERGE (b4, b6, 0x33333333, 2);
- MERGE (b5, b7, 0x33333333, 2);
+ MERGE_0(b0, b2, 0x33333333, 2);
+ MERGE_0(b1, b3, 0x33333333, 2);
+ MERGE(b4, b6, 0x33333333, 2);
+ MERGE(b5, b7, 0x33333333, 2);
- MERGE (b0, b4, 0x0f0f0f0f, 4);
- MERGE (b1, b5, 0x0f0f0f0f, 4);
- MERGE (b2, b6, 0x0f0f0f0f, 4);
- MERGE (b3, b7, 0x0f0f0f0f, 4);
+ MERGE(b0, b4, 0x0f0f0f0f, 4);
+ MERGE(b1, b5, 0x0f0f0f0f, 4);
+ MERGE(b2, b6, 0x0f0f0f0f, 4);
+ MERGE(b3, b7, 0x0f0f0f0f, 4);
- MERGE (b0, b1, 0x00ff00ff, 8);
- MERGE (b2, b3, 0x00ff00ff, 8);
- MERGE (b4, b5, 0x00ff00ff, 8);
- MERGE (b6, b7, 0x00ff00ff, 8);
+ MERGE(b0, b1, 0x00ff00ff, 8);
+ MERGE(b2, b3, 0x00ff00ff, 8);
+ MERGE(b4, b5, 0x00ff00ff, 8);
+ MERGE(b6, b7, 0x00ff00ff, 8);
- MERGE (b0, b2, 0x0000ffff, 16);
- do_put_mem_long(pixels, b0);
- do_put_mem_long(pixels + 4, b2);
- MERGE (b1, b3, 0x0000ffff, 16);
- do_put_mem_long(pixels + 2, b1);
- do_put_mem_long(pixels + 6, b3);
- MERGE (b4, b6, 0x0000ffff, 16);
- do_put_mem_long(pixels + 1, b4);
- do_put_mem_long(pixels + 5, b6);
- MERGE (b5, b7, 0x0000ffff, 16);
- do_put_mem_long(pixels + 3, b5);
- do_put_mem_long(pixels + 7, b7);
- pixels += 8;
- }
+ MERGE(b0, b2, 0x0000ffff, 16);
+ do_put_mem_long(pixels, b0);
+ do_put_mem_long(pixels + 4, b2);
+ MERGE(b1, b3, 0x0000ffff, 16);
+ do_put_mem_long(pixels + 2, b1);
+ do_put_mem_long(pixels + 6, b3);
+ MERGE(b4, b6, 0x0000ffff, 16);
+ do_put_mem_long(pixels + 1, b4);
+ do_put_mem_long(pixels + 5, b6);
+ MERGE(b5, b7, 0x0000ffff, 16);
+ do_put_mem_long(pixels + 3, b5);
+ do_put_mem_long(pixels + 7, b7);
+ pixels += 8;
+ }
}
-static void pfield_doline_n7 (uae_u32 *pixels, int wordcount, int lineno)
+static void pfield_doline_n7(uae_u32* pixels, int wordcount, int lineno)
{
- uae_u8 *real_bplpt[7];
- real_bplpt[0] = DATA_POINTER (0);
- real_bplpt[1] = DATA_POINTER (1);
- real_bplpt[2] = DATA_POINTER (2);
- real_bplpt[3] = DATA_POINTER (3);
- real_bplpt[4] = DATA_POINTER (4);
- real_bplpt[5] = DATA_POINTER (5);
- real_bplpt[6] = DATA_POINTER (6);
+ uae_u8* real_bplpt[7];
+ real_bplpt[0] = DATA_POINTER(0);
+ real_bplpt[1] = DATA_POINTER(1);
+ real_bplpt[2] = DATA_POINTER(2);
+ real_bplpt[3] = DATA_POINTER(3);
+ real_bplpt[4] = DATA_POINTER(4);
+ real_bplpt[5] = DATA_POINTER(5);
+ real_bplpt[6] = DATA_POINTER(6);
- while (wordcount-- > 0) {
- uae_u32 b0,b1,b2,b3,b4,b5,b6,b7;
- b1 = GETLONG ((uae_u32 *)real_bplpt[6]); real_bplpt[6] += 4;
- b2 = GETLONG ((uae_u32 *)real_bplpt[5]); real_bplpt[5] += 4;
- b3 = GETLONG ((uae_u32 *)real_bplpt[4]); real_bplpt[4] += 4;
- b4 = GETLONG ((uae_u32 *)real_bplpt[3]); real_bplpt[3] += 4;
- b5 = GETLONG ((uae_u32 *)real_bplpt[2]); real_bplpt[2] += 4;
- b6 = GETLONG ((uae_u32 *)real_bplpt[1]); real_bplpt[1] += 4;
- b7 = GETLONG ((uae_u32 *)real_bplpt[0]); real_bplpt[0] += 4;
+ while (wordcount-- > 0)
+ {
+ uae_u32 b0, b1, b2, b3, b4, b5, b6, b7;
+ b1 = GETLONG(reinterpret_cast(real_bplpt[6]));
+ real_bplpt[6] += 4;
+ b2 = GETLONG(reinterpret_cast(real_bplpt[5]));
+ real_bplpt[5] += 4;
+ b3 = GETLONG(reinterpret_cast(real_bplpt[4]));
+ real_bplpt[4] += 4;
+ b4 = GETLONG(reinterpret_cast(real_bplpt[3]));
+ real_bplpt[3] += 4;
+ b5 = GETLONG(reinterpret_cast(real_bplpt[2]));
+ real_bplpt[2] += 4;
+ b6 = GETLONG(reinterpret_cast(real_bplpt[1]));
+ real_bplpt[1] += 4;
+ b7 = GETLONG(reinterpret_cast(real_bplpt[0]));
+ real_bplpt[0] += 4;
- MERGE_0(b0, b1, 0x55555555, 1);
- MERGE (b2, b3, 0x55555555, 1);
- MERGE (b4, b5, 0x55555555, 1);
- MERGE (b6, b7, 0x55555555, 1);
+ MERGE_0(b0, b1, 0x55555555, 1);
+ MERGE(b2, b3, 0x55555555, 1);
+ MERGE(b4, b5, 0x55555555, 1);
+ MERGE(b6, b7, 0x55555555, 1);
- MERGE (b0, b2, 0x33333333, 2);
- MERGE (b1, b3, 0x33333333, 2);
- MERGE (b4, b6, 0x33333333, 2);
- MERGE (b5, b7, 0x33333333, 2);
+ MERGE(b0, b2, 0x33333333, 2);
+ MERGE(b1, b3, 0x33333333, 2);
+ MERGE(b4, b6, 0x33333333, 2);
+ MERGE(b5, b7, 0x33333333, 2);
- MERGE (b0, b4, 0x0f0f0f0f, 4);
- MERGE (b1, b5, 0x0f0f0f0f, 4);
- MERGE (b2, b6, 0x0f0f0f0f, 4);
- MERGE (b3, b7, 0x0f0f0f0f, 4);
+ MERGE(b0, b4, 0x0f0f0f0f, 4);
+ MERGE(b1, b5, 0x0f0f0f0f, 4);
+ MERGE(b2, b6, 0x0f0f0f0f, 4);
+ MERGE(b3, b7, 0x0f0f0f0f, 4);
- MERGE (b0, b1, 0x00ff00ff, 8);
- MERGE (b2, b3, 0x00ff00ff, 8);
- MERGE (b4, b5, 0x00ff00ff, 8);
- MERGE (b6, b7, 0x00ff00ff, 8);
+ MERGE(b0, b1, 0x00ff00ff, 8);
+ MERGE(b2, b3, 0x00ff00ff, 8);
+ MERGE(b4, b5, 0x00ff00ff, 8);
+ MERGE(b6, b7, 0x00ff00ff, 8);
- MERGE (b0, b2, 0x0000ffff, 16);
- do_put_mem_long(pixels, b0);
- do_put_mem_long(pixels + 4, b2);
- MERGE (b1, b3, 0x0000ffff, 16);
- do_put_mem_long(pixels + 2, b1);
- do_put_mem_long(pixels + 6, b3);
- MERGE (b4, b6, 0x0000ffff, 16);
- do_put_mem_long(pixels + 1, b4);
- do_put_mem_long(pixels + 5, b6);
- MERGE (b5, b7, 0x0000ffff, 16);
- do_put_mem_long(pixels + 3, b5);
- do_put_mem_long(pixels + 7, b7);
- pixels += 8;
- }
+ MERGE(b0, b2, 0x0000ffff, 16);
+ do_put_mem_long(pixels, b0);
+ do_put_mem_long(pixels + 4, b2);
+ MERGE(b1, b3, 0x0000ffff, 16);
+ do_put_mem_long(pixels + 2, b1);
+ do_put_mem_long(pixels + 6, b3);
+ MERGE(b4, b6, 0x0000ffff, 16);
+ do_put_mem_long(pixels + 1, b4);
+ do_put_mem_long(pixels + 5, b6);
+ MERGE(b5, b7, 0x0000ffff, 16);
+ do_put_mem_long(pixels + 3, b5);
+ do_put_mem_long(pixels + 7, b7);
+ pixels += 8;
+ }
}
-typedef void (*pfield_doline_func)(uae_u32 *, int, int);
+typedef void (*pfield_doline_func)(uae_u32*, int, int);
-static pfield_doline_func pfield_doline_n[9]={
- pfield_doline_n0, ARM_doline_n1, NEON_doline_n2, NEON_doline_n3,
- NEON_doline_n4, pfield_doline_n5, NEON_doline_n6, pfield_doline_n7,
+static pfield_doline_func pfield_doline_n[9] = {
+ pfield_doline_n0,
+ ARM_doline_n1,
+ NEON_doline_n2,
+ NEON_doline_n3,
+ NEON_doline_n4,
+ pfield_doline_n5,
+ NEON_doline_n6,
+ pfield_doline_n7,
NEON_doline_n8
};
#else
-static uae_u8 *real_bplpt[8];
-
-STATIC_INLINE void pfield_doline_1 (uae_u32 *pixels, int wordcount, int planes)
+STATIC_INLINE void pfield_doline_1(uae_u32 *pixels, int wordcount, int planes)
{
- while (wordcount-- > 0) {
- uae_u32 b0,b1,b2,b3,b4,b5,b6,b7;
+ while (wordcount-- > 0) {
+ uae_u32 b0, b1, b2, b3, b4, b5, b6, b7;
- b0 = 0, b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 = 0, b6 = 0, b7 = 0;
- switch (planes) {
- case 8: b0 = GETLONG (real_bplpt[7]); real_bplpt[7] += 4;
- case 7: b1 = GETLONG (real_bplpt[6]); real_bplpt[6] += 4;
- case 6: b2 = GETLONG (real_bplpt[5]); real_bplpt[5] += 4;
- case 5: b3 = GETLONG (real_bplpt[4]); real_bplpt[4] += 4;
- case 4: b4 = GETLONG (real_bplpt[3]); real_bplpt[3] += 4;
- case 3: b5 = GETLONG (real_bplpt[2]); real_bplpt[2] += 4;
- case 2: b6 = GETLONG (real_bplpt[1]); real_bplpt[1] += 4;
- case 1: b7 = GETLONG (real_bplpt[0]); real_bplpt[0] += 4;
- }
-
- MERGE (b0, b1, 0x55555555, 1);
- MERGE (b2, b3, 0x55555555, 1);
- MERGE (b4, b5, 0x55555555, 1);
- MERGE (b6, b7, 0x55555555, 1);
-
- MERGE (b0, b2, 0x33333333, 2);
- MERGE (b1, b3, 0x33333333, 2);
- MERGE (b4, b6, 0x33333333, 2);
- MERGE (b5, b7, 0x33333333, 2);
-
- MERGE (b0, b4, 0x0f0f0f0f, 4);
- MERGE (b1, b5, 0x0f0f0f0f, 4);
- MERGE (b2, b6, 0x0f0f0f0f, 4);
- MERGE (b3, b7, 0x0f0f0f0f, 4);
-
- MERGE (b0, b1, 0x00ff00ff, 8);
- MERGE (b2, b3, 0x00ff00ff, 8);
- MERGE (b4, b5, 0x00ff00ff, 8);
- MERGE (b6, b7, 0x00ff00ff, 8);
-
- MERGE (b0, b2, 0x0000ffff, 16);
- do_put_mem_long (pixels, b0);
- do_put_mem_long (pixels + 4, b2);
- MERGE (b1, b3, 0x0000ffff, 16);
- do_put_mem_long (pixels + 2, b1);
- do_put_mem_long (pixels + 6, b3);
- MERGE (b4, b6, 0x0000ffff, 16);
- do_put_mem_long (pixels + 1, b4);
- do_put_mem_long (pixels + 5, b6);
- MERGE (b5, b7, 0x0000ffff, 16);
- do_put_mem_long (pixels + 3, b5);
- do_put_mem_long (pixels + 7, b7);
- pixels += 8;
- }
-}
-
-/* See above for comments on inlining. These functions should _not_
- be inlined themselves. */
-static void NOINLINE pfield_doline_n1 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 1); }
-static void NOINLINE pfield_doline_n2 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 2); }
-static void NOINLINE pfield_doline_n3 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 3); }
-static void NOINLINE pfield_doline_n4 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 4); }
-static void NOINLINE pfield_doline_n5 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 5); }
-static void NOINLINE pfield_doline_n6 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 6); }
-static void NOINLINE pfield_doline_n7 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 7); }
-static void NOINLINE pfield_doline_n8 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 8); }
-
-#endif /* USE_ARMNEON */
-
-static void pfield_doline (int lineno)
-{
- int wordcount = dp_for_drawing->plflinelen;
- uae_u32 *data = pixdata.apixels_l + MAX_PIXELS_PER_LINE / 4;
-
-#if defined(USE_ARMNEON) && !defined(ANDROID)
- pfield_doline_n[bplplanecnt](data, wordcount, lineno);
-#else
- real_bplpt[0] = DATA_POINTER (0);
- real_bplpt[1] = DATA_POINTER (1);
- real_bplpt[2] = DATA_POINTER (2);
- real_bplpt[3] = DATA_POINTER (3);
- real_bplpt[4] = DATA_POINTER (4);
- real_bplpt[5] = DATA_POINTER (5);
- real_bplpt[6] = DATA_POINTER (6);
- real_bplpt[7] = DATA_POINTER (7);
-
- switch (bplplanecnt) {
- default: break;
- case 0: memset (data, 0, wordcount * 32); break;
- case 1: pfield_doline_n1 (data, wordcount); break;
- case 2: pfield_doline_n2 (data, wordcount); break;
- case 3: pfield_doline_n3 (data, wordcount); break;
- case 4: pfield_doline_n4 (data, wordcount); break;
- case 5: pfield_doline_n5 (data, wordcount); break;
- case 6: pfield_doline_n6 (data, wordcount); break;
- case 7: pfield_doline_n7 (data, wordcount); break;
- case 8: pfield_doline_n8 (data, wordcount); break;
- }
-#endif /* USE_ARMNEON */
-}
-
-void init_row_map (void)
-{
- int i, j;
-
- for (i = gfxvidinfo.drawbuffer.outheight; i < MAX_VIDHEIGHT + 1; i++)
- row_map[i] = row_tmp;
- for (i = 0, j = 0; i < gfxvidinfo.drawbuffer.outheight; i++, j += gfxvidinfo.drawbuffer.rowbytes) {
- row_map[i] = gfxvidinfo.drawbuffer.bufmem + j;
- }
-}
-
-static void init_aspect_maps (void)
-{
- int i, maxl, h;
-
- h = gfxvidinfo.drawbuffer.outheight;
-
- if (h == 0)
- /* Do nothing if the gfx driver hasn't initialized the screen yet */
- return;
-
- if (native2amiga_line_map)
- xfree (native2amiga_line_map);
-
- native2amiga_line_map = xmalloc (int, h);
-
- maxl = (MAXVPOS + 1);
-
- for (i = 0; i < h; i++)
- native2amiga_line_map[i] = -1;
-
- for (i = maxl - 1; i >= minfirstline; i--) {
- for (int j = i - minfirstline; j < h && native2amiga_line_map[j] == -1; j++)
-#ifdef PANDORA
- native2amiga_line_map[j] = i + currprefs.pandora_vertical_offset;
-#else
- native2amiga_line_map[j] = i;
+ b0 = 0, b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 = 0, b6 = 0, b7 = 0;
+ switch (planes) {
+#ifdef AGA
+ case 8: b0 = GETLONG(real_bplpt[7]); real_bplpt[7] += 4;
+ case 7: b1 = GETLONG(real_bplpt[6]); real_bplpt[6] += 4;
#endif
+ case 6: b2 = GETLONG(real_bplpt[5]); real_bplpt[5] += 4;
+ case 5: b3 = GETLONG(real_bplpt[4]); real_bplpt[4] += 4;
+ case 4: b4 = GETLONG(real_bplpt[3]); real_bplpt[3] += 4;
+ case 3: b5 = GETLONG(real_bplpt[2]); real_bplpt[2] += 4;
+ case 2: b6 = GETLONG(real_bplpt[1]); real_bplpt[1] += 4;
+ case 1: b7 = GETLONG(real_bplpt[0]); real_bplpt[0] += 4;
+ }
+
+ MERGE(b0, b1, 0x55555555, 1);
+ MERGE(b2, b3, 0x55555555, 1);
+ MERGE(b4, b5, 0x55555555, 1);
+ MERGE(b6, b7, 0x55555555, 1);
+
+ MERGE(b0, b2, 0x33333333, 2);
+ MERGE(b1, b3, 0x33333333, 2);
+ MERGE(b4, b6, 0x33333333, 2);
+ MERGE(b5, b7, 0x33333333, 2);
+
+ MERGE(b0, b4, 0x0f0f0f0f, 4);
+ MERGE(b1, b5, 0x0f0f0f0f, 4);
+ MERGE(b2, b6, 0x0f0f0f0f, 4);
+ MERGE(b3, b7, 0x0f0f0f0f, 4);
+
+ MERGE(b0, b1, 0x00ff00ff, 8);
+ MERGE(b2, b3, 0x00ff00ff, 8);
+ MERGE(b4, b5, 0x00ff00ff, 8);
+ MERGE(b6, b7, 0x00ff00ff, 8);
+
+ MERGE(b0, b2, 0x0000ffff, 16);
+ do_put_mem_long(pixels, b0);
+ do_put_mem_long(pixels + 4, b2);
+ MERGE(b1, b3, 0x0000ffff, 16);
+ do_put_mem_long(pixels + 2, b1);
+ do_put_mem_long(pixels + 6, b3);
+ MERGE(b4, b6, 0x0000ffff, 16);
+ do_put_mem_long(pixels + 1, b4);
+ do_put_mem_long(pixels + 5, b6);
+ MERGE(b5, b7, 0x0000ffff, 16);
+ do_put_mem_long(pixels + 3, b5);
+ do_put_mem_long(pixels + 7, b7);
+ pixels += 8;
}
}
-/*
- * One drawing frame has been finished. Tell the graphics code about it.
- */
-STATIC_INLINE void do_flush_screen ()
+/* See above for comments on inlining. These functions should _not_
+be inlined themselves. */
+static void NOINLINE pfield_doline_n1(uae_u32 *data, int count) { pfield_doline_1(data, count, 1); }
+static void NOINLINE pfield_doline_n2(uae_u32 *data, int count) { pfield_doline_1(data, count, 2); }
+static void NOINLINE pfield_doline_n3(uae_u32 *data, int count) { pfield_doline_1(data, count, 3); }
+static void NOINLINE pfield_doline_n4(uae_u32 *data, int count) { pfield_doline_1(data, count, 4); }
+static void NOINLINE pfield_doline_n5(uae_u32 *data, int count) { pfield_doline_1(data, count, 5); }
+static void NOINLINE pfield_doline_n6(uae_u32 *data, int count) { pfield_doline_1(data, count, 6); }
+#ifdef AGA
+static void NOINLINE pfield_doline_n7(uae_u32 *data, int count) { pfield_doline_1(data, count, 7); }
+static void NOINLINE pfield_doline_n8(uae_u32 *data, int count) { pfield_doline_1(data, count, 8); }
+#endif
+
+#endif /* USE_ARMNEON */
+
+static void pfield_doline(int lineno)
{
- unlockscr ();
- screenlocked = false;
+ int wordcount = dp_for_drawing->plflinelen;
+ uae_u32 *data = pixdata.apixels_l + MAX_PIXELS_PER_LINE / 4;
+
+ //TODO Test if this is actually faster
+#ifdef NO_USE_ARMNEON
+ pfield_doline_n[bplplanecnt](data, wordcount, lineno);
+#else
+#ifdef SMART_UPDATE
+//#define DATA_POINTER(n) ((debug_bpl_mask & (1 << n)) ? (line_data[lineno] + (n) * MAX_WORDS_PER_LINE * 2) : (debug_bpl_mask_one ? all_ones : all_zeros))
+ real_bplpt[0] = DATA_POINTER(0);
+ real_bplpt[1] = DATA_POINTER(1);
+ real_bplpt[2] = DATA_POINTER(2);
+ real_bplpt[3] = DATA_POINTER(3);
+ real_bplpt[4] = DATA_POINTER(4);
+ real_bplpt[5] = DATA_POINTER(5);
+#ifdef AGA
+ real_bplpt[6] = DATA_POINTER(6);
+ real_bplpt[7] = DATA_POINTER(7);
+#endif
+#endif
+
+ switch (bplplanecnt) {
+ default: break;
+ case 0: memset(data, 0, wordcount * 32); break;
+ case 1: pfield_doline_n1(data, wordcount); break;
+ case 2: pfield_doline_n2(data, wordcount); break;
+ case 3: pfield_doline_n3(data, wordcount); break;
+ case 4: pfield_doline_n4(data, wordcount); break;
+ case 5: pfield_doline_n5(data, wordcount); break;
+ case 6: pfield_doline_n6(data, wordcount); break;
+#ifdef AGA
+ case 7: pfield_doline_n7(data, wordcount); break;
+ case 8: pfield_doline_n8(data, wordcount); break;
+#endif
+}
+#endif /* USE_ARMNEON */
+
+ if (refresh_indicator_buffer && refresh_indicator_height > lineno) {
+ uae_u8 *opline = refresh_indicator_buffer + lineno * MAX_PIXELS_PER_LINE * 2;
+ wordcount *= 32;
+ if (!memcmp(opline, data, wordcount)) {
+ if (refresh_indicator_changed[lineno] != 0xff) {
+ refresh_indicator_changed[lineno]++;
+ if (refresh_indicator_changed[lineno] > refresh_indicator_changed_prev[lineno]) {
+ refresh_indicator_changed_prev[lineno] = refresh_indicator_changed[lineno];
+ }
+ }
+ }
+ else {
+ memcpy(opline, data, wordcount);
+ if (refresh_indicator_changed[lineno] != refresh_indicator_changed_prev[lineno])
+ refresh_indicator_changed_prev[lineno] = 0;
+ refresh_indicator_changed[lineno] = 0;
+ }
+ }
+}
+
+void init_row_map(void)
+{
+ static uae_u8 *oldbufmem;
+ static int oldheight, oldpitch;
+ static bool oldgenlock;
+ int i, j;
+
+ if (gfxvidinfo.outheight > max_uae_height)
+ {
+ write_log(_T("Resolution too high, aborting\n"));
+ abort();
+ }
+ if (!row_map) {
+ row_map = xmalloc(uae_u8*, max_uae_height + 1);
+ row_map_genlock = xmalloc(uae_u8*, max_uae_height + 1);
+ }
+
+ if (oldbufmem && oldbufmem == gfxvidinfo.bufmem &&
+ oldheight == gfxvidinfo.outheight &&
+ oldpitch == gfxvidinfo.rowbytes &&
+ oldgenlock == init_genlock_data)
+ return;
+ xfree(row_map_genlock_buffer);
+ row_map_genlock_buffer = NULL;
+ if (init_genlock_data) {
+ row_map_genlock_buffer = xcalloc(uae_u8, gfxvidinfo.outwidth * (gfxvidinfo.outheight + 2));
+ }
+ xfree(row_map_color_burst_buffer);
+ row_map_color_burst_buffer = NULL;
+ //if (currprefs.cs_color_burst) {
+ // row_map_color_burst_buffer = xcalloc(uae_u8, gfxvidinfo.outheight + 2);
+ //}
+ j = oldheight == 0 ? max_uae_height : oldheight;
+ for (i = gfxvidinfo.outheight; i < max_uae_height + 1 && i < j + 1; i++) {
+ row_map[i] = row_tmp;
+ row_map_genlock[i] = row_tmp;
+ }
+ for (i = 0, j = 0; i < gfxvidinfo.outheight; i++, j += gfxvidinfo.rowbytes) {
+ row_map[i] = gfxvidinfo.bufmem + j;
+ if (init_genlock_data) {
+ row_map_genlock[i] = row_map_genlock_buffer + gfxvidinfo.outwidth * (i + 1);
+ }
+ else {
+ row_map_genlock[i] = NULL;
+ }
+ }
+ oldbufmem = gfxvidinfo.bufmem;
+ oldheight = gfxvidinfo.outheight;
+ oldpitch = gfxvidinfo.rowbytes;
+ oldgenlock = init_genlock_data;
+}
+
+static void init_aspect_maps()
+{
+ int i, maxl, h;
+
+ h = gfxvidinfo.outheight;
+
+ if (h == 0)
+ /* Do nothing if the gfx driver hasn't initialized the screen yet */
+ return;
+
+ linedbld = linedbl = currprefs.gfx_vresolution;
+ if (doublescan > 0 && interlace_seen <= 0) {
+ linedbl = 0;
+ linedbld = 1;
+ }
+
+ if (native2amiga_line_map)
+ xfree(native2amiga_line_map);
+ if (amiga2aspect_line_map)
+ xfree(amiga2aspect_line_map);
+
+ /* At least for this array the +1 is necessary. */
+ amiga2aspect_line_map = xmalloc(int, (MAXVPOS + 1) * 2 + 1);
+ native2amiga_line_map = xmalloc(int, h);
+
+ maxl = (MAXVPOS + 1) << linedbld;
+ min_ypos_for_screen = minfirstline << linedbl;
+ max_drawn_amiga_line = -1;
+ for (i = 0; i < maxl; i++) {
+ int v = i - min_ypos_for_screen;
+ if (v >= h && max_drawn_amiga_line < 0)
+ max_drawn_amiga_line = v;
+ if (i < min_ypos_for_screen || v >= h)
+ v = -1;
+ amiga2aspect_line_map[i] = v;
+ }
+ if (max_drawn_amiga_line < 0)
+ max_drawn_amiga_line = maxl - min_ypos_for_screen;
+
+ for (i = 0; i < h; i++)
+ native2amiga_line_map[i] = -1;
+
+ for (i = maxl - 1; i >= min_ypos_for_screen; i--) {
+ int j;
+ if (amiga2aspect_line_map[i] == -1)
+ continue;
+ for (j = amiga2aspect_line_map[i]; j < h && native2amiga_line_map[j] == -1; j++)
+ native2amiga_line_map[j] = i >> linedbl;
+ }
+
+ visible_left_start = 0;
+ visible_right_stop = MAX_STOP;
+ visible_top_start = 0;
+ visible_bottom_stop = MAX_STOP;
+ set_blanking_limits();
+}
+
+/*
+* A raster line has been built in the graphics buffer. Tell the graphics code
+* to do anything necessary to display it.
+*/
+static void do_flush_line_1(int lineno)
+{
+ if (lineno < first_drawn_line)
+ first_drawn_line = lineno;
+ if (lineno > last_drawn_line)
+ last_drawn_line = lineno;
+
+ //if (gfxvidinfo.maxblocklines == 0)
+ // flush_line(vb, lineno);
+ //else {
+ // if ((last_block_line + 2) < lineno) {
+ // if (first_block_line != NO_BLOCK)
+ // flush_block(vb, first_block_line, last_block_line);
+ // first_block_line = lineno;
+ // }
+ // last_block_line = lineno;
+ // if (last_block_line - first_block_line >= gfxvidinfo.maxblocklines) {
+ // flush_block(vb, first_block_line, last_block_line);
+ // first_block_line = last_block_line = NO_BLOCK;
+ // }
+ //}
+}
+
+STATIC_INLINE void do_flush_line(int lineno)
+{
+ do_flush_line_1(lineno);
+}
+
+/*
+* One drawing frame has been finished. Tell the graphics code about it.
+* Note that the actual flush_screen() call is a no-op for all reasonable
+* systems.
+*/
+STATIC_INLINE void do_flush_screen()
+{
+ flush_screen(); /* vsync mode */
}
/* We only save hardware registers during the hardware frame. Now, when
* drawing the frame, we expand the data into a slightly more useful
* form. */
-static void pfield_expand_dp_bplcon (void)
+static void pfield_expand_dp_bplcon(void)
{
bool pfield_mode_changed = false;
- bplres = dp_for_drawing->bplres;
- bplplanecnt = dp_for_drawing->nr_planes;
- bplham = dp_for_drawing->ham_seen;
- if (aga_mode) {
- bplehb = (dp_for_drawing->bplcon0 & 0x7010) == 0x6000;
- bpldualpf2of = (dp_for_drawing->bplcon3 >> 10) & 7;
- sbasecol[0] = ((dp_for_drawing->bplcon4 >> 4) & 15) << 4;
- sbasecol[1] = ((dp_for_drawing->bplcon4 >> 0) & 15) << 4;
- bplxor = dp_for_drawing->bplcon4 >> 8;
- } else
- bplehb = (dp_for_drawing->bplcon0 & 0xFC00) == 0x6000 || (dp_for_drawing->bplcon0 & 0xFC00) == 0x7000;
+ bplres = dp_for_drawing->bplres;
+ bplplanecnt = dp_for_drawing->nr_planes;
+ bplham = dp_for_drawing->ham_seen;
+ bplehb = dp_for_drawing->ehb_seen;
if ((currprefs.chipset_mask & CSMASK_ECS_DENISE) && (dp_for_drawing->bplcon2 & 0x0200))
bplehb = 0;
+ issprites = dip_for_drawing->nr_sprites > 0;
+ bplcolorburst = (dp_for_drawing->bplcon0 & 0x200) != 0;
+ if (!bplcolorburst)
+ bplcolorburst_field = 0;
+#ifdef ECS_DENISE
int oecsshres = ecsshres;
ecsshres = bplres == RES_SUPERHIRES && (currprefs.chipset_mask & CSMASK_ECS_DENISE) && !(currprefs.chipset_mask & CSMASK_AGA);
pfield_mode_changed = oecsshres != ecsshres;
-
- plf1pri = dp_for_drawing->bplcon2 & 7;
- plf2pri = (dp_for_drawing->bplcon2 >> 3) & 7;
- plf_sprite_mask = 0xFFFF0000 << (4 * plf2pri);
- plf_sprite_mask |= (0x0000FFFF << (4 * plf1pri)) & 0xFFFF;
- plf_sprite_mask_n16 = ~(plf_sprite_mask >> 16);
- bpldualpf = (dp_for_drawing->bplcon0 & 0x400) == 0x400;
- bpldualpfpri = (dp_for_drawing->bplcon2 & 0x40) == 0x40;
+#endif
+ plf1pri = dp_for_drawing->bplcon2 & 7;
+ plf2pri = (dp_for_drawing->bplcon2 >> 3) & 7;
+ plf_sprite_mask = 0xFFFF0000 << (4 * plf2pri);
+ plf_sprite_mask |= (0x0000FFFF << (4 * plf1pri)) & 0xFFFF;
+ bpldualpf = (dp_for_drawing->bplcon0 & 0x400) == 0x400;
+ bpldualpfpri = (dp_for_drawing->bplcon2 & 0x40) == 0x40;
+
+#ifdef AGA
// BYPASS: HAM and EHB select bits are ignored
if (bplbypass != (dp_for_drawing->bplcon0 & 0x20) != 0) {
bpland = 0xff;
@@ -1553,56 +2839,81 @@ static void pfield_expand_dp_bplcon (void)
bpland = 31;
bplehb = 0;
}
-
+ bpldualpf2of = (dp_for_drawing->bplcon3 >> 10) & 7;
+ sbasecol[0] = ((dp_for_drawing->bplcon4 >> 4) & 15) << 4;
+ sbasecol[1] = ((dp_for_drawing->bplcon4 >> 0) & 15) << 4;
+ bplxor = dp_for_drawing->bplcon4 >> 8;
+ int sh = (colors_for_drawing.extra >> CE_SHRES_DELAY) & 3;
+ if (sh != bpldelay_sh) {
+ bpldelay_sh = sh;
+ pfield_mode_changed = true;
+ }
+#endif
+ ecs_genlock_features_active = (currprefs.chipset_mask & CSMASK_ECS_DENISE) && ((dp_for_drawing->bplcon2 & 0x0c00) || ce_is_borderntrans(colors_for_drawing.extra)) ? 1 : 0;
+ if (ecs_genlock_features_active) {
+ ecs_genlock_features_colorkey = false;
+ ecs_genlock_features_mask = 0;
+ if (dp_for_drawing->bplcon3 & 0x0800) {
+ ecs_genlock_features_mask = 1 << ((dp_for_drawing->bplcon2 >> 12) & 7);
+ }
+ if (dp_for_drawing->bplcon3 & 0x0400) {
+ ecs_genlock_features_colorkey = true;
+ }
+ }
if (pfield_mode_changed)
pfield_set_linetoscr();
}
-static bool isham (uae_u16 bplcon0)
+static bool isham(uae_u16 bplcon0)
{
- int p = GET_PLANES (bplcon0);
- if (!(bplcon0 & 0x800))
- return 0;
- if (aga_mode) {
- // AGA only has 6 or 8 plane HAM
- if (p == 6 || p == 8)
- return 1;
- } else {
- // OCS/ECS also supports 5 plane HAM
- if (GET_RES_DENISE (bplcon0) > 0)
- return 0;
- if (p >= 5)
- return 1;
- }
- return 0;
+ int p = GET_PLANES(bplcon0);
+ if (!(bplcon0 & 0x800))
+ return 0;
+ if (currprefs.chipset_mask & CSMASK_AGA) {
+ // AGA only has 6 or 8 plane HAM
+ if (p == 6 || p == 8)
+ return 1;
+ }
+ else {
+ // OCS/ECS also supports 5 plane HAM
+ if (GET_RES_DENISE(bplcon0) > 0)
+ return 0;
+ if (p >= 5)
+ return 1;
+ }
+ return 0;
}
-static void pfield_expand_dp_bplconx (int regno, int v)
+static void pfield_expand_dp_bplconx(int regno, int v)
{
if (regno == 0xffff) {
hposblank = 1;
return;
}
- regno -= 0x1000;
- switch (regno)
- {
- case 0x100: // BPLCON0
- dp_for_drawing->bplcon0 = v;
- dp_for_drawing->bplres = GET_RES_DENISE(v);
- dp_for_drawing->nr_planes = GET_PLANES(v);
- dp_for_drawing->ham_seen = isham (v);
- break;
- case 0x104: // BPLCON2
- dp_for_drawing->bplcon2 = v;
- break;
- case 0x106: // BPLCON3
- dp_for_drawing->bplcon3 = v;
- break;
- case 0x10c: // BPLCON4
- dp_for_drawing->bplcon4 = v;
- break;
- }
- pfield_expand_dp_bplcon();
+ regno -= 0x1000;
+ switch (regno)
+ {
+ case 0x100: // BPLCON0
+ dp_for_drawing->bplcon0 = v;
+ dp_for_drawing->bplres = GET_RES_DENISE(v);
+ dp_for_drawing->nr_planes = GET_PLANES(v);
+ dp_for_drawing->ham_seen = isham(v);
+ break;
+ case 0x104: // BPLCON2
+ dp_for_drawing->bplcon2 = v;
+ break;
+#ifdef ECS_DENISE
+ case 0x106: // BPLCON3
+ dp_for_drawing->bplcon3 = v;
+ break;
+#endif
+#ifdef AGA
+ case 0x10c: // BPLCON4
+ dp_for_drawing->bplcon4 = v;
+ break;
+#endif
+ }
+ pfield_expand_dp_bplcon();
set_res_shift(lores_shift - bplres);
}
@@ -1610,29 +2921,31 @@ static int drawing_color_matches;
static enum { color_match_acolors, color_match_full } color_match_type;
/* Set up colors_for_drawing to the state at the beginning of the currently drawn
- line. Try to avoid copying color tables around whenever possible. */
-static void adjust_drawing_colors (int ctable, int need_full)
+line. Try to avoid copying color tables around whenever possible. */
+static void adjust_drawing_colors(int ctable, int need_full)
{
if (drawing_color_matches != ctable || need_full < 0) {
- if (need_full) {
- color_reg_cpy (&colors_for_drawing, curr_color_tables + ctable);
+ if (need_full) {
+ color_reg_cpy(&colors_for_drawing, curr_color_tables + ctable);
color_match_type = color_match_full;
- } else {
- memcpy (colors_for_drawing.acolors, curr_color_tables[ctable].acolors,
- sizeof colors_for_drawing.acolors);
+ }
+ else {
+ memcpy(colors_for_drawing.acolors, curr_color_tables[ctable].acolors,
+ sizeof colors_for_drawing.acolors);
colors_for_drawing.extra = curr_color_tables[ctable].extra;
color_match_type = color_match_acolors;
- }
+ }
drawing_color_matches = ctable;
- } else if (need_full && color_match_type != color_match_full) {
- color_reg_cpy (&colors_for_drawing, &curr_color_tables[ctable]);
+ }
+ else if (need_full && color_match_type != color_match_full) {
+ color_reg_cpy(&colors_for_drawing, &curr_color_tables[ctable]);
color_match_type = color_match_full;
- }
+ }
}
static void playfield_hard_way(line_draw_func worker_pfield, int first, int last)
{
- if (first < real_playfield_start) {
+ if (first < real_playfield_start) {
int next = last < real_playfield_start ? last : real_playfield_start;
int diff = next - first;
pfield_do_linetoscr_bordersprite_aga(first, next, false);
@@ -1648,67 +2961,112 @@ static void playfield_hard_way(line_draw_func worker_pfield, int first, int last
pfield_do_linetoscr_bordersprite_aga(real_playfield_end, last, false);
}
-STATIC_INLINE void do_color_changes (line_draw_func worker_border, line_draw_func worker_pfield)
+static void do_color_changes(line_draw_func worker_border, line_draw_func worker_pfield, int vp)
{
- int i;
- int lastpos = visible_left_border;
- int endpos = visible_right_border;
+ int i;
+ int lastpos = visible_left_border;
+ int endpos = visible_left_border + gfxvidinfo.outwidth;
- for (i = dip_for_drawing->first_color_change; i <= dip_for_drawing->last_color_change; i++) {
+ for (i = dip_for_drawing->first_color_change; i <= dip_for_drawing->last_color_change; i++) {
int regno = curr_color_changes[i].regno;
unsigned int value = curr_color_changes[i].value;
- int nextpos, nextpos_in_range;
+ int nextpos, nextpos_in_range;
- if (i == dip_for_drawing->last_color_change)
- nextpos = endpos;
- else
- nextpos = shres_coord_hw_to_window_x (curr_color_changes[i].linepos);
+ if (i == dip_for_drawing->last_color_change)
+ nextpos = endpos;
+ else
+ nextpos = coord_hw_to_window_x(curr_color_changes[i].linepos);
- nextpos_in_range = nextpos;
- if (nextpos > endpos)
- nextpos_in_range = endpos;
+ nextpos_in_range = nextpos;
+ if (nextpos > endpos)
+ nextpos_in_range = endpos;
+
+ // left hblank (left edge to hblank end)
+ if (nextpos_in_range > lastpos && lastpos < hblank_left_start) {
+ int t = nextpos_in_range <= hblank_left_start ? nextpos_in_range : hblank_left_start;
+ (*worker_border) (lastpos, t, true);
+ lastpos = t;
+ }
// left border (hblank end to playfield start)
- if (nextpos_in_range > lastpos && lastpos < playfield_start) {
- int t = nextpos_in_range <= playfield_start ? nextpos_in_range : playfield_start;
- (*worker_border) (lastpos, t, false);
- lastpos = t;
- }
+ if (nextpos_in_range > lastpos && lastpos < playfield_start) {
+ int t = nextpos_in_range <= playfield_start ? nextpos_in_range : playfield_start;
+ (*worker_border) (lastpos, t, false);
+ lastpos = t;
+ }
// playfield
- if (nextpos_in_range > lastpos && lastpos >= playfield_start && lastpos < playfield_end) {
- int t = nextpos_in_range <= playfield_end ? nextpos_in_range : playfield_end;
+ if (nextpos_in_range > lastpos && lastpos >= playfield_start && lastpos < playfield_end) {
+ int t = nextpos_in_range <= playfield_end ? nextpos_in_range : playfield_end;
if (plf2pri > 5 && !(currprefs.chipset_mask & CSMASK_AGA))
- weird_bitplane_fix (lastpos, t);
+ weird_bitplane_fix(lastpos, t);
if (bplxor && may_require_hard_way && worker_pfield != pfield_do_linetoscr_bordersprite_aga)
playfield_hard_way(worker_pfield, lastpos, t);
else
- (*worker_pfield) (lastpos, t, false);
- lastpos = t;
- }
+ (*worker_pfield) (lastpos, t, false);
+ lastpos = t;
+ }
// right border (playfield end to hblank start)
- if (nextpos_in_range > lastpos && lastpos >= playfield_end) {
- (*worker_border) (lastpos, nextpos_in_range, false);
- lastpos = nextpos_in_range;
- }
+ if (nextpos_in_range > lastpos && lastpos >= playfield_end) {
+ int t = nextpos_in_range <= hblank_right_stop ? nextpos_in_range : hblank_right_stop;
+ (*worker_border) (lastpos, t, false);
+ lastpos = t;
+ }
- if (regno >= 0x1000) {
- pfield_expand_dp_bplconx (regno, value);
- } else if (regno >= 0 && !(value & COLOR_CHANGE_MASK)) {
- color_reg_set (&colors_for_drawing, regno, value);
- colors_for_drawing.acolors[regno] = getxcolor (value);
- } else if (regno == 0 && (value & COLOR_CHANGE_MASK)) {
+ // right hblank (hblank start to right edge, hblank start may be earlier than playfield end)
+ if (nextpos_in_range > hblank_right_stop) {
+ (*worker_border) (hblank_right_stop, nextpos_in_range, true);
+ lastpos = nextpos_in_range;
+ }
+
+ if (regno >= 0x1000) {
+ pfield_expand_dp_bplconx(regno, value);
+ }
+ else if (regno >= 0 && !(value & COLOR_CHANGE_MASK)) {
+ color_reg_set(&colors_for_drawing, regno, value);
+ colors_for_drawing.acolors[regno] = getxcolor(value);
+ }
+ else if (regno == 0 && (value & COLOR_CHANGE_MASK)) {
if (value & COLOR_CHANGE_BRDBLANK) {
colors_for_drawing.extra &= ~(1 << CE_BORDERBLANK);
+ colors_for_drawing.extra &= ~(1 << CE_BORDERNTRANS);
colors_for_drawing.extra &= ~(1 << CE_BORDERSPRITE);
colors_for_drawing.extra |= (value & 1) != 0 ? (1 << CE_BORDERBLANK) : 0;
colors_for_drawing.extra |= (value & 3) == 2 ? (1 << CE_BORDERSPRITE) : 0;
- }
- }
- if (lastpos >= endpos)
- break;
- }
+ colors_for_drawing.extra |= (value & 5) == 4 ? (1 << CE_BORDERNTRANS) : 0;
+ }
+ else if (value & COLOR_CHANGE_SHRES_DELAY) {
+ colors_for_drawing.extra &= ~(1 << CE_SHRES_DELAY);
+ colors_for_drawing.extra &= ~(1 << (CE_SHRES_DELAY + 1));
+ colors_for_drawing.extra |= (value & 3) << CE_SHRES_DELAY;
+ pfield_expand_dp_bplcon();
+ }
+ else if (value & COLOR_CHANGE_HSYNC_HACK) {
+ hsync_shift_hack = (uae_s8)value;
+ }
+ }
+ if (lastpos >= endpos)
+ break;
+ }
+
+ if (vp < visible_top_start || vp >= visible_bottom_stop) {
+ // outside of visible area
+ // Just overwrite with black. Above code needs to run because of custom registers,
+ // not worth the trouble for separate code path just for max 10 lines or so
+ (*worker_border) (visible_left_border, visible_left_border + gfxvidinfo.outwidth, true);
+ }
+
+ if (hsync_shift_hack > 0) {
+ // hpos shift hack
+ int shift = (hsync_shift_hack << lores_shift) * gfxvidinfo.pixbytes;
+ if (shift) {
+ int firstpos = visible_left_border * gfxvidinfo.pixbytes;
+ int lastpos = (visible_left_border + gfxvidinfo.outwidth) * gfxvidinfo.pixbytes;
+ memmove(xlinebuffer + firstpos, xlinebuffer + firstpos + shift, lastpos - firstpos - shift);
+ memset(xlinebuffer + lastpos - shift, 0, shift);
+ }
+ }
}
STATIC_INLINE bool is_color_changes(struct draw_info *di)
@@ -1718,407 +3076,1001 @@ STATIC_INLINE bool is_color_changes(struct draw_info *di)
return changes > 1 || (changes == 1 && regno != 0xffff && regno != -1);
}
-static void pfield_draw_line (int lineno, int gfx_ypos)
+enum double_how {
+ dh_buf,
+ dh_line,
+ dh_emerg
+};
+
+static void pfield_draw_line(int lineno, int gfx_ypos, int follow_ypos)
{
+ static int warned = 0;
int border = 0;
+ int do_double = 0;
bool have_color_changes;
+ enum double_how dh;
+ int ls = linestate[lineno];
- dp_for_drawing = line_decisions + lineno;
- dip_for_drawing = curr_drawinfo + lineno;
+ dp_for_drawing = line_decisions + lineno;
+ dip_for_drawing = curr_drawinfo + lineno;
- if (dp_for_drawing->plfleft < 0)
- border = 1;
+ if (dp_for_drawing->plfleft >= 0) {
+ lines_count++;
+ resolution_count[dp_for_drawing->bplres]++;
+ }
+
+ switch (ls)
+ {
+ case LINE_REMEMBERED_AS_PREVIOUS:
+ // if (!warned) // happens when program messes up with VPOSW
+ // write_log (_T("Shouldn't get here... this is a bug.\n")), warned++;
+ return;
+
+ case LINE_BLACK:
+ linestate[lineno] = LINE_REMEMBERED_AS_BLACK;
+ border = -1;
+ break;
+
+ case LINE_REMEMBERED_AS_BLACK:
+ return;
+
+ case LINE_AS_PREVIOUS:
+ dp_for_drawing--;
+ dip_for_drawing--;
+ linestate[lineno] = LINE_DONE_AS_PREVIOUS;
+ if (dp_for_drawing->plfleft < 0)
+ border = 1;
+ break;
+
+ case LINE_DONE_AS_PREVIOUS:
+ /* fall through */
+ case LINE_DONE:
+ return;
+
+ case LINE_DECIDED_DOUBLE:
+ if (follow_ypos >= 0) {
+ do_double = 1;
+ linestate[lineno + 1] = LINE_DONE_AS_PREVIOUS;
+ }
+
+ /* fall through */
+ default:
+ if (dp_for_drawing->plfleft < 0)
+ border = 1;
+ linestate[lineno] = LINE_DONE;
+ break;
+ }
have_color_changes = is_color_changes(dip_for_drawing);
-
- xlinebuffer = row_map[gfx_ypos];
+
+ dh = dh_line;
+ xlinebuffer = row_map[gfx_ypos], dh = dh_buf;
xlinebuffer -= linetoscr_x_adjust_pixbytes;
+ xlinebuffer_genlock = row_map_genlock[gfx_ypos] - linetoscr_x_adjust_pixels;
+
+ if (row_map_color_burst_buffer)
+ row_map_color_burst_buffer[gfx_ypos] = bplcolorburst;
if (border == 0) {
- pfield_expand_dp_bplcon ();
- pfield_init_linetoscr (false);
- pfield_doline (lineno);
+ pfield_expand_dp_bplcon();
+ pfield_init_linetoscr(false);
+ pfield_doline(lineno);
- adjust_drawing_colors (dp_for_drawing->ctable, dp_for_drawing->ham_seen || bplehb || ecsshres);
-
- /* The problem is that we must call decode_ham() BEFORE we do the sprites. */
- if (dp_for_drawing->ham_seen) {
+ adjust_drawing_colors(dp_for_drawing->ctable, dp_for_drawing->ham_seen || bplehb || ecsshres);
+
+ /* The problem is that we must call decode_ham() BEFORE we do the sprites. */
+ if (dp_for_drawing->ham_seen) {
int ohposblank = hposblank;
uae_u8 b0 = dp_for_drawing->bplcon0;
uae_u8 b2 = dp_for_drawing->bplcon2;
uae_u8 b3 = dp_for_drawing->bplcon3;
uae_u8 b4 = dp_for_drawing->bplcon4;
- init_ham_decoding ();
- do_color_changes (dummy_worker, decode_ham);
- if (have_color_changes) {
+ init_ham_decoding();
+ do_color_changes(dummy_worker, decode_ham, lineno);
+ if (have_color_changes) {
// do_color_changes() did color changes and register changes, restore them.
- adjust_drawing_colors (dp_for_drawing->ctable, -1);
+ adjust_drawing_colors(dp_for_drawing->ctable, -1);
dp_for_drawing->bplcon0 = b0;
dp_for_drawing->bplcon2 = b2;
dp_for_drawing->bplcon3 = b3;
dp_for_drawing->bplcon4 = b4;
- pfield_expand_dp_bplcon ();
- }
+ pfield_expand_dp_bplcon();
+ }
hposblank = ohposblank;
ham_decode_pixel = src_pixel;
- bplham = dp_for_drawing->ham_at_start;
- }
-
+ bplham = dp_for_drawing->ham_at_start;
+ }
+
if (dip_for_drawing->nr_sprites) {
int i;
+#ifdef AGA
if (ce_is_bordersprite(colors_for_drawing.extra) && dp_for_drawing->bordersprite_seen && !ce_is_borderblank(colors_for_drawing.extra))
- clear_bitplane_border_aga ();
+ clear_bitplane_border_aga();
+#endif
for (i = 0; i < dip_for_drawing->nr_sprites; i++) {
+#ifdef AGA
if (currprefs.chipset_mask & CSMASK_AGA)
- draw_sprites_aga (curr_sprite_entries + dip_for_drawing->first_sprite_entry + i, 1);
+ draw_sprites_aga(curr_sprite_entries + dip_for_drawing->first_sprite_entry + i, 1);
else
- draw_sprites_ecs (curr_sprite_entries + dip_for_drawing->first_sprite_entry + i);
+#endif
+ draw_sprites_ecs(curr_sprite_entries + dip_for_drawing->first_sprite_entry + i);
}
}
-
+
+#ifdef AGA
if (dip_for_drawing->nr_sprites && ce_is_bordersprite(colors_for_drawing.extra) && !ce_is_borderblank(colors_for_drawing.extra) && dp_for_drawing->bordersprite_seen)
- do_color_changes (pfield_do_linetoscr_bordersprite_aga, pfield_do_linetoscr_spr);
+ do_color_changes(pfield_do_linetoscr_bordersprite_aga, pfield_do_linetoscr_spr, lineno);
else
- do_color_changes (pfield_do_fill_line, dip_for_drawing->nr_sprites ? pfield_do_linetoscr_spr : pfield_do_linetoscr);
+#endif
+ do_color_changes(pfield_do_fill_line, dip_for_drawing->nr_sprites ? pfield_do_linetoscr_spr : pfield_do_linetoscr, lineno);
+
+ if (dh == dh_emerg)
+ memcpy(row_map[gfx_ypos], xlinebuffer + linetoscr_x_adjust_pixbytes, gfxvidinfo.pixbytes * gfxvidinfo.outwidth);
+
+ do_flush_line(gfx_ypos);
+ if (do_double) {
+ if (dh == dh_emerg)
+ memcpy(row_map[follow_ypos], xlinebuffer + linetoscr_x_adjust_pixbytes, gfxvidinfo.pixbytes * gfxvidinfo.outwidth);
+ else if (dh == dh_buf)
+ memcpy(row_map[follow_ypos], row_map[gfx_ypos], gfxvidinfo.pixbytes * gfxvidinfo.outwidth);
+ if (need_genlock_data)
+ memcpy(row_map_genlock[follow_ypos], row_map_genlock[gfx_ypos], gfxvidinfo.outwidth);
+ do_flush_line(follow_ypos);
+ }
if (dip_for_drawing->nr_sprites)
- pfield_erase_hborder_sprites ();
-
- } else { // border > 0: top or bottom border
+ pfield_erase_hborder_sprites();
+ }
+ else if (border > 0) { // border > 0: top or bottom border
bool dosprites = false;
- adjust_drawing_colors (dp_for_drawing->ctable, 0);
-
+ adjust_drawing_colors(dp_for_drawing->ctable, 0);
+
+#ifdef AGA /* this makes things complex.. */
if (dp_for_drawing->bordersprite_seen && !ce_is_borderblank(colors_for_drawing.extra) && dip_for_drawing->nr_sprites) {
dosprites = true;
- pfield_expand_dp_bplcon ();
- pfield_init_linetoscr (true);
- pfield_erase_vborder_sprites ();
+ pfield_expand_dp_bplcon();
+ pfield_init_linetoscr(true);
+ pfield_erase_vborder_sprites();
}
+#endif
- if (!dosprites && !have_color_changes) {
+ if (!dosprites && !have_color_changes) {
if (dp_for_drawing->plfleft < -1) {
// blanked border line
int tmp = hposblank;
hposblank = 1;
fill_line_border(lineno);
hposblank = tmp;
- } else {
- // normal border line
- fill_line_border(lineno);
- }
+ }
+ else {
+ // normal border line
+ fill_line_border(lineno);
+ }
+
+ do_flush_line(gfx_ypos);
+ if (do_double) {
+ if (dh == dh_buf) {
+ xlinebuffer = row_map[follow_ypos] - linetoscr_x_adjust_pixbytes;
+ xlinebuffer_genlock = row_map_genlock[follow_ypos] - linetoscr_x_adjust_pixels;
+ fill_line_border(lineno);
+ }
+ /* If dh == dh_line, do_flush_line will re-use the rendered line
+ * from linemem. */
+ do_flush_line(follow_ypos);
+ }
return;
}
+#ifdef AGA
if (dosprites) {
for (int i = 0; i < dip_for_drawing->nr_sprites; i++)
- draw_sprites_aga (curr_sprite_entries + dip_for_drawing->first_sprite_entry + i, 1);
- do_color_changes (pfield_do_linetoscr_bordersprite_aga, pfield_do_linetoscr_bordersprite_aga);
+ draw_sprites_aga(curr_sprite_entries + dip_for_drawing->first_sprite_entry + i, 1);
+ do_color_changes(pfield_do_linetoscr_bordersprite_aga, pfield_do_linetoscr_bordersprite_aga, lineno);
+#else
+ if (0) {
+#endif
- } else {
+ }
+ else {
playfield_start = visible_right_border;
playfield_end = visible_right_border;
- do_color_changes(pfield_do_fill_line, pfield_do_fill_line);
+ do_color_changes(pfield_do_fill_line, pfield_do_fill_line, lineno);
}
+
+ if (dh == dh_emerg)
+ memcpy(row_map[gfx_ypos], xlinebuffer + linetoscr_x_adjust_pixbytes, gfxvidinfo.pixbytes * gfxvidinfo.outwidth);
+ do_flush_line(gfx_ypos);
+ if (do_double) {
+ if (dh == dh_emerg)
+ memcpy(row_map[follow_ypos], xlinebuffer + linetoscr_x_adjust_pixbytes, gfxvidinfo.pixbytes * gfxvidinfo.outwidth);
+ else if (dh == dh_buf)
+ memcpy(row_map[follow_ypos], row_map[gfx_ypos], gfxvidinfo.pixbytes * gfxvidinfo.outwidth);
+ if (need_genlock_data)
+ memcpy(row_map_genlock[follow_ypos], row_map_genlock[gfx_ypos], gfxvidinfo.outwidth);
+ do_flush_line(follow_ypos);
+ }
+
+ } else {
+
+ // top or bottom blanking region
+ int tmp = hposblank;
+ hposblank = 1;
+ fill_line_border(lineno);
+ hposblank = tmp;
+ do_flush_line(gfx_ypos);
+
}
}
-static void center_image (void)
+static void center_image()
{
- int deltaToBorder;
- deltaToBorder = (gfxvidinfo.drawbuffer.outwidth >> currprefs.gfx_resolution) - 320;
-
- visible_left_border = 73 - (deltaToBorder >> 1);
- visible_right_border = 393 + (deltaToBorder >> 1);
- visible_left_border <<= lores_shift;
- visible_right_border <<= lores_shift;
+ int prev_x_adjust = visible_left_border;
+ int prev_y_adjust = thisframe_y_adjust;
- linetoscr_x_adjust_pixels = visible_left_border;
- linetoscr_x_adjust_pixbytes = linetoscr_x_adjust_pixels * gfxvidinfo.drawbuffer.pixbytes;
+ int w = gfxvidinfo.outwidth;
+ if (max_diwstop > 0) {
-#ifdef PANDORA
- thisframe_y_adjust_real = minfirstline + currprefs.pandora_vertical_offset;
-#else
- thisframe_y_adjust_real = minfirstline + VERTICAL_OFFSET;
+ if (max_diwstop - min_diwstart < w )//&& currprefs.gfx_xcenter == 2)
+ /* Try to center. */
+ visible_left_border = (max_diwstop - min_diwstart - w) / 2 + min_diwstart;
+ else
+ visible_left_border = max_diwstop - w - (max_diwstop - min_diwstart - w) / 2;
+ visible_left_border &= ~((xshift(1, lores_shift)) - 1);
+
+ if (!center_reset && !vertical_changed) {
+ /* Would the old value be good enough? If so, leave it as it is if we want to be clever. */
+ if (visible_left_border < prev_x_adjust && prev_x_adjust < min_diwstart && min_diwstart - visible_left_border <= 32)
+ visible_left_border = prev_x_adjust;
+ }
+ }
+ else
+ {
+ visible_left_border = 0;
+ }
+
+ if (visible_left_border > max_diwlastword - 32)
+ visible_left_border = max_diwlastword - 32;
+ if (visible_left_border < 0)
+ visible_left_border = 0;
+ visible_left_border &= ~((xshift(1, lores_shift)) - 1);
+
+ linetoscr_x_adjust_pixels = visible_left_border;
+ linetoscr_x_adjust_pixbytes = linetoscr_x_adjust_pixels * gfxvidinfo.pixbytes;
+
+ visible_right_border = visible_left_border + w;
+ if (visible_right_border > max_diwlastword)
+ visible_right_border = max_diwlastword;
+
+ int max_drawn_amiga_line_tmp = max_drawn_amiga_line;
+ if (max_drawn_amiga_line_tmp > gfxvidinfo.outheight)
+ max_drawn_amiga_line_tmp = gfxvidinfo.outheight;
+ max_drawn_amiga_line_tmp >>= linedbl;
+
+ thisframe_y_adjust = minfirstline;
+ if (thisframe_first_drawn_line >= 0) {
+ if (thisframe_last_drawn_line - thisframe_first_drawn_line < max_drawn_amiga_line_tmp )//&& currprefs.gfx_ycenter == 2)
+ thisframe_y_adjust = (thisframe_last_drawn_line - thisframe_first_drawn_line - max_drawn_amiga_line_tmp) / 2 + thisframe_first_drawn_line;
+ else
+ thisframe_y_adjust = thisframe_first_drawn_line;
+ /* Would the old value be good enough? If so, leave it as it is if we want to be clever. */
+ if (!center_reset && !horizontal_changed) {
+ if (thisframe_y_adjust != prev_y_adjust) {
+ if (prev_y_adjust <= thisframe_first_drawn_line && prev_y_adjust + max_drawn_amiga_line_tmp > thisframe_last_drawn_line)
+ thisframe_y_adjust = prev_y_adjust;
+ }
+ }
+ }
+
+ /* Make sure the value makes sense */
+ if (thisframe_y_adjust + max_drawn_amiga_line_tmp > maxvpos + maxvpos / 2)
+ thisframe_y_adjust = maxvpos + maxvpos / 2 - max_drawn_amiga_line_tmp;
+ if (thisframe_y_adjust < 0)
+ thisframe_y_adjust = 0;
+
+ thisframe_y_adjust_real = thisframe_y_adjust << linedbl;
+ max_ypos_thisframe = (maxvpos_display - minfirstline + 1) << linedbl;
+
+ if (prev_x_adjust != visible_left_border || prev_y_adjust != thisframe_y_adjust) {
+ int redraw = interlace_seen > 0 && linedbl ? 2 : 1;
+ if (redraw > frame_redraw_necessary)
+ frame_redraw_necessary = redraw;
+ }
+
+ max_diwstop = 0;
+ min_diwstart = MAX_STOP;
+
+ center_reset = false;
+ horizontal_changed = false;
+ vertical_changed = false;
+}
+
+static int frame_res_cnt;
+static int autoswitch_old_resolution;
+static void init_drawing_frame(void)
+{
+ int i, maxline;
+ static int frame_res_old;
+
+ int largest_res = 0;
+ int largest_count = 0;
+ int largest_count_res = 0;
+ for (int i = 0; i <= RES_MAX; i++) {
+ if (resolution_count[i])
+ largest_res = i;
+ if (resolution_count[i] >= largest_count) {
+ largest_count = resolution_count[i];
+ largest_count_res = i;
+ }
+ }
+ if (currprefs.gfx_resolution == changed_prefs.gfx_resolution && lines_count > 0) {
+ detected_screen_resolution = largest_res;
+ }
+
+#if 0
+ if (currprefs.gfx_resolution == changed_prefs.gfx_resolution && lines_count > 0) {
+
+ if (currprefs.gfx_autoresolution_vga && programmedmode && gfxvidinfo.gfx_resolution_reserved >= RES_HIRES && gfxvidinfo.gfx_vresolution_reserved >= VRES_DOUBLE) {
+ if (largest_res == RES_SUPERHIRES && (gfxvidinfo.gfx_resolution_reserved < RES_SUPERHIRES || gfxvidinfo.gfx_vresolution_reserved < 1)) {
+ // enable full doubling/superhires support if programmed mode. It may be "half-width" only and may fit in normal display window.
+ gfxvidinfo.gfx_resolution_reserved = RES_SUPERHIRES;
+ gfxvidinfo.gfx_vresolution_reserved = VRES_DOUBLE;
+ graphics_reset(false);
+ }
+ int newres = largest_res;
+ if (htotal < 190)
+ newres = largest_res + 1;
+ if (newres < RES_HIRES)
+ newres = RES_HIRES;
+ if (newres > RES_MAX)
+ newres = RES_MAX;
+ if (changed_prefs.gfx_resolution != newres) {
+ autoswitch_old_resolution = RES_HIRES;
+ write_log(_T("Programmed mode autores = %d -> %d (%d)\n"), changed_prefs.gfx_resolution, newres, largest_res);
+ changed_prefs.gfx_resolution = newres;
+ set_config_changed();
+ return;
+ }
+ }
+ else if (autoswitch_old_resolution == RES_HIRES) {
+ autoswitch_old_resolution = 0;
+ if (changed_prefs.gfx_resolution != RES_HIRES) {
+ changed_prefs.gfx_resolution = RES_HIRES;
+ set_config_changed();
+ return;
+ }
+ }
+
+ if (currprefs.gfx_autoresolution) {
+ int frame_res_detected;
+ int frame_res_lace_detected = frame_res_lace;
+
+ if (currprefs.gfx_autoresolution == 1 || currprefs.gfx_autoresolution >= 100)
+ frame_res_detected = largest_res;
+ else if (largest_count * 100 / lines_count >= currprefs.gfx_autoresolution)
+ frame_res_detected = largest_count_res;
+ else
+ frame_res_detected = largest_count_res - 1;
+ if (frame_res_detected < 0)
+ frame_res_detected = 0;
+
+ if (frame_res_detected >= 0 && frame_res_lace_detected >= 0) {
+ if (frame_res_cnt > 0 && frame_res_old == frame_res_detected * 2 + frame_res_lace_detected) {
+ frame_res_cnt--;
+ if (frame_res_cnt == 0) {
+ int m = frame_res_detected * 2 + frame_res_lace_detected;
+ struct wh *dst = currprefs.gfx_apmode[0].gfx_fullscreen ? &changed_prefs.gfx_size_fs : &changed_prefs.gfx_size_win;
+ while (m < 3 * 2) {
+ struct wh *src = currprefs.gfx_apmode[0].gfx_fullscreen ? &currprefs.gfx_size_fs_xtra[m] : &currprefs.gfx_size_win_xtra[m];
+ if ((src->width > 0 && src->height > 0) || (currprefs.gfx_api || currprefs.gf[0].gfx_filter > 0)) {
+ int nr = m >> 1;
+ int nl = (m & 1) == 0 ? 0 : 1;
+ int nr_o = nr;
+ int nl_o = nl;
+
+ if (currprefs.gfx_autoresolution >= 100 && nl == 0 && nr > 0) {
+ nl = 1;
+ }
+
+ if (currprefs.gfx_autoresolution_minh < 0) {
+ if (nr < nl)
+ nr = nl;
+ }
+ else if (nr < currprefs.gfx_autoresolution_minh) {
+ nr = currprefs.gfx_autoresolution_minh;
+ }
+ if (currprefs.gfx_autoresolution_minv < 0) {
+ if (nl < nr)
+ nl = nr;
+ }
+ else if (nl < currprefs.gfx_autoresolution_minv) {
+ nl = currprefs.gfx_autoresolution_minv;
+ }
+
+ if (nr > gfxvidinfo.gfx_resolution_reserved)
+ nr = gfxvidinfo.gfx_resolution_reserved;
+ if (nl > gfxvidinfo.gfx_vresolution_reserved)
+ nl = gfxvidinfo.gfx_vresolution_reserved;
+
+ if (changed_prefs.gfx_resolution != nr || changed_prefs.gfx_vresolution != nl) {
+ changed_prefs.gfx_resolution = nr;
+ changed_prefs.gfx_vresolution = nl;
+
+ write_log(_T("RES -> %d (%d) LINE -> %d (%d) (%d - %d, %d - %d)\n"), nr, nr_o, nl, nl_o,
+ currprefs.gfx_autoresolution_minh, currprefs.gfx_autoresolution_minv,
+ gfxvidinfo.gfx_resolution_reserved, gfxvidinfo.gfx_vresolution_reserved);
+ set_config_changed();
+ }
+ if (src->width > 0 && src->height > 0) {
+ if (memcmp(dst, src, sizeof *dst)) {
+ *dst = *src;
+ set_config_changed();
+ }
+ }
+ break;
+ }
+ m++;
+ }
+ frame_res_cnt = currprefs.gfx_autoresolution_delay;
+ }
+ }
+ else {
+ frame_res_old = frame_res_detected * 2 + frame_res_lace_detected;
+ frame_res_cnt = currprefs.gfx_autoresolution_delay;
+ if (frame_res_cnt <= 0)
+ frame_res_cnt = 1;
+ }
+ }
+ }
+ }
#endif
- max_ypos_thisframe = (maxvpos_display - minfirstline);
+ for (int i = 0; i <= RES_MAX; i++)
+ resolution_count[i] = 0;
+ lines_count = 0;
+ frame_res = -1;
+ frame_res_lace = 0;
+
+ if (can_use_lores > AUTO_LORES_FRAMES && 0) {
+ lores_factor = 1;
+ lores_set(0);
+ }
+ else {
+ can_use_lores++;
+ lores_reset();
+ }
+
+ init_hardware_for_drawing_frame();
+
+ if (thisframe_first_drawn_line < 0)
+ thisframe_first_drawn_line = minfirstline;
+ if (thisframe_first_drawn_line > thisframe_last_drawn_line)
+ thisframe_last_drawn_line = thisframe_first_drawn_line;
+
+ maxline = ((maxvpos_display + 1) << linedbl) + 2;
+#ifdef SMART_UPDATE
+ for (i = 0; i < maxline; i++) {
+ int ls = linestate[i];
+ switch (ls) {
+ case LINE_DONE_AS_PREVIOUS:
+ linestate[i] = LINE_REMEMBERED_AS_PREVIOUS;
+ break;
+ case LINE_REMEMBERED_AS_BLACK:
+ break;
+ default:
+ linestate[i] = LINE_UNDECIDED;
+ break;
+ }
+}
+#else
+ memset(linestate, LINE_UNDECIDED, maxline);
+#endif
+ last_drawn_line = 0;
+ first_drawn_line = 32767;
+
+ first_block_line = last_block_line = NO_BLOCK;
+ if (frame_redraw_necessary) {
+ reset_decision_table();
+ custom_frame_redraw_necessary = 1;
+ frame_redraw_necessary--;
+ }
+ else {
+ custom_frame_redraw_necessary = 0;
+ }
+
+ center_image();
+
+ thisframe_first_drawn_line = -1;
+ thisframe_last_drawn_line = -1;
+
+ drawing_color_matches = -1;
}
-static void init_drawing_frame (void)
+static int lightpen_y1, lightpen_y2;
+static int statusbar_y1, statusbar_y2;
+
+void putpixel(uae_u8 *buf, uae_u8 *genlockbuf, int bpp, int x, xcolnr c8, int opaq)
{
- lores_reset();
+ if (x <= 0)
+ return;
- init_hardware_for_drawing_frame ();
+ if (genlockbuf)
+ genlockbuf[x] = 0xff;
- linestate_first_undecided = 0;
-
- center_image ();
-
- drawing_color_matches = -1;
+ switch (bpp) {
+ case 1:
+ buf[x] = (uae_u8)c8;
+ break;
+ case 2:
+ {
+ uae_u16 *p = (uae_u16*)buf + x;
+ *p = (uae_u16)c8;
+ break;
+ }
+ case 3:
+ /* no 24 bit yet */
+ break;
+ case 4:
+ {
+ int i;
+ if (1 || opaq || currprefs.gf[0].gfx_filter == 0) {
+ uae_u32 *p = (uae_u32*)buf + x;
+ *p = c8;
+ }
+ else {
+ for (i = 0; i < 4; i++) {
+ int v1 = buf[i + bpp * x];
+ int v2 = (c8 >> (i * 8)) & 255;
+ v1 = (v1 * 2 + v2 * 3) / 5;
+ if (v1 > 255)
+ v1 = 255;
+ buf[i + bpp * x] = v1;
+ }
+ }
+ break;
+ }
+ }
}
-static void draw_status_line (int line, int statusy)
+static uae_u8 *status_line_ptr(int line)
{
- uae_u8 *buf;
+ int y;
- xlinebuffer = row_map[line];
- buf = xlinebuffer;
- draw_status_line_single (buf, statusy, gfxvidinfo.drawbuffer.outwidth);
+ y = line - (gfxvidinfo.outheight - TD_TOTAL_HEIGHT);
+ xlinebuffer = row_map[line];
+ xlinebuffer_genlock = row_map_genlock[line];
+ return xlinebuffer;
}
-static void partial_draw_frame(void)
+static void draw_status_line(int line, int statusy)
{
- if (framecnt == 0) {
- if(!screenlocked) {
- if(!lockscr())
- return;
- screenlocked = true;
- }
-
- struct vidbuffer *vb = &gfxvidinfo.drawbuffer;
- for (; next_line_to_render < max_ypos_thisframe && next_line_to_render < vb->outheight; ++next_line_to_render) {
- int line = next_line_to_render + thisframe_y_adjust_real;
- if(line >= linestate_first_undecided)
- break;
- hposblank = 0;
- pfield_draw_line (line, next_line_to_render);
- }
- }
+ uae_u8 *buf = status_line_ptr(line);
+ if (!buf)
+ return;
+ //if (statusy < 0)
+ // statusline_render(buf, gfxvidinfo.pixbytes, gfxvidinfo.rowbytes, gfxvidinfo.outwidth, TD_TOTAL_HEIGHT, xredcolors, xgreencolors, xbluecolors, NULL);
+ //else
+ draw_status_line_single(buf, statusy, gfxvidinfo.outwidth);
}
-void halt_draw_frame(void)
+static void refresh_indicator_init(void)
{
- if(screenlocked) {
- unlockscr();
- screenlocked = false;
- }
+ xfree(refresh_indicator_buffer);
+ refresh_indicator_buffer = NULL;
+ xfree(refresh_indicator_changed);
+ refresh_indicator_changed = NULL;
+ xfree(refresh_indicator_changed_prev);
+ refresh_indicator_changed_prev = NULL;
+
+ //if (!currprefs.refresh_indicator)
+ return;
+
+ refresh_indicator_height = 600;
+ refresh_indicator_buffer = xcalloc(uae_u8, MAX_PIXELS_PER_LINE * 2 * refresh_indicator_height);
+ refresh_indicator_changed = xcalloc(uae_u8, refresh_indicator_height);
+ refresh_indicator_changed_prev = xcalloc(uae_u8, refresh_indicator_height);
}
-static void finish_drawing_frame (void)
+static const int refresh_indicator_colors[] = { 0x777, 0x0f0, 0x00f, 0xff0, 0xf0f };
+
+static void refresh_indicator_update()
{
- int i;
- struct vidbuffer *vb = &gfxvidinfo.drawbuffer;
-
- if(!screenlocked) {
- if(!lockscr())
- return;
- screenlocked = true;
- }
-
- for (i = next_line_to_render; i < max_ypos_thisframe && i < vb->outheight; i++) {
+ for (int i = 0; i < max_ypos_thisframe; i++) {
+ int i1 = i + min_ypos_for_screen;
int line = i + thisframe_y_adjust_real;
- if(line >= linestate_first_undecided)
+ int whereline = amiga2aspect_line_map[i1];
+ int wherenext = amiga2aspect_line_map[i1 + 1];
+
+ if (whereline >= gfxvidinfo.outheight)
+ break;
+ if (whereline < 0)
+ continue;
+ if (line >= refresh_indicator_height)
break;
- hposblank = 0;
- pfield_draw_line (line, i);
+ xlinebuffer = row_map[whereline];
+ uae_u8 pixel = refresh_indicator_changed_prev[line];
+ if (wherenext >= 0) {
+ pixel = refresh_indicator_changed_prev[line & ~1];
+ }
+
+ int color1 = 0;
+ int color2 = 0;
+ if (pixel <= 4) {
+ color1 = color2 = refresh_indicator_colors[pixel];
+ }
+ else if (pixel <= 8) {
+ color2 = refresh_indicator_colors[pixel - 5];
+ }
+ for (int x = 0; x < 8; x++) {
+ putpixel(xlinebuffer, NULL, gfxvidinfo.pixbytes, x, xcolors[color1], 1);
+ }
+ for (int x = 8; x < 16; x++) {
+ putpixel(xlinebuffer, NULL, gfxvidinfo.pixbytes, x, xcolors[color2], 1);
+ }
}
-
- if (currprefs.leds_on_screen) {
- for (i = 0; i < TD_TOTAL_HEIGHT; i++) {
- int line = gfxvidinfo.drawbuffer.outheight - TD_TOTAL_HEIGHT + i;
- draw_status_line (line, i);
+}
+
+static void draw_frame2()
+{
+ int i;
+
+ for (i = 0; i < max_ypos_thisframe; i++) {
+ int i1 = i + min_ypos_for_screen;
+ int line = i + thisframe_y_adjust_real;
+ int whereline = amiga2aspect_line_map[i1];
+ int wherenext = amiga2aspect_line_map[i1 + 1];
+
+ if (whereline >= gfxvidinfo.outheight)
+ break;
+ if (whereline < 0)
+ continue;
+
+ hposblank = 0;
+ pfield_draw_line(line, whereline, wherenext);
+ }
+}
+
+static void finish_drawing_frame()
+{
+ int i;
+
+ draw_frame2();
+
+ if (currprefs.leds_on_screen)
+ {
+ for (i = 0; i < TD_TOTAL_HEIGHT; i++)
+ {
+ int line = gfxvidinfo.outheight - TD_TOTAL_HEIGHT + i;
+ draw_status_line(line, i);
+ do_flush_line(line);
}
}
- if (currprefs.cs_cd32fmv) {
- if (cd32_fmv_active) {
- cd32_fmv_genlock(vb, &gfxvidinfo.drawbuffer);
- }
- }
+ if (refresh_indicator_buffer)
+ refresh_indicator_update();
- do_flush_screen ();
- next_line_to_render = 0;
+ do_flush_screen();
+}
+
+void hardware_line_completed(int lineno)
+{
+#ifndef SMART_UPDATE
+ {
+ int i, where;
+ /* l is the line that has been finished for drawing. */
+ i = lineno - thisframe_y_adjust_real;
+ if (i >= 0 && i < max_ypos_thisframe) {
+ where = amiga2aspect_line_map[i + min_ypos_for_screen];
+ if (where < gfxvidinfo.drawbuffer.outheight && where >= 0)
+ pfield_draw_line(lineno, where, amiga2aspect_line_map[i + min_ypos_for_screen + 1]);
+ }
+ }
+#endif
}
void check_prefs_picasso(void)
{
#ifdef PICASSO96
- if (picasso_on)
- picasso_refresh ();
+ if (picasso_on && picasso_redraw_necessary)
+ picasso_refresh();
+ picasso_redraw_necessary = 0;
- if (picasso_requested_on == picasso_on && !picasso_requested_forced_on)
- return;
+ if (picasso_requested_on == picasso_on && !picasso_requested_forced_on)
+ return;
+
+ if (picasso_requested_on) {
+ picasso_requested_forced_on = false;
+ picasso_on = false;
+ picasso_requested_on = false;
+ return;
+ }
picasso_requested_forced_on = false;
- picasso_on = picasso_requested_on;
+ picasso_on = picasso_requested_on;
- if (!picasso_on)
- clear_inhibit_frame (IHF_PICASSO);
- else
- set_inhibit_frame (IHF_PICASSO);
+ if (!picasso_on)
+ clear_inhibit_frame(IHF_PICASSO);
+ else
+ set_inhibit_frame(IHF_PICASSO);
- gfx_set_picasso_state (picasso_on);
- picasso_enablescreen (picasso_requested_on);
+ gfx_set_picasso_state(picasso_on);
+ picasso_enablescreen(picasso_requested_on);
- notice_new_xcolors ();
- count_frame ();
+ notice_screen_contents_lost();
+ notice_new_xcolors();
+ count_frame();
+ compute_framesync();
#endif
}
-bool vsync_handle_check (void)
+void redraw_frame(void)
{
- int changed = check_prefs_changed_gfx ();
- if (changed) {
- reset_drawing ();
- notice_new_xcolors ();
- }
- device_check_config();
+ last_drawn_line = 0;
+ first_drawn_line = 32767;
+ finish_drawing_frame();
+ flush_screen();
+}
+
+bool vsync_handle_check(void)
+{
+ int changed = check_prefs_changed_gfx();
+ if (changed > 0) {
+ reset_drawing();
+ init_row_map();
+ init_aspect_maps();
+ notice_screen_contents_lost();
+ notice_new_xcolors();
+ }
+ else if (changed < 0) {
+ reset_drawing();
+ init_row_map();
+ init_aspect_maps();
+ notice_screen_contents_lost();
+ notice_new_xcolors();
+ }
+ check_prefs_changed_cd();
+ check_prefs_changed_audio();
+ check_prefs_changed_custom();
+ check_prefs_changed_cpu();
+ check_prefs_picasso();
return changed != 0;
}
-void vsync_handle_redraw (void)
+void vsync_handle_redraw(int long_field, int lof_changed, uae_u16 bplcon0p, uae_u16 bplcon3p)
{
- if (framecnt == 0) {
- if(render_tid) {
- while(render_thread_busy)
- sleep_millis(1);
- write_comm_pipe_u32 (render_pipe, RENDER_SIGNAL_FRAME_DONE, 1);
- uae_sem_wait (&render_sem);
- }
- }
+ last_redraw_point++;
+ if (lof_changed || interlace_seen <= 0 || (currprefs.gfx_iscanlines && interlace_seen > 0) || last_redraw_point >= 2 || long_field) {
+ last_redraw_point = 0;
- if (quit_program < 0) {
- if(render_tid) {
- while(render_thread_busy)
- sleep_millis(1);
- write_comm_pipe_u32 (render_pipe, RENDER_SIGNAL_QUIT, 1);
- while(render_tid != 0) {
- sleep_millis(10);
- }
- destroy_comm_pipe(render_pipe);
- xfree(render_pipe);
- render_pipe = 0;
- uae_sem_destroy(&render_sem);
- render_sem = 0;
- }
+ if (framecnt == 0)
+ finish_drawing_frame();
+ if (quit_program < 0)
+ {
quit_program = -quit_program;
- set_inhibit_frame (IHF_QUIT_PROGRAM);
+ set_inhibit_frame(IHF_QUIT_PROGRAM);
set_special(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE);
return;
}
- count_frame ();
+ count_frame();
if (framecnt == 0)
- init_drawing_frame ();
+ init_drawing_frame();
+ else if (currprefs.cpu_memory_cycle_exact)
+ init_hardware_for_drawing_frame();
+ }
+ else {
+ if (isvsync_chipset())
+ flush_screen(); /* vsync mode */
+ }
- gui_flicker_led (-1, 0, 0);
+ gui_flicker_led(-1, 0, 0);
}
-void hsync_record_line_state (int lineno)
+void hsync_record_line_state(int lineno, enum nln_how how, int changed)
{
- if (framecnt != 0)
- return;
+ uae_u8 *state;
- linestate_first_undecided = lineno + 1;
+ if (framecnt != 0)
+ return;
- if(render_tid && !(linestate_first_undecided & 0x1f) && !render_thread_busy) {
- write_comm_pipe_u32 (render_pipe, RENDER_SIGNAL_PARTIAL, 1);
- }
+ state = linestate + lineno;
+ changed |= frame_redraw_necessary != 0 || refresh_indicator_buffer != NULL ||
+ ((lineno >= lightpen_y1 && lineno < lightpen_y2) ||
+ (lineno >= statusbar_y1 && lineno < statusbar_y2));
+
+ switch (how) {
+ case nln_normal:
+ *state = changed ? LINE_DECIDED : LINE_DONE;
+ break;
+ case nln_doubled:
+ *state = changed ? LINE_DECIDED_DOUBLE : LINE_DONE;
+ changed |= state[1] != LINE_REMEMBERED_AS_PREVIOUS;
+ state[1] = changed ? LINE_AS_PREVIOUS : LINE_DONE_AS_PREVIOUS;
+ break;
+ case nln_nblack:
+ *state = changed ? LINE_DECIDED : LINE_DONE;
+ if (state[1] != LINE_REMEMBERED_AS_BLACK) {
+ state[1] = LINE_BLACK;
+ }
+ break;
+ case nln_lower:
+ if (lineno > 0 && state[-1] == LINE_UNDECIDED) {
+ state[-1] = LINE_DECIDED; //LINE_BLACK;
+ }
+ *state = changed ? LINE_DECIDED : LINE_DONE;
+ break;
+ case nln_upper:
+ *state = changed ? LINE_DECIDED : LINE_DONE;
+ if (state[1] == LINE_UNDECIDED
+ || state[1] == LINE_REMEMBERED_AS_PREVIOUS
+ || state[1] == LINE_AS_PREVIOUS)
+ state[1] = LINE_DECIDED; //LINE_BLACK;
+ break;
+ case nln_lower_black_always:
+ state[1] = LINE_BLACK;
+ *state = LINE_DECIDED;
+ // if (lineno == (maxvpos + lof_store) * 2 - 1)
+ // *state = LINE_BLACK;
+ break;
+ case nln_lower_black:
+ changed |= state[0] != LINE_DONE;
+ state[1] = LINE_DONE;
+ *state = changed ? LINE_DECIDED : LINE_DONE;
+ // if (lineno == (maxvpos + lof_store) * 2 - 1)
+ // *state = LINE_BLACK;
+ break;
+ //case nln_upper_black_always:
+ // *state = LINE_DECIDED;
+ // if (lineno > 0) {
+ // state[-1] = LINE_BLACK;
+ // }
+ // if (!interlace_seen && lineno == (maxvpos + lof_store) * 2 - 2) {
+ // state[1] = LINE_BLACK;
+ // }
+ // break;
+ //case nln_upper_black:
+ // changed |= state[0] != LINE_DONE;
+ // *state = changed ? LINE_DECIDED : LINE_DONE;
+ // if (lineno > 0) {
+ // state[-1] = LINE_DONE;
+ // }
+ // if (!interlace_seen && lineno == (maxvpos + lof_store) * 2 - 2) {
+ // state[1] = LINE_DONE;
+ // }
+ // break;
+ }
}
-bool notice_interlace_seen (bool lace)
+void notice_resolution_seen(int res, bool lace)
+{
+ if (res > frame_res)
+ frame_res = res;
+ if (res > 0)
+ can_use_lores = 0;
+ if (!frame_res_lace && lace)
+ frame_res_lace = lace;
+}
+
+bool notice_interlace_seen(bool lace)
{
bool changed = false;
// non-lace to lace switch (non-lace active at least one frame)?
if (lace) {
if (interlace_seen == 0) {
changed = true;
+ //write_log (_T("->lace PC=%x\n"), m68k_getpc ());
}
- interlace_seen = -1;
- } else {
+ interlace_seen = currprefs.gfx_vresolution ? 1 : -1;
+ }
+ else {
if (interlace_seen) {
changed = true;
+ //write_log (_T("->non-lace PC=%x\n"), m68k_getpc ());
}
interlace_seen = 0;
}
return changed;
}
-void reset_drawing (void)
+void reset_drawing()
{
- lores_reset ();
+ max_diwstop = 0;
- linestate_first_undecided = 0;
-
- init_aspect_maps ();
+ lores_reset();
- init_row_map();
+ reset_decision_table();
- memset(spixels, 0, sizeof spixels);
- memset(&spixstate, 0, sizeof spixstate);
+ init_aspect_maps();
- init_drawing_frame ();
+ init_row_map();
+
+ last_redraw_point = 0;
+
+ memset(spixels, 0, sizeof spixels);
+ memset(&spixstate, 0, sizeof spixstate);
+
+ init_drawing_frame();
pfield_set_linetoscr();
+
+ notice_screen_contents_lost();
+ frame_res_cnt = currprefs.gfx_autoresolution_delay;
+ lightpen_y1 = lightpen_y2 = -1;
+
+ reset_custom_limits();
+
+ center_reset = true;
+ bplcolorburst_field = 1;
+ hsync_shift_hack = 0;
}
static void gen_direct_drawing_table(void)
{
+#ifdef AGA
// BYPASS color table
for (int i = 0; i < 256; i++) {
uae_u32 v = (i << 16) | (i << 8) | i;
direct_colors_for_drawing.acolors[i] = CONVERT_RGB(v);
}
+#endif
}
-static void *render_thread (void *unused)
+void drawing_init(void)
{
- for(;;) {
- render_thread_busy = false;
- uae_u32 signal = read_comm_pipe_u32_blocking(render_pipe);
- render_thread_busy = true;
- switch(signal) {
- case RENDER_SIGNAL_PARTIAL:
- partial_draw_frame();
- break;
+ refresh_indicator_init();
- case RENDER_SIGNAL_FRAME_DONE:
- finish_drawing_frame();
- uae_sem_post (&render_sem);
- break;
-
- case RENDER_SIGNAL_QUIT:
- render_tid = 0;
- return 0;
- }
- }
-}
-
-void drawing_init (void)
-{
- gen_pfield_tables();
+ gen_pfield_tables();
gen_direct_drawing_table();
- if(render_pipe == 0) {
- render_pipe = xmalloc (smp_comm_pipe, 1);
- init_comm_pipe(render_pipe, 20, 1);
- }
- if(render_sem == 0) {
- uae_sem_init (&render_sem, 0, 0);
- }
- if(render_tid == 0 && render_pipe != 0 && render_sem != 0) {
- uae_start_thread(_T("render"), render_thread, NULL, &render_tid);
- }
-
#ifdef PICASSO96
- if (!isrestore ()) {
- picasso_on = 0;
- picasso_requested_on = 0;
- gfx_set_picasso_state (0);
- }
+ if (!isrestore()) {
+ picasso_on = false;
+ picasso_requested_on = false;
+ gfx_set_picasso_state(0);
+ }
#endif
- xlinebuffer = gfxvidinfo.drawbuffer.bufmem;
+ xlinebuffer = gfxvidinfo.bufmem;
+ xlinebuffer_genlock = nullptr;
- inhibit_frame = 0;
+ inhibit_frame = 0;
- reset_drawing ();
+ reset_drawing();
+}
+
+int isvsync_chipset(void)
+{
+ if (picasso_on || currprefs.gfx_apmode[0].gfx_vsync <= 0)
+ return 0;
+ if (currprefs.gfx_apmode[0].gfx_vsyncmode == 0)
+ return 1;
+ if (currprefs.m68k_speed >= 0)
+ return -1;
+ return currprefs.cachesize ? -3 : -2;
+}
+
+int isvsync_rtg(void)
+{
+ if (!picasso_on || currprefs.gfx_apmode[1].gfx_vsync <= 0)
+ return 0;
+ if (currprefs.gfx_apmode[1].gfx_vsyncmode == 0)
+ return 1;
+ if (currprefs.m68k_speed >= 0)
+ return -1;
+ return currprefs.cachesize ? -3 : -2;
+}
+
+int isvsync(void)
+{
+ if (picasso_on)
+ return isvsync_rtg();
+ else
+ return isvsync_chipset();
}
diff --git a/src/events.cpp b/src/events.cpp
index 447ca2b0..7c68e217 100644
--- a/src/events.cpp
+++ b/src/events.cpp
@@ -14,121 +14,202 @@
#include "options.h"
#include "include/memory.h"
#include "newcpu.h"
+#include "events.h"
+
+static const int pissoff_nojit_value = 256 * CYCLE_UNIT;
+
+unsigned long int event_cycles, nextevent, currcycle;
+int is_syncline, is_syncline_end;
+long cycles_to_next_event;
+long max_cycles_to_next_event;
+long cycles_to_hsync_event;
+unsigned long start_cycles;
+bool event_wait;
-unsigned long int nextevent, currcycle;
-int is_syncline;
frame_time_t vsyncmintime, vsyncmaxtime, vsyncwaittime;
int vsynctimebase;
+int event2_count;
void events_schedule (void)
{
- int i;
+ int i;
- unsigned long int mintime = ~0L;
- for (i = 0; i < ev_max; i++) {
- if (eventtab[i].active) {
- unsigned long int eventtime = eventtab[i].evtime - currcycle;
- if (eventtime < mintime)
- mintime = eventtime;
- }
- }
- nextevent = currcycle + mintime;
+ unsigned long int mintime = ~0L;
+ for (i = 0; i < ev_max; i++)
+ {
+ if (eventtab[i].active)
+ {
+ unsigned long int eventtime = eventtab[i].evtime - currcycle;
+ if (eventtime < mintime)
+ mintime = eventtime;
+ }
+ }
+ nextevent = currcycle + mintime;
}
void do_cycles_cpu_fastest (unsigned long cycles_to_add)
{
- if ((regs.pissoff -= cycles_to_add) > 0)
- return;
+ if ((pissoff -= cycles_to_add) > 0)
+ return;
- cycles_to_add = -regs.pissoff;
- regs.pissoff = 0;
+ cycles_to_add = -pissoff;
+ pissoff = 0;
- /* Keep only CPU emulation running while waiting for sync point. */
- if (is_syncline) {
- int rpt = read_processor_time ();
- int v = rpt - vsyncmintime;
- if (v > vsynctimebase || v < -vsynctimebase) {
- v = 0;
- }
- if (v < speedup_timelimit) {
- regs.pissoff = pissoff_value;
- return;
- }
- is_syncline = 0;
- }
+ if (is_syncline && eventtab[ev_hsync].evtime - currcycle <= cycles_to_add)
+ {
+ int rpt = read_processor_time();
+ int v = rpt - vsyncmintime;
+ if (v > syncbase || v < -syncbase)
+ vsyncmintime = rpt;
+ if (v < speedup_timelimit)
+ {
+ pissoff = pissoff_value;
+ return;
+ }
+ is_syncline = 0;
+ }
- while ((nextevent - currcycle) <= cycles_to_add) {
- int i;
+ while ((nextevent - currcycle) <= cycles_to_add)
+ {
+ int i;
+ cycles_to_add -= (nextevent - currcycle);
+ currcycle = nextevent;
- cycles_to_add -= (nextevent - currcycle);
- currcycle = nextevent;
-
- for (i = 0; i < ev_max; i++) {
- if (eventtab[i].active && eventtab[i].evtime == currcycle) {
- (*eventtab[i].handler)();
- }
- }
- events_schedule();
- }
- currcycle += cycles_to_add;
+ for (i = 0; i < ev_max; i++)
+ {
+ if (eventtab[i].active && eventtab[i].evtime == currcycle)
+ {
+ (*eventtab[i].handler)();
+ }
+ }
+ events_schedule();
+ }
+ currcycle += cycles_to_add;
}
void do_cycles_cpu_norm (unsigned long cycles_to_add)
{
- while ((nextevent - currcycle) <= cycles_to_add) {
- int i;
+ while ((nextevent - currcycle) <= cycles_to_add)
+ {
+ int i;
+ cycles_to_add -= (nextevent - currcycle);
+ currcycle = nextevent;
- cycles_to_add -= (nextevent - currcycle);
- currcycle = nextevent;
-
- for (i = 0; i < ev_max; i++) {
- if (eventtab[i].active && eventtab[i].evtime == currcycle) {
- (*eventtab[i].handler)();
- }
- }
- events_schedule();
- }
- currcycle += cycles_to_add;
+ for (i = 0; i < ev_max; i++)
+ {
+ if (eventtab[i].active && eventtab[i].evtime == currcycle)
+ {
+ (*eventtab[i].handler)();
+ }
+ }
+ events_schedule();
+ }
+ currcycle += cycles_to_add;
}
do_cycles_func do_cycles = do_cycles_cpu_norm;
void MISC_handler(void)
{
- int i;
- evt mintime;
- evt ct = get_cycles();
- static int recursive;
+ int i;
+ evt mintime;
+ evt ct = get_cycles();
+ static int recursive;
- if (recursive) {
- return;
- }
- recursive++;
- eventtab[ev_misc].active = 0;
-
- mintime = ~0L;
- for (i = 0; i < ev2_max; i++) {
- if (eventtab2[i].active) {
- if (eventtab2[i].evtime == ct) {
- eventtab2[i].active = false;
- eventtab2[i].handler(eventtab2[i].data);
- if (eventtab2[i].active) {
- evt eventtime = eventtab2[i].evtime - ct;
- if (eventtime < mintime)
- mintime = eventtime;
- }
- } else {
- evt eventtime = eventtab2[i].evtime - ct;
- if (eventtime < mintime)
- mintime = eventtime;
- }
+ if (recursive)
+ {
+ return;
}
- }
+ recursive++;
+ eventtab[ev_misc].active = 0;
- if (mintime != ~0UL) {
- eventtab[ev_misc].active = true;
- eventtab[ev_misc].evtime = ct + mintime;
- events_schedule();
- }
- recursive--;
+ mintime = ~0L;
+ for (i = 0; i < ev2_max; i++)
+ {
+ if (eventtab2[i].active)
+ {
+ if (eventtab2[i].evtime == ct)
+ {
+ eventtab2[i].active = false;
+ eventtab2[i].handler(eventtab2[i].data);
+ if (eventtab2[i].active)
+ {
+ evt eventtime = eventtab2[i].evtime - ct;
+ if (eventtime < mintime)
+ mintime = eventtime;
+ }
+ }
+ else
+ {
+ evt eventtime = eventtab2[i].evtime - ct;
+ if (eventtime < mintime)
+ mintime = eventtime;
+ }
+ }
+ }
+
+ if (mintime != ~0L)
+ {
+ eventtab[ev_misc].active = true;
+ eventtab[ev_misc].evtime = ct + mintime;
+ events_schedule();
+ }
+ recursive--;
}
+
+void event2_newevent_xx(int no, evt t, uae_u32 data, evfunc2 func)
+{
+ evt et;
+ static int next = ev2_misc;
+
+ et = t + get_cycles();
+ if (no < 0) {
+ no = next;
+ for (;;) {
+ if (!eventtab2[no].active) {
+ event2_count++;
+ break;
+ }
+ if (eventtab2[no].evtime == et && eventtab2[no].handler == func && eventtab2[no].data == data)
+ break;
+ no++;
+ if (no == ev2_max)
+ no = ev2_misc;
+ if (no == next) {
+ write_log(_T("out of event2's!\n"));
+ return;
+ }
+ }
+ next = no;
+ }
+ eventtab2[no].active = true;
+ eventtab2[no].evtime = et;
+ eventtab2[no].handler = func;
+ eventtab2[no].data = data;
+ MISC_handler();
+}
+
+void event2_newevent_x_replace(evt t, uae_u32 data, evfunc2 func)
+{
+ for (int i = 0; i < ev2_max; i++) {
+ if (eventtab2[i].active && eventtab2[i].handler == func) {
+ eventtab2[i].active = false;
+ }
+ }
+ if (int(t) <= 0) {
+ func(data);
+ return;
+ }
+ event2_newevent_xx(-1, t * CYCLE_UNIT, data, func);
+}
+
+
+int current_hpos(void)
+{
+ int hp = current_hpos_safe();
+ if (hp < 0 || hp > 256) {
+ gui_message(_T("hpos = %d!?\n"), hp);
+ hp = 0;
+ }
+ return hp;
+}
\ No newline at end of file
diff --git a/src/expansion.cpp b/src/expansion.cpp
index 7d4610f0..9b691635 100644
--- a/src/expansion.cpp
+++ b/src/expansion.cpp
@@ -1,34 +1,55 @@
- /*
- * UAE - The Un*x Amiga Emulator
- *
- * AutoConfig (tm) Expansions (ZorroII/III)
- *
- * Copyright 1996,1997 Stefan Reinauer
- * Copyright 1997 Brian King
- * - added gfxcard code
- *
- */
+/*
+* UAE - The Un*x Amiga Emulator
+*
+* AutoConfig (tm) Expansions (ZorroII/III)
+*
+* Copyright 1996,1997 Stefan Reinauer
+* Copyright 1997 Brian King
+* - added gfxcard code
+*
+*/
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
#include "uae.h"
-#include "traps.h"
-#include "memory.h"
+//#include "traps.h"
+#include "include/memory.h"
#include "rommgr.h"
#include "custom.h"
#include "newcpu.h"
#include "savestate.h"
#include "zfile.h"
+//#include "catweasel.h"
+//#include "cdtv.h"
+//#include "cdtvcr.h"
#include "threaddep/thread.h"
+//#include "a2091.h"
+//#include "a2065.h"
#include "gfxboard.h"
-#include "cd32_fmv.h"
-#include "gayle.h"
+//#include "cd32_fmv.h"
+//#include "ncr_scsi.h"
+//#include "ncr9x_scsi.h"
+#include "scsi.h"
+#include "debug.h"
+//#include "gayle.h"
+//#include "idecontrollers.h"
+//#include "cpuboard.h"
+//#include "sndboard.h"
+//#include "uae/ppc.h"
#include "autoconf.h"
+//#include "specialmonitors.h"
+#include "inputdevice.h"
+//#include "pci.h"
+//#include "x86.h"
#include "filesys.h"
+//#include "ethernet.h"
+//#include "sana2.h"
+
#define CARD_FLAG_CAN_Z3 1
+#define CARD_FLAG_CHILD 8
// More information in first revision HRM Appendix_G
#define BOARD_PROTOAUTOCONFIG 1
@@ -42,20 +63,22 @@
#define KS12_BOOT_HACK 1
+#define EXP_DEBUG 0
+
#define MAX_EXPANSION_BOARD_SPACE 16
/* ********************************************************** */
/* 00 / 02 */
/* er_Type */
-#define Z2_MEM_8MB 0x00 /* Size of Memory Block */
-#define Z2_MEM_4MB 0x07
-#define Z2_MEM_2MB 0x06
-#define Z2_MEM_1MB 0x05
+#define Z2_MEM_8MB 0x00 /* Size of Memory Block */
+#define Z2_MEM_4MB 0x07
+#define Z2_MEM_2MB 0x06
+#define Z2_MEM_1MB 0x05
#define Z2_MEM_512KB 0x04
#define Z2_MEM_256KB 0x03
#define Z2_MEM_128KB 0x02
-#define Z2_MEM_64KB 0x01
+#define Z2_MEM_64KB 0x01
/* extended definitions */
#define Z3_MEM_16MB 0x00
#define Z3_MEM_32MB 0x01
@@ -85,10 +108,10 @@
#define hackers_id 2011 /* Special ID for test cards */
/* Card Type */
-#define commodore_a2091 3 /* A2091 / A590 Card from C= */
+#define commodore_a2091 3 /* A2091 / A590 Card from C= */
#define commodore_a2091_ram 10 /* A2091 / A590 Ram on HD-Card */
#define commodore_a2232 70 /* A2232 Multiport Expansion */
-#define ass_nexus_scsi 1 /* Nexus SCSI Controller */
+#define ass_nexus_scsi 1 /* Nexus SCSI Controller */
#define gvp_series_2_scsi 11
#define gvp_iv_24_gfx 32
@@ -151,15 +174,15 @@ static bool chipdone;
static int do_mount;
#define FILESYS_DIAGPOINT 0x01e0
-#define FILESYS_BOOTPOINT 0x01f0
+#define FILESYS_BOOTPOINT 0x01e6
#define FILESYS_DIAGAREA 0x2000
/* ********************************************************** */
struct card_data
{
- bool (*initrc)(struct autoconfig_info*);
- bool (*initnum)(struct autoconfig_info*);
+ bool(*initrc)(struct autoconfig_info*);
+ bool(*initnum)(struct autoconfig_info*);
addrbank *(*map)(struct autoconfig_info*);
struct romconfig *rc;
const TCHAR *name;
@@ -169,6 +192,7 @@ struct card_data
uae_u32 size;
// parsing updated fields
const struct expansionromtype *ert;
+ const struct cpuboardsubtype *cst;
struct autoconfig_info aci;
};
@@ -201,26 +225,27 @@ static bool ks11orolder(void)
/* ********************************************************** */
/* Please note: ZorroIII implementation seems to work different
- * than described in the HRM. This claims that ZorroIII config
- * address is 0xff000000 while the ZorroII config space starts
- * at 0x00e80000. In reality, both, Z2 and Z3 cards are
- * configured in the ZorroII config space. Kickstart 3.1 doesn't
- * even do a single read or write access to the ZorroIII space.
- * The original Amiga include files tell the same as the HRM.
- * ZorroIII: If you set ext_size in er_Flags and give a Z2-size
- * in er_Type you can very likely add some ZorroII address space
- * to a ZorroIII card on a real Amiga. This is not implemented
- * yet.
- * -- Stefan
- *
- * Surprising that 0xFF000000 isn't used. Maybe it depends on the
- * ROM. Anyway, the HRM says that Z3 cards may appear in Z2 config
- * space, so what we are doing here is correct.
- * -- Bernd
- */
+* than described in the HRM. This claims that ZorroIII config
+* address is 0xff000000 while the ZorroII config space starts
+* at 0x00e80000. In reality, both, Z2 and Z3 cards are
+* configured in the ZorroII config space. Kickstart 3.1 doesn't
+* even do a single read or write access to the ZorroIII space.
+* The original Amiga include files tell the same as the HRM.
+* ZorroIII: If you set ext_size in er_Flags and give a Z2-size
+* in er_Type you can very likely add some ZorroII address space
+* to a ZorroIII card on a real Amiga. This is not implemented
+* yet.
+* -- Stefan
+*
+* Surprising that 0xFF000000 isn't used. Maybe it depends on the
+* ROM. Anyway, the HRM says that Z3 cards may appear in Z2 config
+* space, so what we are doing here is correct.
+* -- Bernd
+*/
/* Autoconfig address space at 0xE80000 */
static uae_u8 expamem[65536];
+static uae_u8 expamem_write_space[65536];
#define AUTOMATIC_AUTOCONFIG_MAX_ADDRESS 0x80
static int expamem_autoconfig_mode;
static addrbank*(*expamem_map)(struct autoconfig_info*);
@@ -248,36 +273,36 @@ bool expamem_z3hack(struct uae_prefs *p)
return true;
if (z3hack_override == Z3MAPPING_REAL)
return false;
- return p->z3_mapping_mode == Z3MAPPING_UAE;
+ return p->z3_mapping_mode == Z3MAPPING_UAE; //|| cpuboard_memorytype(p) == BOARD_MEMORY_BLIZZARD_12xx;
}
/* Ugly hack for >2M chip RAM in single pool
- * We can't add it any later or early boot menu
- * stops working because it sets kicktag at the end
- * of chip ram...
- */
-static void addextrachip (uae_u32 sysbase)
+* We can't add it any later or early boot menu
+* stops working because it sets kicktag at the end
+* of chip ram...
+*/
+static void addextrachip(uae_u32 sysbase)
{
if (currprefs.chipmem_size <= 0x00200000)
return;
if (sysbase & 0x80000001)
return;
- if (!valid_address (sysbase, 1000))
+ if (!valid_address(sysbase, 1000))
return;
- uae_u32 ml = get_long (sysbase + 322);
- if (!valid_address (ml, 32))
+ uae_u32 ml = get_long(sysbase + 322);
+ if (!valid_address(ml, 32))
return;
uae_u32 next;
- while ((next = get_long (ml))) {
- if (!valid_address (ml, 32))
+ while ((next = get_long(ml))) {
+ if (!valid_address(ml, 32))
return;
- uae_u32 upper = get_long (ml + 24);
- uae_u32 lower = get_long (ml + 20);
+ uae_u32 upper = get_long(ml + 24);
+ uae_u32 lower = get_long(ml + 20);
if (lower & ~0xffff) {
ml = next;
continue;
}
- uae_u16 attr = get_word (ml + 14);
+ uae_u16 attr = get_word(ml + 14);
if ((attr & 0x8002) != 2) {
ml = next;
continue;
@@ -285,32 +310,41 @@ static void addextrachip (uae_u32 sysbase)
if (upper >= currprefs.chipmem_size)
return;
uae_u32 added = currprefs.chipmem_size - upper;
- uae_u32 first = get_long (ml + 16);
- put_long (ml + 24, currprefs.chipmem_size); // mh_Upper
- put_long (ml + 28, get_long (ml + 28) + added); // mh_Free
+ uae_u32 first = get_long(ml + 16);
+ put_long(ml + 24, currprefs.chipmem_size); // mh_Upper
+ put_long(ml + 28, get_long(ml + 28) + added); // mh_Free
uae_u32 next;
while (first) {
next = first;
- first = get_long (next);
+ first = get_long(next);
}
- uae_u32 bytes = get_long (next + 4);
+ uae_u32 bytes = get_long(next + 4);
if (next + bytes == 0x00200000) {
- put_long (next + 4, currprefs.chipmem_size - next);
- } else {
- put_long (0x00200000 + 0, 0);
- put_long (0x00200000 + 4, added);
- put_long (next, 0x00200000);
+ put_long(next + 4, currprefs.chipmem_size - next);
+ }
+ else {
+ put_long(0x00200000 + 0, 0);
+ put_long(0x00200000 + 4, added);
+ put_long(next, 0x00200000);
}
return;
}
}
-addrbank expamem_null;
+addrbank expamem_null, expamem_none;
+DECLARE_MEMORY_FUNCTIONS(expamem_write);
+addrbank expamem_write_bank = {
+ expamem_write_lget, expamem_write_wget, expamem_write_bget,
+ expamem_write_lput, expamem_write_wput, expamem_write_bput,
+ default_xlate, default_check, NULL, NULL, _T("Autoconfig Z2 WRITE"),
+ dummy_lgeti, dummy_wgeti,
+ ABFLAG_IO | ABFLAG_SAFE | ABFLAG_PPCIOSPACE, S_READ, S_WRITE
+};
DECLARE_MEMORY_FUNCTIONS(expamem);
addrbank expamem_bank = {
- expamem_lget, expamem_wget, expamem_bget,
- expamem_lput, expamem_wput, expamem_bput,
+ expamem_lget, expamem_wget, expamem_bget,
+ expamem_lput, expamem_wput, expamem_bput,
default_xlate, default_check, NULL, NULL, _T("Autoconfig Z2"),
dummy_lgeti, dummy_wgeti,
ABFLAG_IO | ABFLAG_SAFE | ABFLAG_PPCIOSPACE, S_READ, S_WRITE
@@ -324,26 +358,26 @@ static addrbank expamemz3_bank = {
ABFLAG_IO | ABFLAG_SAFE | ABFLAG_PPCIOSPACE, S_READ, S_WRITE
};
-static addrbank *expamem_map_clear (void)
+static addrbank *expamem_map_clear(void)
{
- write_log (_T("expamem_map_clear() got called. Shouldn't happen.\n"));
+ write_log(_T("expamem_map_clear() got called. Shouldn't happen.\n"));
return NULL;
}
-static void expamem_init_clear (void)
+static void expamem_init_clear(void)
{
- memset (expamem, 0xff, sizeof expamem);
- expamem_hi = expamem_lo = 0;
+ memset(expamem, 0xff, sizeof expamem);
expamem_map = NULL;
}
/* autoconfig area is "non-existing" after last device */
-static void expamem_init_clear_zero (void)
+static void expamem_init_clear_zero(void)
{
if (currprefs.cpu_model < 68020) {
- map_banks (&dummy_bank, 0xe8, 1, 0);
- if (!currprefs.address_space_24)
- map_banks (&dummy_bank, AUTOCONFIG_Z3 >> 16, 1, 0);
- } else {
+ map_banks(&dummy_bank, 0xe8, 1, 0);
+ if (!currprefs.address_space_24)
+ map_banks(&dummy_bank, AUTOCONFIG_Z3 >> 16, 1, 0);
+ }
+ else {
map_banks(&expamem_bank, 0xe8, 1, 0);
if (!currprefs.address_space_24)
map_banks(&expamemz3_bank, AUTOCONFIG_Z3 >> 16, 1, 0);
@@ -351,17 +385,19 @@ static void expamem_init_clear_zero (void)
expamem_bank_current = NULL;
}
-static void expamem_init_clear2 (void)
+static void expamem_init_clear2(void)
{
expamem_bank.name = _T("Autoconfig Z2");
expamemz3_bank.name = _T("Autoconfig Z3");
- expamem_init_clear_zero();
- ecard = cardno;
+ expamem_init_clear_zero();
+ ecard = cardno;
}
-static addrbank *expamem_init_last (void)
+static addrbank *expamem_init_last(void)
{
- expamem_init_clear2();
+ expamem_init_clear2();
+ write_log(_T("Memory map after autoconfig:\n"));
+ //memory_map_dump();
return NULL;
}
@@ -374,52 +410,82 @@ static uae_u8 REGPARAM2 expamem_read(int addr)
return b;
}
-static void REGPARAM2 expamem_write (uaecptr addr, uae_u32 value)
+static void REGPARAM2 expamem_write(uaecptr addr, uae_u32 value)
{
- addr &= 0xffff;
- if (addr == 00 || addr == 02 || addr == 0x40 || addr == 0x42) {
+ addr &= 0xffff;
+ if (addr == 00 || addr == 02 || addr == 0x40 || addr == 0x42) {
expamem[addr] = (value & 0xf0);
expamem[addr + 2] = (value & 0x0f) << 4;
- } else {
+ }
+ else {
expamem[addr] = ~(value & 0xf0);
expamem[addr + 2] = ~((value & 0x0f) << 4);
- }
+ }
}
-static int REGPARAM2 expamem_type (void)
+static int REGPARAM2 expamem_type(void)
{
return expamem_read(0) & 0xc0;
}
+void expansion_cpu_fallback(void)
+{
+ if (ecard < cardno) {
+ card_data *cd = cards[ecard];
+ if (cd->cst && (cd->cst->deviceflags & EXPANSIONTYPE_FALLBACK_DISABLE)) {
+ expamem_next(NULL, NULL);
+ }
+ }
+}
+
static void call_card_init(int index)
-{
+{
addrbank *ab, *abe;
card_data *cd = cards[ecard];
struct autoconfig_info *aci = &cd->aci;
bool ok = false;
+ if (currprefs.address_space_24 && cd->cst && (cd->cst->deviceflags & EXPANSIONTYPE_FALLBACK_DISABLE)) {
+ write_log(_T("Card %d: skipping autoconfig (fallback mode)\n"), ecard);
+ expamem_next(NULL, NULL);
+ return;
+ }
+
expamem_bank.name = cd->name ? cd->name : _T("None");
aci->prefs = &currprefs;
aci->doinit = true;
aci->devnum = (cd->flags >> 16) & 255;
aci->ert = cd->ert;
+ aci->cst = cd->cst;
aci->rc = cd->rc;
aci->zorro = cd->zorro;
memset(aci->autoconfig_raw, 0xff, sizeof aci->autoconfig_raw);
if (cd->initnum) {
ok = cd->initnum(aci);
- } else {
+ }
+ else {
ok = cd->initrc(aci);
}
if (ok) {
ab = NULL;
if (!cd->map)
- ab = aci->addrbankp;
- } else {
+ ab = aci->Addrbank;
+ }
+ else {
write_log(_T("Card %d: skipping autoconfig (init failed)\n"), ecard);
expamem_next(NULL, NULL);
return;
}
+ if (ab == &expamem_none) {
+ write_log(_T("Card %d: skipping autoconfig (none)\n"), ecard);
+ expamem_init_clear();
+ expamem_init_clear_zero();
+ map_banks(&expamem_bank, 0xE8, 1, 0);
+ if (!currprefs.address_space_24)
+ map_banks(&dummy_bank, AUTOCONFIG_Z3 >> 16, 1, 0);
+ expamem_bank_current = NULL;
+ return;
+ }
if (ab == &expamem_null || cd->zorro < 1 || cd->zorro > 3 || aci->zorro < 0) {
write_log(_T("Card %d: skipping autoconfig (not autoconfig)\n"), ecard);
expamem_next(NULL, NULL);
@@ -441,45 +507,55 @@ static void call_card_init(int index)
expamem_write(i * 4, aci->autoconfig_bytes[i]);
}
expamem_autoconfig_mode = 1;
- } else if (aci->autoconfig_bytes) {
+ }
+ else if (aci->autoconfig_bytes) {
memset(expamem, 0xff, AUTOMATIC_AUTOCONFIG_MAX_ADDRESS);
for (int i = 0; i < 16; i++) {
expamem_write(i * 4, aci->autoconfig_bytes[i]);
}
expamem_autoconfig_mode = 1;
- } else if (aci->autoconfig_raw) {
+ }
+ else if (aci->autoconfig_raw) {
memcpy(expamem, aci->autoconfig_raw, sizeof aci->autoconfig_raw);
}
- } else {
+ }
+ else {
for (int i = 0; i < 16 * 4; i++) {
expamem[i] = abe->sub_banks ? abe->sub_banks[0].bank->bget(i) : abe->bget(i);
}
}
}
+ if (aci->write_bank_address && aci->write_bank_address != 0xffffffff) {
+ map_banks(&expamem_write_bank, aci->write_bank_address >> 16, aci->size >> 16, 0);
+ }
+
if (ab) {
// non-NULL: not using expamem_bank
expamem_bank_current = ab;
if ((cd->flags & CARD_FLAG_CAN_Z3) && currprefs.cs_z3autoconfig && !currprefs.address_space_24) {
map_banks(&expamemz3_bank, AUTOCONFIG_Z3 >> 16, 1, 0);
map_banks(&dummy_bank, 0xE8, 1, 0);
- } else {
- map_banks(&expamem_bank, 0xE8, 1, 0);
- if (!currprefs.address_space_24)
- map_banks(&dummy_bank, AUTOCONFIG_Z3 >> 16, 1, 0);
- }
- } else {
+ }
+ else {
+ map_banks(&expamem_bank, 0xE8, 1, 0);
+ if (!currprefs.address_space_24)
+ map_banks(&dummy_bank, AUTOCONFIG_Z3 >> 16, 1, 0);
+ }
+ }
+ else {
if ((cd->flags & CARD_FLAG_CAN_Z3) && currprefs.cs_z3autoconfig && !currprefs.address_space_24) {
map_banks(&expamemz3_bank, AUTOCONFIG_Z3 >> 16, 1, 0);
map_banks(&dummy_bank, 0xE8, 1, 0);
expamem_bank_current = &expamem_bank;
- } else {
- map_banks(&expamem_bank, 0xE8, 1, 0);
- if (!currprefs.address_space_24)
- map_banks(&dummy_bank, AUTOCONFIG_Z3 >> 16, 1, 0);
- expamem_bank_current = NULL;
}
- }
+ else {
+ map_banks(&expamem_bank, 0xE8, 1, 0);
+ if (!currprefs.address_space_24)
+ map_banks(&dummy_bank, AUTOCONFIG_Z3 >> 16, 1, 0);
+ expamem_bank_current = NULL;
+ }
+ }
}
static void boardmessage(addrbank *mapped, bool success)
@@ -493,12 +569,18 @@ static void boardmessage(addrbank *mapped, bool success)
sizemod = 'M';
size /= 1024;
}
- write_log (_T("Card %d: Z%d 0x%08x %4d%c %s %s%s\n"),
+ write_log(_T("Card %d: Z%d 0x%08x %4d%c %s %s%s\n"),
ecard + 1, (type & 0xc0) == zorroII ? 2 : ((type & 0xc0) == zorroIII ? 3 : 1),
expamem_board_pointer, size, sizemod,
type & rom_card ? _T("ROM") : (type & add_memory ? _T("RAM") : _T("IO ")),
mapped->name,
success ? _T("") : _T(" [SHUT UP]"));
+#if 0
+ for (int i = 0; i < 16; i++) {
+ write_log(_T("%s%02X"), i > 0 ? _T(".") : _T(""), expamem_read(i * 4));
+ }
+ write_log(_T("\n"));
+#endif
}
void expamem_shutup(addrbank *mapped)
@@ -514,7 +596,7 @@ void expamem_next(addrbank *mapped, addrbank *next)
if (mapped)
boardmessage(mapped, mapped->start != 0xffffffff);
- expamem_init_clear();
+ expamem_init_clear();
expamem_init_clear_zero();
for (;;) {
++ecard;
@@ -532,7 +614,8 @@ void expamem_next(addrbank *mapped, addrbank *next)
aci.prefs = &currprefs;
aci.rc = cards[ecard]->rc;
ec->initrc(&aci);
- } else {
+ }
+ else {
call_card_init(ecard);
break;
}
@@ -543,20 +626,43 @@ void expamem_next(addrbank *mapped, addrbank *next)
}
}
-static void expamemz3_map(void)
+// only for custom autoconfig device development purposes, not in use in any normal config
+static uae_u32 REGPARAM2 expamem_write_lget(uaecptr addr)
{
- uaecptr addr = ((expamem_hi << 8) | expamem_lo) << 16;
- if (!expamem_z3hack(&currprefs)) {
- expamem_board_pointer = addr;
- } else {
- if (addr != expamem_board_pointer) {
- put_word (regs.regs[11] + 0x20, expamem_board_pointer >> 16);
- put_word (regs.regs[11] + 0x28, expamem_board_pointer >> 16);
- }
- }
+ addr &= 0xffff;
+ return (expamem_write_space[addr + 0] << 24) | (expamem_write_space[addr + 1] << 16) | (expamem_write_space[addr + 2] << 8) | (expamem_write_space[addr + 3] << 0);
+}
+static uae_u32 REGPARAM2 expamem_write_wget(uaecptr addr)
+{
+ addr &= 0xffff;
+ return (expamem_write_space[addr + 0] << 8) | (expamem_write_space[addr + 1] << 0);
+}
+static uae_u32 REGPARAM2 expamem_write_bget(uaecptr addr)
+{
+ addr &= 0xffff;
+ return expamem_write_space[addr];
+}
+static void REGPARAM2 expamem_write_lput(uaecptr addr, uae_u32 value)
+{
+ addr &= 0xffff;
+ expamem_write_space[addr + 0] = value >> 24;
+ expamem_write_space[addr + 1] = value >> 16;
+ expamem_write_space[addr + 2] = value >> 8;
+ expamem_write_space[addr + 3] = value >> 0;
+}
+static void REGPARAM2 expamem_write_wput(uaecptr addr, uae_u32 value)
+{
+ addr &= 0xffff;
+ expamem_write_space[addr + 0] = value >> 8;
+ expamem_write_space[addr + 1] = value;
+}
+static void REGPARAM2 expamem_write_bput(uaecptr addr, uae_u32 value)
+{
+ addr &= 0xffff;
+ expamem_write_space[addr] = value;
}
-static uae_u32 REGPARAM2 expamem_lget (uaecptr addr)
+static uae_u32 REGPARAM2 expamem_lget(uaecptr addr)
{
if (expamem_bank_current && expamem_bank_current != &expamem_bank) {
if (expamem_autoconfig_mode && (addr & 0xffff) < AUTOMATIC_AUTOCONFIG_MAX_ADDRESS) {
@@ -564,11 +670,11 @@ static uae_u32 REGPARAM2 expamem_lget (uaecptr addr)
}
return expamem_bank_current->sub_banks ? expamem_bank_current->sub_banks[0].bank->lget(addr) : expamem_bank_current->lget(addr);
}
- write_log (_T("warning: Z2 READ.L from address $%08x PC=%x\n"), addr, M68K_GETPC);
- return (expamem_wget (addr) << 16) | expamem_wget (addr + 2);
+ write_log(_T("warning: Z2 READ.L from address $%08x PC=%x\n"), addr, M68K_GETPC);
+ return (expamem_wget(addr) << 16) | expamem_wget(addr + 2);
}
-static uae_u32 REGPARAM2 expamem_wget (uaecptr addr)
+static uae_u32 REGPARAM2 expamem_wget(uaecptr addr)
{
if (expamem_bank_current && expamem_bank_current != &expamem_bank) {
if (expamem_autoconfig_mode && (addr & 0xffff) < AUTOMATIC_AUTOCONFIG_MAX_ADDRESS) {
@@ -580,17 +686,22 @@ static uae_u32 REGPARAM2 expamem_wget (uaecptr addr)
if (expamem_bank_current && expamem_bank_current != &expamem_bank)
return expamem_bank_current->bget(addr) << 8;
}
- uae_u32 v = (expamem_bget (addr) << 8) | expamem_bget (addr + 1);
- write_log (_T("warning: READ.W from address $%08x=%04x PC=%x\n"), addr, v & 0xffff, M68K_GETPC);
- return v;
+ uae_u32 v = (expamem_bget(addr) << 8) | expamem_bget(addr + 1);
+ if (cpuboards[currprefs.cpuboard_type].subtypes[currprefs.cpuboard_subtype].e8) {
+ uae_u32 val = v;
+ cpuboards[currprefs.cpuboard_type].subtypes[currprefs.cpuboard_subtype].e8(addr, &val, 2, false);
+ v = val;
+ }
+ write_log(_T("warning: READ.W from address $%08x=%04x PC=%x\n"), addr, v & 0xffff, M68K_GETPC);
+ return v;
}
-static uae_u32 REGPARAM2 expamem_bget (uaecptr addr)
+static uae_u32 REGPARAM2 expamem_bget(uaecptr addr)
{
- uae_u8 b;
+ uae_u8 b;
if (!chipdone) {
chipdone = true;
- addextrachip (get_long (4));
+ addextrachip(get_long(4));
}
if (expamem_bank_current && expamem_bank_current != &expamem_bank) {
if (expamem_autoconfig_mode && (addr & 0xffff) < AUTOMATIC_AUTOCONFIG_MAX_ADDRESS) {
@@ -598,12 +709,20 @@ static uae_u32 REGPARAM2 expamem_bget (uaecptr addr)
}
return expamem_bank_current->sub_banks ? expamem_bank_current->sub_banks[0].bank->bget(addr) : expamem_bank_current->bget(addr);
}
- addr &= 0xFFFF;
- b = expamem[addr];
- return b;
+ addr &= 0xFFFF;
+ b = expamem[addr];
+ if (cpuboards[currprefs.cpuboard_type].subtypes[currprefs.cpuboard_subtype].e8) {
+ uae_u32 val = b;
+ cpuboards[currprefs.cpuboard_type].subtypes[currprefs.cpuboard_subtype].e8(addr, &val, 1, false);
+ b = val;
+ }
+#if EXP_DEBUG
+ write_log(_T("expamem_bget %x %x\n"), addr, b);
+#endif
+ return b;
}
-static void REGPARAM2 expamem_lput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 expamem_lput(uaecptr addr, uae_u32 value)
{
if (expamem_bank_current && expamem_bank_current != &expamem_bank) {
if (expamem_autoconfig_mode && (addr & 0xffff) < AUTOMATIC_AUTOCONFIG_MAX_ADDRESS) {
@@ -612,149 +731,160 @@ static void REGPARAM2 expamem_lput (uaecptr addr, uae_u32 value)
expamem_bank_current->sub_banks ? expamem_bank_current->sub_banks[0].bank->lput(addr, value) : expamem_bank_current->lput(addr, value);
return;
}
- write_log (_T("warning: Z2 WRITE.L to address $%08x : value $%08x\n"), addr, value);
+ write_log(_T("warning: Z2 WRITE.L to address $%08x : value $%08x\n"), addr, value);
}
-static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 expamem_wput(uaecptr addr, uae_u32 value)
{
- value &= 0xffff;
- if (ecard >= cardno)
- return;
+#if EXP_DEBUG
+ write_log(_T("expamem_wput %x %x\n"), addr, value);
+#endif
+ value &= 0xffff;
+ if (cpuboards[currprefs.cpuboard_type].subtypes[currprefs.cpuboard_subtype].e8) {
+ if (cpuboards[currprefs.cpuboard_type].subtypes[currprefs.cpuboard_subtype].e8(addr, &value, 2, true))
+ return;
+ }
+ if (ecard >= cardno)
+ return;
card_data *cd = cards[ecard];
if (!expamem_map)
expamem_map = cd->map;
- if (expamem_type () != zorroIII) {
- write_log (_T("warning: WRITE.W to address $%08x : value $%x PC=%08x\n"), addr, value, M68K_GETPC);
+ if (expamem_type() != zorroIII) {
+ write_log(_T("warning: WRITE.W to address $%08x : value $%x PC=%08x\n"), addr, value, M68K_GETPC);
}
switch (addr & 0xff) {
- case 0x48:
- // A2630 boot rom writes WORDs to Z2 boards!
- if (expamem_type() == zorroII) {
- expamem_lo = 0;
- expamem_hi = (value >> 8) & 0xff;
- expamem_board_pointer = (expamem_hi | (expamem_lo >> 4)) << 16;
- if (expamem_map) {
- expamem_next(expamem_map(&cd->aci), NULL);
- return;
- }
- if (expamem_bank_current && expamem_bank_current != &expamem_bank) {
- expamem_bank_current->sub_banks ? expamem_bank_current->sub_banks[0].bank->bput(addr, value >> 8) : expamem_bank_current->bput(addr, value >> 8);
- return;
- }
- }
- // Z3 = do nothing
- break;
- case 0x44:
- if (expamem_type() == zorroIII) {
- expamem_hi = (value & 0xff00) >> 8;
- expamem_lo = value & 0x00ff;
- expamemz3_map();
- }
- if (expamem_map) {
- expamem_next(expamem_map(&cd->aci), NULL);
- return;
- }
- if (expamem_autoconfig_mode) {
- map_banks_z3(cd->aci.addrbankp, expamem_board_pointer >> 16, expamem_board_size >> 16);
- cd->initrc(&cd->aci);
- expamem_next(cd->aci.addrbankp, NULL);
- return;
- }
- break;
- case 0x4c:
- if (expamem_map) {
- expamem_next (NULL, NULL);
- return;
- }
- break;
- }
+ case 0x48:
+ // A2630 boot rom writes WORDs to Z2 boards!
+ if (expamem_type() == zorroII) {
+ expamem_lo = 0;
+ expamem_hi = (value >> 8) & 0xff;
+ expamem_board_pointer = (expamem_hi | (expamem_lo >> 4)) << 16;
+ if (expamem_map) {
+ expamem_next(expamem_map(&cd->aci), NULL);
+ return;
+ }
+ if (expamem_bank_current && expamem_bank_current != &expamem_bank) {
+ expamem_bank_current->sub_banks ? expamem_bank_current->sub_banks[0].bank->bput(addr, value >> 8) : expamem_bank_current->bput(addr, value >> 8);
+ return;
+ }
+ }
+ break;
+ case 0x44:
+ if (expamem_type() == zorroIII) {
+ uaecptr addr;
+ expamem_hi = value & 0xff00;
+ addr = (expamem_hi | (expamem_lo >> 4)) << 16;
+ if (!expamem_z3hack(&currprefs)) {
+ expamem_board_pointer = addr;
+ }
+ else {
+ if (addr != expamem_board_pointer) {
+ put_word(regs.regs[11] + 0x20, expamem_board_pointer >> 16);
+ put_word(regs.regs[11] + 0x28, expamem_board_pointer >> 16);
+ }
+ }
+ }
+ if (expamem_map) {
+ expamem_next(expamem_map(&cd->aci), NULL);
+ return;
+ }
+ if (expamem_autoconfig_mode) {
+ map_banks_z3(cd->aci.Addrbank, expamem_board_pointer >> 16, expamem_board_size >> 16);
+ cd->aci.postinit = true;
+ cd->initrc(&cd->aci);
+ expamem_next(cd->aci.Addrbank, NULL);
+ return;
+ }
+ break;
+ case 0x4c:
+ if (expamem_map) {
+ expamem_next(NULL, NULL);
+ return;
+ }
+ break;
+ }
if (expamem_bank_current && expamem_bank_current != &expamem_bank) {
expamem_bank_current->sub_banks ? expamem_bank_current->sub_banks[0].bank->wput(addr, value) : expamem_bank_current->wput(addr, value);
}
}
-static void REGPARAM2 expamem_bput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 expamem_bput(uaecptr addr, uae_u32 value)
{
- value &= 0xff;
- if (ecard >= cardno)
- return;
+#if EXP_DEBUG
+ write_log(_T("expamem_bput %x %x\n"), addr, value);
+#endif
+ value &= 0xff;
+ if (cpuboards[currprefs.cpuboard_type].subtypes[currprefs.cpuboard_subtype].e8) {
+ if (cpuboards[currprefs.cpuboard_type].subtypes[currprefs.cpuboard_subtype].e8(addr, &value, 1, true))
+ return;
+ }
+ if (ecard >= cardno)
+ return;
card_data *cd = cards[ecard];
if (!expamem_map)
expamem_map = cd->map;
if (expamem_type() == protoautoconfig) {
switch (addr & 0xff) {
- case 0x22:
- expamem_hi = value & 0x7f;
- expamem_board_pointer = AUTOCONFIG_Z2 | (expamem_hi * 4096);
- if (expamem_map) {
- expamem_next(expamem_map(&cd->aci), NULL);
- return;
- }
- break;
+ case 0x22:
+ expamem_hi = value & 0x7f;
+ expamem_board_pointer = AUTOCONFIG_Z2 | (expamem_hi * 4096);
+ if (expamem_map) {
+ expamem_next(expamem_map(&cd->aci), NULL);
+ return;
+ }
+ break;
}
- } else {
- switch (addr & 0xff) {
- case 0x48:
- if (expamem_type () == zorroII) {
- expamem_hi = value & 0xff;
- expamem_board_pointer = (expamem_hi | (expamem_lo >> 4)) << 16;
- if (expamem_map) {
- expamem_next(expamem_map(&cd->aci), NULL);
- return;
- }
- if (expamem_autoconfig_mode) {
- map_banks_z2(cd->aci.addrbankp, expamem_board_pointer >> 16, expamem_board_size >> 16);
- cd->initrc(&cd->aci);
- expamem_next(cd->aci.addrbankp, NULL);
- return;
- }
- } else {
- expamem_lo = value & 0xff;
- }
- break;
- case 0x44:
- if (expamem_type() == zorroIII) {
- expamem_hi = value & 0xff;
- expamemz3_map();
- if (expamem_map) {
- expamem_next(expamem_map(&cd->aci), NULL);
- return;
- }
- if (expamem_autoconfig_mode) {
- map_banks_z3(cd->aci.addrbankp, expamem_board_pointer >> 16, expamem_board_size >> 16);
- cd->initrc(&cd->aci);
- expamem_next(cd->aci.addrbankp, NULL);
- return;
- }
- }
- break;
- case 0x4a:
- if (expamem_type () == zorroII) {
- expamem_lo = value & 0xff;
- }
- if (expamem_autoconfig_mode)
- return;
- break;
+ }
+ else {
+ switch (addr & 0xff) {
+ case 0x48:
+ if (expamem_type() == zorroII) {
+ expamem_hi = value & 0xff;
+ expamem_board_pointer = (expamem_hi | (expamem_lo >> 4)) << 16;
+ if (expamem_map) {
+ expamem_next(expamem_map(&cd->aci), NULL);
+ return;
+ }
+ if (expamem_autoconfig_mode) {
+ map_banks_z2(cd->aci.Addrbank, expamem_board_pointer >> 16, expamem_board_size >> 16);
+ cd->aci.postinit = true;
+ cd->initrc(&cd->aci);
+ expamem_next(cd->aci.Addrbank, NULL);
+ return;
+ }
+ }
+ else {
+ expamem_lo = value & 0xff;
+ }
+ break;
- case 0x4c:
- if (expamem_map) {
- expamem_hi = expamem_lo = 0xff;
- expamem_board_pointer = 0xffffffff;
- addrbank *ab = expamem_map(&cd->aci);
- if (ab)
- ab->start = 0xffffffff;
- expamem_next(ab, NULL);
- return;
- }
- break;
- }
+ case 0x4a:
+ if (expamem_type() == zorroII) {
+ expamem_lo = value & 0xff;
+ }
+ if (expamem_autoconfig_mode)
+ return;
+ break;
+
+ case 0x4c:
+ if (expamem_map) {
+ expamem_hi = expamem_lo = 0xff;
+ expamem_board_pointer = 0xffffffff;
+ addrbank *ab = expamem_map(&cd->aci);
+ if (ab)
+ ab->start = 0xffffffff;
+ expamem_next(ab, NULL);
+ return;
+ }
+ break;
+ }
}
if (expamem_bank_current && expamem_bank_current != &expamem_bank) {
expamem_bank_current->sub_banks ? expamem_bank_current->sub_banks[0].bank->bput(addr, value) : expamem_bank_current->bput(addr, value);
}
}
-static uae_u32 REGPARAM2 expamemz3_bget (uaecptr addr)
+static uae_u32 REGPARAM2 expamemz3_bget(uaecptr addr)
{
int reg = addr & 0xff;
if (!expamem_bank_current)
@@ -764,20 +894,20 @@ static uae_u32 REGPARAM2 expamemz3_bget (uaecptr addr)
return expamem_bank_current->bget(reg + 0);
}
-static uae_u32 REGPARAM2 expamemz3_wget (uaecptr addr)
+static uae_u32 REGPARAM2 expamemz3_wget(uaecptr addr)
{
- uae_u32 v = (expamemz3_bget (addr) << 8) | expamemz3_bget (addr + 1);
- write_log (_T("warning: Z3 READ.W from address $%08x=%04x PC=%x\n"), addr, v & 0xffff, M68K_GETPC);
+ uae_u32 v = (expamemz3_bget(addr) << 8) | expamemz3_bget(addr + 1);
+ write_log(_T("warning: Z3 READ.W from address $%08x=%04x PC=%x\n"), addr, v & 0xffff, M68K_GETPC);
return v;
}
-static uae_u32 REGPARAM2 expamemz3_lget (uaecptr addr)
+static uae_u32 REGPARAM2 expamemz3_lget(uaecptr addr)
{
- write_log (_T("warning: Z3 READ.L from address $%08x PC=%x\n"), addr, M68K_GETPC);
- return (expamemz3_wget (addr) << 16) | expamemz3_wget (addr + 2);
+ write_log(_T("warning: Z3 READ.L from address $%08x PC=%x\n"), addr, M68K_GETPC);
+ return (expamemz3_wget(addr) << 16) | expamemz3_wget(addr + 2);
}
-static void REGPARAM2 expamemz3_bput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 expamemz3_bput(uaecptr addr, uae_u32 value)
{
int reg = addr & 0xff;
if (!expamem_bank_current)
@@ -788,22 +918,19 @@ static void REGPARAM2 expamemz3_bput (uaecptr addr, uae_u32 value)
if (expamem_type() == zorroII) {
expamem_hi = value & 0xff;
expamem_board_pointer = (expamem_hi | (expamem_lo >> 4)) << 16;
- } else {
+ }
+ else {
expamem_lo = value & 0xff;
}
- } else if (reg == 0x44) {
- if (expamem_type() == zorroIII) {
- expamem_hi = value & 0xff;
- expamemz3_map();
- }
- } else if (reg == 0x4a) {
+ }
+ else if (reg == 0x4a) {
if (expamem_type() == zorroII)
expamem_lo = value & 0xff;
}
expamem_bank_current->bput(reg, value);
}
-static void REGPARAM2 expamemz3_wput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 expamemz3_wput(uaecptr addr, uae_u32 value)
{
int reg = addr & 0xff;
if (!expamem_bank_current)
@@ -812,26 +939,35 @@ static void REGPARAM2 expamemz3_wput (uaecptr addr, uae_u32 value)
reg += 2;
if (reg == 0x44) {
if (expamem_type() == zorroIII) {
- expamem_hi = (value & 0xff00) >> 8;
- expamem_lo = value & 0x00ff;
- expamemz3_map();
+ uaecptr addr;
+ expamem_hi = value & 0xff00;
+ addr = (expamem_hi | (expamem_lo >> 4)) << 16;;
+ if (!expamem_z3hack(&currprefs)) {
+ expamem_board_pointer = addr;
+ }
+ else {
+ if (addr != expamem_board_pointer) {
+ put_word(regs.regs[11] + 0x20, expamem_board_pointer >> 16);
+ put_word(regs.regs[11] + 0x28, expamem_board_pointer >> 16);
+ }
+ }
}
}
expamem_bank_current->wput(reg, value);
}
-static void REGPARAM2 expamemz3_lput (uaecptr addr, uae_u32 value)
+static void REGPARAM2 expamemz3_lput(uaecptr addr, uae_u32 value)
{
- write_log (_T("warning: Z3 WRITE.L to address $%08x : value $%08x\n"), addr, value);
+ write_log(_T("warning: Z3 WRITE.L to address $%08x : value $%08x\n"), addr, value);
}
#ifdef CD32
-static bool expamem_init_cd32fmv (struct autoconfig_info *aci)
+static bool expamem_init_cd32fmv(struct autoconfig_info *aci)
{
- expamem_init_clear ();
+ expamem_init_clear();
load_rom_rc(aci->rc, ROMTYPE_CD32CART, 262144, 0, expamem, 128, 0);
memcpy(aci->autoconfig_raw, expamem, sizeof aci->autoconfig_raw);
- expamem_map = cd32_fmv_init;
+ //expamem_map = cd32_fmv_init;
return true;
}
@@ -840,10 +976,14 @@ static bool expamem_init_cd32fmv (struct autoconfig_info *aci)
/* ********************************************************** */
/*
- * Fast Memory
- */
+* Fast Memory
+*/
+
MEMORY_ARRAY_FUNCTIONS(fastmem, 0);
+MEMORY_ARRAY_FUNCTIONS(fastmem, 1);
+MEMORY_ARRAY_FUNCTIONS(fastmem, 2);
+MEMORY_ARRAY_FUNCTIONS(fastmem, 3);
addrbank fastmem_bank[MAX_RAM_BOARDS] =
{
@@ -853,14 +993,143 @@ addrbank fastmem_bank[MAX_RAM_BOARDS] =
fastmem0_xlate, fastmem0_check, NULL, _T("*"), _T("Fast memory"),
fastmem0_lget, fastmem0_wget,
ABFLAG_RAM | ABFLAG_THREADSAFE, 0, 0
+ },
+ {
+ fastmem1_lget, fastmem1_wget, fastmem1_bget,
+ fastmem1_lput, fastmem1_wput, fastmem1_bput,
+ fastmem1_xlate, fastmem1_check, NULL, _T("*"), _T("Fast memory 2"),
+ fastmem1_lget, fastmem1_wget,
+ ABFLAG_RAM | ABFLAG_THREADSAFE, 0, 0
+ },
+ {
+ fastmem2_lget, fastmem2_wget, fastmem2_bget,
+ fastmem2_lput, fastmem2_wput, fastmem2_bput,
+ fastmem2_xlate, fastmem2_check, NULL, _T("*"), _T("Fast memory 3"),
+ fastmem2_lget, fastmem2_wget,
+ ABFLAG_RAM | ABFLAG_THREADSAFE, 0, 0
+ },
+ {
+ fastmem3_lget, fastmem3_wget, fastmem3_bget,
+ fastmem3_lput, fastmem3_wput, fastmem3_bput,
+ fastmem3_xlate, fastmem3_check, NULL, _T("*"), _T("Fast memory 4"),
+ fastmem3_lget, fastmem3_wget,
+ ABFLAG_RAM | ABFLAG_THREADSAFE, 0, 0
}
};
+#ifdef CATWEASEL
+
+/*
+* Catweasel ZorroII
+*/
+
+DECLARE_MEMORY_FUNCTIONS(catweasel);
+
+static uae_u32 catweasel_mask;
+static uae_u32 catweasel_start;
+
+static uae_u32 REGPARAM2 catweasel_lget(uaecptr addr)
+{
+ write_log(_T("catweasel_lget @%08X!\n"), addr);
+ return 0;
+}
+
+static uae_u32 REGPARAM2 catweasel_wget(uaecptr addr)
+{
+ write_log(_T("catweasel_wget @%08X!\n"), addr);
+ return 0;
+}
+
+static uae_u32 REGPARAM2 catweasel_bget(uaecptr addr)
+{
+ addr -= catweasel_start & catweasel_mask;
+ addr &= catweasel_mask;
+ return catweasel_do_bget(addr);
+}
+
+static void REGPARAM2 catweasel_lput(uaecptr addr, uae_u32 l)
+{
+ write_log(_T("catweasel_lput @%08X=%08X!\n"), addr, l);
+}
+
+static void REGPARAM2 catweasel_wput(uaecptr addr, uae_u32 w)
+{
+ write_log(_T("catweasel_wput @%08X=%04X!\n"), addr, w);
+}
+
+static void REGPARAM2 catweasel_bput(uaecptr addr, uae_u32 b)
+{
+ addr -= catweasel_start & catweasel_mask;
+ addr &= catweasel_mask;
+ catweasel_do_bput(addr, b);
+}
+
+static int REGPARAM2 catweasel_check(uaecptr addr, uae_u32 size)
+{
+ return 0;
+}
+
+static uae_u8 *REGPARAM2 catweasel_xlate(uaecptr addr)
+{
+ write_log(_T("catweasel_xlate @%08X size %08X\n"), addr);
+ return 0;
+}
+
+static Addrbank catweasel_bank = {
+ catweasel_lget, catweasel_wget, catweasel_bget,
+ catweasel_lput, catweasel_wput, catweasel_bput,
+ catweasel_xlate, catweasel_check, NULL, NULL, _T("Catweasel"),
+ dummy_lgeti, dummy_wgeti,
+ ABFLAG_IO, S_READ, S_WRITE
+};
+
+static Addrbank *expamem_map_catweasel(int devnum)
+{
+ catweasel_start = expamem_board_pointer;
+ map_banks_z2(&catweasel_bank, catweasel_start >> 16, 1);
+ return &catweasel_bank;
+}
+
+static bool expamem_init_catweasel(struct autoconfig_info *aci)
+{
+ uae_u8 productid = cwc.type >= CATWEASEL_TYPE_MK3 ? 66 : 200;
+ uae_u16 vendorid = cwc.type >= CATWEASEL_TYPE_MK3 ? 4626 : 5001;
+
+ catweasel_mask = (cwc.type >= CATWEASEL_TYPE_MK3) ? 0xffff : 0x1ffff;
+
+ expamem_init_clear();
+
+ expamem_write(0x00, (cwc.type >= CATWEASEL_TYPE_MK3 ? Z2_MEM_64KB : Z2_MEM_128KB) | zorroII);
+
+ expamem_write(0x04, productid);
+
+ expamem_write(0x08, 0);
+
+ expamem_write(0x10, vendorid >> 8);
+ expamem_write(0x14, vendorid & 0xff);
+
+ expamem_write(0x18, 0x00); /* ser.no. Byte 0 */
+ expamem_write(0x1c, 0x00); /* ser.no. Byte 1 */
+ expamem_write(0x20, 0x00); /* ser.no. Byte 2 */
+ expamem_write(0x24, 0x00); /* ser.no. Byte 3 */
+
+ expamem_write(0x28, 0x00); /* Rom-Offset hi */
+ expamem_write(0x2c, 0x00); /* ROM-Offset lo */
+
+ expamem_write(0x40, 0x00); /* Ctrl/Statusreg.*/
+
+ memcpy(aci->autoconfig_raw, expamem, sizeof aci->autoconfig_raw);
+
+ return true;
+}
+
+#endif
+
#ifdef FILESYS
/*
* Filesystem device ROM/RAM space
- */
+*/
DECLARE_MEMORY_FUNCTIONS(filesys);
addrbank filesys_bank = {
@@ -876,43 +1145,53 @@ static bool filesys_write(uaecptr addr)
return addr >= 0x4000;
}
-static uae_u32 REGPARAM2 filesys_lget (uaecptr addr)
+static uae_u32 REGPARAM2 filesys_lget(uaecptr addr)
{
- uae_u8 *m;
- addr -= filesys_bank.start;
- addr &= 65535;
- m = filesys_bank.baseaddr + addr;
- return do_get_mem_long ((uae_u32 *)m);
+ uae_u8 *m;
+ addr -= filesys_bank.start & 65535;
+ addr &= 65535;
+ m = filesys_bank.baseaddr + addr;
+#if EXP_DEBUG
+ write_log(_T("filesys_lget %x %x\n"), addr, do_get_mem_long((uae_u32 *)m));
+#endif
+ return do_get_mem_long((uae_u32 *)m);
}
-static uae_u32 REGPARAM2 filesys_wget (uaecptr addr)
+static uae_u32 REGPARAM2 filesys_wget(uaecptr addr)
{
- uae_u8 *m;
- addr -= filesys_bank.start;
- addr &= 65535;
- m = filesys_bank.baseaddr + addr;
- return do_get_mem_word ((uae_u16 *)m);
+ uae_u8 *m;
+ addr -= filesys_bank.start & 65535;
+ addr &= 65535;
+ m = filesys_bank.baseaddr + addr;
+#if EXP_DEBUG
+ write_log(_T("filesys_wget %x %x\n"), addr, do_get_mem_word((uae_u16 *)m));
+#endif
+ return do_get_mem_word((uae_u16 *)m);
}
-static uae_u32 REGPARAM2 filesys_bget (uaecptr addr)
+static uae_u32 REGPARAM2 filesys_bget(uaecptr addr)
{
- addr -= filesys_bank.start;
- addr &= 65535;
- return filesys_bank.baseaddr[addr];
+ addr -= filesys_bank.start & 65535;
+ addr &= 65535;
+#if EXP_DEBUG
+ write_log(_T("filesys_bget %x %x\n"), addr, filesys_bank.baseaddr[addr]);
+#endif
+ return filesys_bank.baseaddr[addr];
}
+
static void REGPARAM2 filesys_bput(uaecptr addr, uae_u32 b)
{
- addr -= filesys_bank.start;
+ addr -= filesys_bank.start & 65535;
addr &= 65535;
if (!filesys_write(addr))
return;
filesys_bank.baseaddr[addr] = b;
}
-static void REGPARAM2 filesys_lput (uaecptr addr, uae_u32 l)
+static void REGPARAM2 filesys_lput(uaecptr addr, uae_u32 l)
{
- addr -= filesys_bank.start;
+ addr -= filesys_bank.start & 65535;
addr &= 65535;
if (!filesys_write(addr))
return;
@@ -922,9 +1201,9 @@ static void REGPARAM2 filesys_lput (uaecptr addr, uae_u32 l)
filesys_bank.baseaddr[addr + 3] = l >> 0;
}
-static void REGPARAM2 filesys_wput (uaecptr addr, uae_u32 w)
+static void REGPARAM2 filesys_wput(uaecptr addr, uae_u32 w)
{
- addr -= filesys_bank.start;
+ addr -= filesys_bank.start & 65535;
addr &= 65535;
if (!filesys_write(addr))
return;
@@ -934,13 +1213,13 @@ static void REGPARAM2 filesys_wput (uaecptr addr, uae_u32 w)
static int REGPARAM2 filesys_check(uaecptr addr, uae_u32 size)
{
- addr -= filesys_bank.start;
+ addr -= filesys_bank.start & 65535;
addr &= 65535;
return (addr + size) <= filesys_bank.allocated_size;
}
static uae_u8 *REGPARAM2 filesys_xlate(uaecptr addr)
{
- addr -= filesys_bank.start;
+ addr -= filesys_bank.start & 65535;
addr &= 65535;
return filesys_bank.baseaddr + addr;
}
@@ -953,16 +1232,40 @@ addrbank uaeboard_bank = {
uaeboard_lput, uaeboard_wput, uaeboard_bput,
uaeboard_xlate, uaeboard_check, NULL, _T("*"), _T("UAE Board"),
dummy_lgeti, dummy_wgeti,
- ABFLAG_IO | ABFLAG_SAFE, S_READ, S_WRITE
+ ABFLAG_IO | ABFLAG_SAFE | ABFLAG_PPCIOSPACE, S_READ, S_WRITE
};
uae_u32 uaeboard_base; /* Determined by the OS */
+static uae_u32 uaeboard_ram_start;
#define UAEBOARD_WRITEOFFSET 0x4000
uae_u8 *uaeboard_map_ram(uaecptr p)
{
- p -= filesys_bank.start;
- return filesys_bank.baseaddr + p;
+ if (currprefs.uaeboard > 1) {
+ p -= uaeboard_base;
+ return uaeboard_bank.baseaddr + p;
+ }
+ else {
+ p -= filesys_bank.start;
+ return filesys_bank.baseaddr + p;
+ }
+}
+
+uaecptr uaeboard_alloc_ram(uae_u32 size)
+{
+ uaecptr p;
+ size += 7;
+ size &= ~7;
+ if (currprefs.uaeboard > 1) {
+ p = uaeboard_ram_start + uaeboard_base;
+ memset(uaeboard_bank.baseaddr + uaeboard_ram_start, 0, size);
+ }
+ else {
+ p = uaeboard_ram_start + filesys_bank.start;
+ memset(filesys_bank.baseaddr + uaeboard_ram_start, 0, size);
+ }
+ uaeboard_ram_start += size;
+ return p;
}
static bool uaeboard_write(uaecptr addr)
@@ -1037,14 +1340,19 @@ static uae_u8 *REGPARAM2 uaeboard_xlate(uaecptr addr)
{
addr -= uaeboard_base & 65535;
addr &= 65535;
- return uaeboard_bank.baseaddr + addr;
+ return filesys_bank.baseaddr + addr;
}
static addrbank *expamem_map_uaeboard(struct autoconfig_info *aci)
{
uaeboard_base = expamem_board_pointer;
+ uaeboard_ram_start = UAEBOARD_WRITEOFFSET;
uaeboard_bank.start = uaeboard_base;
map_banks_z2(&uaeboard_bank, uaeboard_base >> 16, 1);
+ if (currprefs.uaeboard > 1) {
+ rtarea_bank.start = uaeboard_base + 65536;
+ map_banks_z2(&rtarea_bank, (uaeboard_base + 65536) >> 16, 1);
+ }
return &uaeboard_bank;
}
@@ -1063,14 +1371,16 @@ static bool expamem_init_uaeboard(struct autoconfig_info *aci)
{
bool ks12 = ks12orolder();
struct uae_prefs *p = aci->prefs;
+ bool hide = p->uae_hide_autoconfig;
+ bool rom = p->uaeboard > 1;
aci->label = _T("UAE Boot ROM");
- aci->addrbankp = &uaeboard_bank;
+ aci->Addrbank = &uaeboard_bank;
aci->get_params = get_params_filesys;
aci->set_params = set_params_filesys;
expamem_init_clear();
- expamem_write(0x00, Z2_MEM_64KB | zorroII | (ks12));
+ expamem_write(0x00, (p->uaeboard > 1 ? Z2_MEM_128KB : Z2_MEM_64KB) | zorroII | (ks12 || !rom ? 0 : rom_card));
expamem_write(0x08, no_shutup);
@@ -1085,8 +1395,53 @@ static bool expamem_init_uaeboard(struct autoconfig_info *aci)
uae_u8 *ptr = uaeboard_bank.baseaddr;
- expamem_write(0x28, 0x00); /* ROM-Offset hi */
- expamem_write(0x2c, 0x00); /* ROM-Offset lo */
+ if (rom) {
+
+ int diagoffset = 0x80;
+ int diagpoint = 24;
+ int bootpoint = diagpoint + 16;
+ /* struct DiagArea - the size has to be large enough to store several device ROMTags */
+ const uae_u8 diagarea[] = {
+ 0x90, 0x00, /* da_Config, da_Flags */
+ 0x03, 0x00, /* da_Size */
+ (uae_u8)(diagpoint >> 8), (uae_u8)diagpoint,
+ (uae_u8)(bootpoint >> 8), (uae_u8)bootpoint,
+ 0, (uae_u8)(hide ? 0 : 14), // Name offset
+ 0, 0, 0, 0,
+ (uae_u8)(hide ? 0 : 'U'), (uae_u8)(hide ? 0 : 'A'), (uae_u8)(hide ? 0 : 'E'), 0
+ };
+ expamem_write(0x28, diagoffset >> 8); /* ROM-Offset hi */
+ expamem_write(0x2c, diagoffset & 0xff); /* ROM-Offset lo */
+ /* Build a DiagArea */
+ memcpy(expamem + diagoffset, diagarea, sizeof diagarea);
+ diagpoint += diagoffset;
+ bootpoint += diagoffset;
+
+ if (aci->doinit) {
+ if (p->uaeboard > 2) {
+ /* Call hwtrap_install */
+ put_word_host(expamem + diagpoint + 0, 0x4EB9); /* JSR */
+ put_long_host(expamem + diagpoint + 2, filesys_get_entry(9));
+ diagpoint += 6;
+ }
+ /* Call DiagEntry */
+ put_word_host(expamem + diagpoint + 0, 0x4EF9); /* JMP */
+ put_long_host(expamem + diagpoint + 2, ROM_filesys_diagentry);
+
+ /* What comes next is a plain bootblock */
+ put_word_host(expamem + bootpoint + 0, 0x4EF9); /* JMP */
+ put_long_host(expamem + bootpoint + 2, EXPANSION_bootcode);
+
+ put_long_host(rtarea_bank.baseaddr + RTAREA_FSBOARD, uaeboard_bank.start + 0x2000);
+ }
+
+ }
+ else {
+
+ expamem_write(0x28, 0x00); /* ROM-Offset hi */
+ expamem_write(0x2c, 0x00); /* ROM-Offset lo */
+
+ }
memcpy(aci->autoconfig_raw, expamem, sizeof aci->autoconfig_raw);
@@ -1099,10 +1454,13 @@ static bool expamem_init_uaeboard(struct autoconfig_info *aci)
}
/*
- * Z3fastmem Memory
- */
+* Z3fastmem Memory
+*/
MEMORY_ARRAY_FUNCTIONS(z3fastmem, 0);
+MEMORY_ARRAY_FUNCTIONS(z3fastmem, 1);
+MEMORY_ARRAY_FUNCTIONS(z3fastmem, 2);
+MEMORY_ARRAY_FUNCTIONS(z3fastmem, 3);
addrbank z3fastmem_bank[MAX_RAM_BOARDS] =
{
@@ -1112,14 +1470,45 @@ addrbank z3fastmem_bank[MAX_RAM_BOARDS] =
z3fastmem0_xlate, z3fastmem0_check, NULL, _T("*"), _T("Zorro III Fast RAM"),
z3fastmem0_lget, z3fastmem0_wget,
ABFLAG_RAM | ABFLAG_THREADSAFE, 0, 0
- }
+ },
+ {
+ z3fastmem1_lget, z3fastmem1_wget, z3fastmem1_bget,
+ z3fastmem1_lput, z3fastmem1_wput, z3fastmem1_bput,
+ z3fastmem1_xlate, z3fastmem1_check, NULL, _T("*"), _T("Zorro III Fast RAM #2"),
+ z3fastmem1_lget, z3fastmem1_wget,
+ ABFLAG_RAM | ABFLAG_THREADSAFE, 0, 0
+ },
+ {
+ z3fastmem2_lget, z3fastmem2_wget, z3fastmem2_bget,
+ z3fastmem2_lput, z3fastmem2_wput, z3fastmem2_bput,
+ z3fastmem2_xlate, z3fastmem2_check, NULL, _T("*"), _T("Zorro III Fast RAM #3"),
+ z3fastmem2_lget, z3fastmem2_wget,
+ ABFLAG_RAM | ABFLAG_THREADSAFE, 0, 0
+ },
+ {
+ z3fastmem3_lget, z3fastmem3_wget, z3fastmem3_bget,
+ z3fastmem3_lput, z3fastmem3_wput, z3fastmem3_bput,
+ z3fastmem3_xlate, z3fastmem3_check, NULL, _T("*"), _T("Zorro III Fast RAM #4"),
+ z3fastmem3_lget, z3fastmem3_wget,
+ ABFLAG_RAM | ABFLAG_THREADSAFE, 0, 0
+ }
+};
+
+MEMORY_FUNCTIONS(z3chipmem);
+
+addrbank z3chipmem_bank = {
+ z3chipmem_lget, z3chipmem_wget, z3chipmem_bget,
+ z3chipmem_lput, z3chipmem_wput, z3chipmem_bput,
+ z3chipmem_xlate, z3chipmem_check, NULL, _T("*"), _T("MegaChipRAM"),
+ z3chipmem_lget, z3chipmem_wget,
+ ABFLAG_RAM | ABFLAG_THREADSAFE, 0, 0
};
/* ********************************************************** */
/*
* Expansion Card (ZORRO II) for 64/128/256/512KB 1/2/4/8MB of Fast Memory
- */
+*/
static addrbank *expamem_map_fastcard(struct autoconfig_info *aci)
{
@@ -1130,19 +1519,52 @@ static addrbank *expamem_map_fastcard(struct autoconfig_info *aci)
uae_u32 size = ab->allocated_size;
ab->start = start;
if (ab->start && size) {
- map_banks_z2 (ab, ab->start >> 16, size >> 16);
- }
+ map_banks_z2(ab, ab->start >> 16, size >> 16);
+ }
return ab;
}
static bool fastmem_autoconfig(struct uae_prefs *p, struct autoconfig_info *aci, int zorro, uae_u8 type, uae_u32 serial, int allocated)
{
- uae_u16 mid = 0;
- uae_u8 pid;
+ uae_u16 mid = 0;
+ uae_u8 pid;
uae_u8 flags = 0;
+ DEVICE_MEMORY_CALLBACK dmc = NULL;
+ struct romconfig *dmc_rc = NULL;
uae_u8 ac[16] = { 0 };
int boardnum = aci->devnum;
+ if (aci->cst) {
+ mid = aci->cst->memory_mid;
+ pid = aci->cst->memory_pid;
+ serial = aci->cst->memory_serial;
+ }
+ else if (aci->ert) {
+ const struct expansionromtype *ert = aci->ert;
+ struct romconfig *rc = get_device_romconfig(p, ert->romtype, 0);
+ if (ert->subtypes) {
+ const struct expansionsubromtype *srt = &ert->subtypes[rc->subtype];
+ if (srt->memory_mid) {
+ mid = srt->memory_mid;
+ pid = srt->memory_pid;
+ serial = srt->memory_serial;
+ if (!srt->memory_after)
+ type |= chainedconfig;
+ }
+ }
+ else {
+ if (ert->memory_mid) {
+ mid = ert->memory_mid;
+ pid = ert->memory_pid;
+ serial = ert->memory_serial;
+ if (!ert->memory_after)
+ type |= chainedconfig;
+ }
+ }
+ dmc = ert->memory_callback;
+ dmc_rc = rc;
+ }
+
uae_u8 *forceac = NULL;
struct ramboard *rb = NULL;
@@ -1151,29 +1573,34 @@ static bool fastmem_autoconfig(struct uae_prefs *p, struct autoconfig_info *aci,
rb = &p->fastmem[boardnum];
if (rb->autoconfig[0]) {
forceac = rb->autoconfig;
- } else if (rb->manufacturer) {
+ }
+ else if (rb->manufacturer) {
mid = rb->manufacturer;
pid = rb->product;
serial = 0;
- } else {
- pid = 81;
}
- } else {
+ else {
+ pid = p->maprom && !p->cpuboard_type ? 1 : 81;
+ }
+ }
+ else {
int subsize = (allocated == 0x100000 ? Z3_SS_MEM_1MB
- : allocated == 0x200000 ? Z3_SS_MEM_2MB
- : allocated == 0x400000 ? Z3_SS_MEM_4MB
- : allocated == 0x800000 ? Z3_SS_MEM_8MB
- : Z3_SS_MEM_SAME);
- rb = &p->z3fastmem[boardnum];
+ : allocated == 0x200000 ? Z3_SS_MEM_2MB
+ : allocated == 0x400000 ? Z3_SS_MEM_4MB
+ : allocated == 0x800000 ? Z3_SS_MEM_8MB
+ : Z3_SS_MEM_SAME);
+ struct ramboard *rb = &p->z3fastmem[boardnum];
if (rb->autoconfig[0]) {
forceac = rb->autoconfig;
- } else if (rb->manufacturer) {
+ }
+ else if (rb->manufacturer) {
mid = rb->manufacturer;
pid = rb->product;
serial = 0;
- } else {
- pid = 83;
- }
+ }
+ else {
+ pid = p->maprom && !p->cpuboard_type ? 3 : 83;
+ }
flags |= care_addr | force_z3 | (allocated > 0x800000 ? ext_size : subsize);
}
}
@@ -1190,17 +1617,21 @@ static bool fastmem_autoconfig(struct uae_prefs *p, struct autoconfig_info *aci,
if (flags)
ac[0x08 / 4] = flags;
}
- } else {
- ac[0x00 / 4] = type;
- ac[0x04 / 4] = pid;
- ac[0x08 / 4] = flags;
- ac[0x10 / 4] = mid >> 8;
- ac[0x14 / 4] = (uae_u8)mid;
- ac[0x18 / 4] = serial >> 24;
- ac[0x1c / 4] = serial >> 16;
- ac[0x20 / 4] = serial >> 8;
- ac[0x24 / 4] = serial >> 0;
}
+ else {
+ ac[0x00 / 4] = type;
+ ac[0x04 / 4] = pid;
+ ac[0x08 / 4] = flags;
+ ac[0x10 / 4] = mid >> 8;
+ ac[0x14 / 4] = (uae_u8)mid;
+ ac[0x18 / 4] = serial >> 24;
+ ac[0x1c / 4] = serial >> 16;
+ ac[0x20 / 4] = serial >> 8;
+ ac[0x24 / 4] = serial >> 0;
+ }
+
+ if (dmc && dmc_rc)
+ dmc(dmc_rc, ac, allocated);
expamem_write(0x00, ac[0x00 / 4]);
expamem_write(0x04, ac[0x04 / 4]);
@@ -1213,11 +1644,29 @@ static bool fastmem_autoconfig(struct uae_prefs *p, struct autoconfig_info *aci,
expamem_write(0x20, ac[0x20 / 4]); /* ser.no. Byte 2 */
expamem_write(0x24, ac[0x24 / 4]); /* ser.no. Byte 3 */
- expamem_write (0x28, 0x00); /* ROM-Offset hi */
- expamem_write (0x2c, 0x00); /* ROM-Offset lo */
+ expamem_write(0x28, 0x00); /* ROM-Offset hi */
+ expamem_write(0x2c, 0x00); /* ROM-Offset lo */
- expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
+ expamem_write(0x40, 0x00); /* Ctrl/Statusreg.*/
+ if (rb && rb->manual_config) {
+ aci->start = rb->start_address;
+ aci->size = rb->end_address - rb->start_address + 1;
+ memcpy(&aci->autoconfig_bytes, ac, sizeof ac);
+ return false;
+ }
+
+ return true;
+}
+
+static const uae_u8 a2630_autoconfig[] = { 0xe7, 0x51, 0x40, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+static bool megachipram_init(struct autoconfig_info *aci)
+{
+ aci->zorro = 0;
+ aci->start = 0x10000000;
+ aci->size = aci->prefs->z3chipmem_size;
+ aci->label = _T("32-bit Chip RAM");
return true;
}
@@ -1231,7 +1680,7 @@ static bool expamem_init_fastcard_2(struct autoconfig_info *aci, int zorro)
aci->label = zorro == 1 ? _T("Z1 Fast RAM") : _T("Z2 Fast RAM");
aci->zorro = zorro;
- expamem_init_clear ();
+ expamem_init_clear();
if (size == 65536)
type |= Z2_MEM_64KB;
else if (size == 131072)
@@ -1249,14 +1698,39 @@ static bool expamem_init_fastcard_2(struct autoconfig_info *aci, int zorro)
else if (size == 0x800000)
type |= Z2_MEM_8MB;
- aci->addrbankp = bank;
+ aci->Addrbank = bank;
+ aci->write_bank_address = p->fastmem[aci->devnum].write_address;
+
+#ifndef AMIBERRY
+ if (aci->devnum == 0) {
+ if (ISCPUBOARDP(p, BOARD_COMMODORE, BOARD_COMMODORE_SUB_A26x0)) {
+ expamem_write(1 * 4, p->cpu_model <= 68020 ? 0x50 : 0x51);
+ for (int i = 2; i < 16; i++)
+ expamem_write(i * 4, a2630_autoconfig[i]);
+ type &= 7;
+ type |= a2630_autoconfig[0] & ~7;
+ expamem_write(0, type);
+ memcpy(aci->autoconfig_raw, expamem, sizeof aci->autoconfig_raw);
+ return true;
+ }
+ }
+#endif
if (!fastmem_autoconfig(p, aci, BOARD_AUTOCONFIG_Z2, type, 1, size)) {
aci->zorro = -1;
}
+ if (expamem_write_space[0] != 0x00 && expamem_write_space[0] != 0xff && aci->write_bank_address) {
+ memcpy(expamem, expamem_write_space, 65536);
+ memcpy(bank->baseaddr, expamem_write_space, 65536);
+ }
+
memcpy(aci->autoconfig_raw, expamem, sizeof aci->autoconfig_raw);
+ if (p->fastmem[aci->devnum].no_reset_unmap && bank->allocated_size) {
+ map_banks_z2(bank, bank->start >> 16, size >> 16);
+ }
+
return true;
}
@@ -1269,6 +1743,11 @@ static bool expamem_init_fastcard_z1(struct autoconfig_info *aci)
return expamem_init_fastcard_2(aci, 1);
}
+bool expansion_is_next_board_fastram(void)
+{
+ return ecard + 1 < MAX_EXPANSION_BOARD_SPACE && cards[ecard + 1] && cards[ecard + 1]->map == expamem_map_fastcard;
+}
+
/* ********************************************************** */
#ifdef FILESYS
@@ -1277,14 +1756,14 @@ static bool expamem_rtarea_init(struct autoconfig_info *aci)
{
aci->start = rtarea_base;
aci->size = 65536;
- aci->addrbankp = &rtarea_bank;
+ aci->Addrbank = &rtarea_bank;
aci->label = _T("UAE Boot ROM");
return true;
}
-/*
- * Filesystem device
- */
+/*
+* Filesystem device
+*/
static void expamem_map_filesys_update(void)
{
@@ -1295,15 +1774,23 @@ static void expamem_map_filesys_update(void)
org(a);
}
-static addrbank *expamem_map_filesys (struct autoconfig_info *aci)
+static addrbank *expamem_map_filesys(struct autoconfig_info *aci)
{
+ // Warn if PPC doing autoconfig and UAE expansion enabled
+ static bool warned;
+ if (!warned && regs.halted < 0) {
+ warned = true;
+ // can't show dialogs from PPC thread, deadlock danger.
+ regs.halted = -2;
+ }
mapped_free(&filesys_bank);
filesys_bank.start = expamem_board_pointer;
filesys_bank.mask = filesys_bank.reserved_size - 1;
if (expamem_board_pointer == 0xffffffff)
return &filesys_bank;
mapped_malloc(&filesys_bank);
- memcpy (filesys_bank.baseaddr, expamem, 0x3000);
+ memcpy(filesys_bank.baseaddr, expamem, 0x3000);
+ uaeboard_ram_start = UAEBOARD_WRITEOFFSET;
map_banks_z2(&filesys_bank, filesys_bank.start >> 16, 1);
expamem_map_filesys_update();
return &filesys_bank;
@@ -1346,66 +1833,70 @@ static void add_ks12_boot_hack(void)
static bool expamem_init_filesys(struct autoconfig_info *aci)
{
bool ks12 = ks12orolder();
+ bool hide = currprefs.uae_hide_autoconfig;
if (aci) {
aci->label = ks12 ? _T("Pre-KS 1.3 UAE FS ROM") : _T("UAE FS ROM");
aci->get_params = get_params_filesys;
aci->set_params = set_params_filesys;
- aci->addrbankp = &filesys_bank;
+ aci->Addrbank = &filesys_bank;
}
- /* struct DiagArea - the size has to be large enough to store several device ROMTags */
+#if 0
+ FILE *f = fopen("d:\\amiga\\amiga\\source\\acap\\autoconf", "rb");
+ fread(expamem, 1, 256, f);
+ fclose(f);
+ memcpy(filesys_bank.baseaddr, expamem, 0x3000);
+ return NULL;
+#endif
+
+ /* struct DiagArea - the size has to be large enough to store several device ROMTags */
const uae_u8 diagarea[] = {
0x90, 0x00, /* da_Config, da_Flags */
- 0x02, 0x00, /* da_Size */
+ 0x02, 0x00, /* da_Size */
FILESYS_DIAGPOINT >> 8, FILESYS_DIAGPOINT & 0xff,
FILESYS_BOOTPOINT >> 8, FILESYS_BOOTPOINT & 0xff,
- 0, (uae_u8)(14), // Name offset
+ 0, (uae_u8)(hide ? 0 : 14), // Name offset
0, 0, 0, 0,
- (uae_u8)('U'), (uae_u8)('A'), (uae_u8)('E'), 0
- };
+ (uae_u8)(hide ? 0 : 'U'), (uae_u8)(hide ? 0 : 'A'), (uae_u8)(hide ? 0 : 'E'), 0
+ };
- expamem_init_clear();
- expamem_write (0x00, Z2_MEM_64KB | zorroII | (ks12 || !do_mount ? 0 : rom_card));
+ expamem_init_clear();
+ expamem_write(0x00, Z2_MEM_64KB | zorroII | (ks12 || !do_mount ? 0 : rom_card));
- expamem_write (0x08, no_shutup);
+ expamem_write(0x08, no_shutup);
- expamem_write (0x04, 82);
- expamem_write (0x10, uae_id >> 8);
- expamem_write (0x14, uae_id & 0xff);
+ expamem_write(0x04, currprefs.maprom && !currprefs.cpuboard_type ? 2 : 82);
+ expamem_write(0x10, uae_id >> 8);
+ expamem_write(0x14, uae_id & 0xff);
- expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
- expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
- expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
- expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
+ expamem_write(0x18, 0x00); /* ser.no. Byte 0 */
+ expamem_write(0x1c, 0x00); /* ser.no. Byte 1 */
+ expamem_write(0x20, 0x00); /* ser.no. Byte 2 */
+ expamem_write(0x24, 0x01); /* ser.no. Byte 3 */
- /* er_InitDiagVec */
- expamem_write (0x28, 0x20); /* ROM-Offset hi */
- expamem_write (0x2c, 0x00); /* ROM-Offset lo */
+ /* er_InitDiagVec */
+ expamem_write(0x28, 0x20); /* ROM-Offset hi */
+ expamem_write(0x2c, 0x00); /* ROM-Offset lo */
- expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
+ expamem_write(0x40, 0x00); /* Ctrl/Statusreg.*/
if (aci && !aci->doinit) {
memcpy(aci->autoconfig_raw, expamem, sizeof aci->autoconfig_raw);
return true;
}
- /* Build a DiagArea */
- memcpy (expamem + FILESYS_DIAGAREA, diagarea, sizeof diagarea);
+ /* Build a DiagArea */
+ memcpy(expamem + FILESYS_DIAGAREA, diagarea, sizeof diagarea);
- put_word_host(expamem + FILESYS_DIAGAREA + FILESYS_DIAGPOINT + 0,
- 0x7000 | 2); // MOVEQ #x,D0
- /* Call hwtrap_install */
- put_word_host(expamem + FILESYS_DIAGAREA + FILESYS_DIAGPOINT + 2, 0x4EB9); /* JSR */
- put_long_host(expamem + FILESYS_DIAGAREA + FILESYS_DIAGPOINT + 4, filesys_get_entry(9));
- /* Call DiagEntry */
- put_word_host(expamem + FILESYS_DIAGAREA + FILESYS_DIAGPOINT + 8, 0x4EF9); /* JMP */
- put_long_host(expamem + FILESYS_DIAGAREA + FILESYS_DIAGPOINT + 10, ROM_filesys_diagentry);
+ /* Call DiagEntry */
+ put_word_host(expamem + FILESYS_DIAGAREA + FILESYS_DIAGPOINT, 0x4EF9); /* JMP */
+ put_long_host(expamem + FILESYS_DIAGAREA + FILESYS_DIAGPOINT + 2, ROM_filesys_diagentry);
- /* What comes next is a plain bootblock */
+ /* What comes next is a plain bootblock */
put_word_host(expamem + FILESYS_DIAGAREA + FILESYS_BOOTPOINT, 0x4EF9); /* JMP */
put_long_host(expamem + FILESYS_DIAGAREA + FILESYS_BOOTPOINT + 2, EXPANSION_bootcode);
-
+
if (ks12)
add_ks12_boot_hack();
@@ -1415,10 +1906,10 @@ static bool expamem_init_filesys(struct autoconfig_info *aci)
#endif
/*
- * Zorro III expansion memory
- */
+* Zorro III expansion memory
+*/
-static addrbank *expamem_map_z3fastmem (struct autoconfig_info *aci)
+static addrbank *expamem_map_z3fastmem(struct autoconfig_info *aci)
{
int devnum = aci->devnum;
addrbank *ab = &z3fastmem_bank[devnum];
@@ -1433,7 +1924,7 @@ static addrbank *expamem_map_z3fastmem (struct autoconfig_info *aci)
static bool expamem_init_z3fastmem(struct autoconfig_info *aci)
{
addrbank *bank = &z3fastmem_bank[aci->devnum];
-
+
uae_u32 size = aci->prefs->z3fastmem[aci->devnum].size;
aci->label = _T("Z3 Fast RAM");
@@ -1453,30 +1944,29 @@ static bool expamem_init_z3fastmem(struct autoconfig_info *aci)
if (size < 0x1000000)
code = Z3_MEM_16MB; /* Z3 physical board size is always at least 16M */
- expamem_init_clear();
- if (!fastmem_autoconfig(aci->prefs, aci, BOARD_AUTOCONFIG_Z3, add_memory | zorroIII | code, 1, size))
- aci->zorro = -1;
+ expamem_init_clear();
+ fastmem_autoconfig(aci->prefs, aci, BOARD_AUTOCONFIG_Z3, add_memory | zorroIII | code, 1, size);
memcpy(aci->autoconfig_raw, expamem, sizeof aci->autoconfig_raw);
- aci->addrbankp = bank;
+ aci->Addrbank = bank;
if (!aci->doinit)
return true;
uae_u32 start = bank->start;
- bool alwaysmapz3 = aci->prefs->z3_mapping_mode != Z3MAPPING_REAL;
+ bool alwaysmapz3 = aci->prefs->z3_mapping_mode != Z3MAPPING_REAL || aci->prefs->z3fastmem[aci->devnum].no_reset_unmap;
if ((alwaysmapz3 || expamem_z3hack(aci->prefs)) && bank->allocated_size) {
- map_banks_z3(bank, start >> 16, size >> 16);
- }
+ map_banks_z3(bank, start >> 16, size >> 16);
+ }
return true;
}
#ifdef PICASSO96
/*
- * Fake Graphics Card (ZORRO III) - BDK
- */
+* Fake Graphics Card (ZORRO III) - BDK
+*/
-static addrbank *expamem_map_gfxcard_z3 (struct autoconfig_info *aci)
+static addrbank *expamem_map_gfxcard_z3(struct autoconfig_info *aci)
{
int devnum = aci->devnum;
gfxmem_banks[devnum]->start = expamem_board_pointer;
@@ -1484,7 +1974,7 @@ static addrbank *expamem_map_gfxcard_z3 (struct autoconfig_info *aci)
return gfxmem_banks[devnum];
}
-static addrbank *expamem_map_gfxcard_z2 (struct autoconfig_info *aci)
+static addrbank *expamem_map_gfxcard_z2(struct autoconfig_info *aci)
{
int devnum = aci->devnum;
gfxmem_banks[devnum]->start = expamem_board_pointer;
@@ -1492,27 +1982,27 @@ static addrbank *expamem_map_gfxcard_z2 (struct autoconfig_info *aci)
return gfxmem_banks[devnum];
}
-static bool expamem_init_gfxcard (struct autoconfig_info *aci, bool z3)
+static bool expamem_init_gfxcard(struct autoconfig_info *aci, bool z3)
{
int devnum = aci->devnum;
struct uae_prefs *p = aci->prefs;
int size = p->rtgboards[devnum].rtgmem_size;
- int code = (size == 0x100000 ? Z2_MEM_1MB
- : size == 0x200000 ? Z2_MEM_2MB
- : size == 0x400000 ? Z2_MEM_4MB
- : size == 0x800000 ? Z2_MEM_8MB
- : size == 0x1000000 ? Z3_MEM_16MB
- : size == 0x2000000 ? Z3_MEM_32MB
- : size == 0x4000000 ? Z3_MEM_64MB
- : size == 0x8000000 ? Z3_MEM_128MB
- : size == 0x10000000 ? Z3_MEM_256MB
- : size == 0x20000000 ? Z3_MEM_512MB
- : Z3_MEM_1GB);
- int subsize = (size == 0x100000 ? Z3_SS_MEM_1MB
- : size == 0x200000 ? Z3_SS_MEM_2MB
- : size == 0x400000 ? Z3_SS_MEM_4MB
- : size == 0x800000 ? Z3_SS_MEM_8MB
- : Z3_SS_MEM_SAME);
+ int code = (size == 0x100000 ? Z2_MEM_1MB
+ : size == 0x200000 ? Z2_MEM_2MB
+ : size == 0x400000 ? Z2_MEM_4MB
+ : size == 0x800000 ? Z2_MEM_8MB
+ : size == 0x1000000 ? Z3_MEM_16MB
+ : size == 0x2000000 ? Z3_MEM_32MB
+ : size == 0x4000000 ? Z3_MEM_64MB
+ : size == 0x8000000 ? Z3_MEM_128MB
+ : size == 0x10000000 ? Z3_MEM_256MB
+ : size == 0x20000000 ? Z3_MEM_512MB
+ : Z3_MEM_1GB);
+ int subsize = (size == 0x100000 ? Z3_SS_MEM_1MB
+ : size == 0x200000 ? Z3_SS_MEM_2MB
+ : size == 0x400000 ? Z3_SS_MEM_4MB
+ : size == 0x800000 ? Z3_SS_MEM_8MB
+ : Z3_SS_MEM_SAME);
aci->label = _T("UAE RTG");
aci->direct_vram = true;
@@ -1520,51 +2010,51 @@ static bool expamem_init_gfxcard (struct autoconfig_info *aci, bool z3)
if (size < 0x1000000 && z3)
code = Z3_MEM_16MB; /* Z3 physical board size is always at least 16M */
- expamem_init_clear();
- expamem_write (0x00, (z3 ? zorroIII : zorroII) | code);
+ expamem_init_clear();
+ expamem_write(0x00, (z3 ? zorroIII : zorroII) | code);
- expamem_write (0x08, care_addr | (z3 ? (force_z3 | (size > 0x800000 ? ext_size: subsize)) : 0));
- expamem_write (0x04, 96);
+ expamem_write(0x08, care_addr | (z3 ? (force_z3 | (size > 0x800000 ? ext_size : subsize)) : 0));
+ expamem_write(0x04, 96);
- expamem_write (0x10, uae_id >> 8);
- expamem_write (0x14, uae_id & 0xff);
+ expamem_write(0x10, uae_id >> 8);
+ expamem_write(0x14, uae_id & 0xff);
- expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
- expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
- expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
- expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
+ expamem_write(0x18, 0x00); /* ser.no. Byte 0 */
+ expamem_write(0x1c, 0x00); /* ser.no. Byte 1 */
+ expamem_write(0x20, 0x00); /* ser.no. Byte 2 */
+ expamem_write(0x24, 0x01); /* ser.no. Byte 3 */
- expamem_write (0x28, 0x00); /* ROM-Offset hi */
- expamem_write (0x2c, 0x00); /* ROM-Offset lo */
+ expamem_write(0x28, 0x00); /* ROM-Offset hi */
+ expamem_write(0x2c, 0x00); /* ROM-Offset lo */
- expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
+ expamem_write(0x40, 0x00); /* Ctrl/Statusreg.*/
memcpy(aci->autoconfig_raw, expamem, sizeof aci->autoconfig_raw);
- aci->addrbankp = gfxmem_banks[devnum];
+ aci->Addrbank = gfxmem_banks[devnum];
return true;
}
static bool expamem_init_gfxcard_z3(struct autoconfig_info *aci)
{
- return expamem_init_gfxcard (aci, true);
+ return expamem_init_gfxcard(aci, true);
}
-static bool expamem_init_gfxcard_z2 (struct autoconfig_info *aci)
+static bool expamem_init_gfxcard_z2(struct autoconfig_info *aci)
{
- return expamem_init_gfxcard (aci, false);
+ return expamem_init_gfxcard(aci, false);
}
#endif
#ifdef SAVESTATE
static size_t fast_filepos[MAX_RAM_BOARDS], z3_filepos[MAX_RAM_BOARDS];
-static size_t p96_filepos;
+static size_t z3_fileposchip, p96_filepos;
#endif
-void free_fastmemory (int boardnum)
+void free_fastmemory(int boardnum)
{
- mapped_free (&fastmem_bank[boardnum]);
+ mapped_free(&fastmem_bank[boardnum]);
}
-static bool mapped_malloc_dynamic (uae_u32 *currpsize, uae_u32 *changedpsize, addrbank *bank, int max, const TCHAR *label)
+static bool mapped_malloc_dynamic(uae_u32 *currpsize, uae_u32 *changedpsize, addrbank *bank, int max, const TCHAR *label)
{
int alloc = *currpsize;
@@ -1578,12 +2068,12 @@ static bool mapped_malloc_dynamic (uae_u32 *currpsize, uae_u32 *changedpsize, ad
bank->mask = alloc - 1;
bank->label = label ? label : _T("*");
- if (mapped_malloc (bank)) {
+ if (mapped_malloc(bank)) {
*currpsize = alloc;
*changedpsize = alloc;
return true;
}
- write_log (_T("Out of memory for %s, %d bytes.\n"), label ? label : _T("?"), alloc);
+ write_log(_T("Out of memory for %s, %d bytes.\n"), label ? label : _T("?"), alloc);
return false;
}
@@ -1594,7 +2084,8 @@ uaecptr expansion_startaddress(struct uae_prefs *p, uaecptr addr, uae_u32 size)
return addr;
if (addr < 0x10000000) {
return (addr + size - 1) & ~(size - 1);
- } else {
+ }
+ else {
if (size < 16 * 1024 * 1024)
size = 16 * 1024 * 1024;
if (!expamem_z3hack(p))
@@ -1603,48 +2094,61 @@ uaecptr expansion_startaddress(struct uae_prefs *p, uaecptr addr, uae_u32 size)
return addr;
}
-static void allocate_expamem (void)
+static void allocate_expamem(void)
{
for (int i = 0; i < MAX_RTG_BOARDS; i++) {
memcpy(&currprefs.rtgboards[i], &changed_prefs.rtgboards[i], sizeof(struct rtgboardconfig));
}
+ currprefs.z3chipmem_size = changed_prefs.z3chipmem_size;
for (int i = 0; i < MAX_RAM_BOARDS; i++) {
- currprefs.fastmem[i].size = changed_prefs.fastmem[i].size;
- currprefs.z3fastmem[i].size = changed_prefs.z3fastmem[i].size;
- }
+ currprefs.fastmem[i].size = changed_prefs.fastmem[i].size;
+ currprefs.z3fastmem[i].size = changed_prefs.z3fastmem[i].size;
+ }
+
+ z3chipmem_bank.start = Z3BASE_UAE;
+
+ if (currprefs.mbresmem_high_size >= 128 * 1024 * 1024)
+ z3chipmem_bank.start += (currprefs.mbresmem_high_size - 128 * 1024 * 1024) + 16 * 1024 * 1024;
+
+ if (currprefs.z3chipmem_size && z3fastmem_bank[0].start - z3chipmem_bank.start < currprefs.z3chipmem_size)
+ currprefs.z3chipmem_size = changed_prefs.z3chipmem_size = 0;
for (int i = 0; i < MAX_RAM_BOARDS; i++) {
- if (fastmem_bank[i].reserved_size != currprefs.fastmem[i].size) {
- free_fastmemory (i);
+ if (fastmem_bank[i].reserved_size != currprefs.fastmem[i].size) {
+ free_fastmemory(i);
if (fastmem_bank[i].start == 0xffffffff) {
fastmem_bank[i].reserved_size = 0;
- } else {
- fastmem_bank[i].reserved_size = currprefs.fastmem[i].size;
- fastmem_bank[i].mask = fastmem_bank[i].reserved_size - 1;
- if (fastmem_bank[i].reserved_size && fastmem_bank[i].start != 0xffffffff) {
- mapped_malloc (&fastmem_bank[i]);
- if (fastmem_bank[i].baseaddr == 0) {
- write_log (_T("Out of memory for fastmem card.\n"));
- }
- }
}
- memory_hardreset(1);
- }
- }
+ else {
+ fastmem_bank[i].reserved_size = currprefs.fastmem[i].size;
+ fastmem_bank[i].mask = fastmem_bank[i].reserved_size - 1;
+ if (currprefs.fastmem[i].manual_config) {
+ fastmem_bank[i].start = currprefs.fastmem[i].start_address;
+ }
+ if (fastmem_bank[i].reserved_size && fastmem_bank[i].start != 0xffffffff) {
+ mapped_malloc(&fastmem_bank[i]);
+ if (fastmem_bank[i].baseaddr == 0) {
+ write_log(_T("Out of memory for fastmem card.\n"));
+ }
+ }
+ }
+ memory_hardreset(1);
+ }
+ }
- if (z3fastmem_bank[0].reserved_size != currprefs.z3fastmem[0].size) {
- mapped_free (&z3fastmem_bank[0]);
- mapped_malloc_dynamic (&currprefs.z3fastmem[0].size, &changed_prefs.z3fastmem[0].size, &z3fastmem_bank[0], 1, _T("*"));
- memory_hardreset(1);
+ if (z3fastmem_bank[0].reserved_size != currprefs.z3fastmem[0].size) {
+ mapped_free(&z3fastmem_bank[0]);
+ mapped_malloc_dynamic(&currprefs.z3fastmem[0].size, &changed_prefs.z3fastmem[0].size, &z3fastmem_bank[0], 1, _T("*"));
+ memory_hardreset(1);
}
for (int i = 1; i < MAX_RAM_BOARDS; i++) {
if (currprefs.z3fastmem[i].size && z3fastmem_bank[i].start == 0xffffffff) {
z3fastmem_bank[i].start = expansion_startaddress(&currprefs, z3fastmem_bank[i - 1].start, currprefs.z3fastmem[i - 1].size);
}
if (z3fastmem_bank[i].reserved_size != currprefs.z3fastmem[i].size) {
- mapped_free (&z3fastmem_bank[i]);
+ mapped_free(&z3fastmem_bank[i]);
z3fastmem_bank[i].reserved_size = currprefs.z3fastmem[i].size;
z3fastmem_bank[i].mask = z3fastmem_bank[i].reserved_size - 1;
@@ -1652,77 +2156,113 @@ static void allocate_expamem (void)
if (z3fastmem_bank[i].reserved_size) {
mapped_malloc(&z3fastmem_bank[i]);
if (z3fastmem_bank[i].baseaddr == 0) {
- write_log (_T("Out of memory for 32 bit fast memory #%d.\n"), i);
+ write_log(_T("Out of memory for 32 bit fast memory #%d.\n"), i);
}
}
- memory_hardreset (1);
+ memory_hardreset(1);
}
- }
+ }
+ if (z3chipmem_bank.reserved_size != currprefs.z3chipmem_size) {
+ mapped_free(&z3chipmem_bank);
+ mapped_malloc_dynamic(&currprefs.z3chipmem_size, &changed_prefs.z3chipmem_size, &z3chipmem_bank, 16, _T("*"));
+ memory_hardreset(1);
+ }
#ifdef PICASSO96
struct rtgboardconfig *rbc = &currprefs.rtgboards[0];
if (gfxmem_banks[0]->reserved_size != rbc->rtgmem_size) {
- mapped_free (gfxmem_banks[0]);
- mapped_malloc_dynamic (&rbc->rtgmem_size, &changed_prefs.rtgboards[0].rtgmem_size, gfxmem_banks[0], 1, NULL);
- memory_hardreset(1);
- }
+ mapped_free(gfxmem_banks[0]);
+ if (rbc->rtgmem_type < GFXBOARD_HARDWARE)
+ mapped_malloc_dynamic(&rbc->rtgmem_size, &changed_prefs.rtgboards[0].rtgmem_size, gfxmem_banks[0], 1, NULL);
+ memory_hardreset(1);
+ }
#endif
#ifdef SAVESTATE
- if (savestate_state == STATE_RESTORE) {
+ if (savestate_state == STATE_RESTORE) {
for (int i = 0; i < MAX_RAM_BOARDS; i++) {
- if (fastmem_bank[i].allocated_size > 0) {
- restore_ram (fast_filepos[i], fastmem_bank[i].baseaddr);
- if (!fastmem_bank[i].start) {
- // old statefile compatibility support
- fastmem_bank[i].start = 0x00200000;
- }
- map_banks (&fastmem_bank[i], fastmem_bank[i].start >> 16, currprefs.fastmem[i].size >> 16,
- fastmem_bank[i].allocated_size);
- }
- if (z3fastmem_bank[i].allocated_size > 0) {
- restore_ram (z3_filepos[i], z3fastmem_bank[i].baseaddr);
- map_banks (&z3fastmem_bank[i], z3fastmem_bank[i].start >> 16, currprefs.z3fastmem[i].size >> 16,
- z3fastmem_bank[i].allocated_size);
- }
- }
+ if (fastmem_bank[i].allocated_size > 0) {
+ restore_ram(fast_filepos[i], fastmem_bank[i].baseaddr);
+ if (!fastmem_bank[i].start) {
+ // old statefile compatibility support
+ fastmem_bank[i].start = 0x00200000;
+ }
+ map_banks(&fastmem_bank[i], fastmem_bank[i].start >> 16, currprefs.fastmem[i].size >> 16,
+ fastmem_bank[i].allocated_size);
+ }
+ if (z3fastmem_bank[i].allocated_size > 0) {
+ restore_ram(z3_filepos[i], z3fastmem_bank[i].baseaddr);
+ map_banks(&z3fastmem_bank[i], z3fastmem_bank[i].start >> 16, currprefs.z3fastmem[i].size >> 16,
+ z3fastmem_bank[i].allocated_size);
+ }
+ }
+ if (z3chipmem_bank.allocated_size > 0) {
+ restore_ram(z3_fileposchip, z3chipmem_bank.baseaddr);
+ map_banks(&z3chipmem_bank, z3chipmem_bank.start >> 16, currprefs.z3chipmem_size >> 16,
+ z3chipmem_bank.allocated_size);
+ }
#ifdef PICASSO96
if (gfxmem_banks[0]->allocated_size > 0 && gfxmem_banks[0]->start > 0) {
- restore_ram (p96_filepos, gfxmem_banks[0]->baseaddr);
+ restore_ram(p96_filepos, gfxmem_banks[0]->baseaddr);
map_banks(gfxmem_banks[0], gfxmem_banks[0]->start >> 16, currprefs.rtgboards[0].rtgmem_size >> 16,
gfxmem_banks[0]->allocated_size);
- }
+ }
#endif
- }
+ }
#endif /* SAVESTATE */
}
-static uaecptr check_boot_rom (struct uae_prefs *p, int *boot_rom_type)
+static uaecptr check_boot_rom(struct uae_prefs *p, int *boot_rom_type)
{
- uaecptr b = RTAREA_DEFAULT;
- addrbank *ab;
+ uaecptr b = RTAREA_DEFAULT;
+ addrbank *ab;
+ if (p->uaeboard > 1) {
+ *boot_rom_type = 2;
+ return uaeboard_bank.start ? uaeboard_bank.start + 0x10000 : 0x00eb0000;
+ }
*boot_rom_type = 0;
if (p->boot_rom == 1)
return 0;
*boot_rom_type = 1;
- ab = &get_mem_bank (RTAREA_DEFAULT);
- if (ab) {
- if (valid_address (RTAREA_DEFAULT, 65536))
- b = RTAREA_BACKUP;
- }
- if (nr_directory_units (NULL))
- return b;
- if (nr_directory_units (p))
- return b;
+ if (p->cs_cdtvcd || is_device_rom(p, ROMTYPE_CDTVSCSI, 0) >= 0 || p->uae_hide > 1)
+ b = RTAREA_BACKUP;
+ if (p->cs_mbdmac == 1 || p->cpuboard_type)
+ b = RTAREA_BACKUP;
+#ifndef AMIBERRY
+ // CSPPC enables MMU at boot and remaps 0xea0000->0xeffff.
+ if (ISCPUBOARDP(p, BOARD_BLIZZARD, BOARD_BLIZZARD_SUB_PPC))
+ b = RTAREA_BACKUP_2;
+#endif
+ ab = &get_mem_bank(RTAREA_DEFAULT);
+ if (ab) {
+ if (valid_address(RTAREA_DEFAULT, 65536))
+ b = RTAREA_BACKUP;
+ }
+ if (nr_directory_units(NULL))
+ return b;
+ if (nr_directory_units(p))
+ return b;
if (p->socket_emu)
return b;
- if (p->input_tablet > 0)
- return b;
- if (p->rtgboards[0].rtgmem_size)
+ if (p->uaeserial)
return b;
+ if (p->scsi == 1)
+ return b;
+ if (p->sana2)
+ return b;
+ if (p->input_tablet > 0)
+ return b;
+ if (p->rtgboards[0].rtgmem_size && p->rtgboards[0].rtgmem_type < GFXBOARD_HARDWARE)
+ return b;
+#ifndef AMIBERRY
+ if (p->win32_automount_removable)
+ return b;
+#endif
if (p->chipmem_size > 2 * 1024 * 1024)
- return b;
+ return b;
+ if (p->z3chipmem_size)
+ return b;
if (p->boot_rom >= 3)
return b;
if (p->boot_rom == 2 && b == 0xf00000) {
@@ -1730,20 +2270,62 @@ static uaecptr check_boot_rom (struct uae_prefs *p, int *boot_rom_type)
return b;
}
*boot_rom_type = 0;
- return 0;
+ return 0;
}
-uaecptr need_uae_boot_rom (struct uae_prefs *p)
+uaecptr need_uae_boot_rom(struct uae_prefs *p)
{
- uaecptr v;
+ uaecptr v;
- uae_boot_rom_type = 0;
- v = check_boot_rom (p, &uae_boot_rom_type);
- if (!rtarea_base) {
- uae_boot_rom_type = 0;
- v = 0;
- }
- return v;
+ uae_boot_rom_type = 0;
+ v = check_boot_rom(p, &uae_boot_rom_type);
+ if (!rtarea_base) {
+ uae_boot_rom_type = 0;
+ v = 0;
+ }
+ return v;
+}
+
+static void add_cpu_expansions(struct uae_prefs *p, int zorro, int *fastmem_nump)
+{
+ int fastmem_num = MAX_RAM_BOARDS;
+ if (fastmem_nump)
+ fastmem_num = *fastmem_nump;
+
+ const struct cpuboardsubtype *cst = &cpuboards[p->cpuboard_type].subtypes[p->cpuboard_subtype];
+ if (cst->init && cst->initzorro == zorro) {
+ int idx;
+ struct boardromconfig *brc = get_device_rom(p, ROMTYPE_CPUBOARD, 0, &idx);
+ if (brc) {
+ struct romconfig *rc = &brc->roms[idx];
+ cards_set[cardno].flags = cst->initflag;
+ cards_set[cardno].name = cst->name;
+ cards_set[cardno].initrc = cst->init;
+ cards_set[cardno].rc = rc;
+ cards_set[cardno].zorro = zorro;
+ cards_set[cardno].cst = cst;
+ cards_set[cardno++].map = NULL;
+ if (cst->init2) {
+ cards_set[cardno].flags = cst->initflag | CARD_FLAG_CHILD;
+ cards_set[cardno].name = cst->name;
+ cards_set[cardno].initrc = cst->init2;
+ cards_set[cardno].zorro = zorro;
+ cards_set[cardno].cst = cst;
+ cards_set[cardno++].map = NULL;
+ }
+ if (fastmem_num < MAX_RAM_BOARDS && zorro == 2 && cst->memory_mid && p->fastmem[fastmem_num].size) {
+ cards_set[cardno].flags = (fastmem_num << 16) | CARD_FLAG_CHILD;
+ cards_set[cardno].name = _T("Z2Fast");
+ cards_set[cardno].initnum = expamem_init_fastcard;
+ cards_set[cardno].zorro = zorro;
+ cards_set[cardno].cst = cst;
+ cards_set[cardno++].map = expamem_map_fastcard;
+ fastmem_num++;
+ }
+ }
+ }
+ if (fastmem_nump)
+ *fastmem_nump = fastmem_num;
}
static void add_expansions(struct uae_prefs *p, int zorro, int *fastmem_nump, int mode)
@@ -1757,15 +2339,81 @@ static void add_expansions(struct uae_prefs *p, int zorro, int *fastmem_nump, in
for (int j = 0; j < MAX_DUPLICATE_EXPANSION_BOARDS; j++) {
struct romconfig *rc = get_device_romconfig(p, ert->romtype, j);
if (rc) {
- if (mode == 2)
+ int mid = ert->memory_mid;
+ bool memory_after = ert->memory_after;
+ bool added = false;
+ if (ert->subtypes) {
+ const struct expansionsubromtype *srt = &ert->subtypes[rc->subtype];
+ mid = srt->memory_mid;
+ memory_after = srt->memory_after;
+ }
+
+ if (mode == 1 && ert->memory_mid)
continue;
- cards_set[cardno].flags = 0;
+ if (mode == 2 && !ert->memory_mid)
+ continue;
+ if (fastmem_num < MAX_RAM_BOARDS && zorro == 2 && mid && !memory_after && p->fastmem[fastmem_num].size) {
+ cards_set[cardno].flags = (fastmem_num << 16);
+ cards_set[cardno].name = _T("Z2Fast");
+ cards_set[cardno].initnum = expamem_init_fastcard;
+ cards_set[cardno].zorro = zorro;
+ cards_set[cardno].ert = ert;
+ cards_set[cardno++].map = expamem_map_fastcard;
+ fastmem_num++;
+ added = true;
+ }
+ if (fastmem_num < MAX_RAM_BOARDS && zorro == 3 && mid && !memory_after && p->z3fastmem[fastmem_num].size) {
+ cards_set[cardno].flags = CARD_FLAG_CAN_Z3 | (fastmem_num << 16);
+ cards_set[cardno].name = _T("Z3Fast");
+ cards_set[cardno].initnum = expamem_init_z3fastmem;
+ cards_set[cardno].zorro = zorro;
+ cards_set[cardno].ert = ert;
+ cards_set[cardno++].map = expamem_map_z3fastmem;
+ fastmem_num++;
+ added = true;
+ }
+ cards_set[cardno].flags = added ? CARD_FLAG_CHILD : 0;
cards_set[cardno].name = ert->name;
cards_set[cardno].initrc = ert->init;
cards_set[cardno].rc = rc;
cards_set[cardno].zorro = zorro;
cards_set[cardno].ert = ert;
cards_set[cardno++].map = NULL;
+ if (ert->init2) {
+ cards_set[cardno].flags = CARD_FLAG_CHILD;
+ cards_set[cardno].name = ert->name;
+ cards_set[cardno].initrc = ert->init2;
+ cards_set[cardno].rc = rc;
+ cards_set[cardno].zorro = zorro;
+ cards_set[cardno++].map = NULL;
+ }
+ if (fastmem_num < MAX_RAM_BOARDS && zorro == 1 && mid && p->fastmem[fastmem_num].size) {
+ cards_set[cardno].flags = (fastmem_num << 16) | CARD_FLAG_CHILD;
+ cards_set[cardno].name = _T("Z1Fast");
+ cards_set[cardno].initnum = expamem_init_fastcard_z1;
+ cards_set[cardno].zorro = zorro;
+ cards_set[cardno].ert = ert;
+ cards_set[cardno++].map = NULL;
+ fastmem_num++;
+ }
+ if (fastmem_num < MAX_RAM_BOARDS && zorro == 2 && mid && memory_after && p->fastmem[fastmem_num].size) {
+ cards_set[cardno].flags = (fastmem_num << 16) | CARD_FLAG_CHILD;
+ cards_set[cardno].name = _T("Z2Fast");
+ cards_set[cardno].initnum = expamem_init_fastcard;
+ cards_set[cardno].zorro = zorro;
+ cards_set[cardno].ert = ert;
+ cards_set[cardno++].map = expamem_map_fastcard;
+ fastmem_num++;
+ }
+ if (fastmem_num < MAX_RAM_BOARDS && zorro == 3 && mid && memory_after && p->z3fastmem[fastmem_num].size) {
+ cards_set[cardno].flags = CARD_FLAG_CAN_Z3 | (fastmem_num << 16) | CARD_FLAG_CHILD;
+ cards_set[cardno].name = _T("Z3Fast");
+ cards_set[cardno].initnum = expamem_init_z3fastmem;
+ cards_set[cardno].zorro = zorro;
+ cards_set[cardno].ert = ert;
+ cards_set[cardno++].map = expamem_map_z3fastmem;
+ fastmem_num++;
+ }
}
}
}
@@ -1774,6 +2422,21 @@ static void add_expansions(struct uae_prefs *p, int zorro, int *fastmem_nump, in
*fastmem_nump = fastmem_num;
}
+uae_u32 expansion_board_size(addrbank *ab)
+{
+ uae_u32 size = 0;
+ uae_u8 code = (ab->bget(0) & 0xf0) | ((ab->bget(2) & 0xf0) >> 4);
+ if ((code & 0xc0) == zorroII) {
+ // Z2
+ code &= 7;
+ if (code == 0)
+ size = 8 * 1024 * 1024;
+ else
+ size = 32768 << code;
+ }
+ return size;
+}
+
static uae_u8 autoconfig_read(const uae_u8 *autoconfig, int offset)
{
uae_u8 b = (autoconfig[offset] & 0xf0) | (autoconfig[offset + 2] >> 4);
@@ -1833,7 +2496,8 @@ static void expansion_parse_autoconfig(struct card_data *cd, const uae_u8 *autoc
break;
}
- } else if ((code & 0xc0) == zorroIII) {
+ }
+ else if ((code & 0xc0) == zorroIII) {
// Z3
cd->zorro = 3;
@@ -1851,7 +2515,8 @@ static void expansion_parse_autoconfig(struct card_data *cd, const uae_u8 *autoc
expamem_board_pointer = expamem_z3hack(cd->aci.prefs) ? expamem_z3_pointer_uae : expamem_z3_pointer_real;
expamem_board_size = expamem_z3_size;
- } else if ((code & 0xc0) == 0x40) {
+ }
+ else if ((code & 0xc0) == 0x40) {
cd->zorro = 1;
// 0x40 = "Box without init/diagnostic code"
// proto autoconfig "box" size.
@@ -1879,6 +2544,7 @@ static void reset_ac_data(struct uae_prefs *p)
if (p->mbresmem_high_size >= 128 * 1024 * 1024)
expamem_z3_pointer_uae += (p->mbresmem_high_size - 128 * 1024 * 1024) + 16 * 1024 * 1024;
+ expamem_z3_pointer_uae += p->z3chipmem_size;
expamem_board_pointer = 0;
expamem_board_size = 0;
memset(slots_20, 0, sizeof slots_20);
@@ -1891,22 +2557,25 @@ static void reset_ac(struct uae_prefs *p)
do_mount = 1;
if (need_uae_boot_rom(p) == 0)
- do_mount = 0;
+ do_mount = 0;
if (uae_boot_rom_type <= 0)
do_mount = 0;
- /* check if Kickstart version is below 1.3 */
- if (ks12orolder() && do_mount) {
- /* warn user */
+ /* check if Kickstart version is below 1.3 */
+ if (ks12orolder() && do_mount && p->uaeboard < 2) {
+ /* warn user */
#if KS12_BOOT_HACK
do_mount = -1;
#else
- write_log (_T("Kickstart version is below 1.3! Disabling automount devices.\n"));
- do_mount = 0;
+ write_log(_T("Kickstart version is below 1.3! Disabling automount devices.\n"));
+ do_mount = 0;
#endif
- }
+ }
- uae_id = hackers_id;
+ if (p->uae_hide)
+ uae_id = commodore;
+ else
+ uae_id = hackers_id;
for (int i = 0; i < MAX_EXPANSION_BOARD_SPACE; i++) {
memset(&cards_set[i], 0, sizeof(struct card_data));
@@ -1923,6 +2592,21 @@ void expansion_generate_autoconfig_info(struct uae_prefs *p)
expansion_scan_autoconfig(p, true);
}
+bool alloc_expansion_bank(addrbank *bank, struct autoconfig_info *aci)
+{
+ bank->start = aci->start;
+ bank->reserved_size = aci->size;
+ aci->Addrbank = bank;
+ return mapped_malloc(bank);
+}
+
+void free_expansion_bank(addrbank *bank)
+{
+ mapped_free(bank);
+ bank->start = NULL;
+ bank->reserved_size = 0;
+}
+
struct autoconfig_info *expansion_get_autoconfig_data(struct uae_prefs *p, int index)
{
if (index >= cardno)
@@ -1941,7 +2625,7 @@ struct autoconfig_info *expansion_get_autoconfig_by_address(struct uae_prefs *p,
return NULL;
}
-struct autoconfig_info *expansion_get_autoconfig_info(struct uae_prefs *p,int romtype, int devnum)
+struct autoconfig_info *expansion_get_autoconfig_info(struct uae_prefs *p, int romtype, int devnum)
{
for (int i = 0; i < cardno; i++) {
struct card_data *cd = cards[i];
@@ -1949,7 +2633,12 @@ struct autoconfig_info *expansion_get_autoconfig_info(struct uae_prefs *p,int ro
if (cd->rc->back->device_type == romtype && cd->rc->back->device_num == devnum) {
return &cd->aci;
}
- } else {
+ }
+ else if (cd->cst) {
+ if ((romtype & ROMTYPE_CPUBOARD) && (cd->cst->romtype & ROMTYPE_CPUBOARD))
+ return &cd->aci;
+ }
+ else {
// z2 and z3 ram boards are "fake"
if ((romtype == ROMTYPE_RAMZ2 && !_tcsicmp(cd->name, _T("Z2Fast")))
|| (romtype == ROMTYPE_RAMZ3 && !_tcsicmp(cd->name, _T("Z3Fast")))
@@ -1977,16 +2666,20 @@ static void expansion_init_cards(struct uae_prefs *p)
aci->devnum = (cd->flags >> 16) & 255;
aci->prefs = p;
aci->ert = cd->ert;
+ aci->cst = cd->cst;
aci->start = 0xffffffff;
aci->zorro = cd->zorro;
if (cd->initnum) {
ok = cd->initnum(aci);
- } else {
+ }
+ else {
aci->rc = cd->rc;
ok = cd->initrc(aci);
}
-
- if ((aci->zorro == 1 || aci->zorro == 2 || aci->zorro == 3) && (aci->autoconfig_raw[0] != 0xff || aci->autoconfigp)) {
+ if (cd->flags & CARD_FLAG_CHILD)
+ aci->parent_of_previous = true;
+
+ if ((aci->zorro == 1 || aci->zorro == 2 || aci->zorro == 3) && aci->Addrbank != &expamem_null && aci->Addrbank != &expamem_none && (aci->autoconfig_raw[0] != 0xff || aci->autoconfigp)) {
uae_u8 ac2[16];
const uae_u8 *a = aci->autoconfigp;
if (!a) {
@@ -2037,6 +2730,10 @@ static int get_order(struct uae_prefs *p, struct card_data *cd)
{
if (!cd)
return EXPANSION_ORDER_MAX - 1;
+ if (cd->cst)
+ return -4; // Accelerator must be always first
+ if (cd->aci.hardwired)
+ return -3;
if (cd->aci.get_params) {
struct expansion_params parms;
if (cd->aci.get_params(p, &parms))
@@ -2060,6 +2757,19 @@ static int get_order(struct uae_prefs *p, struct card_data *cd)
return EXPANSION_ORDER_MAX - 1;
}
+bool expansion_can_move(struct uae_prefs *p, int index)
+{
+ if (index < 0 || index >= cardno)
+ return false;
+ struct card_data *cd = cards[index];
+ if (cd->aci.parent_of_previous)
+ return false;
+ int order1 = get_order(p, cd);
+ if (order1 < 0 || order1 >= EXPANSION_ORDER_MAX - 1)
+ return false;
+ return true;
+}
+
static void expansion_parse_cards(struct uae_prefs *p, bool log)
{
if (log)
@@ -2076,11 +2786,13 @@ static void expansion_parse_cards(struct uae_prefs *p, bool log)
aci->devnum = (cd->flags >> 16) & 255;
aci->prefs = p;
aci->ert = cd->ert;
+ aci->cst = cd->cst;
aci->zorro = cd->zorro;
aci->start = 0xffffffff;
if (cd->initnum) {
ok = cd->initnum(aci);
- } else {
+ }
+ else {
aci->rc = cd->rc;
ok = cd->initrc(aci);
}
@@ -2094,6 +2806,22 @@ static void expansion_parse_cards(struct uae_prefs *p, bool log)
if (ok) {
TCHAR label[MAX_DPATH];
label[0] = 0;
+ if (aci->cst && !label[0]) {
+#if 0
+ const TCHAR *man = NULL;
+ for (int i = 0; cpuboards[i].name && man == NULL; i++) {
+ const struct cpuboardtype *cbt = &cpuboards[i];
+ if (cbt->subtypes) {
+ for (int j = 0; cbt->subtypes[j].name && man == NULL; j++) {
+ if (&cbt->subtypes[j] == aci->cst)
+ man = cpuboards[i].name;
+ }
+ }
+ }
+ _stprintf(label, _T("%s (%s)"), aci->cst->name, man);
+#endif
+ _tcscpy(label, aci->cst->name);
+ }
if (cd->rc && !label[0]) {
const struct expansionromtype *ert = get_device_expansion_rom(cd->rc->back->device_type);
if (ert) {
@@ -2103,9 +2831,11 @@ static void expansion_parse_cards(struct uae_prefs *p, bool log)
if (!label[0]) {
if (aci->label) {
_tcscpy(label, aci->label);
- } else if (aci->addrbankp && aci->addrbankp->label) {
- _tcscpy(label, aci->addrbankp->label);
- } else {
+ }
+ else if (aci->Addrbank && aci->Addrbank->label) {
+ _tcscpy(label, aci->Addrbank->label);
+ }
+ else {
_tcscpy(label, _T(""));
}
}
@@ -2114,7 +2844,7 @@ static void expansion_parse_cards(struct uae_prefs *p, bool log)
_stprintf(s, _T(" [%d]"), aci->devnum + 1);
}
- if ((aci->zorro == 1 || aci->zorro == 2 || aci->zorro == 3) && (aci->autoconfig_raw[0] != 0xff || aci->autoconfigp)) {
+ if ((aci->zorro == 1 || aci->zorro == 2 || aci->zorro == 3) && aci->Addrbank != &expamem_none && (aci->autoconfig_raw[0] != 0xff || aci->autoconfigp)) {
uae_u8 ac2[16];
const uae_u8 *a = aci->autoconfigp;
if (!a) {
@@ -2155,15 +2885,16 @@ static void expansion_parse_cards(struct uae_prefs *p, bool log)
cd->size = expamem_board_size;
if ((type & 0xc0) == zorroIII) {
aci->start = expamem_z3hack(p) ? expamem_z3_pointer_uae : expamem_z3_pointer_real;
- } else {
+ }
+ else {
aci->start = expamem_board_pointer;
}
aci->size = cd->size;
memcpy(aci->autoconfig_bytes, a, sizeof aci->autoconfig_bytes);
- if (aci->addrbankp) {
- aci->addrbankp->start = expamem_board_pointer;
- if (aci->addrbankp->reserved_size == 0 && !(type & add_memory) && expamem_board_size < 524288) {
- aci->addrbankp->reserved_size = expamem_board_size;
+ if (aci->Addrbank) {
+ aci->Addrbank->start = expamem_board_pointer;
+ if (aci->Addrbank->reserved_size == 0 && !(type & add_memory) && expamem_board_size < 524288) {
+ aci->Addrbank->reserved_size = expamem_board_size;
}
}
aci->zorro = cd->zorro;
@@ -2171,18 +2902,21 @@ static void expansion_parse_cards(struct uae_prefs *p, bool log)
if (expamem_z3_pointer_real + expamem_board_size < expamem_z3_pointer_real) {
expamem_z3_pointer_real = 0xffffffff;
expamem_z3_highram_real = 0xffffffff;
- } else {
+ }
+ else {
expamem_z3_pointer_real += expamem_board_size;
}
if (expamem_z3_pointer_uae + expamem_board_size < expamem_z3_pointer_uae) {
expamem_z3_pointer_uae = 0xffffffff;
expamem_z3_highram_uae = 0xffffffff;
- } else {
+ }
+ else {
expamem_z3_pointer_uae += expamem_board_size;
}
if (expamem_board_pointer + expamem_board_size < expamem_board_pointer) {
expamem_board_pointer = 0xffffffff;
- } else {
+ }
+ else {
expamem_board_pointer += expamem_board_size;
}
if ((type & add_memory) || aci->direct_vram) {
@@ -2193,14 +2927,18 @@ static void expansion_parse_cards(struct uae_prefs *p, bool log)
}
}
- } else {
+ }
+ else {
cd->base = aci->start;
cd->size = aci->size;
if (log)
write_log(_T("'%s' no autoconfig %08x - %08x.\n"), aci->label ? aci->label : _T(""), cd->base, cd->base + cd->size - 1);
}
_tcscpy(aci->name, label);
- } else {
+ if (cd->flags & CARD_FLAG_CHILD)
+ aci->parent_of_previous = true;
+ }
+ else {
if (log)
write_log(_T("init failed.\n"), i);
}
@@ -2209,12 +2947,159 @@ static void expansion_parse_cards(struct uae_prefs *p, bool log)
write_log(_T("END\n"));
}
-static bool add_card_sort(int index, bool *inuse, int *new_cardnop)
+int expansion_autoconfig_move(struct uae_prefs *p, int index, int dir, bool test)
+{
+ if (index < 0 || index >= cardno)
+ return -1;
+ if (!dir)
+ return -1;
+ struct card_data *cd1 = cards[index];
+ int order1 = get_order(p, cd1);
+ if (order1 < 0 || order1 >= EXPANSION_ORDER_MAX - 1)
+ return -1;
+ struct card_data *cd2;
+ int order2;
+ for (;;) {
+ if (index + dir < 0 || index + dir >= cardno)
+ return -1;
+ cd2 = cards[index + dir];
+ if (cd1->aci.parent_of_previous && !cd2->aci.parent_of_previous)
+ return -1;
+ order2 = get_order(p, cd2);
+ if (order2 >= 0 && order2 < EXPANSION_ORDER_MAX - 1) {
+ if (!cd1->aci.parent_of_previous && !cd2->aci.parent_of_previous)
+ break;
+ }
+ dir += dir < 0 ? -1 : 1;
+ }
+ if (test) {
+ return 0;
+ }
+ set_order(p, cd1, order2);
+ set_order(p, cd2, order1);
+ if (p != &currprefs)
+ expansion_scan_autoconfig(p, false);
+ for (int i = 0; i < cardno; i++) {
+ if (cards[i] == cd1)
+ return i;
+ }
+ return -1;
+}
+
+static void expansion_recalc_order(struct uae_prefs *p)
+{
+ int ordermin = 1;
+ for (;;) {
+ int order = EXPANSION_ORDER_MAX;
+ int idx = -1;
+ for (int i = 0; i < cardno; i++) {
+ struct card_data *cdc = cards[i];
+ int o = get_order(p, cdc);
+ if (o >= ordermin && order > o) {
+ order = o;
+ idx = i;
+ }
+ }
+ if (idx < 0)
+ break;
+ set_order(p, cards[idx], ordermin);
+ ordermin++;
+ }
+}
+
+void expansion_set_autoconfig_sort(struct uae_prefs *p)
+{
+ for (int i = 0; i < cardno; i++) {
+ set_order(p, cards[i], i + 1);
+ }
+ expansion_recalc_order(p);
+}
+
+static bool ischild(struct card_data *cd)
+{
+ if (cd->aci.parent_name)
+ return true;
+ if (cd->aci.parent_address_space)
+ return true;
+ if (cd->aci.parent_of_previous)
+ return true;
+ if (cd->aci.parent_romtype)
+ return true;
+ return false;
+}
+
+static void check_card_child(int index, bool *inuse, int *new_cardnop)
{
struct card_data *cd = &cards_set[index];
int new_cardno = *new_cardnop;
+ // address space "conflict" parent?
+ for (int i = 0; i < cardno; i++) {
+ struct card_data *cdc = &cards_set[i];
+ if (inuse[i])
+ continue;
+ if (!cdc->aci.parent_address_space)
+ continue;
+ if (cd->aci.start && cd->aci.size && cdc->aci.start >= cd->aci.start && cdc->aci.start < cd->aci.start + cd->aci.size) {
+ cards[new_cardno++] = cdc;
+ cdc->aci.parent_of_previous = true;
+ inuse[i] = true;
+ }
+ }
+ // romtype parent?
+ for (int i = 0; i < cardno; i++) {
+ struct card_data *cdc = &cards_set[i];
+ if (inuse[i])
+ continue;
+ const int *parent = cdc->aci.parent_romtype;
+ if (!parent)
+ continue;
+ for (int j = 0; parent[j]; j++) {
+ if (cd->rc && parent[j] == (cd->rc->back->device_type & ROMTYPE_MASK)) {
+ cards[new_cardno++] = cdc;
+ cdc->aci.parent_of_previous = true;
+ inuse[i] = true;
+ }
+ }
+ }
+ // named parent
+ for (int i = 0; i < cardno; i++) {
+ struct card_data *cdc = &cards_set[i];
+ if (inuse[i])
+ continue;
+ if (cdc->aci.parent_name && cd->name && !_tcsicmp(cdc->aci.parent_name, cd->name)) {
+ cards[new_cardno++] = cdc;
+ cdc->aci.parent_of_previous = true;
+ inuse[i] = true;
+ }
+ }
+ *new_cardnop = new_cardno;
+}
+
+static bool add_card_sort(int index, bool *inuse, int *new_cardnop)
+{
+ struct card_data *cd = &cards_set[index];
+ if (ischild(cd))
+ return false;
+ int new_cardno = *new_cardnop;
cards[new_cardno++] = cd;
inuse[index] = true;
+ int index2 = index + 1;
+ // any children?
+ while (index2 < cardno) {
+ struct card_data *cdc = &cards_set[index2];
+ struct autoconfig_info *aci = &cdc->aci;
+ if (inuse[index2])
+ break;
+ if (!ischild(cdc))
+ break;
+ if (aci->parent_of_previous) {
+ cards[new_cardno++] = cdc;
+ inuse[index2] = true;
+ check_card_child(index2, inuse, &new_cardno);
+ }
+ index2++;
+ }
+ check_card_child(index, inuse, &new_cardno);
*new_cardnop = new_cardno;
return true;
}
@@ -2248,9 +3133,13 @@ static void expansion_autoconfig_sort(struct uae_prefs *p)
if (inuse2[i])
continue;
struct card_data *cd = &cards_set[i];
+ if (ischild(cd))
+ continue;
if (cd->zorro != z)
continue;
int order = get_order(p, cd);
+ if (cd->aci.hardwired)
+ order = -1;
if (order >= 0)
continue;
if (testorder > order) {
@@ -2274,6 +3163,8 @@ static void expansion_autoconfig_sort(struct uae_prefs *p)
if (inuse2[i])
continue;
struct card_data *cd = &cards_set[i];
+ if (ischild(cd))
+ continue;
if (cd->zorro != z)
continue;
if (get_order(p, cd) < EXPANSION_ORDER_MAX - 1)
@@ -2294,6 +3185,8 @@ static void expansion_autoconfig_sort(struct uae_prefs *p)
if (inuse2[i])
continue;
struct card_data *cd = &cards_set[i];
+ if (ischild(cd))
+ continue;
if (cd->zorro != z)
continue;
inuse2[i] = true;
@@ -2310,37 +3203,124 @@ static void expansion_autoconfig_sort(struct uae_prefs *p)
for (int i = 0; i < cardno; i++) {
struct autoconfig_info *aci = &cards[i]->aci;
tcards[i] = cards[i];
- tcards[i]->aci.can_sort = get_order(p, cards[i]) < EXPANSION_ORDER_MAX - 1 && get_order(p, cards[i]) >= 0;
+ tcards[i]->aci.can_sort = !aci->hardwired && !aci->parent_of_previous && get_order(p, cards[i]) < EXPANSION_ORDER_MAX - 1 && get_order(p, cards[i]) >= 0;
}
- new_cardno = 0;
+ if (!p->autoconfig_custom_sort) {
- // re-sort by board size
- for (int idx = 0; idx < cardno; idx++) {
- struct card_data *cd = tcards[idx];
- if (!cd)
- continue;
- int z = cd->zorro;
- if (z != 2 && z != 3) {
- cards[new_cardno++] = cd;
- tcards[idx] = NULL;
- }
- }
- for (int z = 2; z <= 3; z++) {
- for (;;) {
- int idx2 = -1;
- uae_u32 size = 0;
- for (int j = 0; j < cardno; j++) {
- struct card_data *cdc = tcards[j];
- if (cdc && cdc->size > size && cdc->zorro == z) {
- size = cdc->size;
- idx2 = j;
+ new_cardno = 0;
+
+ // accelerator and hardwired first
+ for (int idx = 0; idx < cardno; idx++) {
+ struct card_data *cd = tcards[idx];
+ if (!cd)
+ continue;
+ if (cd->cst || cd->aci.hardwired) {
+ cards[new_cardno++] = cd;
+ tcards[idx] = NULL;
+ for (int j = idx + 1; j < cardno; j++) {
+ struct card_data *cdc = tcards[j];
+ if (!cdc || !ischild(cdc))
+ break;
+ cards[new_cardno++] = cdc;
+ tcards[j] = NULL;
}
}
- if (idx2 < 0)
+ }
+ // re-sort by board size
+ for (int idx = 0; idx < cardno; idx++) {
+ struct card_data *cd = tcards[idx];
+ if (!cd)
+ continue;
+ int z = cd->zorro;
+ if ((z != 2 && z != 3 && !ischild(cd)) || cd->cst) {
+ cards[new_cardno++] = cd;
+ tcards[idx] = NULL;
+ for (int j = idx + 1; j < cardno; j++) {
+ struct card_data *cdc = tcards[j];
+ if (!cdc || !ischild(cdc))
+ break;
+ cards[new_cardno++] = cdc;
+ tcards[j] = NULL;
+ }
+ }
+ }
+ for (int z = 2; z <= 3; z++) {
+ for (;;) {
+ int idx2 = -1;
+ uae_u32 size = 0;
+ for (int j = 0; j < cardno; j++) {
+ struct card_data *cdc = tcards[j];
+ if (cdc && cdc->size > size && cdc->zorro == z && !ischild(cdc)) {
+ size = cdc->size;
+ idx2 = j;
+ }
+ }
+ if (idx2 < 0)
+ break;
+ cards[new_cardno++] = tcards[idx2];
+ tcards[idx2] = NULL;
+ for (int j = idx2 + 1; j < cardno; j++) {
+ struct card_data *cdc = tcards[j];
+ if (!cdc || !ischild(cdc))
+ break;
+ cards[new_cardno++] = cdc;
+ tcards[j] = NULL;
+ }
+ }
+ }
+
+ }
+ else {
+
+ // re-sort by configuration data
+ new_cardno = 0;
+ for (;;) {
+ int order = EXPANSION_ORDER_MAX;
+ int idx = -1;
+ for (int i = 0; i < cardno; i++) {
+ struct card_data *cd = tcards[i];
+ if (cd && get_order(p, cd) < order && !cd->aci.parent_of_previous) {
+ order = get_order(p, cd);
+ idx = i;
+ }
+ }
+ if (idx >= 0) {
+ struct card_data *cd = tcards[idx];
+ struct autoconfig_info *aci = &cd->aci;
+ cards[new_cardno++] = cd;
+ tcards[idx] = NULL;
+ // sort children, if any
+ int child = 0;
+ for (int j = idx + 1; j < cardno; j++) {
+ struct card_data *cdc = tcards[j];
+ if (!cdc || !cdc->aci.parent_of_previous)
+ break;
+ child++;
+ }
+ for (;;) {
+ order = EXPANSION_ORDER_MAX;
+ int cidx = -1;
+ for (int j = 0; j < child; j++) {
+ struct card_data *cdc = tcards[j + idx + 1];
+ if (cdc && get_order(p, cdc) < order) {
+ order = get_order(p, cdc);
+ cidx = j;
+ }
+ }
+ if (cidx < 0)
+ break;
+ cards[new_cardno++] = tcards[idx + 1 + cidx];
+ tcards[idx + 1 + cidx] = NULL;
+ }
+ for (int j = 0; j < child; j++) {
+ if (tcards[idx + 1 + j]) {
+ cards[new_cardno++] = tcards[idx + 1 + j];
+ }
+ }
+ }
+ if (idx < 0)
break;
- cards[new_cardno++] = tcards[idx2];
- tcards[idx2] = NULL;
}
}
@@ -2358,14 +3338,37 @@ static void expansion_add_autoconfig(struct uae_prefs *p)
reset_ac(p);
+ if (p->cpuboard_type) {
+ // This may require first 128k slot.
+ cards_set[cardno].flags = 1;
+ cards_set[cardno].name = _T("CPUBoard");
+#ifndef AMIBERRY
+ cards_set[cardno].initrc = cpuboard_autoconfig_init;
+#endif
+ cards_set[cardno].zorro = BOARD_NONAUTOCONFIG_BEFORE;
+ cards_set[cardno].cst = &cpuboards[p->cpuboard_type].subtypes[p->cpuboard_subtype];;
+ cards_set[cardno++].map = NULL;
+ }
+
+ if (p->z3chipmem_size) {
+ cards_set[cardno].flags = 0;
+ cards_set[cardno].name = _T("MegaChipRAM");
+ cards_set[cardno].initrc = megachipram_init;
+ cards_set[cardno].zorro = BOARD_NONAUTOCONFIG_BEFORE;
+ cards_set[cardno++].map = NULL;
+ }
+
// add possible non-autoconfig boards
+ add_cpu_expansions(p, BOARD_NONAUTOCONFIG_BEFORE, NULL);
add_expansions(p, BOARD_NONAUTOCONFIG_BEFORE, NULL, 0);
fastmem_num = 0;
add_expansions(p, BOARD_PROTOAUTOCONFIG, &fastmem_num, 0);
+ add_cpu_expansions(p, BOARD_AUTOCONFIG_Z2, &fastmem_num);
// immediately after Z2Fast so that it can be emulated as A590/A2091 with fast ram.
add_expansions(p, BOARD_AUTOCONFIG_Z2, &fastmem_num, 0);
+ add_cpu_expansions(p, BOARD_NONAUTOCONFIG_AFTER_Z2, NULL);
add_expansions(p, BOARD_NONAUTOCONFIG_AFTER_Z2, NULL, 0);
while (fastmem_num < MAX_RAM_BOARDS) {
@@ -2377,10 +3380,10 @@ static void expansion_add_autoconfig(struct uae_prefs *p)
cards_set[cardno++].map = expamem_map_fastcard;
}
fastmem_num++;
- }
+ }
#ifdef FILESYS
- if (do_mount && p->uaeboard >= 0) {
+ if (do_mount && p->uaeboard >= 0 && p->uaeboard < 2) {
cards_set[cardno].flags = 0;
cards_set[cardno].name = _T("UAEFS");
cards_set[cardno].zorro = 2;
@@ -2394,13 +3397,14 @@ static void expansion_add_autoconfig(struct uae_prefs *p)
cards_set[cardno].initnum = expamem_init_uaeboard;
cards_set[cardno++].map = expamem_map_uaeboard;
}
- if (do_mount) {
+ if (do_mount && p->uaeboard < 2) {
cards_set[cardno].flags = 0;
cards_set[cardno].name = _T("UAEBOOTROM");
cards_set[cardno].zorro = BOARD_NONAUTOCONFIG_BEFORE;
cards_set[cardno].initnum = expamem_rtarea_init;
cards_set[cardno++].map = NULL;
- }
+
+ }
#endif
#ifdef PICASSO96
for (int i = 0; i < MAX_RTG_BOARDS; i++) {
@@ -2412,13 +3416,54 @@ static void expansion_add_autoconfig(struct uae_prefs *p)
cards_set[cardno].initnum = expamem_init_gfxcard_z2;
cards_set[cardno++].map = expamem_map_gfxcard_z2;
}
- }
+ }
+#endif
+#ifdef GFXBOARD
+ for (int i = 0; i < MAX_RTG_BOARDS; i++) {
+ struct rtgboardconfig *rbc = &p->rtgboards[i];
+ if (rbc->rtgmem_size && rbc->rtgmem_type >= GFXBOARD_HARDWARE && gfxboard_get_configtype(rbc) <= 2) {
+ cards_set[cardno].flags = 4 | (i << 16);
+ if (gfxboard_get_func(rbc)) {
+ cards_set[cardno].name = _T("Z2RTG");
+ cards_set[cardno].zorro = 2;
+ cards_set[cardno].flags = (i << 16);
+ cards_set[cardno++].initnum = gfxboard_init_board;
+ }
+ else {
+ cards_set[cardno].name = _T("Z2RTG");
+ cards_set[cardno].zorro = 2;
+ cards_set[cardno++].initnum = gfxboard_init_memory;
+ if (gfxboard_num_boards(rbc) == 3) {
+ cards_set[cardno].flags = (i << 16) | CARD_FLAG_CHILD;
+ cards_set[cardno].name = _T("Gfxboard VRAM Zorro II Extra");
+ cards_set[cardno].zorro = 2;
+ cards_set[cardno++].initnum = gfxboard_init_memory_p4_z2;
+ }
+ if (gfxboard_is_registers(rbc)) {
+ cards_set[cardno].flags = (i << 16) | CARD_FLAG_CHILD;
+ cards_set[cardno].name = _T("Gfxboard Registers");
+ cards_set[cardno].zorro = 2;
+ cards_set[cardno++].initnum = gfxboard_init_registers;
+ }
+ }
+ }
+ }
+#endif
+#ifndef AMIBERRY
+ if (p->monitoremu == MONITOREMU_FIRECRACKER24) {
+ cards_set[cardno].flags = 0;
+ cards_set[cardno].name = _T("FireCracker24");
+ cards_set[cardno].zorro = 2;
+ cards_set[cardno++].initnum = specialmonitor_autoconfig_init;
+ }
#endif
/* Z3 boards last */
fastmem_num = 0;
+ add_cpu_expansions(p, BOARD_AUTOCONFIG_Z3, &fastmem_num);
+
// add combo Z3 boards (something + Z3 RAM)
add_expansions(p, BOARD_AUTOCONFIG_Z3, &fastmem_num, 2);
@@ -2442,13 +3487,32 @@ static void expansion_add_autoconfig(struct uae_prefs *p)
cards_set[cardno].initnum = expamem_init_gfxcard_z3;
cards_set[cardno++].map = expamem_map_gfxcard_z3;
}
- }
+ }
+#endif
+#ifdef GFXBOARD
+ for (int i = 0; i < MAX_RTG_BOARDS; i++) {
+ struct rtgboardconfig *rbc = &p->rtgboards[i];
+ if (rbc->rtgmem_size && rbc->rtgmem_type >= GFXBOARD_HARDWARE && gfxboard_get_configtype(rbc) == 3) {
+ cards_set[cardno].flags = 4 | CARD_FLAG_CAN_Z3 | (i << 16);
+ cards_set[cardno].name = _T("Z3RTG");
+ cards_set[cardno].zorro = 3;
+ cards_set[cardno++].initnum = gfxboard_init_memory;
+ if (gfxboard_is_registers(rbc)) {
+ cards_set[cardno].flags = 1 | (i << 16) | CARD_FLAG_CHILD;
+ cards_set[cardno].zorro = 3;
+ cards_set[cardno].name = _T("Gfxboard Registers");
+ cards_set[cardno++].initnum = gfxboard_init_registers;
+ }
+ }
+ }
#endif
// add non-memory Z3 boards
add_expansions(p, BOARD_AUTOCONFIG_Z3, NULL, 1);
+ add_cpu_expansions(p, BOARD_NONAUTOCONFIG_AFTER_Z3, NULL);
add_expansions(p, BOARD_NONAUTOCONFIG_AFTER_Z3, NULL, 0);
+
}
void expansion_scan_autoconfig(struct uae_prefs *p, bool log)
@@ -2460,13 +3524,13 @@ void expansion_scan_autoconfig(struct uae_prefs *p, bool log)
expansion_parse_cards(p, log);
}
-void expamem_reset (void)
+void expamem_reset(void)
{
reset_ac(&currprefs);
chipdone = false;
- allocate_expamem ();
+ allocate_expamem();
expamem_bank.name = _T("Autoconfig [reset]");
expansion_add_autoconfig(&currprefs);
@@ -2474,21 +3538,21 @@ void expamem_reset (void)
expansion_autoconfig_sort(&currprefs);
expansion_parse_cards(&currprefs, true);
- if (cardno == 0 || savestate_state)
- expamem_init_clear_zero ();
- else
+ if (cardno == 0 || savestate_state)
+ expamem_init_clear_zero();
+ else
call_card_init(0);
}
-void expansion_init (void)
+void expansion_init(void)
{
if (savestate_state != STATE_RESTORE) {
- for (int i = 0; i < MAX_RAM_BOARDS; i++) {
- fastmem_bank[i].reserved_size = 0;
+ for (int i = 0; i < MAX_RAM_BOARDS; i++) {
+ fastmem_bank[i].reserved_size = 0;
fastmem_bank[i].mask = 0;
- fastmem_bank[i].baseaddr = NULL;
- }
+ fastmem_bank[i].baseaddr = NULL;
+ }
#ifdef PICASSO96
for (int i = 0; i < MAX_RTG_BOARDS; i++) {
@@ -2498,14 +3562,22 @@ void expansion_init (void)
}
#endif
+#ifdef CATWEASEL
+ catweasel_mask = catweasel_start = 0;
+#endif
+
for (int i = 0; i < MAX_RAM_BOARDS; i++) {
- z3fastmem_bank[i].reserved_size = 0;
+ z3fastmem_bank[i].reserved_size = 0;
z3fastmem_bank[i].mask = 0;
- z3fastmem_bank[i].baseaddr = NULL;
- }
- }
-
- allocate_expamem ();
+ z3fastmem_bank[i].baseaddr = NULL;
+ }
+
+ z3chipmem_bank.reserved_size = 0;
+ z3chipmem_bank.mask = z3chipmem_bank.start = 0;
+ z3chipmem_bank.baseaddr = NULL;
+ }
+
+ allocate_expamem();
if (currprefs.uaeboard) {
uaeboard_bank.reserved_size = 0x10000;
@@ -2514,31 +3586,57 @@ void expansion_init (void)
}
-void expansion_cleanup (void)
+void expansion_cleanup(void)
{
for (int i = 0; i < MAX_RAM_BOARDS; i++) {
- mapped_free (&fastmem_bank[i]);
- mapped_free (&z3fastmem_bank[i]);
- }
+ mapped_free(&fastmem_bank[i]);
+ mapped_free(&z3fastmem_bank[i]);
+ }
+ mapped_free(&z3chipmem_bank);
#ifdef PICASSO96
for (int i = 0; i < MAX_RTG_BOARDS; i++) {
- mapped_free (gfxmem_banks[i]);
+ if (currprefs.rtgboards[i].rtgmem_type < GFXBOARD_HARDWARE) {
+ mapped_free(gfxmem_banks[i]);
+ }
}
#endif
#ifdef FILESYS
- mapped_free (&filesys_bank);
+ mapped_free(&filesys_bank);
#endif
if (currprefs.uaeboard) {
mapped_free(&uaeboard_bank);
}
+
+#ifdef CATWEASEL
+ catweasel_free();
+#endif
}
void expansion_map(void)
{
map_banks(&expamem_bank, 0xE8, 1, 0);
// map non-autoconfig ram boards
+ for (int i = 0; i < MAX_RAM_BOARDS; i++) {
+ struct ramboard *rb = &currprefs.fastmem[i];
+ if (rb->manual_config) {
+ map_banks(&fastmem_bank[i], rb->start_address >> 16, (rb->end_address - rb->start_address + 1) >> 16, 0);
+ }
+ else if (rb->no_reset_unmap && rb->start_address) {
+ map_banks(&fastmem_bank[i], rb->start_address >> 16, rb->size >> 16, 0);
+ }
+ rb = &currprefs.z3fastmem[i];
+ if (rb->manual_config) {
+ map_banks(&z3fastmem_bank[i], rb->start_address >> 16, (rb->end_address - rb->start_address + 1) >> 16, 0);
+ }
+ else if (rb->no_reset_unmap && rb->start_address) {
+ map_banks(&z3fastmem_bank[i], rb->start_address >> 16, rb->size >> 16, 0);
+ }
+ }
+ if (currprefs.z3chipmem_size) {
+ map_banks_z3(&z3chipmem_bank, z3chipmem_bank.start >> 16, currprefs.z3chipmem_size >> 16);
+ }
if (do_mount < 0 && ks11orolder()) {
filesys_bank.start = 0xe90000;
mapped_free(&filesys_bank);
@@ -2549,21 +3647,22 @@ void expansion_map(void)
}
}
-static void clear_bank (addrbank *ab)
+static void clear_bank(addrbank *ab)
{
if (!ab->baseaddr || !ab->allocated_size)
return;
- memset (ab->baseaddr, 0, ab->allocated_size > 0x800000 ? 0x800000 : ab->allocated_size);
+ memset(ab->baseaddr, 0, ab->allocated_size > 0x800000 ? 0x800000 : ab->allocated_size);
}
void expansion_clear(void)
{
for (int i = 0; i < MAX_RAM_BOARDS; i++) {
- clear_bank (&fastmem_bank[i]);
- clear_bank (&z3fastmem_bank[i]);
- }
+ clear_bank(&fastmem_bank[i]);
+ clear_bank(&z3fastmem_bank[i]);
+ }
+ clear_bank(&z3chipmem_bank);
for (int i = 0; i < MAX_RTG_BOARDS; i++) {
- clear_bank (gfxmem_banks[i]);
+ clear_bank(gfxmem_banks[i]);
}
}
@@ -2571,68 +3670,78 @@ void expansion_clear(void)
/* State save/restore code. */
-uae_u8 *save_fram (int *len, int num)
+uae_u8 *save_fram(int *len, int num)
{
- *len = fastmem_bank[num].allocated_size;
- return fastmem_bank[num].baseaddr;
+ *len = fastmem_bank[num].allocated_size;
+ return fastmem_bank[num].baseaddr;
}
-uae_u8 *save_zram (int *len, int num)
+uae_u8 *save_zram(int *len, int num)
{
- *len = z3fastmem_bank[num].allocated_size;
- return z3fastmem_bank[num].baseaddr;
+ if (num < 0) {
+ *len = z3chipmem_bank.allocated_size;
+ return z3chipmem_bank.baseaddr;
+ }
+ *len = z3fastmem_bank[num].allocated_size;
+ return z3fastmem_bank[num].baseaddr;
}
-uae_u8 *save_pram (int *len)
+uae_u8 *save_pram(int *len)
{
*len = gfxmem_banks[0]->allocated_size;
return gfxmem_banks[0]->baseaddr;
}
-void restore_fram (int len, size_t filepos, int num)
+void restore_fram(int len, size_t filepos, int num)
{
fast_filepos[num] = filepos;
- changed_prefs.fastmem[num].size = len;
+ changed_prefs.fastmem[num].size = len;
}
-void restore_zram (int len, size_t filepos, int num)
+void restore_zram(int len, size_t filepos, int num)
{
- z3_filepos[num] = filepos;
- changed_prefs.z3fastmem[num].size = len;
+ if (num == -1) {
+ z3_fileposchip = filepos;
+ changed_prefs.z3chipmem_size = len;
+ }
+ else {
+ z3_filepos[num] = filepos;
+ changed_prefs.z3fastmem[num].size = len;
+ }
}
-void restore_pram (int len, size_t filepos)
+void restore_pram(int len, size_t filepos)
{
- p96_filepos = filepos;
+ p96_filepos = filepos;
changed_prefs.rtgboards[0].rtgmem_size = len;
}
-uae_u8 *save_expansion (int *len, uae_u8 *dstptr)
+uae_u8 *save_expansion(int *len, uae_u8 *dstptr)
{
uae_u8 *dst, *dstbak;
- if (dstptr)
- dst = dstbak = dstptr;
- else
- dstbak = dst = xmalloc (uae_u8, 6 * 4);
- save_u32 (fastmem_bank[0].start);
- save_u32 (z3fastmem_bank[0].start);
- save_u32 (gfxmem_banks[0]->start);
- save_u32 (rtarea_base);
- save_u32 (0 /* fastmem_bank[1].start */);
- *len = dst - dstbak;
- return dstbak;
+ if (dstptr)
+ dst = dstbak = dstptr;
+ else
+ dstbak = dst = xmalloc(uae_u8, 6 * 4);
+ save_u32(fastmem_bank[0].start);
+ save_u32(z3fastmem_bank[0].start);
+ save_u32(gfxmem_banks[0]->start);
+ save_u32(rtarea_base);
+ save_u32(fastmem_bank[1].start);
+ *len = 4 + 4 + 4 + 4 + 4;
+ return dstbak;
}
-uae_u8 *restore_expansion (uae_u8 *src)
+uae_u8 *restore_expansion(uae_u8 *src)
{
- fastmem_bank[0].start = restore_u32 ();
- z3fastmem_bank[0].start = restore_u32 ();
- gfxmem_banks[0]->start = restore_u32 ();
- rtarea_base = restore_u32 ();
- restore_u32 (); /* ignore fastmem_bank[1].start */
- if (rtarea_base != 0 && rtarea_base != RTAREA_DEFAULT && rtarea_base != RTAREA_BACKUP && rtarea_base != RTAREA_BACKUP_2)
- rtarea_base = 0;
- return src;
+ fastmem_bank[0].start = restore_u32();
+ z3fastmem_bank[0].start = restore_u32();
+ gfxmem_banks[0]->start = restore_u32();
+ rtarea_base = restore_u32();
+ fastmem_bank[1].start = restore_u32();
+ if (rtarea_base != 0 && rtarea_base != RTAREA_DEFAULT && rtarea_base != RTAREA_BACKUP && rtarea_base != RTAREA_BACKUP_2)
+ rtarea_base = 0;
+ return src;
}
uae_u8 *save_expansion_info(int *len, uae_u8 *dstptr)
@@ -2652,7 +3761,8 @@ uae_u8 *save_expansion_info(int *len, uae_u8 *dstptr)
save_u32(ec->rc->back->device_num);
save_string(ec->rc->romfile);
save_string(ec->rc->romident);
- } else {
+ }
+ else {
save_u32(0xffffffff);
}
save_u32(ec->base);
@@ -2689,23 +3799,1884 @@ uae_u8 *restore_expansion_info(uae_u8 *src)
#endif /* SAVESTATE */
+#if 0
+static const struct expansionsubromtype a2090_sub[] = {
+ {
+ _T("A2090a"), _T("a2090a"),
+ 0, 0, 0,
+ { 0 },
+ },
+ {
+ _T("A2090a + 1M RAM"), _T("a2090a_2"),
+ 0, 0, 0,
+ { 0 },
+ },
+ {
+ NULL
+ }
+};
+#endif
+static const struct expansionsubromtype a2091_sub[] = {
+ {
+ _T("DMAC-01"), _T("dmac01"), 0,
+ commodore, commodore_a2091_ram, 0, true,
+ { 0 }
+ },
+ {
+ _T("DMAC-02"), _T("dmac02"), 0,
+ commodore, commodore_a2091_ram, 0, true,
+ { 0 }
+ },
+ {
+ NULL
+ }
+};
+static const struct expansionsubromtype gvp1_sub[] = {
+ {
+ _T("Impact A2000-1/X"), _T("a2000-1"), 0,
+ 1761, 8, 0, false,
+ { 0 }
+ },
+ {
+ _T("Impact A2000-HC"), _T("a2000-hc"), 0,
+ 1761, 8, 0, false,
+ { 0 }
+ },
+ {
+ _T("Impact A2000-HC+2"), _T("a2000-hc+"), 0,
+ 1761, 8, 0, false,
+ { 0 }
+ },
+ {
+ NULL
+ }
+};
+static const struct expansionsubromtype masoboshi_sub[] = {
+ {
+ _T("MC-302"), _T("mc-302"), 0,
+ 2157, 3, 0, false,
+ { 0 }
+ },
+ {
+ _T("MC-702"), _T("mc-702"), 0,
+ 2157, 3, 0, false,
+ { 0 }
+ },
+ {
+ NULL
+ }
+};
+static const struct expansionsubromtype rochard_sub[] = {
+ {
+ _T("IDE"), _T("ide"), 0,
+ 2144, 2, 0, false,
+ { 0 }
+ },
+ {
+ _T("IDE+SCSI"), _T("scsi"), 0,
+ 2144, 2, 0, false,
+ { 0 }
+ },
+ {
+ NULL
+ }
+};
+static const struct expansionsubromtype supra_sub[] = {
+ {
+ _T("A500 ByteSync/XP"), _T("bytesync"), ROMTYPE_NONE | ROMTYPE_SUPRA,
+ 1056, 9, 0, false,
+ { 0xd1, 13, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00 },
+ },
+ {
+ _T("A2000 Word Sync"), _T("wordsync"), ROMTYPE_NONE | ROMTYPE_SUPRA,
+ 1056, 9, 0, false,
+ { 0xd1, 12, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00 },
+ },
+ {
+ _T("A500 Autoboot"), _T("500"), ROMTYPE_NONE | ROMTYPE_SUPRA,
+ 1056, 5, 0, false,
+ { 0xd1, 8, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00 },
+ },
+ {
+ _T("Non Autoboot (4x4)"), _T("4x4"), ROMTYPE_NOT | ROMTYPE_SUPRA,
+ 1056, 2, 0, false,
+ { 0xc1, 1, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+ },
+ {
+ _T("A2000 DMA"), _T("dma"), ROMTYPE_NONE | ROMTYPE_SUPRADMA,
+ 1056, 2, 0, false,
+ { 0xd1, 3, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00 },
+ },
+ {
+ NULL
+ }
+};
+
+static const struct expansionsubromtype mediator_sub[] = {
+ {
+ _T("1200"), _T("1200"), ROMTYPE_NOT | ROMTYPE_MEDIATOR
+ },
+ {
+ _T("1200SX"), _T("1200sx"), ROMTYPE_NOT | ROMTYPE_MEDIATOR
+ },
+ {
+ _T("1200TX"), _T("1200tx"), ROMTYPE_NOT | ROMTYPE_MEDIATOR
+ },
+ {
+ _T("4000MK2"), _T("4000mkii"), ROMTYPE_NOT | ROMTYPE_MEDIATOR
+ },
+ {
+ NULL
+ }
+};
+static const struct expansionboardsettings mediator_settings[] = {
+ {
+ _T("Full PCI DMA"),
+ _T("fulldma")
+ },
+ {
+ _T("Win Size"),
+ _T("winsize")
+ },
+ {
+ _T("Swap Config"),
+ _T("swapconfig")
+ },
+ {
+ NULL
+ }
+};
+static const struct expansionboardsettings bridge_settings[] = {
+ {
+ _T("Full PCI DMA"),
+ _T("fulldma")
+ },
+ {
+ NULL
+ }
+};
+
+static const struct expansionboardsettings x86at286_bridge_settings[] = {
+ {
+ // 14
+ _T("Default video\0") _T("Monochrome\0") _T("Color\0"),
+ _T("video\0") _T("mono\0") _T("color\0"),
+ true, false, 14
+ },
+ {
+ // 15
+ _T("Keyboard lock"),
+ _T("keylock"),
+ false
+ },
+ { // 16 - 18
+ _T("Memory\0") _T("1M\0") _T("2M\0") _T("4M\0") _T("8M\0") _T("16M\0"),
+ _T("memory\0") _T("1M\0") _T("2M\0") _T("4M\0") _T("8M\0") _T("16M\0"),
+ true, false, 0
+ },
+ { // 19 - 20
+ _T("CPU core\0") _T("DOSBox simple\0") _T("DOSBox normal\0") _T("DOSBox full\0") _T("DOSBox auto\0"),
+ _T("cpu\0") _T("dbsimple\0") _T("dbnormal\0") _T("dbfull\0") _T("dbauto\0"),
+ true, false, 0
+ },
+ { // 22
+ _T("FPU"),
+ _T("fpu"),
+ false, false, 1
+ },
+ { // 23 - 25
+ _T("CPU Arch\0") _T("auto\0") _T("386\0") _T("386_prefetch\0") _T("386_slow\0") _T("486_slow\0") _T("486_prefetch\0") _T("pentium_slow\0"),
+ _T("cpuarch\0") _T("auto\0") _T("386\0") _T("386_prefetch\0") _T("386_slow\0") _T("486_slow\0") _T("486_prefetch\0") _T("pentium_slow\0"),
+ true, false, 0
+ },
+ {
+ NULL
+ }
+};
+
+static const struct expansionboardsettings x86at386_bridge_settings[] = {
+ {
+ // 15
+ _T("Keyboard lock"),
+ _T("keylock"),
+ false, false, 15
+ },
+ { // 16 - 18
+ _T("Memory\0") _T("1M\0") _T("2M\0") _T("4M\0") _T("8M\0") _T("16M\0") _T("32M\0") _T("64M\0"),
+ _T("memory\0") _T("1M\0") _T("2M\0") _T("4M\0") _T("8M\0") _T("16M\0") _T("32M\0") _T("64M\0"),
+ true, false, 0
+ },
+ { // 19 - 20
+ _T("CPU core\0") _T("DOSBox simple\0") _T("DOSBox normal\0") _T("DOSBox full\0") _T("DOSBox auto\0"),
+ _T("cpu\0") _T("dbsimple\0") _T("dbnormal\0") _T("dbfull\0") _T("dbauto\0"),
+ true, false, 0
+ },
+ { // 22
+ _T("FPU"),
+ _T("fpu"),
+ false, false, 1
+ },
+ { // 23 - 25
+ _T("CPU Arch\0") _T("auto\0") _T("386\0") _T("386_prefetch\0") _T("386_slow\0") _T("486_slow\0") _T("486_prefetch\0") _T("pentium_slow\0"),
+ _T("cpuarch\0") _T("auto\0") _T("386\0") _T("386_prefetch\0") _T("386_slow\0") _T("486_slow\0") _T("486_prefetch\0") _T("pentium_slow\0"),
+ true, false, 0
+ },
+ {
+ NULL
+ }
+};
+
+static const struct expansionboardsettings x86_bridge_settings[] = {
+ {
+ // 2-3
+ _T("Memory (SW1:3-4)\0") _T("128K\0") _T("256K\0") _T("512K\0") _T("640K\0"),
+ _T("memory\0") _T("128k\0") _T("256k\0") _T("512k\0") _T("640k\0"),
+ true, false, 2
+ },
+ {
+ // 4-5
+ _T("Default video (J1)\0") _T("Monochrome\0") _T("Color 40x25\0") _T("Color 80x25\0") _T("None\0"),
+ _T("video\0") _T("mono\0") _T("color40\0") _T("color80\0") _T("none\0"),
+ true, false, 0
+ },
+ { // 19 - 21
+ _T("CPU core\0") _T("Fake86\0") _T("DOSBox simple\0") _T("DOSBox normal\0") _T("DOSBox full\0") _T("DOSBox auto\0"),
+ _T("cpu\0") _T("fake86\0") _T("dbsimple\0") _T("dbnormal\0") _T("dbfull\0") _T("dbauto\0"),
+ true, false, 19 - 6
+ },
+ { // 22
+ _T("FPU (DOSBox CPU only)"),
+ _T("fpu")
+ },
+ { // 23 - 25
+ _T("CPU Arch (DOSBox CPU only)\0") _T("auto") _T("386\0") _T("386_prefetch\0") _T("386_slow\0") _T("486_slow\0") _T("486_prefetch\0") _T("pentium_slow\0"),
+ _T("cpuarch\0") _T("auto") _T("386\0") _T("386_prefetch\0") _T("386_slow\0") _T("486_slow\0") _T("486_prefetch\0") _T("pentium_slow\0"),
+ true, false, 0
+ },
+ {
+ NULL
+ }
+};
+
+static const struct expansionboardsettings x86_bridge_sidecar_settings[] = {
+ {
+ // 0
+ _T("System Diagnostics (SW1:1)"),
+ _T("diagnostics"),
+ },
+ {
+ // 1
+ _T("8037 installed (SW1:2)"),
+ _T("fpu"),
+ },
+ {
+ // 2-3
+ _T("Memory (SW1:3-4)\0") _T("128K\0") _T("256K\0") _T("512K\0") _T("640K\0"),
+ _T("memory\0") _T("128k\0") _T("256k\0") _T("512k\0") _T("640k\0"),
+ true
+ },
+ {
+ // 4-5
+ _T("Default video (SW1:5-6)\0") _T("Monochrome\0") _T("Color 40x25\0") _T("Color 80x25\0") _T("None\0"),
+ _T("video\0") _T("mono\0") _T("color40\0") _T("color80\0") _T("none\0"),
+ true
+ },
+ {
+ // 6-7
+ _T("Floppy drives (SW1:7-8)\0") _T("1\0") _T("2\0") _T("3\0") _T("4\0"),
+ _T("floppy\0") _T("floppy1\0") _T("floppy2\0") _T("floppy3\0") _T("floppy4\0"),
+ true
+ },
+ {
+ // 8
+ _T("Disable mono video emulation (SW2:1)"),
+ _T("mono_card")
+ },
+ {
+ // 9
+ _T("Disable color video emulation (SW2:2)"),
+ _T("color_card")
+ },
+ {
+ // 10-11
+ _T("Address sector (SW2:3-4)\0") _T("A0000-AFFFF (1)\0") _T("A0000-AFFFF (2)\0") _T("D0000-DFFFF\0") _T("E0000-EFFFF\0"),
+ _T("memory\0") _T("sector_a0000_1\0") _T("sector_a0000_2\0") _T("sector_d0000\0") _T("sector_e0000\0"),
+ true
+ },
+ {
+ // 12
+ _T("Disable parallel port emulation (J11)"),
+ _T("parport_card")
+ },
+ { // 19 - 21
+ _T("CPU core\0") _T("Fake86\0") _T("DOSBox simple\0") _T("DOSBox normal\0") _T("DOSBox full\0") _T("DOSBox auto\0"),
+ _T("cpu\0") _T("fake86\0") _T("dbsimple\0") _T("dbnormal\0") _T("dbfull\0") _T("dbauto\0"),
+ true, false, 19 - 13
+ },
+ { // 22
+ _T("FPU (DOSBox CPU only)"),
+ _T("fpu")
+ },
+ { // 23 - 25
+ _T("CPU Arch (DOSBox CPU only)\0") _T("auto") _T("386\0") _T("386_prefetch\0") _T("386_slow\0") _T("486_slow\0") _T("486_prefetch\0") _T("pentium_slow\0"),
+ _T("cpuarch\0") _T("auto") _T("386\0") _T("386_prefetch\0") _T("386_slow\0") _T("486_slow\0") _T("486_prefetch\0") _T("pentium_slow\0"),
+ true, false, 0
+ },
+ {
+ NULL
+ }
+};
+
+static const struct expansionboardsettings toccata_soundcard_settings[] = {
+ {
+ _T("Paula/CD audio mixer"),
+ _T("mixer")
+ },
+ {
+ NULL
+ }
+};
+
+static const struct expansionboardsettings x86_athdxt_settings[] = {
+ {
+ _T("ROM Address\0") _T("0xCC000\0") _T("0xDC000\0") _T("0xEC000\0"),
+ _T("baseaddress\0") _T("0xcc000\0") _T("0xdc000\0") _T("0xec000\0"),
+ true
+ },
+ {
+ NULL
+ }
+};
+
+
+static const struct expansionboardsettings harlequin_settings[] = {
+ {
+ _T("Model\0") _T("Harlequin (PAL)\0") _T("Harlequin (NTSC)\0") _T("Harlequin Plus (PAL)\0") _T("Harlequin Plus (NTSC)\0"),
+ _T("model\0") _T("pal\0") _T("ntsc\0") _T("pluspal\0") _T("plusntsc\0"),
+ true
+ },
+ {
+ _T("VRAM\0") _T("1.5M\0") _T("2M\0") _T("3M\0") _T("4M\0"),
+ _T("vram\0") _T("1.5m\0") _T("2m\0") _T("3m\0") _T("4m\0"),
+ true
+ },
+ {
+ _T("Genlock"),
+ _T("genlock")
+ },
+ {
+ NULL
+ }
+};
+
+static struct expansionboardsettings ne2k_isa_settings[] = {
+ {
+ _T("IO\0") _T("240\0") _T("260\0") _T("280\0") _T("2A0\0") _T("300\0") _T("320\0") _T("340\0") _T("360\0"),
+ _T("io\0") _T("240\0") _T("260\0") _T("280\0") _T("2A0\0") _T("300\0") _T("320\0") _T("340\0") _T("360\0"),
+ true, false, 0
+ },
+ {
+ _T("IRQ\0") _T("3\0") _T("4\0") _T("5\0") _T("7\0") _T("9\0") _T("10\0") _T("11\0") _T("12\0") _T("15\0"),
+ _T("irq\0") _T("3\0") _T("4\0") _T("5\0") _T("7\0") _T("9\0") _T("10\0") _T("11\0") _T("12\0") _T("15\0"),
+ true, false, 0
+ },
+ {
+ NULL, NULL,
+ true, false, 4
+ },
+ {
+ NULL
+ }
+};
+
+static struct expansionboardsettings lanrover_settings[] = {
+ {
+ _T("Interrupt level\0") _T("2\0") _T("6\0"),
+ _T("irq\0") _T("2\0") _T("6\0"),
+ true, false, 0
+ },
+ {
+ _T("MAC\0"),
+ _T("mac\0"),
+ 2, false, 0
+ },
+ {
+ NULL, NULL,
+ true, false, 15
+ },
+ {
+ NULL
+ }
+};
+static struct expansionboardsettings ethernet_settings[] = {
+ {
+ _T("MAC\0"),
+ _T("mac\0"),
+ 2, false, 0
+ },
+ {
+ NULL, NULL,
+ true, false, 16
+ },
+ {
+ NULL
+ }
+};
+
+static struct expansionboardsettings *netsettings[] = {
+ ethernet_settings,
+ lanrover_settings,
+ ne2k_isa_settings,
+ NULL
+};
+
+struct netdriverdata **target_ethernet_enumerate(void);
+
+uae_u32 ethernet_getselection(const TCHAR *name)
+{
+#ifndef AMIBERRY
+ struct netdriverdata **ndd = target_ethernet_enumerate();
+ if (!ndd)
+ return 0;
+ for (int i = 0; ndd && i < MAX_TOTAL_NET_DEVICES; i++) {
+ if (ndd[i] && !_tcsicmp(ndd[i]->name, name))
+ return i << 16;
+ }
+#endif
+ return 0;
+}
+
+const TCHAR *ethernet_getselectionname(uae_u32 settings)
+{
+#ifndef AMIBERRY
+ struct netdriverdata **ndd = target_ethernet_enumerate();
+ if (!ndd)
+ return 0;
+ settings = (settings >> 16) & 255;
+ for (int i = 0; ndd && i < MAX_TOTAL_NET_DEVICES; i++) {
+ if (i == settings)
+ return ndd[i]->name;
+ }
+#endif
+ return _T("slirp");
+}
+
+void ethernet_updateselection(void)
+{
+#ifndef AMIBERRY
+ static int updated;
+ if (updated)
+ return;
+ updated = 1;
+ struct netdriverdata **ndd = target_ethernet_enumerate();
+ if (!ndd)
+ return;
+ static TCHAR tmp1[MAX_DPATH];
+ static TCHAR tmp2[MAX_DPATH];
+ _tcscpy(tmp1, _T("Network mode"));
+ _tcscpy(tmp2, _T("netmode"));
+ TCHAR *p1 = tmp1 + _tcslen(tmp1) + 1;
+ TCHAR *p2 = tmp2 + _tcslen(tmp2) + 1;
+ for (int i = 0; ndd && i < MAX_TOTAL_NET_DEVICES; i++) {
+ if (ndd[i]) {
+ TCHAR mac[20];
+ mac[0] = 0;
+ if (ndd[i]->type == UAENET_SLIRP || ndd[i]->type == UAENET_SLIRP_INBOUND) {
+ _stprintf(mac, _T(" xx:xx:xx:%02X:%02X:%02X"),
+ ndd[i]->mac[3], ndd[i]->mac[4], ndd[i]->mac[5]);
+ }
+ _stprintf(p1, _T("%s%s"), ndd[i]->desc, mac[0] ? mac : _T(""));
+ p1 += _tcslen(p1) + 1;
+ _tcscpy(p2, ndd[i]->name);
+ p2 += _tcslen(p2) + 1;
+ }
+ }
+ *p1 = 0;
+ *p2 = 0;
+ for (int i = 0; netsettings[i]; i++) {
+ struct expansionboardsettings *ebs = netsettings[i];
+ int j;
+ for (j = 0; ebs[j].name; j++);
+ ebs[j].name = tmp1;
+ ebs[j].configname = tmp2;
+ }
+#endif
+}
+
+static void fastlane_memory_callback(struct romconfig *rc, uae_u8 *ac, int size)
+{
+ struct zfile *z = read_device_from_romconfig(rc, NULL);
+ if (z) {
+ // load autoconfig data from rom file
+ uae_u8 act[16] = { 0 };
+ zfile_fseek(z, 0x80, SEEK_SET);
+ zfile_fread(act, 1, 16, z);
+ zfile_fclose(z);
+ for (int i = 1; i < 16; i++) {
+ ac[i] = ~act[i];
+ act[i] = ~act[i];
+ }
+ // don't overwrite uae configured memory size
+ ac[0] = (ac[0] & 7) | (act[0] & 0xf8);
+ ac[2] = (ac[2] & 0x0f) | (act[2] & 0xf0);
+ }
+}
+static void hda506_memory_callback(struct romconfig *rc, uae_u8 *ac, int size)
+{
+ if (currprefs.cs_a1000ram)
+ ac[1] = 1;
+ else
+ ac[1] = 2;
+}
+static void nexus_memory_callback(struct romconfig *rc, uae_u8 *ac, int size)
+{
+ if (rc->device_settings & 1)
+ ac[0] &= ~(1 << 5);
+ if (size <= 2 * 1024 * 1024)
+ ac[1] = 2;
+ else if (size <= 4 * 1024 * 1024)
+ ac[1] = 4;
+ else
+ ac[1] = 8;
+}
+static const struct expansionboardsettings golemfast_settings[] = {
+ {
+ _T("IDE"),
+ _T("ide")
+ },
+ {
+ NULL
+ }
+};
+static const struct expansionboardsettings nexus_settings[] = {
+ {
+ _T("MEM TEST"),
+ _T("memtest")
+ },
+ {
+ NULL
+ }
+};
+static const struct expansionboardsettings buddha_settings[] = {
+ {
+ _T("Model\0") _T("Buddha\0") _T("Catweasel Z2\0"),
+ _T("model\0") _T("buddha\0") _T("cwz2\0"),
+ true, false, 0
+ },
+ {
+ NULL
+ }
+};
+
+static const struct expansionboardsettings adscsi2000_settings[] = {
+ {
+ _T("Cache (B)"),
+ _T("B")
+ },
+ {
+ NULL
+ }
+};
+static const struct expansionboardsettings warpengine_settings[] = {
+ {
+ _T("Jumper H"),
+ _T("jumper_h")
+ },
+ {
+ _T("Jumper J"),
+ _T("jumper_j")
+ },
+ {
+ _T("Jumper K"),
+ _T("jumper_k")
+ },
+ {
+ NULL
+ }
+};
+static const struct expansionboardsettings a4091_settings[] = {
+ {
+ _T("Fast Bus"),
+ _T("fastbus"),
+ },
+ {
+ _T("Delayed autoboot"),
+ _T("delayedautoboot")
+ },
+ {
+ _T("Syncronous mode"),
+ _T("syncmode")
+ },
+ {
+ _T("Termination"),
+ _T("term")
+ },
+ {
+ _T("LUN"),
+ _T("lun")
+ },
+ {
+ NULL
+ }
+};
+static const struct expansionboardsettings dataflyersplus_settings[] = {
+ {
+ _T("Configuration\0") _T("SCSI+IDE\0") _T("SCSI\0") _T("IDE\0"),
+ _T("config\0") _T("scsiide") _T("scsi\0") _T("ide\0"),
+ true
+ },
+ {
+ NULL
+ }
+};
+
const struct expansionromtype expansionroms[] = {
- /* built-in controllers */
+#if 0
+ {
+ _T("cpuboard"), _T("Accelerator"), _T("Accelerator"),
+ NULL, NULL, add_cpuboard_unit, ROMTYPE_CPUBOARD, 0, 0, 0, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI | EXPANSIONTYPE_IDE
+ },
+
+ /* PCI Bridgeboards */
+
+ {
+ _T("grex"), _T("G-REX"), _T("DCE"),
+ grex_init, NULL, NULL, ROMTYPE_GREX | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_PCI_BRIDGE
+ },
+ {
+ _T("mediator"), _T("Mediator"), _T("Elbox"),
+ mediator_init, mediator_init2, NULL, ROMTYPE_MEDIATOR | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ mediator_sub, 0,
+ false, EXPANSIONTYPE_PCI_BRIDGE,
+ 0, 0, 0, false, NULL,
+ false, 0, mediator_settings
+ },
+ {
+ _T("prometheus"), _T("Prometheus"), _T("Matay"),
+ prometheus_init, NULL, NULL, ROMTYPE_PROMETHEUS | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z3, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_PCI_BRIDGE,
+ 0, 0, 0, false, NULL,
+ false, 0, bridge_settings
+ },
+
+ /* SCSI/IDE expansion */
+
+ {
+ _T("apollo"), _T("Apollo 500/2000"), _T("3-State"),
+ apollo_init_hd, NULL, apollo_add_scsi_unit, ROMTYPE_APOLLOHD, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI | EXPANSIONTYPE_IDE,
+ 8738, 0, 0
+ },
+ {
+ _T("add500"), _T("ADD-500"), _T("Archos"),
+ add500_init, NULL, add500_add_scsi_unit, ROMTYPE_ADD500, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI,
+ 8498, 27, 0, true, NULL
+ },
+ {
+ _T("blizzardscsikitiii"), _T("SCSI Kit III"), _T("Phase 5"),
+ NULL, NULL, cpuboard_ncr9x_add_scsi_unit, ROMTYPE_BLIZKIT3, 0, 0, 0, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI
+ },
+ {
+ _T("blizzardscsikitiv"), _T("SCSI Kit IV"), _T("Phase 5"),
+ NULL, NULL, cpuboard_ncr9x_add_scsi_unit, ROMTYPE_BLIZKIT4, 0, 0, 0, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI
+ },
+ {
+ _T("oktagon2008"), _T("Oktagon 2008"), _T("BSC/Alfa Data"),
+ ncr_oktagon_autoconfig_init, NULL, oktagon_add_scsi_unit, ROMTYPE_OKTAGON, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI
+ },
+ {
+ _T("alfapower"), _T("AlfaPower/AT-Bus 2008"), _T("BSC/Alfa Data"),
+ alf_init, NULL, alf_add_ide_unit, ROMTYPE_ALFA, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_IDE,
+ 2092, 8, 0
+ },
+ {
+ _T("alfapowerplus"), _T("AlfaPower Plus"), _T("BSC/Alfa Data"),
+ alf_init, NULL, alf_add_ide_unit, ROMTYPE_ALFAPLUS, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_IDE,
+ 2092, 8, 0
+ },
+ {
+ _T("cltda1000scsi"), _T("A1000/A2000 SCSI"), _T("C-Ltd"),
+ cltda1000scsi_init, NULL, cltda1000scsi_add_scsi_unit, ROMTYPE_CLTDSCSI | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI,
+ 0, 0, 0, false, NULL,
+ false, 0, NULL,
+ { 0xc1, 0x0c, 0x00, 0x00, 0x03, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+ },
+ {
+ _T("a2090a"), _T("A2090a"), _T("Commodore"),
+ a2090_init, NULL, a2090_add_scsi_unit, ROMTYPE_A2090 | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI | EXPANSIONTYPE_CUSTOM_SECONDARY
+ },
+ {
+ _T("a2091"), _T("A590/A2091"), _T("Commodore"),
+ a2091_init, NULL, a2091_add_scsi_unit, ROMTYPE_A2091 | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ a2091_sub, 1,
+ true, EXPANSIONTYPE_SCSI | EXPANSIONTYPE_CUSTOM_SECONDARY,
+ commodore, commodore_a2091, 0, true, NULL
+ },
+ {
+ _T("a4091"), _T("A4091"), _T("Commodore"),
+ ncr710_a4091_autoconfig_init, NULL, a4091_add_scsi_unit, ROMTYPE_A4091, 0, 0, BOARD_AUTOCONFIG_Z3, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI,
+ 0, 0, 0, false, NULL,
+ true, 0, a4091_settings
+ },
+ {
+ _T("dataflyerscsiplus"), _T("DataFlyer SCSI+"), _T("Expansion Systems"),
+ dataflyer_init, NULL, dataflyer_add_scsi_unit, ROMTYPE_DATAFLYERP | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI
+ },
+ {
+ _T("dataflyerplus"), _T("DataFlyer Plus"), _T("Expansion Systems"),
+ dataflyerplus_init, NULL, dataflyerplus_add_idescsi_unit, ROMTYPE_DATAFLYER, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI | EXPANSIONTYPE_IDE,
+ 0, 0, 0, false, NULL,
+ false, 0, dataflyersplus_settings
+ },
+ {
+ _T("gvp1"), _T("GVP Series I"), _T("Great Valley Products"),
+ gvp_init_s1, NULL, gvp_s1_add_scsi_unit, ROMTYPE_GVPS1 | ROMTYPE_NONE, ROMTYPE_GVPS12, 0, BOARD_AUTOCONFIG_Z2, false,
+ gvp1_sub, 1,
+ true, EXPANSIONTYPE_SCSI
+ },
+ {
+ _T("gvp"), _T("GVP Series II"), _T("Great Valley Products"),
+ gvp_init_s2, NULL, gvp_s2_add_scsi_unit, ROMTYPE_GVPS2 | ROMTYPE_NONE, ROMTYPE_GVPS12, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI,
+ 2017, 10, 0
+ },
+ {
+ _T("vector"), _T("Vector Falcon 8000"), _T("HK-Computer"),
+ vector_init, NULL, vector_add_scsi_unit, ROMTYPE_VECTOR, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI
+ },
+ {
+ _T("adide"), _T("AdIDE"), _T("ICD"),
+ adide_init, NULL, adide_add_ide_unit, ROMTYPE_ADIDE | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_IDE
+ },
+ {
+ _T("adscsi2000"), _T("AdSCSI Advantage 2000"), _T("ICD"),
+ adscsi_init, NULL, adscsi_add_scsi_unit, ROMTYPE_ADSCSI, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI,
+ 0, 0, 0, false, NULL,
+ true, 0, adscsi2000_settings
+ },
+ {
+ _T("buddha"), _T("Buddha"), _T("Individual Computers"),
+ buddha_init, NULL, buddha_add_ide_unit, ROMTYPE_BUDDHA, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_IDE,
+ 0, 0, 0, false, NULL,
+ false, 4, buddha_settings,
+ { 0xd1, 0x00, 0x00, 0x00, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00 },
+ },
+ {
+ _T("trumpcardpro"), _T("Grand Slam"), _T("IVS"),
+ trumpcardpro_init, NULL, trumpcardpro_add_scsi_unit, ROMTYPE_IVSTPRO, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI,
+ 2112, 4, 0, false, NULL,
+ true, 0, NULL,
+ { 0xd1, 0x34, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00 },
+ },
+ {
+ _T("kommos"), _T("Kommos A500/A2000 SCSI"), _T("Jürgen Kommos"),
+ kommos_init, NULL, kommos_add_scsi_unit, ROMTYPE_KOMMOS, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI
+ },
+ {
+ _T("golem"), _T("Golem SCSI II"), _T("Kupke"),
+ golem_init, NULL, golem_add_scsi_unit, ROMTYPE_GOLEM, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI,
+ 2079, 3, 0
+ },
+ {
+ _T("golemfast"), _T("Golem Fast SCSI/IDE"), _T("Kupke"),
+ golemfast_init, NULL, golemfast_add_idescsi_unit, ROMTYPE_GOLEMFAST, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI | EXPANSIONTYPE_IDE,
+ 0, 0, 0, false, NULL,
+ true, 0, golemfast_settings
+ },
+ {
+ _T("multievolution"), _T("Multi Evolution 500/2000"), _T("MacroSystem"),
+ ncr_multievolution_init, NULL, multievolution_add_scsi_unit, ROMTYPE_MEVOLUTION, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI,
+ 18260, 8, 0, true
+ },
+ {
+ _T("scram8490"), _T("SCRAM (DP8490V)"), _T("MegaMicro"),
+ scram5380_init, NULL, scram5380_add_scsi_unit, ROMTYPE_SCRAM5380, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI,
+ 4096, 4, 0, false, NULL,
+ false, 0, NULL,
+ { 0xd1, 3, 0x40, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00 }
+ },
+ {
+ _T("scram5394"), _T("SCRAM (NCR53C94)"), _T("MegaMicro"),
+ ncr_scram5394_init, NULL, scram5394_add_scsi_unit, ROMTYPE_SCRAM5394, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI,
+ 4096, 4, 0, false, NULL,
+ false, 0, NULL,
+ { 0xd1, 7, 0x40, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00 }
+ },
+ {
+ _T("paradox"), _T("Paradox SCSI"), _T("Mainhattan Data"),
+ paradox_init, NULL, paradox_add_scsi_unit, ROMTYPE_PARADOX | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI | EXPANSIONTYPE_PARALLEL_ADAPTER
+ },
+ {
+ _T("ateam"), _T("A-Team"), _T("Mainhattan Data"),
+ ateam_init, NULL, ateam_add_ide_unit, ROMTYPE_ATEAM, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_IDE
+ },
+ {
+ _T("mtecat"), _T("AT 500"), _T("M-Tec"),
+ mtec_init, NULL, mtec_add_ide_unit, ROMTYPE_MTEC, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_IDE
+ },
+ {
+ _T("masoboshi"), _T("MasterCard"), _T("Masoboshi"),
+ masoboshi_init, NULL, masoboshi_add_idescsi_unit, ROMTYPE_MASOBOSHI | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ masoboshi_sub, 0,
+ true, EXPANSIONTYPE_SCSI | EXPANSIONTYPE_IDE
+ },
+ {
+ _T("hardframe"), _T("HardFrame"), _T("Microbotics"),
+ hardframe_init, NULL, hardframe_add_scsi_unit, ROMTYPE_HARDFRAME, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI,
+ 0, 0, 0, false, NULL,
+ true
+ },
+ {
+ _T("stardrive"), _T("StarDrive"), _T("Microbotics"),
+ stardrive_init, NULL, stardrive_add_scsi_unit, ROMTYPE_STARDRIVE | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI,
+ 1010, 0, 0, false, NULL,
+ false, 0, NULL,
+ { 0xc1, 2, 0x00, 0x00, 0x03, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
+
+ },
+ {
+ _T("filecard2000"), _T("Filecard 2000/OSSI 500"), _T("Otronic"),
+ ossi_init, NULL, ossi_add_scsi_unit, ROMTYPE_OSSI, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI,
+ 0, 0, 0, false, NULL,
+ false, 0, NULL,
+ { 0xc1, 1, 0x00, 0x00, 0x07, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+ },
+ {
+ _T("fastlane"), _T("Fastlane"), _T("Phase 5"),
+ ncr_fastlane_autoconfig_init, NULL, fastlane_add_scsi_unit, ROMTYPE_FASTLANE, 0, 0, BOARD_AUTOCONFIG_Z3, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI,
+ 8512, 10, 0, false, fastlane_memory_callback
+ },
+ {
+ _T("phoenixboard"), _T("Phoenix Board SCSI"), _T("Phoenix Microtechnologies"),
+ phoenixboard_init, NULL, phoenixboard_add_scsi_unit, ROMTYPE_PHOENIXB, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI,
+ },
+ {
+ _T("ptnexus"), _T("Nexus"), _T("Preferred Technologies"),
+ ptnexus_init, NULL, ptnexus_add_scsi_unit, ROMTYPE_PTNEXUS | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI,
+ 2102, 4, 0, false, nexus_memory_callback,
+ false, 0, nexus_settings,
+ { 0xd1, 0x01, 0x00, 0x00, 0x08, 0x36, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00 },
+ },
+ {
+ _T("protar"), _T("A500 HD"), _T("Protar"),
+ protar_init, NULL, protar_add_ide_unit, ROMTYPE_PROTAR, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ NULL, 0,
+ true, EXPANSIONTYPE_SCSI,
+ 4149, 51, 0
+ },
+ {
+ _T("rochard"), _T("RocHard RH800C"), _T("Roctec"),
+ rochard_init, NULL, rochard_add_idescsi_unit, ROMTYPE_ROCHARD | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ rochard_sub, 0,
+ true, EXPANSIONTYPE_IDE | EXPANSIONTYPE_SCSI,
+ 2144, 2, 0, false, NULL,
+ false, 2, NULL
+ },
+ {
+ _T("supradrive"), _T("SupraDrive"), _T("Supra Corporation"),
+ supra_init, NULL, supra_add_scsi_unit, ROMTYPE_SUPRA | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, false,
+ supra_sub, 0,
+ true, EXPANSIONTYPE_SCSI
+ },
+#if 0 /* driver is MIA, 3rd party ScottDevice driver is not enough for full implementation. */
+ {
+ _T("microforge"), _T("Hard Disk"), _T("Micro Forge"),
+ microforge_init, NULL, microforge_add_scsi_unit, ROMTYPE_MICROFORGE | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SASI | EXPANSIONTYPE_SCSI
+ },
+#endif
+
+ {
+ _T("omtiadapter"), _T("OMTI-Adapter"), _T("C't"),
+ omtiadapter_init, NULL, omtiadapter_scsi_unit, ROMTYPE_OMTIADAPTER | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_CUSTOM | EXPANSIONTYPE_SCSI
+ },
+ {
+ _T("alf1"), _T("A.L.F."), _T("Elaborate Bytes"),
+ alf1_init, NULL, alf1_add_scsi_unit, ROMTYPE_ALF1 | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_CUSTOM | EXPANSIONTYPE_SCSI
+ },
+ {
+ _T("promigos"), _T("Promigos"), _T("Flesch und Hörnemann"),
+ promigos_init, NULL, promigos_add_scsi_unit, ROMTYPE_PROMIGOS | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_CUSTOM | EXPANSIONTYPE_SCSI
+ },
+ {
+ _T("tecmar"), _T("T-Card/T-Disk"), _T("Tecmar"),
+ tecmar_init, NULL, tecmar_add_scsi_unit, ROMTYPE_TECMAR | ROMTYPE_NOT, 0, 0, BOARD_PROTOAUTOCONFIG, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SASI | EXPANSIONTYPE_SCSI,
+ 1001, 1, 0
+ },
+ {
+ _T("system2000"), _T("System 2000"), _T("Vortex"),
+ system2000_init, NULL, system2000_add_scsi_unit, ROMTYPE_SYSTEM2000 | ROMTYPE_NONE, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_CUSTOM | EXPANSIONTYPE_SCSI
+ },
+ {
+ _T("xebec"), _T("9720H"), _T("Xebec"),
+ xebec_init, NULL, xebec_add_scsi_unit, ROMTYPE_XEBEC | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SASI | EXPANSIONTYPE_SCSI
+ },
+#if 0
+ {
+ _T("kronos"), _T("Kronos"), _T("C-Ltd"),
+ kronos_init, kronos_add_scsi_unit, ROMTYPE_KRONOS, 0, 0, 2, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_SCSI,
+ 0, 0, 0,
+ { 0xd1, 4, 0x00, 0x00, 0x03, 0xec, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00 },
+ },
+#endif
+ {
+ _T("hda506"), _T("HDA-506"), _T("Spirit Technology"),
+ hda506_init, NULL, hda506_add_scsi_unit, ROMTYPE_HDA506 | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_CUSTOM | EXPANSIONTYPE_SCSI,
+ 0, 0, 0, false, NULL,
+ false, 0, NULL,
+ { 0xc1, 0x04, 0x00, 0x00, 0x07, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+ },
+ {
+ _T("amax"), _T("AMAX ROM dongle"), _T("ReadySoft"),
+ NULL, NULL, NULL, ROMTYPE_AMAX | ROMTYPE_NONE, 0, 0, 0, false
+ },
+
+#if 0
+ {
+ _T("x86_xt_hd"), _T("x86 XT"), _T("x86"),
+ x86_xt_hd_init, NULL, x86_add_xt_hd_unit, ROMTYPE_X86_HD | ROMTYPE_NONE, 0, 0, BOARD_NONAUTOCONFIG_AFTER_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_CUSTOM | EXPANSIONTYPE_SCSI
+ },
+#endif
+ {
+ _T("x86athdprimary"), _T("AT IDE Primary"), _T("x86"),
+ x86_at_hd_init_1, NULL, x86_add_at_hd_unit_1, ROMTYPE_X86_AT_HD1 | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_AFTER_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_IDE
+ },
+ {
+ _T("x86athdsecondary"), _T("AT IDE Secondary"), _T("x86"),
+ x86_at_hd_init_2, NULL, x86_add_at_hd_unit_2, ROMTYPE_X86_AT_HD2 | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_AFTER_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_IDE
+ },
+ {
+ _T("x86athdxt"), _T("XTIDE Universal BIOS HD"), _T("x86"),
+ x86_at_hd_init_xt, NULL, x86_add_at_hd_unit_xt, ROMTYPE_X86_XT_IDE | ROMTYPE_NONE, 0, 0, BOARD_NONAUTOCONFIG_AFTER_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_IDE,
+ 0, 0, 0, false, NULL,
+ false, 0, x86_athdxt_settings
+ },
+
+ /* PC Bridgeboards */
+
+ {
+ _T("a1060"), _T("A1060 Sidecar"), _T("Commodore"),
+ a1060_init, NULL, NULL, ROMTYPE_A1060 | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_X86_BRIDGE,
+ 0, 0, 0, false, NULL,
+ false, 0, x86_bridge_sidecar_settings
+ },
+ {
+ _T("a2088"), _T("A2088"), _T("Commodore"),
+ a2088xt_init, NULL, NULL, ROMTYPE_A2088 | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_X86_BRIDGE,
+ 0, 0, 0, false, NULL,
+ false, 0, x86_bridge_settings
+ },
+ {
+ _T("a2088t"), _T("A2088T"), _T("Commodore"),
+ a2088t_init, NULL, NULL, ROMTYPE_A2088T | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_X86_BRIDGE,
+ 0, 0, 0, false, NULL,
+ false, 0, x86_bridge_settings
+ },
+ {
+ _T("a2286"), _T("A2286"), _T("Commodore"),
+ a2286_init, NULL, NULL, ROMTYPE_A2286 | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_X86_BRIDGE,
+ 0, 0, 0, false, NULL,
+ false, 0, x86at286_bridge_settings
+ },
+ {
+ _T("a2386"), _T("A2386SX"), _T("Commodore"),
+ a2386_init, NULL, NULL, ROMTYPE_A2386 | ROMTYPE_NONE, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_X86_BRIDGE,
+ 0, 0, 0, false, NULL,
+ false, 0, x86at386_bridge_settings
+ },
+
+ // only here for rom selection and settings
+ {
+ _T("picassoiv"), _T("Picasso IV"), _T("Village Tronic"),
+ NULL, NULL, NULL, ROMTYPE_PICASSOIV | ROMTYPE_NONE, 0, 0, BOARD_IGNORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_RTG
+ },
+ {
+ _T("x86vga"), _T("x86 VGA"), _T("x86"),
+ NULL, NULL, NULL, ROMTYPE_x86_VGA | ROMTYPE_NONE, 0, 0, BOARD_IGNORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_RTG
+ },
+ {
+ _T("harlequin"), _T("Harlequin"), _T("ACS"),
+ NULL, NULL, NULL, ROMTYPE_HARLEQUIN | ROMTYPE_NOT, 0, 0, BOARD_IGNORE, false,
+ NULL, 0,
+ false, EXPANSIONTYPE_RTG,
+ 0, 0, 0, false, NULL,
+ false, 0, harlequin_settings
+ },
+
+ /* Sound Cards */
+
+ {
+ _T("toccata"), _T("Toccata"), _T("MacroSystem"),
+ sndboard_init, NULL, NULL, ROMTYPE_TOCCATA | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SOUND,
+ 0, 0, 0, false, NULL,
+ false, 0, toccata_soundcard_settings,
+ { 0xc1, 12, 0, 0, 18260 >> 8, 18260 & 255 }
+ },
+ {
+ _T("es1370"), _T("ES1370 PCI"), _T("Ensoniq"),
+ pci_expansion_init, NULL, NULL, ROMTYPE_ES1370 | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SOUND
+ },
+ {
+ _T("fm801"), _T("FM801 PCI"), _T("Fortemedia"),
+ pci_expansion_init, NULL, NULL, ROMTYPE_FM801 | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SOUND
+ },
+ {
+ _T("uaesnd_z2"), _T("UAESND Z2"), NULL,
+ uaesndboard_init_z2, NULL, NULL, ROMTYPE_UAESNDZ2 | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SOUND,
+ 0, 0, 0, false, NULL,
+ false, 0, NULL,
+ { 0xc1, 2, 0x00, 0x00, 6502 >> 8, 6502 & 255, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+ },
+ {
+ _T("uaesnd_z3"), _T("UAESND Z3"), NULL,
+ uaesndboard_init_z3, NULL, NULL, ROMTYPE_UAESNDZ3 | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z3, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SOUND,
+ 0, 0, 0, false, NULL,
+ false, 0, NULL,
+ { 0x80, 2, 0x10, 0x00, 6502 >> 8, 6502 & 255, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+ },
+#if 0
+ {
+ _T("pmx"), _T("pmx"), NULL,
+ pmx_init, NULL, NULL, ROMTYPE_PMX | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_SOUND,
+ 0, 0, 0, false, NULL,
+ false, 0, NULL,
+ { 0xc1, 0x30, 0x00, 0x00, 0x0e, 0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+ },
+#endif
+
+ /* Network */
+ {
+ _T("a2065"), _T("A2065"), _T("Commodore"),
+ a2065_init, NULL, NULL, ROMTYPE_A2065 | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_NET,
+ 0, 0, 0, false, NULL,
+ false, 0, ethernet_settings,
+ { 0xc1, 0x70, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+ },
+ {
+ _T("ariadne"), _T("Ariadne"), _T("Village Tronic"),
+ ariadne_init, NULL, NULL, ROMTYPE_ARIADNE | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_NET,
+ 0, 0, 0, false, NULL,
+ false, 0, ethernet_settings,
+ { 0xc1, 0xc9, 0x00, 0x00, 2167 >> 8, 2167 & 255, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+ },
+ {
+ _T("ariadne2"), _T("Ariadne II"), _T("Village Tronic"),
+ ariadne2_init, NULL, NULL, ROMTYPE_ARIADNE2 | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_NET,
+ 0, 0, 0, false, NULL,
+ false, 0, ethernet_settings,
+ { 0xc1, 0xca, 0x00, 0x00, 2167 >> 8, 2167 & 255, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+ },
+ {
+ _T("hydra"), _T("AmigaNet"), _T("Hydra Systems"),
+ hydra_init, NULL, NULL, ROMTYPE_HYDRA | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_NET,
+ 0, 0, 0, false, NULL,
+ false, 0, ethernet_settings,
+ { 0xc1, 0x01, 0x00, 0x00, 2121 >> 8, 2121 & 255, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+ },
+ {
+ _T("eb920"), _T("LAN Rover/EB920"), _T("ASDG"),
+ lanrover_init, NULL, NULL, ROMTYPE_LANROVER | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_NET,
+ 0, 0, 0, false, NULL,
+ false, 0, lanrover_settings,
+ { 0xc1, 0xfe, 0x00, 0x00, 1023 >> 8, 1023 & 255, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+ },
+ {
+ _T("xsurf"), _T("X-Surf"), _T("Individual Computers"),
+ xsurf_init, NULL, NULL, ROMTYPE_XSURF | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_NET,
+ 0, 0, 0, false, NULL,
+ false, 0, ethernet_settings,
+ { 0xc1, 0x17, 0x00, 0x00, 4626 >> 8, 4626 & 255, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+ },
+ {
+ _T("xsurf100z2"), _T("X-Surf-100 Z2"), _T("Individual Computers"),
+ xsurf100_init, NULL, NULL, ROMTYPE_XSURF100Z2 | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_NET,
+ 0, 0, 0, false, NULL,
+ false, 0, ethernet_settings,
+ { 0xc1, 0x64, 0x10, 0x00, 4626 >> 8, 4626 & 255, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00 }
+ },
+ {
+ _T("xsurf100z3"), _T("X-Surf-100 Z3"), _T("Individual Computers"),
+ xsurf100_init, NULL, NULL, ROMTYPE_XSURF100Z3 | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z3, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_NET,
+ 0, 0, 0, false, NULL,
+ false, 0, ethernet_settings,
+ { 0x82, 0x64, 0x32, 0x00, 4626 >> 8, 4626 & 255, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00 }
+ },
+ {
+ _T("ne2000_pcmcia"), _T("RTL8019 PCMCIA (NE2000 compatible)"), NULL,
+ gayle_init_ne2000_pcmcia, NULL, NULL, ROMTYPE_NE2KPCMCIA | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_NET,
+ 0, 0, 0, false, NULL,
+ false, 0, ethernet_settings,
+ },
+ {
+ _T("ne2000_pci"), _T("RTL8029 PCI (NE2000 compatible)"), NULL,
+ pci_expansion_init, NULL, NULL, ROMTYPE_NE2KPCI | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_NET,
+ 0, 0, 0, false, NULL,
+ false, 0, ethernet_settings,
+ },
+ {
+ _T("ne2000_isa"), _T("RTL8019 ISA (NE2000 compatible)"), NULL,
+ isa_expansion_init, NULL, NULL, ROMTYPE_NE2KISA | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_NET,
+ 0, 0, 0, false, NULL,
+ false, 0, ne2k_isa_settings
+ },
+
+ /* Catweasel */
+ {
+ _T("catweasel"), _T("Catweasel"), _T("Individual Computers"),
+ expamem_init_catweasel, NULL, NULL, ROMTYPE_CATWEASEL | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_FLOPPY
+ },
+
+ /* built-in controllers */
{
_T("cd32fmv"), _T("CD32 FMV"), _T("Commodore"),
expamem_init_cd32fmv, NULL, NULL, ROMTYPE_CD32CART, 0, 0, BOARD_AUTOCONFIG_Z2, true,
- EXPANSIONTYPE_INTERNAL
+ NULL, 0,
+ false, EXPANSIONTYPE_INTERNAL
+ },
+ {
+ _T("cdtvdmac"), _T("CDTV DMAC"), _T("Commodore"),
+ cdtv_init, NULL, NULL, ROMTYPE_CDTVDMAC | ROMTYPE_NOT, 0, 0, BOARD_AUTOCONFIG_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_INTERNAL
+ },
+ {
+ _T("cdtvscsi"), _T("CDTV SCSI"), _T("Commodore"),
+ cdtvscsi_init, NULL, cdtv_add_scsi_unit, ROMTYPE_CDTVSCSI | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_AFTER_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_INTERNAL | EXPANSIONTYPE_SCSI
+ },
+ {
+ _T("cdtvcr"), _T("CDTV-CR"), _T("Commodore"),
+ cdtvcr_init, NULL, NULL, ROMTYPE_CDTVCR | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_AFTER_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_INTERNAL
+ },
+ {
+ _T("scsi_a3000"), _T("A3000 SCSI"), _T("Commodore"),
+ a3000scsi_init, NULL, a3000_add_scsi_unit, ROMTYPE_SCSI_A3000 | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_AFTER_Z2, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_INTERNAL | EXPANSIONTYPE_SCSI
+ },
+ {
+ _T("scsi_a4000t"), _T("A4000T SCSI"), _T("Commodore"),
+ a4000t_scsi_init, NULL, a4000t_add_scsi_unit, ROMTYPE_SCSI_A4000T | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
+ NULL, 0,
+ false, EXPANSIONTYPE_INTERNAL | EXPANSIONTYPE_SCSI
},
{
_T("ide_mb"), _T("A600/A1200/A4000 IDE"), _T("Commodore"),
gayle_ide_init, NULL, gayle_add_ide_unit, ROMTYPE_MB_IDE | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
- EXPANSIONTYPE_INTERNAL | EXPANSIONTYPE_IDE
+ NULL, 0,
+ false, EXPANSIONTYPE_INTERNAL | EXPANSIONTYPE_IDE
},
{
_T("pcmcia_mb"), _T("A600/A1200 PCMCIA"), _T("Commodore"),
gayle_pcmcia_init, NULL, gayle_add_pcmcia_unit, ROMTYPE_MB_PCMCIA | ROMTYPE_NOT, 0, 0, BOARD_NONAUTOCONFIG_BEFORE, true,
- EXPANSIONTYPE_INTERNAL
+ NULL, 0,
+ false, EXPANSIONTYPE_INTERNAL
},
+#endif
+
+ {
+ NULL
+ }
+};
+
+static const struct expansionboardsettings blizzardboard_settings[] = {
+ {
+ _T("MapROM"),
+ _T("maprom")
+ },
+ {
+ NULL
+ }
+};
+
+static const struct expansionboardsettings blizzardboard_settings_mk2[] = {
+ {
+ _T("MapROM"),
+ _T("maprom")
+ },
+ {
+ _T("SCSI Kit II"),
+ _T("scsikitii")
+ },
+ {
+ NULL
+ }
+};
+
+static const struct cpuboardsubtype gvpboard_sub[] = {
+#if 0
+
+ {
+ _T("A3001 Series I"),
+ _T("A3001SI"),
+ ROMTYPE_CB_A3001S1, 0,
+ gvp_add_ide_unit, EXPANSIONTYPE_IDE | EXPANSIONTYPE_24BIT,
+ BOARD_MEMORY_Z2,
+ 8 * 1024 * 1024,
+ 0,
+ gvp_ide_rom_autoconfig_init, NULL, BOARD_AUTOCONFIG_Z2, 0
+ },
+ {
+ _T("A3001 Series II"),
+ _T("A3001SII"),
+ 0, 0,
+ gvp_add_ide_unit, EXPANSIONTYPE_IDE | EXPANSIONTYPE_24BIT,
+ BOARD_MEMORY_Z2,
+ 8 * 1024 * 1024,
+ 0,
+ gvp_ide_rom_autoconfig_init, gvp_ide_controller_autoconfig_init, BOARD_AUTOCONFIG_Z2, 0
+ },
+ {
+ _T("A530"),
+ _T("GVPA530"),
+ ROMTYPE_GVPS2, 0,
+ gvp_s2_add_accelerator_scsi_unit, EXPANSIONTYPE_SCSI | EXPANSIONTYPE_24BIT,
+ BOARD_MEMORY_Z2,
+ 8 * 1024 * 1024,
+ 0,
+ gvp_init_accelerator, NULL, BOARD_AUTOCONFIG_Z2, 1,
+ NULL, NULL,
+ 2017, 9, 0, false
+ },
+ {
+ _T("G-Force 030"),
+ _T("GVPGFORCE030"),
+ ROMTYPE_GVPS2, ROMTYPE_GVPS12,
+ gvp_s2_add_accelerator_scsi_unit, EXPANSIONTYPE_SCSI,
+ BOARD_MEMORY_25BITMEM,
+ 128 * 1024 * 1024,
+ 0,
+ gvp_init_accelerator, NULL, BOARD_AUTOCONFIG_Z2, 1
+ },
+ {
+ _T("Tek Magic 2040/2060"),
+ _T("TekMagic"),
+ ROMTYPE_CB_TEKMAGIC, 0,
+ tekmagic_add_scsi_unit, EXPANSIONTYPE_SCSI,
+ BOARD_MEMORY_HIGHMEM,
+ 128 * 1024 * 1024
+ },
+#endif
+ {
+ NULL
+ }
+};
+static const struct cpuboardsubtype blizzardboard_sub[] = {
+#if 0
+ {
+ _T("Blizzard 1230 II"),
+ _T("Blizzard1230II"),
+ ROMTYPE_CB_B1230MK2, 0,
+ cpuboard_ncr9x_add_scsi_unit, EXPANSIONTYPE_SCSI,
+ BOARD_MEMORY_BLIZZARD_12xx,
+ 64 * 1024 * 1024,
+ 0,
+ NULL, NULL, 0, 0,
+ blizzardboard_settings_mk2
+ },
+ {
+ _T("Blizzard 1230 III"),
+ _T("Blizzard1230III"),
+ ROMTYPE_CB_B1230MK3, 0,
+ NULL, 0,
+ BOARD_MEMORY_BLIZZARD_12xx,
+ 32 * 1024 * 1024,
+ 0,
+ NULL, NULL, 0, 0,
+ blizzardboard_settings
+ },
+ {
+ _T("Blizzard 1230 IV"),
+ _T("Blizzard1230IV"),
+ ROMTYPE_CB_BLIZ1230, 0,
+ NULL, EXPANSIONTYPE_FALLBACK_DISABLE | EXPANSIONTYPE_HAS_FALLBACK,
+ BOARD_MEMORY_BLIZZARD_12xx,
+ 256 * 1024 * 1024,
+ 0,
+ NULL, NULL, 0, 0,
+ blizzardboard_settings
+ },
+ {
+ _T("Blizzard 1260"),
+ _T("Blizzard1260"),
+ ROMTYPE_CB_BLIZ1260, 0,
+ NULL, EXPANSIONTYPE_FALLBACK_DISABLE | EXPANSIONTYPE_HAS_FALLBACK,
+ BOARD_MEMORY_BLIZZARD_12xx,
+ 256 * 1024 * 1024,
+ 0,
+ NULL, NULL, 0, 0,
+ blizzardboard_settings
+ },
+ {
+ _T("Blizzard 2060"),
+ _T("Blizzard2060"),
+ ROMTYPE_CB_BLIZ2060, 0,
+ cpuboard_ncr9x_add_scsi_unit, EXPANSIONTYPE_SCSI | EXPANSIONTYPE_FALLBACK_DISABLE | EXPANSIONTYPE_HAS_FALLBACK,
+ BOARD_MEMORY_HIGHMEM,
+ 128 * 1024 * 1024,
+ 0,
+ NULL, NULL, 0, 0,
+ blizzardboard_settings
+ },
+ {
+ _T("Blizzard PPC"),
+ _T("BlizzardPPC"),
+ ROMTYPE_CB_BLIZPPC, 0,
+ blizzardppc_add_scsi_unit, EXPANSIONTYPE_SCSI,
+ BOARD_MEMORY_BLIZZARD_PPC,
+ 256 * 1024 * 1024
+ },
+#endif
+ {
+ NULL
+ }
+};
+static const struct cpuboardsubtype cyberstormboard_sub[] = {
+#if 0
+ {
+ _T("CyberStorm MK I"),
+ _T("CyberStormMK1"),
+ ROMTYPE_CB_CSMK1, 0,
+ cpuboard_ncr9x_add_scsi_unit, EXPANSIONTYPE_SCSI,
+ BOARD_MEMORY_HIGHMEM,
+ 128 * 1024 * 1024
+ },
+ {
+ _T("CyberStorm MK II"),
+ _T("CyberStormMK2"),
+ ROMTYPE_CB_CSMK2, 0,
+ cpuboard_ncr9x_add_scsi_unit, EXPANSIONTYPE_SCSI | EXPANSIONTYPE_FALLBACK_DISABLE | EXPANSIONTYPE_HAS_FALLBACK,
+ BOARD_MEMORY_HIGHMEM,
+ 128 * 1024 * 1024
+ },
+ {
+ _T("CyberStorm MK III"),
+ _T("CyberStormMK3"),
+ ROMTYPE_CB_CSMK3, 0,
+ cyberstorm_add_scsi_unit, EXPANSIONTYPE_SCSI,
+ BOARD_MEMORY_HIGHMEM,
+ 128 * 1024 * 1024
+ },
+ {
+ _T("CyberStorm PPC"),
+ _T("CyberStormPPC"),
+ ROMTYPE_CB_CSPPC, 0,
+ cyberstorm_add_scsi_unit, EXPANSIONTYPE_SCSI,
+ BOARD_MEMORY_HIGHMEM,
+ 128 * 1024 * 1024
+ },
+#endif
+ {
+ NULL
+ }
+};
+static const struct cpuboardsubtype warpengine_sub[] = {
+#if 0
+ {
+ _T("Warp Engine A4000"),
+ _T("WarpEngineA4000"),
+ ROMTYPE_CB_WENGINE, 0,
+ warpengine_add_scsi_unit, EXPANSIONTYPE_SCSI,
+ BOARD_MEMORY_HIGHMEM,
+ 128 * 1024 * 1024,
+ 0x01000000,
+ ncr710_warpengine_autoconfig_init, NULL, BOARD_AUTOCONFIG_Z3, 1,
+ warpengine_settings
+ },
+#endif
+ {
+ NULL
+ }
+};
+static const struct expansionboardsettings mtec_settings[] = {
+ {
+ _T("SCSI disabled"),
+ _T("scsioff")
+ },
+ {
+ NULL
+ }
+};
+static const struct cpuboardsubtype mtec_sub[] = {
+#if 0
+ {
+ _T("E-Matrix 530"),
+ _T("e-matrix530"),
+ ROMTYPE_CB_EMATRIX, 0,
+ ematrix_add_scsi_unit, EXPANSIONTYPE_SCSI,
+ BOARD_MEMORY_CUSTOM_32,
+ 128 * 1024 * 1024,
+ 0,
+ ncr_ematrix_autoconfig_init, NULL, BOARD_AUTOCONFIG_Z2, 1,
+ mtec_settings
+ },
+#endif
+ {
+ NULL
+ }
+};
+
+static const struct expansionboardsettings ivsvector_settings[] = {
+ {
+ // 0/1
+ _T("Memory (JP12)\0") _T("4M\0") _T("8M\0") _T("16M\0") _T("32M\0"),
+ _T("memory\0") _T("4m\0") _T("8m\0") _T("16m\0") _T("32m\0"),
+ true, false, 0
+ },
+ {
+ // 3
+ _T("Disable FastROM (JP17)"),
+ _T("disfastrom"),
+ false, false, 1
+ },
+ {
+ // 4
+ _T("Autoboot (JP20)"),
+ _T("autoboot"),
+ false, false, 0
+ },
+ {
+ // 5
+ _T("Dis68kRAM (JP14)"),
+ _T("dis68kram"),
+ false, false, 1
+ },
+ {
+ // 6
+ _T("Burst (JP13)"),
+ _T("burst"),
+ false, false, 1
+ },
+ {
+ NULL
+ }
+};
+
+
+static const struct expansionboardsettings a26x0board_settings[] = {
+ {
+ _T("OSMODE (J304)"),
+ _T("j304")
+ },
+ {
+ NULL
+ }
+};
+static const struct cpuboardsubtype commodore_sub[] = {
+#if 0
+ {
+ _T("A2620/A2630"),
+ _T("A2630"),
+ ROMTYPE_CB_A26x0, 0,
+ NULL, 0,
+ BOARD_MEMORY_25BITMEM,
+ 128 * 1024 * 1024,
+ 0,
+ NULL, NULL, 0, 0,
+ a26x0board_settings,
+ cpuboard_io_special
+ },
+#endif
+ {
+ NULL
+ }
+};
+static const struct cpuboardsubtype dbk_sub[] = {
+#if 0
+ {
+ _T("1230/1240"),
+ _T("DKB12x0"),
+ ROMTYPE_CB_DKB12x0, 0,
+ cpuboard_dkb_add_scsi_unit, EXPANSIONTYPE_SCSI,
+ 0,
+ 128 * 1024 * 1024,
+ 0,
+ ncr_dkb_autoconfig_init, NULL, BOARD_AUTOCONFIG_Z2, 0
+ },
+ {
+ _T("Wildfire"),
+ _T("wildfire"),
+ ROMTYPE_CB_DBK_WF, 0,
+ wildfire_add_scsi_unit, EXPANSIONTYPE_SCSI | EXPANSIONTYPE_HAS_FALLBACK,
+ BOARD_MEMORY_HIGHMEM,
+ 128 * 1024 * 1024,
+ 0,
+ dkb_wildfire_pci_init, NULL, BOARD_NONAUTOCONFIG_BEFORE, 0
+ },
+#endif
+ {
+ NULL
+ }
+};
+static const struct cpuboardsubtype fusionforty_sub[] = {
+#if 0
+ {
+ _T("Fusion Forty"),
+ _T("FusionForty"),
+ ROMTYPE_CB_FUSION, 0,
+ NULL, 0,
+ BOARD_MEMORY_HIGHMEM,
+ 128 * 1024 * 1024
+ },
+#endif
+ {
+ NULL
+ }
+};
+static const struct cpuboardsubtype ivs_sub[] = {
+#if 0
+ {
+ _T("Vector"),
+ _T("Vector"),
+ ROMTYPE_CB_VECTOR, 0,
+ ivsvector_add_scsi_unit, EXPANSIONTYPE_SCSI,
+ BOARD_MEMORY_HIGHMEM,
+ 32 * 1024 * 1024,
+ 0,
+ ivsvector_init, NULL, BOARD_AUTOCONFIG_Z2, 1,
+ ivsvector_settings, NULL,
+ 2112, 240, 0, false
+ },
+#endif
+ {
+ NULL
+ }
+};
+
+static const struct expansionboardsettings apollo_settings[] = {
+ {
+ _T("SCSI module installed"),
+ _T("scsi")
+ },
+ {
+ NULL
+ }
+};
+
+static const struct cpuboardsubtype apollo_sub[] = {
+#if 0
+ {
+ _T("Apollo 1240/1260"),
+ _T("Apollo"),
+ ROMTYPE_CB_APOLLO, 0,
+ apollo_add_scsi_unit, EXPANSIONTYPE_SCSI,
+ BOARD_MEMORY_HIGHMEM,
+ 128 * 1024 * 1024,
+ 0,
+ apollo_init_cpu, NULL, 2, 0,
+ apollo_settings
+ },
+#endif
+ {
+ NULL
+ }
+};
+static const struct cpuboardsubtype kupkeboard_sub[] = {
+#if 0
+ {
+ _T("Golem 030"),
+ _T("golem030"),
+ ROMTYPE_CB_GOLEM030, 0,
+ NULL, 0,
+ BOARD_MEMORY_25BITMEM,
+ 16 * 1024 * 1024
+ },
+#endif
+ {
+ NULL
+ }
+};
+static const struct cpuboardsubtype icboard_sub[] = {
+ {
+ _T("ACA 500"),
+ _T("aca500"),
+ ROMTYPE_CB_ACA500, 0,
+ NULL, EXPANSIONTYPE_24BIT
+ },
+ {
+ NULL
+ }
+};
+static const struct cpuboardsubtype dceboard_sub[] = {
+#if 0
+ {
+ _T("SX32 Pro"),
+ _T("sx32pro"),
+ ROMTYPE_CB_SX32PRO, 0,
+ NULL, 0,
+ BOARD_MEMORY_CUSTOM_32,
+ 64 * 1024 * 1024
+ },
+#endif
+ {
+ NULL
+ }
+};
+
+static const struct cpuboardsubtype dummy_sub[] = {
+ { NULL }
+};
+
+const struct cpuboardtype cpuboards[] = {
+ {
+ -1,
+ _T("-"),
+ dummy_sub, 0
+ },
+#if 0
+ {
+ BOARD_ACT,
+ _T("ACT"),
+ apollo_sub, 0
+ },
+ {
+ BOARD_COMMODORE,
+ _T("Commodore"),
+ commodore_sub, 0
+ },
+ {
+ BOARD_DCE,
+ _T("DCE"),
+ dceboard_sub, 0
+ },
+ {
+ BOARD_DKB,
+ _T("DKB"),
+ dbk_sub, 0
+ },
+ {
+ BOARD_GVP,
+ _T("Great Valley Products"),
+ gvpboard_sub, 0
+ },
+ {
+ BOARD_KUPKE,
+ _T("Kupke"),
+ kupkeboard_sub, 0
+ },
+ {
+ BOARD_MACROSYSTEM,
+ _T("MacroSystem"),
+ warpengine_sub, 0
+ },
+ {
+ BOARD_MTEC,
+ _T("M-Tec"),
+ mtec_sub, 0
+ },
+ {
+ BOARD_BLIZZARD,
+ _T("Phase 5 - Blizzard"),
+ blizzardboard_sub, 0
+ },
+ {
+ BOARD_CYBERSTORM,
+ _T("Phase 5 - CyberStorm"),
+ cyberstormboard_sub, 0
+ },
+ {
+ BOARD_RCS,
+ _T("RCS Management"),
+ fusionforty_sub, 0
+ },
+ {
+ BOARD_IVS,
+ _T("Interactive Video Systems"),
+ ivs_sub, 0
+ },
+#endif
+#if 0
+ {
+ BOARD_IC,
+ _T("Individual Computers"),
+ icboard_sub, 0
+ },
+#endif
+ {
+ NULL
+ }
+};
+
+const struct memoryboardtype memoryboards[]
+{
+ // z2
+ {
+ _T("UAE"), _T("0xf00000 RAM"),
+ 2, 0xf00000, 0xffff, 0xff
+ },
+ {
+ _T("DKB"), _T("Insider I/II"),
+ 2, 0x800000, 0xffff, 0xff
+ },
+ {
+ _T("GVP"), _T("Impact A2000-RAM8"),
+ 2, 0, 2077, 9
+ },
+ {
+ _T("Kupke"), _T("Golem RAM-Card"),
+ 2, 0, 2073, 3
+ },
+ {
+ _T("Supra"), _T("SupraRAM 500RX"),
+ 2, 0, 1056, 10
+ },
+ {
+ _T("Supra"), _T("SupraRAM 2000"),
+ 2, 0, 1056, 9
+ },
+ // z3
+ {
+ _T("E3B"), _T("ZorRAM"),
+ 3, 0, 3643, 32
+ },
+
{
NULL
diff --git a/src/filesys.cpp b/src/filesys.cpp
index 1b5b33fc..dca8481c 100644
--- a/src/filesys.cpp
+++ b/src/filesys.cpp
@@ -27,34 +27,54 @@
#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 "traps.h"
#include "fsusage.h"
#include "native2amiga.h"
+#include "scsidev.h"
#include "fsdb.h"
#include "zfile.h"
-#include "zarchive.h"
#include "gui.h"
-#include "gayle.h"
#include "savestate.h"
#include "bsdsocket.h"
#include "uaeresource.h"
#include "inputdevice.h"
+#include "clipboard.h"
#include "blkdev.h"
-#include "picasso96.h"
-#include "rommgr.h"
+#ifdef RETROPLATFORM
+#include "rp.h"
+#endif
-#define TRAPMD 1
+#define TRACING_ENABLED 0
+int log_filesys = 0;
-#define KS12_BOOT_HACK 1
+#if TRACING_ENABLED
+#if 0
+#define TRACE(x) if (log_filesys > 0 && (unit->volflags & MYVOLUMEINFO_CDFS)) { write_log x; }
+#else
+#define TRACE(x) if (log_filesys > 0) { write_log x; }
+#endif
+#define TRACEI(x) if (log_filesys > 0) { write_log x; }
+#define TRACE2(x) if (log_filesys >= 2) { write_log x; }
+#define TRACE3(x) if (log_filesys >= 3) { write_log x; }
+#define DUMPLOCK(u,x) dumplock(u,x)
+#else
+#define TRACE(x)
+#define DUMPLOCK(u,x)
+#define TRACEI(x)
+#define TRACE2(x)
+#define TRACE3(x)
+#endif
#define UNIT_LED(unit) (LED_HD)
+#define RTAREA_HEARTBEAT 0xFFFC
+
static int bootrom_header;
static uae_u32 dlg (uae_u32 a)
@@ -62,20 +82,42 @@ static uae_u32 dlg (uae_u32 a)
return (dbg (a + 0) << 24) | (dbg (a + 1) << 16) | (dbg (a + 2) << 8) | (dbg (a + 3) << 0);
}
-#define UAEFS_VERSION "UAEfs 0.5"
+static void aino_test (a_inode *aino)
+{
+#ifdef AINO_DEBUG
+ a_inode *aino2 = aino, *aino3;
+ for (;;) {
+ if (!aino || !aino->next)
+ return;
+ if ((aino->checksum1 ^ aino->checksum2) != 0xaaaa5555) {
+ write_log (_T("PANIC: corrupted or freed but used aino detected!"), aino);
+ }
+ aino3 = aino;
+ aino = aino->next;
+ if (aino->prev != aino3) {
+ write_log (_T("PANIC: corrupted aino linking!\n"));
+ break;
+ }
+ if (aino == aino2) break;
+ }
+#endif
+}
-uaecptr filesys_initcode, filesys_initcode_ptr;
+static void aino_test_init (a_inode *aino)
+{
+#ifdef AINO_DEBUG
+ aino->checksum1 = (uae_u32)aino;
+ aino->checksum2 = aino->checksum1 ^ 0xaaaa5555;
+#endif
+}
+
+
+uaecptr filesys_initcode;
static uaecptr bootrom_start;
static uae_u32 fsdevname, fshandlername, filesys_configdev;
-static uaecptr afterdos_name, afterdos_id, afterdos_initcode;
static int filesys_in_interrupt;
static uae_u32 mountertask;
static int automountunit = -1;
-static int autocreatedunit;
-static uaecptr ROM_filesys_doio, ROM_filesys_doio_original;
-static uaecptr ROM_filesys_putmsg, ROM_filesys_putmsg_original;
-static uaecptr ROM_filesys_putmsg_return;
-static uaecptr ROM_filesys_hack_remove;
#define FS_STARTUP 0
#define FS_GO_DOWN 1
@@ -83,41 +125,42 @@ static uaecptr ROM_filesys_hack_remove;
#define DEVNAMES_PER_HDF 32
#define UNIT_FILESYSTEM 0
+#define UNIT_CDFS 1
typedef struct {
int unit_type;
int open; // >0 start as filesystem, <0 = allocated but do not start
- TCHAR *devname; /* device name, e.g. UAE0: */
- uaecptr devname_amiga;
- uaecptr startup;
+ TCHAR *devname; /* device name, e.g. UAE0: */
+ uaecptr devname_amiga;
+ uaecptr startup;
uaecptr devicenode;
uaecptr parmpacket;
- TCHAR *volname; /* volume name, e.g. CDROM, WORK, etc. */
- int volflags; /* volume flags, readonly, stream uaefsdb support */
- TCHAR *rootdir; /* root native directory/hdf. empty drive if invalid path */
- struct zvolume *zarchive;
- TCHAR *rootdirdiff; /* "diff" file/directory */
- bool readonly; /* disallow write access? */
- bool locked; /* action write protect */
+ TCHAR *volname; /* volume name, e.g. CDROM, WORK, etc. */
+ int volflags; /* volume flags, readonly, stream uaefsdb support */
+ TCHAR *rootdir; /* root native directory/hdf. empty drive if invalid path */
+ struct zvolume *zarchive;
+ TCHAR *rootdirdiff; /* "diff" file/directory */
+ bool readonly; /* disallow write access? */
+ bool locked; /* action write protect */
bool unknown_media; /* ID_UNREADABLE_DISK */
- int bootpri; /* boot priority. -128 = no autoboot, -129 = no mount */
- int devno;
+ int bootpri; /* boot priority. -128 = no autoboot, -129 = no mount */
+ int devno;
int controller_type;
int controller_unit;
- bool wasisempty; /* if true, this unit was created empty */
- bool canremove; /* if true, this unit can be safely ejected and remounted */
- bool configureddrive; /* if true, this is drive that was manually configured */
+ bool wasisempty; /* if true, this unit was created empty */
+ bool canremove; /* if true, this unit can be safely ejected and remounted */
+ bool configureddrive; /* if true, this is drive that was manually configured */
bool inject_icons; /* inject icons if directory filesystem */
-
- struct hardfiledata hf;
- /* Threading stuff */
- smp_comm_pipe *volatile unit_pipe, *volatile back_pipe;
- uae_thread_id tid;
- struct _unit *self;
- /* Reset handling */
- uae_sem_t reset_sync_sem;
- volatile int reset_state;
+ struct hardfiledata hf;
+
+ /* Threading stuff */
+ smp_comm_pipe *volatile unit_pipe, *volatile back_pipe;
+ uae_thread_id tid;
+ struct _unit *self;
+ /* Reset handling */
+ uae_sem_t reset_sync_sem;
+ volatile int reset_state;
/* RDB stuff */
uaecptr rdb_devname_amiga[DEVNAMES_PER_HDF];
@@ -130,6 +173,12 @@ typedef struct {
/* filesystem seglist */
uaecptr filesysseg;
uae_u32 rdb_dostype;
+
+ /* CDFS */
+ bool cd_open;
+ int cddevno;
+ void *cdfs_superblock;
+
} UnitInfo;
struct uaedev_mount_info {
@@ -148,21 +197,22 @@ int nr_units (void)
return cnt;
}
-int nr_directory_units (struct uae_prefs *p)
+int nr_directory_units(struct uae_prefs *p)
{
- int i, cnt = 0;
- if (p) {
- for (i = 0; i < p->mountitems; i++) {
+ int i, cnt = 0;
+ if (p) {
+ for (i = 0; i < p->mountitems; i++) {
if (p->mountconfig[i].ci.controller_type == HD_CONTROLLER_TYPE_UAE)
- cnt++;
- }
- } else {
- for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
+ cnt++;
+ }
+ }
+ else {
+ for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
if (mountinfo.ui[i].open > 0 && mountinfo.ui[i].controller_type == HD_CONTROLLER_TYPE_UAE)
- cnt++;
- }
- }
- return cnt;
+ cnt++;
+ }
+ }
+ return cnt;
}
static int is_virtual (int unit_no)
@@ -224,6 +274,12 @@ static UnitInfo *getuip(struct uae_prefs *p, int index)
return NULL;
return &mountinfo.ui[index];
}
+static int getuindex (struct uae_prefs *p, int index)
+{
+ if (index < 0)
+ return -1;
+ return p->mountconfig[index].unitnum;
+}
int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo *mi)
{
@@ -251,12 +307,12 @@ int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo *
} else if (uci->ci.type == UAEDEV_HDF) {
ui->hf.ci.readonly = true;
ui->hf.ci.blocksize = uci->ci.blocksize;
- int err = hdf_open (&ui->hf, uci->ci.rootdir);
- if (err <= 0) {
+ if (!hdf_open (&ui->hf, uci->ci.rootdir)) {
mi->ismedia = false;
mi->ismounted = true;
- mi->error = err;
if (uci->ci.reserved == 0 && uci->ci.sectors == 0 && uci->ci.surfaces == 0) {
+ if (ui->hf.flags & 1)
+ return FILESYS_HARDDRIVE;
return FILESYS_HARDFILE_RDB;
}
return -1;
@@ -275,15 +331,22 @@ int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo *
mi->ismedia = di.media_inserted != 0;
_tcscpy (mi->rootdir, di.label);
}
+#if 0
+ if (ui->hf.ci.cd_emu_unit == 0)
+ _tcscpy (mi->rootdir, _T("CD"));
+ else
+ _stprintf (mi->rootdir, _T("CD %d"), ui->hf.ci.cd_emu_unit);
+#endif
}
- } else {
+ }
+ else if (uci->ci.type != UAEDEV_TAPE) {
if (ui->controller_type == HD_CONTROLLER_TYPE_UAE) { // what is this? || (ui->controller && p->cs_ide)) {
- mi->ismounted = 1;
- if (uci->ci.type == UAEDEV_HDF)
- mi->ismedia = ui->hf.drive_empty ? false : true;
- else
- mi->ismedia = true;
- }
+ mi->ismounted = 1;
+ if (uci->ci.type == UAEDEV_HDF)
+ mi->ismedia = ui->hf.drive_empty ? false : true;
+ else
+ mi->ismedia = true;
+ }
}
if (mi->size < 0)
@@ -297,6 +360,8 @@ int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo *
if (uci->ci.type == UAEDEV_DIR)
return FILESYS_VIRTUAL;
if (uci->ci.reserved == 0 && uci->ci.sectors == 0 && uci->ci.surfaces == 0) {
+ if (ui->hf.flags & 1)
+ return FILESYS_HARDDRIVE;
return FILESYS_HARDFILE_RDB;
}
return FILESYS_HARDFILE;
@@ -336,23 +401,23 @@ static void fixcharset (TCHAR *s)
au_fs_copy (s, strlen (tmp) + 1, tmp);
}
-TCHAR *validatevolumename (TCHAR *s, const TCHAR *def)
+TCHAR *validatevolumename(TCHAR *s, const TCHAR *def)
{
- stripsemicolon (s);
- fixcharset (s);
- striplength (s, 30);
+ stripsemicolon(s);
+ fixcharset(s);
+ striplength(s, 30);
if (_tcslen(s) == 0 && def) {
xfree(s);
s = my_strdup(def);
}
return s;
}
-TCHAR *validatedevicename (TCHAR *s, const TCHAR *def)
+TCHAR *validatedevicename(TCHAR *s, const TCHAR *def)
{
- stripsemicolon (s);
- stripspace (s);
- fixcharset (s);
- striplength (s, 30);
+ stripsemicolon(s);
+ stripspace(s);
+ fixcharset(s);
+ striplength(s, 30);
if (_tcslen(s) == 0 && def) {
xfree(s);
s = my_strdup(def);
@@ -360,7 +425,7 @@ TCHAR *validatedevicename (TCHAR *s, const TCHAR *def)
return s;
}
-TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, struct zvolume *zv, const TCHAR *def)
+TCHAR *filesys_createvolname(const TCHAR *volname, const TCHAR *rootdir, struct zvolume *zv, const TCHAR *def)
{
TCHAR *nvol = NULL;
int i, archivehd;
@@ -372,12 +437,6 @@ TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, struct
else if (my_existsdir(rootdir))
archivehd = 0;
- if (zv && zv->volumename && _tcslen(zv->volumename) > 0) {
- nvol = my_strdup(zv->volumename);
- nvol = validatevolumename (nvol, def);
- return nvol;
- }
-
if ((!volname || _tcslen (volname) == 0) && rootdir && archivehd >= 0) {
p = my_strdup (rootdir);
for (i = _tcslen (p) - 1; i >= 0; i--) {
@@ -401,6 +460,7 @@ TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, struct
nvol = my_strdup (p + i);
}
if (!nvol && archivehd >= 0) {
+ TCHAR *s = NULL;
if (volname && _tcslen (volname) > 0)
nvol = my_strdup (volname);
else
@@ -412,7 +472,7 @@ TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, struct
else
nvol = my_strdup (_T(""));
}
- nvol = validatevolumename (nvol, def);
+ validatevolumename (nvol, def);
xfree (p);
return nvol;
}
@@ -484,15 +544,15 @@ static int set_filesys_unit_1 (int nr, struct uaedev_config_info *ci)
}
}
- if (ci->controller_type != HD_CONTROLLER_TYPE_UAE) {
- ui = &mountinfo.ui[nr];
- memset (ui, 0, sizeof (UnitInfo));
- memcpy (&ui->hf.ci, &c, sizeof (struct uaedev_config_info));
- ui->readonly = c.readonly;
- ui->unit_type = -1;
- ui->open = -1;
- return nr;
- }
+ if (ci->controller_type != HD_CONTROLLER_TYPE_UAE || ci->type == UAEDEV_TAPE) {
+ ui = &mountinfo.ui[nr];
+ memset(ui, 0, sizeof(UnitInfo));
+ memcpy(&ui->hf.ci, &c, sizeof(struct uaedev_config_info));
+ ui->readonly = c.readonly;
+ ui->unit_type = -1;
+ ui->open = -1;
+ return nr;
+ }
for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
if (nr == i || !mountinfo.ui[i].open || mountinfo.ui[i].rootdir == NULL)
@@ -505,7 +565,6 @@ static int set_filesys_unit_1 (int nr, struct uaedev_config_info *ci)
ui = &mountinfo.ui[nr];
memset (ui, 0, sizeof (UnitInfo));
- memcpy (&ui->hf.ci, &c, sizeof (struct uaedev_config_info));
if (c.volname[0]) {
int flags = 0;
@@ -514,17 +573,18 @@ static int set_filesys_unit_1 (int nr, struct uaedev_config_info *ci)
if (set_filesys_volume (c.rootdir, &flags, &c.readonly, &emptydrive, &ui->zarchive) < 0)
return -1;
}
- ui->volname = filesys_createvolname (c.volname, c.rootdir, ui->zarchive, _T("harddrive"));
+ ui->volname = filesys_createvolname(c.volname, c.rootdir, ui->zarchive, _T("harddrive"));
ui->volflags = flags;
} else {
ui->unit_type = UNIT_FILESYSTEM;
+ memcpy (&ui->hf.ci, &c, sizeof (struct uaedev_config_info));
ui->hf.unitnum = nr;
ui->volname = 0;
if (ui->hf.ci.rootdir[0]) {
- if (hdf_open (&ui->hf) <= 0 && !c.readonly) {
+ if (!hdf_open (&ui->hf) && !c.readonly) {
write_log (_T("Attempting to open '%s' in read-only mode.\n"), ui->hf.ci.rootdir);
ui->hf.ci.readonly = c.readonly = true;
- if (hdf_open (&ui->hf) > 0) {
+ if (hdf_open (&ui->hf)) {
error_log (_T("'%s' opened in read-only mode.\n"), ui->hf.ci.rootdir);
}
}
@@ -577,9 +637,7 @@ static int set_filesys_unit_1 (int nr, struct uaedev_config_info *ci)
if (c.bootpri > 127)
c.bootpri = 127;
ui->bootpri = c.bootpri;
- ui->inject_icons = c.inject_icons;
ui->open = 1;
-
return nr;
err:
if (ui->hf.handle_valid)
@@ -603,26 +661,32 @@ static int add_filesys_unit (struct uaedev_config_info *ci)
return -1;
ret = set_filesys_unit_1 (-1, ci);
+#ifdef RETROPLATFORM
+ if (ret >= 0) {
+ rp_hd_device_enable (ret, true);
+ rp_harddrive_image_change (ret, ci->readonly, ci->rootdir);
+ }
+#endif
return ret;
}
-int kill_filesys_unitconfig (struct uae_prefs *p, int nr)
+int kill_filesys_unitconfig(struct uae_prefs *p, int nr)
{
struct uaedev_config_data *uci;
- if (nr < 0)
- return 0;
- uci = getuci (p->mountconfig, nr);
- hardfile_do_disk_change (uci, 0);
+ if (nr < 0)
+ return 0;
+ uci = getuci(p->mountconfig, nr);
+ hardfile_do_disk_change(uci, 0);
if (uci->configoffset >= 0 && uci->ci.controller_type == HD_CONTROLLER_TYPE_UAE)
- filesys_media_change (uci->ci.rootdir, 0, uci);
- while (nr < MOUNT_CONFIG_SIZE) {
- memmove (&p->mountconfig[nr], &p->mountconfig[nr + 1], sizeof (struct uaedev_config_data));
- nr++;
- }
- p->mountitems--;
- memset (&p->mountconfig[MOUNT_CONFIG_SIZE - 1], 0, sizeof (struct uaedev_config_data));
- return 1;
+ filesys_media_change(uci->ci.rootdir, 0, uci);
+ while (nr < MOUNT_CONFIG_SIZE) {
+ memmove(&p->mountconfig[nr], &p->mountconfig[nr + 1], sizeof(struct uaedev_config_data));
+ nr++;
+ }
+ p->mountitems--;
+ memset(&p->mountconfig[MOUNT_CONFIG_SIZE - 1], 0, sizeof(struct uaedev_config_data));
+ return 1;
}
int move_filesys_unitconfig (struct uae_prefs *p, int nr, int to)
@@ -658,105 +722,20 @@ static void allocuci (struct uae_prefs *p, int nr, int idx)
allocuci (p, nr, idx, -1);
}
-static const TCHAR *getunittype(struct uaedev_config_info *uci)
-{
- return uci->type == UAEDEV_CD ? _T("CD") : _T("HD");
-}
-
-static int cpuboard_hd;
-static romconfig cpuboard_dummy;
-
-static void add_cpuboard_unit_init(void)
-{
- memset(&cpuboard_dummy, 0, sizeof cpuboard_dummy);
- cpuboard_dummy.device_id = 7;
-}
-
-static bool add_ide_unit(int type, int unit, struct uaedev_config_info *uci)
-{
- bool added = false;
- if (type >= HD_CONTROLLER_TYPE_IDE_EXPANSION_FIRST && type <= HD_CONTROLLER_TYPE_IDE_LAST) {
- for (int i = 0; expansionroms[i].name; i++) {
- if (i == type - HD_CONTROLLER_TYPE_IDE_EXPANSION_FIRST) {
- const struct expansionromtype *ert = &expansionroms[i];
- if ((ert->deviceflags & 2) && is_board_enabled(&currprefs, ert->romtype, uci->controller_type_unit)) {
- cpuboard_hd = 1;
- if (ert->add) {
- struct romconfig *rc = get_device_romconfig(&currprefs, ert->romtype, uci->controller_type_unit);
- write_log(_T("Adding IDE %s '%s' unit %d ('%s')\n"), getunittype(uci),
- ert->name, unit, uci->rootdir);
- ert->add(unit, uci, rc);
- }
- if (cpuboard_hd)
- added = true;
- }
- }
- }
- }
- return added;
-}
-
static void initialize_mountinfo(void)
{
int nr;
UnitInfo *uip = &mountinfo.ui[0];
- autocreatedunit = 0;
-
for (nr = 0; nr < currprefs.mountitems; nr++) {
- struct uaedev_config_data *uci = &currprefs.mountconfig[nr];
- if (uci->ci.controller_type == HD_CONTROLLER_TYPE_UAE && (uci->ci.type == UAEDEV_DIR || uci->ci.type == UAEDEV_HDF)) {
- struct uaedev_config_info ci;
- memcpy (&ci, &uci->ci, sizeof (struct uaedev_config_info));
- ci.flags = MYVOLUMEINFO_REUSABLE;
- int idx = set_filesys_unit_1 (-1, &ci);
- allocuci (&currprefs, nr, idx);
- }
- }
- nr = nr_units ();
-
- // init all controllers first
- add_cpuboard_unit_init();
- for (int i = 0; expansionroms[i].name; i++) {
- const struct expansionromtype *ert = &expansionroms[i];
- for (int j = 0; j < MAX_DUPLICATE_EXPANSION_BOARDS; j++) {
- struct romconfig *rc = get_device_romconfig(&currprefs, ert->romtype, j);
- if ((ert->deviceflags & 3) && rc) {
- if (ert->add) {
- struct uaedev_config_info ci = { 0 };
- ci.controller_type_unit = j;
- ert->add(-1, &ci, rc);
- }
- }
- }
- }
-
- for (nr = 0; nr < currprefs.mountitems; nr++) {
- struct uaedev_config_info *uci = &currprefs.mountconfig[nr].ci;
- int type = uci->controller_type;
- int unit = uci->controller_unit;
- bool added = false;
- if (type == HD_CONTROLLER_TYPE_UAE) {
- continue;
- } else if (type != HD_CONTROLLER_TYPE_IDE_AUTO && type >= HD_CONTROLLER_TYPE_IDE_FIRST && type <= HD_CONTROLLER_TYPE_IDE_LAST) {
- added = add_ide_unit(type, unit, uci);
- } else if (type == HD_CONTROLLER_TYPE_IDE_AUTO) {
- for (int st = HD_CONTROLLER_TYPE_IDE_FIRST; st <= HD_CONTROLLER_TYPE_IDE_LAST; st++) {
- added = add_ide_unit(st, unit, uci);
- if (added)
- break;
- }
- } else if (type == HD_CONTROLLER_TYPE_PCMCIA) {
- if (uci->controller_type_unit == 0) {
- gayle_add_pcmcia_sram_unit (uci);
- added = true;
- } else {
- gayle_add_pcmcia_ide_unit (uci);
- added = true;
- }
- }
- if (added)
- allocuci (&currprefs, nr, -1);
+ struct uaedev_config_data *uci = &currprefs.mountconfig[nr];
+ if (uci->ci.controller_type == HD_CONTROLLER_TYPE_UAE && (uci->ci.type == UAEDEV_DIR || uci->ci.type == UAEDEV_HDF)) {
+ struct uaedev_config_info ci;
+ memcpy(&ci, &uci->ci, sizeof(struct uaedev_config_info));
+ ci.flags = MYVOLUMEINFO_REUSABLE;
+ int idx = set_filesys_unit_1(-1, &ci);
+ allocuci(&currprefs, nr, idx);
+ }
}
}
@@ -766,7 +745,7 @@ int sprintf_filesys_unit (TCHAR *buffer, int num)
if (uip[num].volname != 0)
_stprintf (buffer, _T("(DH%d:) Filesystem, %s: %s %s"), num, uip[num].volname,
- uip[num].rootdir, uip[num].readonly ? _T("ro") : _T(""));
+ uip[num].rootdir, uip[num].readonly ? "ro" : "");
else
_stprintf (buffer, _T("(DH%d:) Hardfile, \"%s\", size %d Mbytes"), num,
uip[num].rootdir, (int)(uip[num].hf.virtsize / (1024 * 1024)));
@@ -778,7 +757,6 @@ static void free_mountinfo (void)
int i;
for (i = 0; i < MAX_FILESYSTEM_UNITS; i++)
close_filesys_unit (mountinfo.ui + i);
- gayle_free_units ();
}
struct hardfiledata *get_hardfile_data (int nr)
@@ -813,8 +791,6 @@ struct hardfiledata *get_hardfile_data (int nr)
#define dp64_Arg4 52
#define dp64_Arg5 56
-#define dp_Max 60
-
/* result codes */
#define DOS_TRUE ((uae_u32)-1L)
#define DOS_FALSE (0L)
@@ -828,15 +804,7 @@ struct hardfiledata *get_hardfile_data (int nr)
#define ST_SOFTLINK 3
#define ST_LINKDIR 4
-#if 1
-#define MAXFILESIZE32 (0xffffffff)
-#else
-/* technically correct but most native
- * filesystems don't enforce it
- */
#define MAXFILESIZE32 (0x7fffffff)
-#endif
-#define MAXFILESIZE32_2G (0x7fffffff)
/* Passed as type to Lock() */
#define SHARED_LOCK -2 /* File is readable by others */
@@ -895,7 +863,6 @@ struct hardfiledata *get_hardfile_data (int nr)
#define ACTION_READ_LINK 1024
/* OS4 64-bit filesize packets */
-#define ACTION_FILESYSTEM_ATTR 3005
#define ACTION_CHANGE_FILE_POSITION64 8001
#define ACTION_GET_FILE_POSITION64 8002
#define ACTION_CHANGE_FILE_SIZE64 8003
@@ -918,13 +885,6 @@ struct hardfiledata *get_hardfile_data (int nr)
#define DISK_TYPE_DOS_FFS 0x444f5301 /* DOS\1 */
#define CDFS_DOSTYPE 0x43440000 /* CDxx */
-typedef struct _dpacket {
- uaecptr packet_addr;
- uae_u8 *packet_data;
- uae_u8 packet_array[dp_Max];
- bool need_flush;
-} dpacket;
-
typedef struct {
uae_u32 uniq;
/* The directory we're going through. */
@@ -936,7 +896,7 @@ typedef struct {
struct lockrecord
{
struct lockrecord *next;
- dpacket *packet;
+ uae_u32 packet;
uae_u64 pos;
uae_u64 len;
uae_u32 mode;
@@ -986,7 +946,6 @@ typedef struct _unit {
/* Amiga stuff */
uaecptr dosbase;
- /* volume points to our IO board, always 1:1 mapping */
uaecptr volume;
uaecptr port; /* Our port */
uaecptr locklist;
@@ -1005,7 +964,7 @@ typedef struct _unit {
/* ExKeys */
ExamineKey examine_keys[EXKEYS];
int next_exkey;
- unsigned int total_locked_ainos;
+ unsigned long total_locked_ainos;
/* ExAll */
ExAllKey exalls[EXALLKEYS];
@@ -1017,10 +976,10 @@ typedef struct _unit {
struct lockrecord *waitingrecords;
a_inode rootnode;
- unsigned int aino_cache_size;
+ unsigned long aino_cache_size;
a_inode *aino_hash[MAX_AINO_HASH];
- unsigned int nr_cache_hits;
- unsigned int nr_cache_lookups;
+ unsigned long nr_cache_hits;
+ unsigned long nr_cache_lookups;
struct notify *notifyhash[NOTIFY_HASH_SIZE];
@@ -1049,141 +1008,112 @@ typedef struct _unit {
static uae_u32 a_uniq, key_uniq;
-#define PUT_PCK_RES1(p,v) do { put_long_host((p)->packet_data + dp_Res1, (v)); } while (0)
-#define PUT_PCK_RES2(p,v) do { put_long_host((p)->packet_data + dp_Res2, (v)); } while (0)
-#define GET_PCK_TYPE(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Type)))
-#define GET_PCK_RES1(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Res1)))
-#define GET_PCK_RES2(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Res2)))
-#define GET_PCK_ARG1(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Arg1)))
-#define GET_PCK_ARG2(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Arg2)))
-#define GET_PCK_ARG3(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Arg3)))
-#define GET_PCK_ARG4(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Arg4)))
-#define GET_PCK_ARG5(p) ((uae_s32)(get_long_host((p)->packet_data + dp_Arg5)))
-
-#define PUT_PCK64_RES0(p,v) do { put_long_host((p)->packet_data + dp64_Res0, (v)); } while (0)
-#define PUT_PCK64_RES1(p,v) do { put_long_host((p)->packet_data + dp64_Res1, (((uae_u64)v) >> 32)); put_long_host((p)->packet_data + dp64_Res1 + 4, ((uae_u32)v)); } while (0)
-#define PUT_PCK64_RES2(p,v) do { put_long_host((p)->packet_data + dp64_Res2, (v)); } while (0)
-
-#define GET_PCK64_TYPE(p) ((uae_s32)(get_long_host((p)->packet_data + dp64_Type)))
-#define GET_PCK64_RES0(p) ((uae_s32)(get_long_host((p)->packet_data + dp64_Res0)))
-#define GET_PCK64_RES1(p) ( (((uae_s64)(get_long_host((p)->packet_data + dp64_Res1))) << 32) | (((uae_s64)(get_long_host((p)->packet_data + dp64_Res1 + 4))) << 0) )
-#define GET_PCK64_ARG1(p) ((uae_s32)(get_long_host((p)->packet_data + dp64_Arg1)))
-#define GET_PCK64_ARG2(p) ( (((uae_s64)(get_long_host((p)->packet_data + dp64_Arg2))) << 32) | (((uae_s64)(get_long_host((p)->packet_data + dp64_Arg2 + 4))) << 0) )
-#define GET_PCK64_ARG3(p) ((uae_s32)(get_long_host((p)->packet_data + dp64_Arg3)))
-#define GET_PCK64_ARG4(p) ((uae_s32)(get_long_host((p)->packet_data + dp64_Arg4)))
-#define GET_PCK64_ARG5(p) ( (((uae_s64)(get_long_host((p)->packet_data + dp64_Arg5))) << 32) | (((uae_s64)(get_long_host((p)->packet_data + dp64_Arg5 + 4))) << 0) )
-
-static void readdpacket(TrapContext *ctx, dpacket *packet, uaecptr pck)
+static void set_quadp(uaecptr p, uae_s64 v)
{
- // Read enough to get also all 64-bit fields
- packet->packet_addr = pck;
- if (!valid_address(pck, dp_Max)) {
- trap_get_bytes(ctx, packet->packet_array, pck, dp_Max);
- packet->packet_data = packet->packet_array;
- packet->need_flush = true;
- } else {
- packet->packet_data = get_real_address(pck);
- packet->need_flush = false;
- }
-}
-static void writedpacket(TrapContext *ctx, dpacket *packet)
-{
- if (!packet->need_flush)
+ if (!valid_address(p, 8))
return;
- int type = GET_PCK_TYPE(packet);
- if (type >= 8000 && type < 9000 && GET_PCK64_RES0(packet) == DP64_INIT) {
- // 64-bit RESx fields
- trap_put_bytes(ctx, packet->packet_data + 12, packet->packet_addr + 12, 32 - 12);
- } else {
- // dp_Res1 and dp_Res2
- trap_put_bytes(ctx, packet->packet_data + 12, packet->packet_addr + 12, 20 - 12);
- }
+ put_long(p, v >> 32);
+ put_long(p + 4, (uae_u64)v);
}
-
-static void set_quadp(TrapContext *ctx, uaecptr p, uae_s64 v)
+static uae_u64 get_quadp(uaecptr p)
{
- if (!trap_valid_address(ctx, p, 8))
- return;
- trap_put_quad(ctx, p, v);
-}
-static uae_u64 get_quadp(TrapContext *ctx, uaecptr p)
-{
- if (!trap_valid_address(ctx, p, 8))
+ if (!valid_address(p, 8))
return 0;
- return trap_get_quad(ctx, p);
+ return ((uae_u64)get_long(p) << 32) | get_long(p + 4);
}
+typedef uaecptr dpacket;
+#define PUT_PCK_RES1(p,v) do { put_long ((p) + dp_Res1, (v)); } while (0)
+#define PUT_PCK_RES2(p,v) do { put_long ((p) + dp_Res2, (v)); } while (0)
+#define GET_PCK_TYPE(p) ((uae_s32)(get_long ((p) + dp_Type)))
+#define GET_PCK_RES1(p) ((uae_s32)(get_long ((p) + dp_Res1)))
+#define GET_PCK_RES2(p) ((uae_s32)(get_long ((p) + dp_Res2)))
+#define GET_PCK_ARG1(p) ((uae_s32)(get_long ((p) + dp_Arg1)))
+#define GET_PCK_ARG2(p) ((uae_s32)(get_long ((p) + dp_Arg2)))
+#define GET_PCK_ARG3(p) ((uae_s32)(get_long ((p) + dp_Arg3)))
+#define GET_PCK_ARG4(p) ((uae_s32)(get_long ((p) + dp_Arg4)))
+#define GET_PCK_ARG5(p) ((uae_s32)(get_long ((p) + dp_Arg5)))
+
+#define PUT_PCK64_RES0(p,v) do { put_long ((p) + dp64_Res0, (v)); } while (0)
+#define PUT_PCK64_RES1(p,v) do { put_long ((p) + dp64_Res1, (((uae_u64)v) >> 32)); put_long ((p) + dp64_Res1 + 4, ((uae_u32)v)); } while (0)
+#define PUT_PCK64_RES2(p,v) do { put_long ((p) + dp64_Res2, (v)); } while (0)
+
+#define GET_PCK64_TYPE(p) ((uae_s32)(get_long ((p) + dp64_Type)))
+#define GET_PCK64_RES0(p) ((uae_s32)(get_long ((p) + dp64_Res0)))
+#define GET_PCK64_RES1(p) ( (((uae_s64)(get_long ((p) + dp64_Res1))) << 32) | (((uae_s64)(get_long ((p) + dp64_Res1 + 4))) << 0) )
+#define GET_PCK64_ARG1(p) ((uae_s32)(get_long ((p) + dp64_Arg1)))
+#define GET_PCK64_ARG2(p) ( (((uae_s64)(get_long ((p) + dp64_Arg2))) << 32) | (((uae_s64)(get_long ((p) + dp64_Arg2 + 4))) << 0) )
+#define GET_PCK64_ARG3(p) ((uae_s32)(get_long ((p) + dp64_Arg3)))
+#define GET_PCK64_ARG4(p) ((uae_s32)(get_long ((p) + dp64_Arg4)))
+#define GET_PCK64_ARG5(p) ( (((uae_s64)(get_long ((p) + dp64_Arg5))) << 32) | (((uae_s64)(get_long ((p) + dp64_Arg5 + 4))) << 0) )
+
static int flush_cache(Unit *unit, int num);
-static TCHAR *char1 (TrapContext *ctx, uaecptr addr)
+static TCHAR *char1 (uaecptr addr)
{
- uae_char buf[1024];
-
-#if TRAPMD
- trap_get_string(ctx, (uae_u8*)buf, addr, sizeof(buf));
-#else
+ static uae_char buf[1024];
+ static TCHAR bufx[1024];
unsigned int i = 0;
do {
- buf[i] = trap_get_byte(ctx, addr);
+ buf[i] = get_byte(addr);
addr++;
} while (buf[i++] && i < sizeof(buf));
-#endif
- return au_fs(buf);
+ return au_fs_copy (bufx, sizeof (bufx) / sizeof (TCHAR), buf);
}
-static TCHAR *bstr1 (TrapContext *ctx, uaecptr addr)
+static TCHAR *bstr1 (uaecptr addr)
{
- uae_char buf[257];
- int n = trap_get_byte(ctx, addr);
-
+ static TCHAR bufx[257];
+ static uae_char buf[257];
+ int i;
+ int n = get_byte(addr);
addr++;
-#if TRAPMD
- trap_get_bytes(ctx, (uae_u8*)buf, addr, n);
-#else
- for (int i = 0; i < n; i++, addr++)
- buf[i] = trap_get_byte(ctx, addr);
-#endif
- buf[n] = 0;
- return au_fs(buf);
+
+ for (i = 0; i < n; i++, addr++)
+ buf[i] = get_byte(addr);
+ buf[i] = 0;
+ return au_fs_copy (bufx, sizeof (bufx) / sizeof (TCHAR), buf);
}
-static TCHAR *bstr (TrapContext *ctx, Unit *unit, uaecptr addr)
+static TCHAR *bstr (Unit *unit, uaecptr addr)
{
- int n = trap_get_byte(ctx, addr);
+ int i;
+ int n = get_byte(addr);
uae_char buf[257];
addr++;
-#if TRAPMD
- trap_get_bytes(ctx, (uae_u8*)buf, addr, n);
-#else
- for (int i = 0; i < n; i++, addr++)
- buf[i] = trap_get_byte(ctx, addr);
-#endif
- buf[n] = 0;
+ for (i = 0; i < n; i++, addr++)
+ buf[i] = get_byte (addr);
+ buf[i] = 0;
au_fs_copy (unit->tmpbuf3, sizeof (unit->tmpbuf3) / sizeof (TCHAR), buf);
return unit->tmpbuf3;
}
-static TCHAR *cstr (TrapContext *ctx, Unit *unit, uaecptr addr)
+static TCHAR *cstr (Unit *unit, uaecptr addr)
{
+ int i;
uae_char buf[257];
- trap_get_string(ctx, buf, addr, sizeof buf);
+ for (i = 0;;i++,addr++) {
+ buf[i] = get_byte (addr);
+ if (!buf[i])
+ break;
+ }
au_fs_copy (unit->tmpbuf3, sizeof (unit->tmpbuf3) / sizeof (TCHAR), buf);
return unit->tmpbuf3;
}
-static TCHAR *bstr_cut (TrapContext *ctx, Unit *unit, uaecptr addr)
+static TCHAR *bstr_cut (Unit *unit, uaecptr addr)
{
TCHAR *p = unit->tmpbuf3;
int i, colon_seen = 0, off;
- int n = trap_get_byte(ctx, addr);
+ int n = get_byte (addr);
uae_char buf[257];
off = 0;
addr++;
for (i = 0; i < n; i++, addr++) {
- uae_u8 c = trap_get_byte(ctx, addr);
+ uae_u8 c = get_byte(addr);
buf[i] = c;
if (c == '/' || (c == ':' && colon_seen++ == 0))
off = i + 1;
@@ -1197,7 +1127,7 @@ static TCHAR *bstr_cut (TrapContext *ctx, Unit *unit, uaecptr addr)
static const uae_s64 msecs_per_day = 24 * 60 * 60 * 1000;
static const uae_s64 diff = ((8 * 365 + 2) * (24 * 60 * 60)) * (uae_u64)1000;
-void timeval_to_amiga (struct mytimeval *tv, int *days, int *mins, int *ticks, int tickcount)
+void timeval_to_amiga (struct mytimeval *tv, int *days, int *mins, int *ticks)
{
/* tv.tv_sec is secs since 1-1-1970 */
/* days since 1-1-1978 */
@@ -1212,10 +1142,10 @@ void timeval_to_amiga (struct mytimeval *tv, int *days, int *mins, int *ticks, i
t -= *days * msecs_per_day;
*mins = t / (60 * 1000);
t -= *mins * (60 * 1000);
- *ticks = t / (1000 / tickcount);
+ *ticks = t / (1000 / 50);
}
-void amiga_to_timeval (struct mytimeval *tv, int days, int mins, int ticks, int tickcount)
+void amiga_to_timeval (struct mytimeval *tv, int days, int mins, int ticks)
{
uae_s64 t;
@@ -1225,7 +1155,7 @@ void amiga_to_timeval (struct mytimeval *tv, int days, int mins, int ticks, int
days = 9900 * 365; // in future far enough?
if (mins < 0 || mins >= 24 * 60)
mins = 0;
- if (ticks < 0 || ticks >= 60 * tickcount)
+ if (ticks < 0 || ticks >= 60 * 50)
ticks = 0;
t = ticks * 20;
@@ -1239,7 +1169,8 @@ void amiga_to_timeval (struct mytimeval *tv, int days, int mins, int ticks, int
static Unit *units = 0;
-static Unit *find_unit (uaecptr port)
+static Unit*
+ find_unit (uaecptr port)
{
Unit* u;
for (u = units; u; u = u->next)
@@ -1346,19 +1277,6 @@ static uae_u32 fs_fsize (struct fs_filehandle *fsf)
return (uae_u32)fs_fsize64 (fsf);
}
-static uae_s64 key_filesize(Key *k)
-{
- if (k->aino->vfso)
- return k->aino->vfso->size;
- return fs_fsize64 (k->fd);
-}
-static uae_s64 key_seek(Key *k, uae_s64 offset, int whence)
-{
- if (k->aino->vfso)
- return k->file_pos;
- return fs_lseek64 (k->fd, offset, whence);
-}
-
static void set_volume_name (Unit *unit, struct mytimeval *tv)
{
int namelen;
@@ -1367,15 +1285,13 @@ static void set_volume_name (Unit *unit, struct mytimeval *tv)
s = ua_fs (unit->ui.volname, -1);
namelen = strlen (s);
- if (namelen >= 58)
- namelen = 58;
- put_byte (unit->volume + 64, namelen);
+ put_byte (unit->volume + 44, namelen);
for (i = 0; i < namelen; i++)
- put_byte (unit->volume + 64 + 1 + i, s[i]);
- put_byte (unit->volume + 64 + 1 + namelen, 0);
+ put_byte (unit->volume + 45 + i, s[i]);
+ put_byte (unit->volume + 45 + namelen, 0);
if (tv && (tv->tv_sec || tv->tv_usec)) {
int days, mins, ticks;
- timeval_to_amiga (tv, &days, &mins, &ticks, 50);
+ timeval_to_amiga (tv, &days, &mins, &ticks);
put_long (unit->volume + 16, days);
put_long (unit->volume + 20, mins);
put_long (unit->volume + 24, ticks);
@@ -1390,7 +1306,7 @@ static int filesys_isvolume(Unit *unit)
{
if (!unit->volume)
return 0;
- return get_byte (unit->volume + 64) || unit->ui.unknown_media;
+ return get_byte (unit->volume + 44) || unit->ui.unknown_media;
}
static void clear_exkeys(Unit *unit)
@@ -1462,38 +1378,25 @@ int filesys_eject (int nr)
}
static uae_u32 heartbeat;
+static int heartbeat_count;
+static int heartbeat_task;
-static uae_u32 REGPARAM2 debugger_helper(TrapContext *ctx)
+// This uses filesystem process to reduce resource usage
+void setsystime (void)
{
- int mode = trap_get_dreg(ctx, 1);
- switch (mode)
- {
- case 1:
- // Execute debugger_boot() to get here.
- write_log(_T("debugger #1\n"));
- // return RunCommand(() parameters
- // does nothing if D1 == 0.
- break;
- case 2:
- // called when RunCommand() returns
- // D0 = RunCommand() return code.
- write_log(_T("debugger #2\n"));
- break;
- default:
- write_log(_T("Unknown debugger hook %d\n"), mode);
- return 0;
- }
- return 1;
+ if (!currprefs.tod_hack || !rtarea_base)
+ return;
+ heartbeat = get_long (rtarea_base + RTAREA_HEARTBEAT);
+ heartbeat_task = 1;
+ heartbeat_count = 10;
}
-static void debugger_boot(void)
+static void setsystime_vblank (void)
{
Unit *u;
- TrapContext *ctx = NULL;
-
for (u = units; u; u = u->next) {
- if (is_virtual(u->unit) && filesys_isvolume(u)) {
- put_byte(u->volume + 173 - 32, get_byte(u->volume + 173 - 32) | 2);
+ if (is_virtual (u->unit) && filesys_isvolume (u)) {
+ put_byte (u->volume + 173 - 32, 1);
uae_Signal (get_long (u->volume + 176 - 32), 1 << 13);
break;
}
@@ -1504,7 +1407,6 @@ int filesys_insert (int nr, const TCHAR *volume, const TCHAR *rootdir, bool read
{
UnitInfo *ui;
Unit *u;
- TrapContext *ctx = NULL;
if (!mountertask)
return 0;
@@ -1560,7 +1462,7 @@ int filesys_insert (int nr, const TCHAR *volume, const TCHAR *rootdir, bool read
return 100 + nr;
}
-static uae_u32 filesys_media_change_reply (int mode)
+static uae_u32 filesys_media_change_reply (TrapContext *ctx, int mode)
{
int nr;
UnitInfo *ui = NULL;
@@ -1585,6 +1487,12 @@ static uae_u32 filesys_media_change_reply (int mode)
zfile_fclose_archive (u->zarchive);
u->zarchive = NULL;
u->ui.unknown_media = false;
+#ifdef RETROPLATFORM
+ if (ui->unit_type == UNIT_CDFS)
+ rp_cd_image_change (ui->cddevno, NULL);
+ else
+ rp_harddrive_image_change (nr, false, NULL);
+#endif
} else {
u->mount_changed = 0;
}
@@ -1595,7 +1503,6 @@ static uae_u32 filesys_media_change_reply (int mode)
struct mytimeval ctime = { 0 };
bool emptydrive = false;
struct uaedev_config_data *uci = NULL;
-
clear_exkeys (u);
xfree (u->ui.rootdir);
ui->rootdir = u->ui.rootdir = my_strdup (u->mount_rootdir);
@@ -1607,9 +1514,11 @@ static uae_u32 filesys_media_change_reply (int mode)
if (emptydrive)
return 0;
xfree (u->ui.volname);
- ui->volname = u->ui.volname = filesys_createvolname (u->mount_volume, u->mount_rootdir, u->zarchive, _T("removable"));
+ ui->volname = u->ui.volname = filesys_createvolname(u->mount_volume, u->mount_rootdir, u->zarchive, _T("removable"));
+#ifdef RETROPLATFORM
+ rp_harddrive_image_change (nr, u->mount_readonly, u->mount_rootdir);
+#endif
uci = getuci (currprefs.mountconfig, nr);
-
if (u->ui.unknown_media) {
write_log (_T("FILESYS: inserted unreadable volume NR=%d RO=%d\n"), nr, u->mount_readonly);
} else {
@@ -1626,7 +1535,7 @@ static uae_u32 filesys_media_change_reply (int mode)
if (uci != NULL)
uci->ci.readonly = u->mount_readonly;
}
- put_byte (u->volume + 64, 0);
+ put_byte (u->volume + 44, 0);
put_byte (u->volume + 172 - 32, 1);
}
@@ -1651,7 +1560,6 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf
int nr = -1;
TCHAR volname[MAX_DPATH], *volptr;
TCHAR devname[MAX_DPATH];
- TrapContext *ctx = NULL;
if (!mountertask)
return 0;
@@ -1692,10 +1600,9 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf
if (uci) {
volptr = my_strdup (uci->ci.volname);
} else {
- struct uaedev_config_info ci2 = { 0 };
- _tcscpy(ci2.rootdir, rootdir);
- target_get_volume_name (&mountinfo, &ci2, 1, 0, -1);
- _tcscpy(volname, ci2.volname);
+ struct uaedev_config_info ci2 = { 0 };
+ _tcscpy(ci2.rootdir, rootdir);
+ target_get_volume_name(&mountinfo, &ci2, 1, 0, -1);
volptr = volname;
if (!volname[0])
volptr = NULL;
@@ -1705,7 +1612,7 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf
}
}
if (!volptr) {
- volptr = filesys_createvolname (NULL, rootdir, NULL, _T("removable"));
+ volptr = filesys_createvolname(NULL, rootdir, NULL, _T("removable"));
_tcscpy (volname, volptr);
xfree (volptr);
volptr = volname;
@@ -1731,7 +1638,7 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf
if (uci)
_tcscpy (devname, uci->ci.devname);
else
- _stprintf (devname, _T("RDH%d"), autocreatedunit++);
+ _stprintf (devname, _T("RDH%d"), nr_units());
_tcscpy (ci.devname, devname);
_tcscpy (ci.volname, volptr);
_tcscpy (ci.rootdir, rootdir);
@@ -1751,17 +1658,6 @@ int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_conf
return 0;
}
-int hardfile_added (struct uaedev_config_info *ci)
-{
- if (ci->controller_type == HD_CONTROLLER_TYPE_PCMCIA) {
- if (ci->controller_type_unit == 1)
- return gayle_add_pcmcia_ide_unit(ci);
- if (ci->controller_type_unit == 0)
- return gayle_add_pcmcia_sram_unit(ci);
- }
- return 0;
-}
-
int hardfile_media_change (struct hardfiledata *hfd, struct uaedev_config_info *ci, bool inserted, bool timer)
{
if (!hfd)
@@ -1783,7 +1679,7 @@ int hardfile_media_change (struct hardfiledata *hfd, struct uaedev_config_info *
}
}
memcpy (&hfd->ci, &hfd->delayedci, sizeof (struct uaedev_config_info));
- if (hdf_open (hfd) <= 0) {
+ if (!hdf_open (hfd)) {
write_log (_T("HARDFILE: '%s' failed to open\n"), hfd->ci.rootdir);
return 0;
}
@@ -1819,9 +1715,23 @@ int hardfile_media_change (struct hardfiledata *hfd, struct uaedev_config_info *
return 0;
}
+int hardfile_remount (int nr)
+{
+ /* this does work but every media reinsert duplicates the device.. */
+#if 0
+ if (!mountertask)
+ return 0;
+ automountunit = nr;
+ uae_Signal (mountertask, 1 << 13);
+#endif
+ return 1;
+}
+
/* flags and comments supported? */
static int fsdb_cando (Unit *unit)
{
+ if (unit->volflags & MYVOLUMEINFO_ARCHIVE)
+ return 1;
return 1;
}
@@ -1831,6 +1741,7 @@ static void prepare_for_open (TCHAR *name)
static void de_recycle_aino (Unit *unit, a_inode *aino)
{
+ aino_test (aino);
if (aino->next == 0 || aino == &unit->rootnode)
return;
aino->next->prev = aino->prev;
@@ -1879,9 +1790,11 @@ static int flush_cache(Unit *unit, int num)
a_inode **aip;
aip = &parent->child;
+ aino_test (parent);
if (parent && !parent->locked_children) {
for (;;) {
a_inode *aino = *aip;
+ aino_test (aino);
if (aino == 0)
break;
/* Not recyclable if next == 0 (i.e., not chained into
@@ -1923,21 +1836,34 @@ static int flush_cache(Unit *unit, int num)
static void recycle_aino (Unit *unit, a_inode *new_aino)
{
+ aino_test (new_aino);
if (new_aino->dir || new_aino->shlock > 0
|| new_aino->elock || new_aino == &unit->rootnode)
/* Still in use */
return;
+ TRACE3((_T("Recycling; cache size %d, total_locked %d\n"),
+ unit->aino_cache_size, unit->total_locked_ainos));
if (unit->aino_cache_size > 5000 + unit->total_locked_ainos) {
/* Reap a few. */
flush_cache (unit, 50);
+#if 0
+ {
+ TCHAR buffer[40];
+ _stprintf (buffer, "%d ainos reaped.\n", i);
+ TRACE ((buffer));
+ }
+#endif
}
+ aino_test (new_aino);
/* Chain it into circular list. */
new_aino->next = unit->rootnode.next;
new_aino->prev = &unit->rootnode;
new_aino->prev->next = new_aino;
new_aino->next->prev = new_aino;
+ aino_test (new_aino->next);
+ aino_test (new_aino->prev);
unit->aino_cache_size++;
}
@@ -1955,7 +1881,7 @@ static void update_child_names (Unit *unit, a_inode *a, a_inode *parent)
TCHAR *new_name;
TCHAR dirsep[2] = { FSDB_DIR_SEPARATOR, '\0' };
- a->parent = parent;
+ a->parent = parent;
name_start = _tcsrchr (a->nname, FSDB_DIR_SEPARATOR);
if (name_start == 0) {
write_log (_T("malformed file name"));
@@ -1975,6 +1901,8 @@ static void update_child_names (Unit *unit, a_inode *a, a_inode *parent)
static void move_aino_children (Unit *unit, a_inode *from, a_inode *to)
{
+ aino_test (from);
+ aino_test (to);
to->child = from->child;
from->child = 0;
update_child_names (unit, to->child, to);
@@ -1984,6 +1912,9 @@ static void delete_aino (Unit *unit, a_inode *aino)
{
a_inode **aip;
+ TRACE((_T("deleting aino %x\n"), aino->uniq));
+
+ aino_test (aino);
aino->dirty = 1;
aino->deleted = 1;
de_recycle_aino (unit, aino);
@@ -1991,13 +1922,16 @@ static void delete_aino (Unit *unit, a_inode *aino)
/* If any ExKeys are currently pointing at us, advance them. */
if (aino->parent->exnext_count > 0) {
int i;
+ TRACE((_T("entering exkey validation\n")));
for (i = 0; i < EXKEYS; i++) {
ExamineKey *k = unit->examine_keys + i;
if (k->uniq == 0)
continue;
if (k->aino == aino->parent) {
+ TRACE((_T("Same parent found for %d\n"), i));
if (k->curr_file == aino) {
k->curr_file = aino->sibling;
+ TRACE((_T("Advancing curr_file\n")));
}
}
}
@@ -2061,11 +1995,12 @@ static a_inode *lookup_aino (Unit *unit, uae_u32 uniq)
unit->nr_cache_hits++;
unit->nr_cache_lookups++;
unit->aino_hash[hash] = a;
+ aino_test (a);
return a;
}
-static a_inode *aino_from_lock (TrapContext *ctx, Unit *unit, uaecptr lock)
+static a_inode *aino_from_lock (Unit *unit, uaecptr lock)
{
- return lookup_aino (unit, trap_get_long(ctx, lock + 4));
+ return lookup_aino (unit, get_long (lock + 4));
}
TCHAR *build_nname (const TCHAR *d, const TCHAR *n)
@@ -2092,6 +2027,7 @@ TCHAR *build_aname (const TCHAR *d, const TCHAR *n)
static TCHAR *get_nname (Unit *unit, a_inode *base, TCHAR *rel, TCHAR **modified_rel, uae_u64 *uniq_ext)
{
TCHAR *found;
+ TCHAR *p = 0;
*modified_rel = 0;
@@ -2101,6 +2037,8 @@ static TCHAR *get_nname (Unit *unit, a_inode *base, TCHAR *rel, TCHAR **modified
return NULL;
}
+ aino_test (base);
+
/* If we have a mapping of some other aname to "rel", we must pretend
* it does not exist.
* This can happen for example if an Amiga program creates a
@@ -2132,15 +2070,27 @@ static TCHAR *create_nname (Unit *unit, a_inode *base, TCHAR *rel)
{
TCHAR *p;
+ aino_test (base);
/* We are trying to create a file called REL. */
/* If the name is used otherwise in the directory (or globally), we
* need a new unique nname. */
if (fsdb_name_invalid (rel) || fsdb_used_as_nname (base, rel)) {
+#if 0
+oh_dear:
+#endif
p = fsdb_create_unique_nname (base, rel);
return p;
}
p = build_nname (base->nname, rel);
+#if 0
+ /* Delete this code once we know everything works. */
+ if (access (p, R_OK) >= 0 || errno != ENOENT) {
+ write_log (_T("Filesystem in trouble... please report.\n"));
+ xfree (p);
+ goto oh_dear;
+ }
+#endif
return p;
}
@@ -2211,6 +2161,9 @@ static void init_child_aino (Unit *unit, a_inode *base, a_inode *aino)
base->locked_children++;
}
init_child_aino_tree(unit, base, aino);
+
+ aino_test_init (aino);
+ aino_test (aino);
}
static a_inode *new_child_aino (Unit *unit, a_inode *base, TCHAR *rel)
@@ -2220,6 +2173,8 @@ static a_inode *new_child_aino (Unit *unit, a_inode *base, TCHAR *rel)
a_inode *aino = NULL;
int isvirtual = unit->volflags & MYVOLUMEINFO_ARCHIVE;
+ TRACE((_T("new_child_aino %s, %s\n"), base->aname, rel));
+
if (!isvirtual)
aino = fsdb_lookup_aino_aname (base, rel);
if (aino == 0) {
@@ -2248,6 +2203,7 @@ static a_inode *new_child_aino (Unit *unit, a_inode *base, TCHAR *rel)
init_child_aino (unit, base, aino);
recycle_aino (unit, aino);
+ TRACE((_T("created aino %x, lookup, amigaos_mode %d\n"), aino->uniq, aino->amigaos_mode));
return aino;
}
@@ -2273,6 +2229,7 @@ static a_inode *create_child_aino (Unit *unit, a_inode *base, TCHAR *rel, int is
aino->dirty = 1;
recycle_aino (unit, aino);
+ TRACE((_T("created aino %x, create\n"), aino->uniq));
return aino;
}
@@ -2281,6 +2238,9 @@ static a_inode *lookup_child_aino (Unit *unit, a_inode *base, TCHAR *rel, int *e
a_inode *c = base->child;
int l0 = _tcslen (rel);
+ aino_test (base);
+ aino_test (c);
+
if (base->dir == 0) {
*err = ERROR_OBJECT_WRONG_TYPE;
return 0;
@@ -2302,12 +2262,15 @@ static a_inode *lookup_child_aino (Unit *unit, a_inode *base, TCHAR *rel, int *e
}
/* Different version because for this one, REL is an nname. */
-static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, TCHAR *rel, uae_u32 *err, uae_u64 uniq_external, struct virtualfilesysobject *vfso)
+static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, TCHAR *rel, uae_u32 *err, uae_u64 uniq_external)
{
a_inode *c = base->child;
int l0 = _tcslen (rel);
int isvirtual = unit->volflags & MYVOLUMEINFO_ARCHIVE;
+ aino_test (base);
+ aino_test (c);
+
*err = 0;
while (c != 0) {
int l1 = _tcslen (c->nname);
@@ -2319,7 +2282,7 @@ static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, TCHAR *
}
if (c != 0)
return c;
- if (!isvirtual && !vfso)
+ if (!isvirtual)
c = fsdb_lookup_aino_nname (base, rel);
if (c == 0) {
c = xcalloc (a_inode, 1);
@@ -2333,22 +2296,18 @@ static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, TCHAR *
c->comment = 0;
c->uniq_external = uniq_external;
c->has_dbentry = 0;
- if (vfso) {
- c->dir = vfso->dir;
- c->comment = my_strdup(vfso->comment);
- c->amigaos_mode = vfso->amigaos_mode;
- c->vfso = vfso;
- } else if (!fill_file_attrs (unit, base, c)) {
+ if (!fill_file_attrs(unit, base, c)) {
xfree (c);
*err = ERROR_NO_FREE_STORE;
return 0;
}
- if (c->dir && !isvirtual && !vfso)
+ if (c->dir && !isvirtual)
fsdb_clean_dir (c);
}
init_child_aino (unit, base, c);
recycle_aino (unit, c);
+ TRACE((_T("created aino %x, exnext\n"), c->uniq));
return c;
}
@@ -2360,7 +2319,10 @@ static a_inode *get_aino (Unit *unit, a_inode *base, const TCHAR *rel, int *err)
a_inode *curr;
int i;
+ aino_test (base);
+
*err = 0;
+ TRACE((_T("get_path(%s,%s)\n"), base->aname, rel));
/* root-relative path? */
for (i = 0; rel[i] && rel[i] != '/' && rel[i] != ':'; i++)
@@ -2377,27 +2339,28 @@ static a_inode *get_aino (Unit *unit, a_inode *base, const TCHAR *rel, int *err)
if (*p == '/') {
if (curr->parent != 0)
curr = curr->parent;
- p++;
- } else {
- a_inode *next;
+ p++;
+ } else {
+ a_inode *next;
- TCHAR *component_end;
- component_end = _tcschr (p, '/');
- if (component_end != 0)
- *component_end = '\0';
- next = lookup_child_aino (unit, curr, p, err);
- if (next == 0) {
- /* if only last component not found, return parent dir. */
- if (*err != ERROR_OBJECT_NOT_AROUND || component_end != 0)
- curr = NULL;
- /* ? what error is appropriate? */
- break;
- }
- curr = next;
- if (component_end)
- p = component_end+1;
- else
- break;
+ TCHAR *component_end;
+ component_end = _tcschr (p, '/');
+ if (component_end != 0)
+ *component_end = '\0';
+ next = lookup_child_aino (unit, curr, p, err);
+ if (next == 0) {
+ /* if only last component not found, return parent dir. */
+ if (*err != ERROR_OBJECT_NOT_AROUND || component_end != 0)
+ curr = NULL;
+ /* ? what error is appropriate? */
+ break;
+ }
+ curr = next;
+ if (component_end)
+ p = component_end+1;
+ else
+ break;
+
}
}
xfree (tmp);
@@ -2423,6 +2386,15 @@ static Notify *new_notify (Unit *unit, TCHAR *name)
return n;
}
+#if 0
+static void free_notify_item(Notify *n)
+{
+ xfree(n->fullname);
+ xfree(n->partname);
+ xfree(n);
+}
+#endif
+
static void free_notify (Unit *unit, int hash, Notify *n)
{
Notify *n1, *prev = 0;
@@ -2448,7 +2420,7 @@ static void startup_update_unit (Unit *unit, UnitInfo *uinfo)
unit->ui.volname = my_strdup (uinfo->volname); /* might free later for rename */
}
-static Unit *startup_create_unit (TrapContext *ctx, UnitInfo *uinfo, int num)
+static Unit *startup_create_unit (UnitInfo *uinfo, int num)
{
int i;
Unit *unit, *u;
@@ -2466,7 +2438,7 @@ static Unit *startup_create_unit (TrapContext *ctx, UnitInfo *uinfo, int num)
uinfo->self = unit;
unit->volume = 0;
- unit->port = trap_get_areg(ctx, 5);
+ unit->port = m68k_areg (regs, 5);
unit->unit = num;
startup_update_unit (unit, uinfo);
@@ -2503,6 +2475,7 @@ static Unit *startup_create_unit (TrapContext *ctx, UnitInfo *uinfo, int num)
unit->rootnode.comment = 0;
unit->rootnode.has_dbentry = 0;
unit->rootnode.volflags = uinfo->volflags;
+ aino_test_init (&unit->rootnode);
unit->aino_cache_size = 0;
for (i = 0; i < MAX_AINO_HASH; i++)
unit->aino_hash[i] = 0;
@@ -2525,7 +2498,7 @@ static void filesys_start_thread (UnitInfo *ui, int nr)
if (is_virtual (nr)) {
ui->unit_pipe = xmalloc (smp_comm_pipe, 1);
ui->back_pipe = xmalloc (smp_comm_pipe, 1);
- init_comm_pipe (ui->unit_pipe, 400, 3);
+ init_comm_pipe (ui->unit_pipe, 100, 3);
init_comm_pipe (ui->back_pipe, 100, 1);
uae_start_thread (_T("filesys"), filesys_thread, (void *)ui, &ui->tid);
}
@@ -2535,24 +2508,18 @@ static void filesys_start_thread (UnitInfo *ui, int nr)
}
}
-static uae_u32 REGPARAM2 startup_handler (TrapContext *ctx)
+static uae_u32 REGPARAM2 startup_handler (TrapContext *context)
{
- uae_u32 mode = trap_get_dreg(ctx, 0);
-
- if (mode == 1) {
- return 0;
- }
-
/* Just got the startup packet. It's in D3. DosBase is in A2,
* our allocated volume structure is in A3, A5 is a pointer to
* our port. */
- uaecptr rootnode = trap_get_long(ctx, trap_get_areg(ctx, 2) + 34);
- uaecptr dos_info = trap_get_long(ctx, rootnode + 24) << 2;
- uaecptr pkt = trap_get_dreg(ctx, 3);
- uaecptr arg1 = trap_get_long(ctx, pkt + dp_Arg1);
- uaecptr arg2 = trap_get_long(ctx, pkt + dp_Arg2);
- uaecptr arg3 = trap_get_long(ctx, pkt + dp_Arg3);
- uaecptr devnode, volume;
+ uaecptr rootnode = get_long (m68k_areg (regs, 2) + 34);
+ uaecptr dos_info = get_long (rootnode + 24) << 2;
+ uaecptr pkt = m68k_dreg (regs, 3);
+ uaecptr arg1 = get_long (pkt + dp_Arg1);
+ uaecptr arg2 = get_long (pkt + dp_Arg2);
+ uaecptr arg3 = get_long (pkt + dp_Arg3);
+ uaecptr devnode;
int nr;
Unit *unit;
UnitInfo *uinfo;
@@ -2573,28 +2540,28 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *ctx)
continue;
if (!is_virtual (nr))
continue;
+
if (mountinfo.ui[nr].startup == arg2)
break;
}
if (nr == MAX_FILESYSTEM_UNITS) {
write_log (_T("Attempt to mount unknown filesystem device\n"));
- trap_put_long(ctx, pkt + dp_Res1, DOS_FALSE);
- trap_put_long(ctx, pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED);
+ put_long (pkt + dp_Res1, DOS_FALSE);
+ put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED);
return 0;
}
uinfo = mountinfo.ui + nr;
//devnode = arg3 << 2;
devnode = uinfo->devicenode;
- volume = trap_get_areg(ctx, 3) + 32;
cdays = 3800 + nr;
ed = my_existsdir (uinfo->rootdir);
ef = my_existsfile (uinfo->rootdir);
if (!uinfo->wasisempty && !ef && !ed) {
write_log (_T("Failed attempt to mount device '%s' (%s)\n"), uinfo->devname, uinfo->rootdir);
- trap_put_long(ctx, pkt + dp_Res1, DOS_FALSE);
- trap_put_long(ctx, pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED);
+ put_long (pkt + dp_Res1, DOS_FALSE);
+ put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED);
return 0;
}
@@ -2602,7 +2569,7 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *ctx)
late = 1;
filesys_start_thread (uinfo, nr);
}
- unit = startup_create_unit(ctx, uinfo, nr);
+ unit = startup_create_unit (uinfo, nr);
unit->volflags = uinfo->volflags;
unit->rootnode.uniq_external = uniq;
@@ -2612,20 +2579,20 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *ctx)
unit->ui.volname, unit->volflags, uinfo->wasisempty, ed, ef, unit->ui.rootdir);
/* fill in our process in the device node */
- trap_put_long(ctx, devnode + 8, unit->port);
- unit->dosbase = trap_get_areg(ctx, 2);
+ put_long (devnode + 8, unit->port);
+ unit->dosbase = m68k_areg (regs, 2);
/* make new volume */
- unit->volume = volume;
+ unit->volume = m68k_areg (regs, 3) + 32;
put_long (unit->volume + 180 - 32, devnode);
#ifdef UAE_FILESYS_THREADS
- unit->locklist = trap_get_areg(ctx, 3) + 8;
+ unit->locklist = m68k_areg (regs, 3) + 8;
#else
- unit->locklist = trap_get_areg(ctx, 3);
+ unit->locklist = m68k_areg (regs, 3);
#endif
- unit->dummy_message = trap_get_areg(ctx, 3) + 12;
+ unit->dummy_message = m68k_areg (regs, 3) + 12;
- trap_put_long(ctx, unit->dummy_message + 10, 0);
+ put_long (unit->dummy_message + 10, 0);
/* Prepare volume information */
put_long (unit->volume + 4, 2); /* Type = dt_volume */
@@ -2634,9 +2601,9 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *ctx)
put_long (unit->volume + 20, 0);
put_long (unit->volume + 24, 0);
put_long (unit->volume + 28, 0); /* lock list */
- put_long (unit->volume + 40, (unit->volume + 64) >> 2); /* Name */
+ put_long (unit->volume + 40, (unit->volume + 44) >> 2); /* Name */
- put_byte (unit->volume + 64, 0);
+ put_byte (unit->volume + 44, 0);
if (!uinfo->wasisempty && !uinfo->unknown_media) {
int isvirtual = unit->volflags & (MYVOLUMEINFO_ARCHIVE);
/* Set volume if non-empty */
@@ -2646,30 +2613,25 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *ctx)
}
put_long (unit->volume + 8, unit->port);
- /* not FFS because it is not understood by WB1.x C:Info */
- put_long(unit->volume + 32, DISK_TYPE_DOS);
+ put_long (unit->volume + 32, DISK_TYPE_DOS_FFS);
- trap_put_long(ctx, pkt + dp_Res1, DOS_TRUE);
+ put_long (pkt + dp_Res1, DOS_TRUE);
return 1 | (late ? 2 : 0);
}
-static bool is_writeprotected(Unit *unit)
-{
- return unit->ui.readonly || unit->ui.locked || currprefs.harddrive_read_only;
-}
-
-static void do_info(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr info, bool disk_info)
+static void
+ do_info (Unit *unit, dpacket packet, uaecptr info, bool disk_info)
{
struct fs_usage fsu;
int ret, err = ERROR_NO_FREE_STORE;
int blocksize, nr;
uae_u32 dostype;
bool fs = false, media = false;
- uae_u8 buf[36] = { 0 }; // InfoData
blocksize = 512;
- dostype = get_long(unit->volume + 32);
+ /* not FFS because it is not understood by WB1.x C:Info */
+ dostype = DISK_TYPE_DOS;
nr = unit->unit;
if (unit->volflags & MYVOLUMEINFO_ARCHIVE) {
ret = zfile_fs_usage_archive (unit->ui.rootdir, 0, &fsu);
@@ -2687,72 +2649,61 @@ static void do_info(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr info,
PUT_PCK_RES2 (packet, err);
return;
}
- put_long_host(buf, 0); /* errors */
- put_long_host(buf + 4, nr); /* unit number */
- put_long_host(buf + 8, is_writeprotected(unit) ? 80 : 82); /* state */
- put_long_host(buf + 20, blocksize); /* bytesperblock */
- put_long_host(buf + 32, 0); /* inuse */
+
+ put_long (info, 0); /* errors */
+ put_long (info + 4, nr); /* unit number */
+ put_long (info + 8, unit->ui.readonly || unit->ui.locked ? 80 : 82); /* state */
+ put_long (info + 20, blocksize); /* bytesperblock */
+ put_long (info + 32, 0); /* inuse */
if (unit->ui.unknown_media) {
if (!disk_info) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_NOT_A_DOS_DISK);
return;
}
- put_long_host(buf + 12, 0);
- put_long_host(buf + 16, 0);
- put_long_host(buf + 24, ('B' << 24) | ('A' << 16) | ('D' << 8) | (0 << 0)); /* ID_UNREADABLE_DISK */
- put_long_host(buf + 28, 0);
+ put_long (info + 12, 0);
+ put_long (info + 16, 0);
+ put_long (info + 24, ('B' << 24) | ('A' << 16) | ('D' << 8) | (0 << 0)); /* ID_UNREADABLE_DISK */
+ put_long (info + 28, 0);
} else if (!media) {
if (!disk_info) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_NO_DISK);
return;
}
- put_long_host(buf + 12, 0);
- put_long_host(buf + 16, 0);
- put_long_host(buf + 24, -1); /* ID_NO_DISK_PRESENT */
- put_long_host(buf + 28, 0);
+ put_long (info + 12, 0);
+ put_long (info + 16, 0);
+ put_long (info + 24, -1); /* ID_NO_DISK_PRESENT */
+ put_long (info + 28, 0);
} else {
if (fs && currprefs.filesys_limit) {
- if (fsu.total > (uae_s64)currprefs.filesys_limit * 1024) {
- uae_s64 oldtotal = fsu.total;
- fsu.total = currprefs.filesys_limit * 1024;
- fsu.avail = ((fsu.avail / 1024) * (fsu.total / 1024)) / (oldtotal / 1024);
- fsu.avail *= 1024;
+ if (fsu.fsu_blocks > (uae_u64)currprefs.filesys_limit * 1024 / blocksize) {
+ uae_u32 oldblocks = fsu.fsu_blocks;
+ fsu.fsu_blocks = (uae_u32)((uae_u64)currprefs.filesys_limit * 1024 / blocksize);
+ fsu.fsu_bavail = (uae_u32)((uae_u64)fsu.fsu_bavail * fsu.fsu_blocks / oldblocks);
}
}
- uae_s64 numblocks = 0;
- while (blocksize < 32768 || numblocks == 0) {
- numblocks = fsu.total / blocksize;
- if (numblocks <= 10)
- numblocks = 10;
- if (numblocks <= 0x7fffffff)
- break;
- blocksize *= 2;
- }
- uae_s64 inuse = (numblocks * blocksize - fsu.avail) / blocksize;
- if (inuse > numblocks)
- inuse = numblocks;
-
- put_long_host(buf + 12, (uae_u32)numblocks); /* numblocks */
- put_long_host(buf + 16, (uae_u32)inuse); /* inuse */
- put_long_host(buf + 20, blocksize); /* bytesperblock */
- put_long_host(buf + 24, dostype); /* disk type */
- put_long_host(buf + 28, unit->volume >> 2); /* volume node */
- put_long_host(buf + 32, (get_long(unit->volume + 28) || unit->keys) ? -1 : 0); /* inuse */
+ put_long (info + 12, fsu.fsu_blocks ); /* numblocks */
+ put_long (info + 16, fsu.fsu_blocks - fsu.fsu_bavail); /* inuse */
+ put_long (info + 24, dostype); /* disk type */
+ put_long (info + 28, unit->volume >> 2); /* volume node */
+ put_long (info + 32, (get_long (unit->volume + 28) || unit->keys) ? -1 : 0); /* inuse */
}
- trap_put_bytes(ctx, buf, info, sizeof buf);
PUT_PCK_RES1 (packet, DOS_TRUE);
}
-static void action_disk_info(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_disk_info (Unit *unit, dpacket packet)
{
- do_info(ctx, unit, packet, GET_PCK_ARG1 (packet) << 2, true);
+ TRACE((_T("ACTION_DISK_INFO\n")));
+ do_info (unit, packet, GET_PCK_ARG1 (packet) << 2, true);
}
-static void action_info(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_info (Unit *unit, dpacket packet)
{
- do_info(ctx, unit, packet, GET_PCK_ARG2 (packet) << 2, false);
+ TRACE((_T("ACTION_INFO\n")));
+ do_info (unit, packet, GET_PCK_ARG2 (packet) << 2, false);
}
static void free_key (Unit *unit, Key *k)
@@ -2809,76 +2760,73 @@ static Key *new_key (Unit *unit)
return k;
}
-static a_inode *find_aino (TrapContext *ctx, Unit *unit, uaecptr lock, const TCHAR *name, int *err)
+#if TRACING_ENABLED
+static void
+ dumplock (Unit *unit, uaecptr lock)
+{
+ a_inode *a;
+ TRACE((_T("LOCK: 0x%lx"), lock));
+ if (!lock) {
+ TRACE((_T("\n")));
+ return;
+ }
+ TRACE((_T("{ next=0x%lx, mode=%ld, handler=0x%lx, volume=0x%lx, aino %lx "),
+ get_long (lock) << 2, get_long (lock+8),
+ get_long (lock+12), get_long (lock+16),
+ get_long (lock + 4)));
+ a = aino_from_lock (unit, lock);
+ if (a == 0) {
+ TRACE((_T("not found!")));
+ } else {
+ TRACE((_T("%s"), a->nname));
+ }
+ TRACE((_T(" }\n")));
+}
+#endif
+
+static a_inode *find_aino (Unit *unit, uaecptr lock, const TCHAR *name, int *err)
{
a_inode *a;
if (lock) {
- a_inode *olda = aino_from_lock(ctx, unit, lock);
+ a_inode *olda = aino_from_lock (unit, lock);
if (olda == 0) {
/* That's the best we can hope to do. */
a = get_aino (unit, &unit->rootnode, name, err);
} else {
+ TRACE((_T("aino: 0x%08lx"), (unsigned long int)olda->uniq));
+ TRACE((_T(" \"%s\"\n"), olda->nname));
a = get_aino (unit, olda, name, err);
}
} else {
a = get_aino (unit, &unit->rootnode, name, err);
}
+ if (a) {
+ TRACE((_T("aino=\"%s\"\n"), a->nname));
+ }
+ aino_test (a);
return a;
}
-static uaecptr make_lock (TrapContext *ctx, Unit *unit, uae_u32 uniq, long mode)
+static uaecptr make_lock (Unit *unit, uae_u32 uniq, long mode)
{
/* allocate lock from the list kept by the assembly code */
uaecptr lock;
-#if TRAPMD
-
- struct trapmd md1[] =
- {
- { TRAPCMD_GET_LONG, { unit->locklist }, 1, 0 },
- { TRAPCMD_GET_LONG, { 0 }, 2, 1 },
- { TRAPCMD_PUT_LONG, { unit->locklist, 0 } },
- };
- trap_multi(ctx, md1, sizeof md1 / sizeof(struct trapmd));
- lock = md1[0].params[0] + 4;
-
-#else
-
- lock = trap_get_long(ctx, unit->locklist);
- trap_put_long(ctx, unit->locklist, trap_get_long(ctx, lock));
+ lock = get_long (unit->locklist);
+ put_long (unit->locklist, get_long (lock));
lock += 4;
-#endif
-
-#if TRAPMD
- struct trapmd md2[] =
- {
- { TRAPCMD_PUT_LONG, { lock + 4, uniq } },
- { TRAPCMD_PUT_LONG, { lock + 8, mode } },
- { TRAPCMD_PUT_LONG, { lock + 12, unit->port } },
- { TRAPCMD_PUT_LONG, { lock + 16, unit->volume >> 2 } },
-
- /* prepend to lock chain */
- { TRAPCMD_GET_LONG, { unit->volume + 28 }, 5, 1 },
- { TRAPCMD_PUT_LONG, { lock, 0 } },
- { TRAPCMD_PUT_LONG, { unit->volume + 28, lock >> 2 } }
- };
- trap_multi(ctx, md2, sizeof md2 / sizeof(struct trapmd));
-
-#else
-
- trap_put_long(ctx, lock + 4, uniq);
- trap_put_long(ctx, lock + 8, mode);
- trap_put_long(ctx, lock + 12, unit->port);
- trap_put_long(ctx, lock + 16, unit->volume >> 2);
+ put_long (lock + 4, uniq);
+ put_long (lock + 8, mode);
+ put_long (lock + 12, unit->port);
+ put_long (lock + 16, unit->volume >> 2);
/* prepend to lock chain */
- trap_put_long(ctx, lock, trap_get_long(ctx, unit->volume + 28));
- trap_put_long(ctx, unit->volume + 28, lock >> 2);
-
-#endif
+ put_long (lock, get_long (unit->volume + 28));
+ put_long (unit->volume + 28, lock >> 2);
+ DUMPLOCK(unit, lock);
return lock;
}
@@ -2891,23 +2839,23 @@ static uaecptr make_lock (TrapContext *ctx, Unit *unit, uae_u32 uniq, long mode)
#define NRF_NOTIFY_INITIAL 16
#define NRF_MAGIC (1 << 31)
-static void notify_send (TrapContext *ctx, Unit *unit, Notify *n)
+static void notify_send (Unit *unit, Notify *n)
{
uaecptr nr = n->notifyrequest;
- int flags = trap_get_long(ctx, nr + 12);
+ int flags = get_long (nr + 12);
if (flags & NRF_SEND_MESSAGE) {
if (!(flags & NRF_WAIT_REPLY) || ((flags & NRF_WAIT_REPLY) && !(flags & NRF_MAGIC))) {
uae_NotificationHack (unit->port, nr);
} else if (flags & NRF_WAIT_REPLY) {
- trap_put_long(ctx, nr + 12, trap_get_long(ctx, nr + 12) | NRF_MAGIC);
+ put_long (nr + 12, get_long (nr + 12) | NRF_MAGIC);
}
} else if (flags & NRF_SEND_SIGNAL) {
- uae_Signal (trap_get_long(ctx, nr + 16), 1 << trap_get_byte(ctx, nr + 20));
+ uae_Signal (get_long (nr + 16), 1 << get_byte (nr + 20));
}
}
-static void notify_check (TrapContext *ctx, Unit *unit, a_inode *a)
+static void notify_check (Unit *unit, a_inode *a)
{
Notify *n;
int hash = notifyhash (a->aname);
@@ -2915,9 +2863,9 @@ static void notify_check (TrapContext *ctx, Unit *unit, a_inode *a)
uaecptr nr = n->notifyrequest;
if (same_aname(n->partname, a->aname)) {
int err;
- a_inode *a2 = find_aino(ctx, unit, 0, n->fullname, &err);
+ a_inode *a2 = find_aino (unit, 0, n->fullname, &err);
if (err == 0 && a == a2)
- notify_send(ctx, unit, n);
+ notify_send (unit, n);
}
}
if (a->parent) {
@@ -2926,29 +2874,46 @@ static void notify_check (TrapContext *ctx, Unit *unit, a_inode *a)
uaecptr nr = n->notifyrequest;
if (same_aname(n->partname, a->parent->aname)) {
int err;
- a_inode *a2 = find_aino(ctx, unit, 0, n->fullname, &err);
+ a_inode *a2 = find_aino (unit, 0, n->fullname, &err);
if (err == 0 && a->parent == a2)
- notify_send(ctx, unit, n);
+ notify_send (unit, n);
}
}
}
}
-static void action_add_notify(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_add_notify (Unit *unit, dpacket packet)
{
uaecptr nr = GET_PCK_ARG1 (packet);
int flags;
Notify *n;
TCHAR *name, *p, *partname;
- name = char1 (ctx, trap_get_long(ctx, nr + 4));
- flags = trap_get_long(ctx, nr + 12);
+ TRACE((_T("ACTION_ADD_NOTIFY\n")));
+
+ name = my_strdup (char1 (get_long (nr + 4)));
+ flags = get_long (nr + 12);
if (!(flags & (NRF_SEND_MESSAGE | NRF_SEND_SIGNAL))) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_BAD_NUMBER);
return;
}
+#if 0
+ write_log (_T("Notify:\n"));
+ write_log (_T("nr_Name '%s'\n"), char1 (get_long (nr + 0)));
+ write_log (_T("nr_FullName '%s'\n"), name);
+ write_log (_T("nr_UserData %08X\n"), get_long (nr + 8));
+ write_log (_T("nr_Flags %08X\n"), flags);
+ if (flags & NRF_SEND_MESSAGE) {
+ write_log (_T("Message NotifyRequest, port = %08X\n"), get_long (nr + 16));
+ } else if (flags & NRF_SEND_SIGNAL) {
+ write_log (_T("Signal NotifyRequest, Task = %08X signal = %d\n"), get_long (nr + 16), get_long (nr + 20));
+ } else {
+ write_log (_T("corrupt NotifyRequest\n"));
+ }
+#endif
p = name + _tcslen (name) - 1;
if (p[0] == ':')
@@ -2963,18 +2928,20 @@ static void action_add_notify(TrapContext *ctx, Unit *unit, dpacket *packet)
n->fullname = name;
if (flags & NRF_NOTIFY_INITIAL) {
int err;
- a_inode *a = find_aino(ctx, unit, 0, n->fullname, &err);
+ a_inode *a = find_aino (unit, 0, n->fullname, &err);
if (err == 0)
- notify_send(ctx, unit, n);
+ notify_send (unit, n);
}
PUT_PCK_RES1 (packet, DOS_TRUE);
}
-static void action_remove_notify(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_remove_notify (Unit *unit, dpacket packet)
{
uaecptr nr = GET_PCK_ARG1 (packet);
Notify *n;
int hash;
+ TRACE((_T("ACTION_REMOVE_NOTIFY\n")));
for (hash = 0; hash < NOTIFY_HASH_SIZE; hash++) {
for (n = unit->notifyhash[hash]; n; n = n->next) {
if (n->notifyrequest == nr) {
@@ -2991,19 +2958,18 @@ static void action_remove_notify(TrapContext *ctx, Unit *unit, dpacket *packet)
PUT_PCK_RES1 (packet, DOS_TRUE);
}
-static void free_lock (TrapContext *ctx, Unit *unit, uaecptr lock)
+static void free_lock (Unit *unit, uaecptr lock)
{
if (! lock)
return;
- uaecptr curlock = get_long(unit->volume + 28);
- if (lock == curlock << 2) {
- put_long(unit->volume + 28, trap_get_long(ctx, lock));
+ if (lock == get_long (unit->volume + 28) << 2) {
+ put_long (unit->volume + 28, get_long (lock));
} else {
- uaecptr current = curlock;
+ uaecptr current = get_long (unit->volume + 28);
uaecptr next = 0;
while (current) {
- next = trap_get_long(ctx, current << 2);
+ next = get_long (current << 2);
if (lock == next << 2)
break;
current = next;
@@ -3012,36 +2978,31 @@ static void free_lock (TrapContext *ctx, Unit *unit, uaecptr lock)
write_log (_T("tried to unlock non-existing lock %x\n"), lock);
return;
}
- trap_put_long(ctx, current << 2, trap_get_long(ctx, lock));
+ put_long (current << 2, get_long (lock));
}
lock -= 4;
-#if TRAPMD
- struct trapmd md2[] =
- {
- { TRAPCMD_GET_LONG, { unit->locklist }, 1, 1 },
- { TRAPCMD_PUT_LONG, { lock } },
- { TRAPCMD_PUT_LONG, { unit->locklist, lock } }
- };
- trap_multi(ctx, md2, sizeof md2 / sizeof(struct trapmd));
-#else
- trap_put_long(ctx, lock, trap_get_long(ctx, unit->locklist));
- trap_put_long(ctx, unit->locklist, lock);
-#endif
+ put_long (lock, get_long (unit->locklist));
+ put_long (unit->locklist, lock);
}
-static void action_lock(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_lock (Unit *unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
uaecptr name = GET_PCK_ARG2 (packet) << 2;
- int mode = GET_PCK_ARG3 (packet);
+ long mode = GET_PCK_ARG3 (packet);
a_inode *a;
int err;
if (mode != SHARED_LOCK && mode != EXCLUSIVE_LOCK) {
+ TRACE((_T("Bad mode %d (should be %d or %d).\n"), mode, SHARED_LOCK, EXCLUSIVE_LOCK));
mode = SHARED_LOCK;
}
- a = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err);
+ TRACE((_T("ACTION_LOCK(0x%08x, \"%s\", %d)\n"), lock, bstr (unit, name), mode));
+ DUMPLOCK(unit, lock);
+
+ a = find_aino (unit, lock, bstr (unit, name), &err);
if (err == 0 && (a->elock || (mode != SHARED_LOCK && a->shlock > 0))) {
err = ERROR_OBJECT_IN_USE;
}
@@ -3056,15 +3017,17 @@ static void action_lock(TrapContext *ctx, Unit *unit, dpacket *packet)
else
a->elock = 1;
de_recycle_aino (unit, a);
- PUT_PCK_RES1 (packet, make_lock (ctx, unit, a->uniq, mode) >> 2);
+ PUT_PCK_RES1 (packet, make_lock (unit, a->uniq, mode) >> 2);
}
-static void action_free_lock(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void action_free_lock (Unit *unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
a_inode *a;
+ TRACE((_T("ACTION_FREE_LOCK(0x%lx)\n"), lock));
+ DUMPLOCK(unit, lock);
- a = aino_from_lock(ctx, unit, lock);
+ a = aino_from_lock (unit, lock);
if (a == 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND);
@@ -3075,12 +3038,13 @@ static void action_free_lock(TrapContext *ctx, Unit *unit, dpacket *packet)
else
a->shlock--;
recycle_aino (unit, a);
- free_lock(ctx, unit, lock);
+ free_lock(unit, lock);
PUT_PCK_RES1 (packet, DOS_TRUE);
}
-static uaecptr action_dup_lock_2(TrapContext *ctx, Unit *unit, dpacket *packet, uae_u32 uniq)
+static uaecptr
+ action_dup_lock_2 (Unit *unit, dpacket packet, uae_u32 uniq)
{
uaecptr out;
a_inode *a;
@@ -3101,42 +3065,119 @@ static uaecptr action_dup_lock_2(TrapContext *ctx, Unit *unit, dpacket *packet,
}
a->shlock++;
de_recycle_aino (unit, a);
- out = make_lock(ctx, unit, a->uniq, -2) >> 2;
+ out = make_lock (unit, a->uniq, -2) >> 2;
PUT_PCK_RES1 (packet, out);
return out;
}
-static void action_dup_lock(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_dup_lock (Unit *unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
+ TRACE((_T("ACTION_DUP_LOCK(0x%lx)\n"), lock));
if (!lock) {
PUT_PCK_RES1 (packet, 0);
return;
}
- action_dup_lock_2(ctx, unit, packet, trap_get_long(ctx, lock + 4));
+ action_dup_lock_2 (unit, packet, get_long(lock + 4));
}
-static void action_lock_from_fh(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_lock_from_fh (Unit *unit, dpacket packet)
{
Key *k = lookup_key (unit, GET_PCK_ARG1 (packet));
+ TRACE((_T("ACTION_COPY_DIR_FH(0x%lx,'%s')\n"), GET_PCK_ARG1 (packet), k ? k->aino->aname : _T("")));
if (k == 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
return;
}
- action_dup_lock_2(ctx, unit, packet, k->aino->uniq);
+ action_dup_lock_2 (unit, packet, k->aino->uniq);
}
-static void free_exkey (Unit *unit, a_inode *aino)
+static void free_exkey (Unit *unit, ExamineKey *ek)
{
- if (--aino->exnext_count == 0) {
- unit->total_locked_ainos -= aino->locked_children;
- aino->locked_children = 0;
+ if (--ek->aino->exnext_count == 0) {
+ TRACE ((_T("Freeing ExKey and reducing total_locked from %d by %d\n"),
+ unit->total_locked_ainos, ek->aino->locked_children));
+ unit->total_locked_ainos -= ek->aino->locked_children;
+ ek->aino->locked_children = 0;
}
+ ek->aino = 0;
+ ek->uniq = 0;
+}
+
+static ExamineKey *lookup_exkey (Unit *unit, uae_u32 uniq)
+{
+ ExamineKey *ek;
+ int i;
+
+ ek = unit->examine_keys;
+ for (i = 0; i < EXKEYS; i++, ek++) {
+ /* Did we find a free one? */
+ if (ek->uniq == uniq)
+ return ek;
+ }
+ write_log (_T("Houston, we have a BIG problem.\n"));
+ return 0;
+}
+
+/* This is so sick... who invented ACTION_EXAMINE_NEXT? What did he THINK??? */
+static ExamineKey *new_exkey (Unit *unit, a_inode *aino)
+{
+ uae_u32 uniq;
+ uae_u32 oldest = 0xFFFFFFFE;
+ ExamineKey *ek, *oldest_ek = 0;
+ int i;
+
+ ek = unit->examine_keys;
+ for (i = 0; i < EXKEYS; i++, ek++) {
+ /* Did we find a free one? */
+ if (ek->aino == 0)
+ continue;
+ if (ek->uniq < oldest)
+ oldest = (oldest_ek = ek)->uniq;
+ }
+ ek = unit->examine_keys;
+ for (i = 0; i < EXKEYS; i++, ek++) {
+ /* Did we find a free one? */
+ if (ek->aino == 0)
+ goto found;
+ }
+ /* This message should usually be harmless. */
+ write_log (_T("Houston, we have a problem (%s).\n"), aino->nname);
+ free_exkey (unit, oldest_ek);
+ ek = oldest_ek;
+ found:
+
+ uniq = unit->next_exkey;
+ if (uniq >= 0xFFFFFFFE) {
+ /* Things will probably go wrong, but most likely the Amiga will crash
+ * before this happens because of something else. */
+ uniq = 1;
+ }
+ unit->next_exkey = uniq+1;
+ ek->aino = aino;
+ ek->curr_file = 0;
+ ek->uniq = uniq;
+ return ek;
}
static void move_exkeys (Unit *unit, a_inode *from, a_inode *to)
{
+ int i;
+ unsigned long tmp = 0;
+ for (i = 0; i < EXKEYS; i++) {
+ ExamineKey *k = unit->examine_keys + i;
+ if (k->uniq == 0)
+ continue;
+ if (k->aino == from) {
+ k->aino = to;
+ tmp++;
+ }
+ }
+ if (tmp != from->exnext_count)
+ write_log (_T("filesys.c: Bug in ExNext bookkeeping. BAD.\n"));
to->exnext_count = from->exnext_count;
to->locked_children = from->locked_children;
from->exnext_count = 0;
@@ -3146,7 +3187,7 @@ static void move_exkeys (Unit *unit, a_inode *from, a_inode *to)
static bool get_statinfo(Unit *unit, a_inode *aino, struct mystat *statbuf)
{
bool ok = true;
- memset (statbuf, 0, sizeof(struct mystat));
+ memset (statbuf, 0, sizeof &statbuf);
/* No error checks - this had better work. */
if (unit->volflags & MYVOLUMEINFO_ARCHIVE)
ok = zfile_stat_archive (aino->nname, statbuf) != 0;
@@ -3155,37 +3196,23 @@ static bool get_statinfo(Unit *unit, a_inode *aino, struct mystat *statbuf)
return ok;
}
-static void get_fileinfo(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr info, a_inode *aino, bool longfilesize)
+static void
+ get_fileinfo (Unit *unit, dpacket packet, uaecptr info, a_inode *aino, bool longfilesize)
{
struct mystat statbuf;
int days, mins, ticks;
int i, n, entrytype, blocksize;
uae_s64 numblocks;
int fsdb_can = fsdb_cando (unit);
- const TCHAR *xs;
+ const char *xs;
char *x, *x2;
- uae_u8 *buf;
- uae_u8 buf_array[260] = { 0 };
- if (!valid_address(info, (sizeof buf_array) - 36)) {
- buf = buf_array;
- } else {
- buf = get_real_address(info);
- }
-
- if (aino->vfso) {
- fsdb_can = 1;
- statbuf.mode = aino->vfso->amigaos_mode;
- statbuf.mtime.tv_sec = 0;
- statbuf.mtime.tv_usec = 0;
- statbuf.size = aino->vfso->size;
- } else if (!get_statinfo(unit, aino, &statbuf)) {
+ if (!get_statinfo(unit, aino, &statbuf)) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_NOT_A_DOS_DISK);
return;
}
- put_long_host(buf + 0, aino->uniq);
if (aino->parent == 0) {
/* Guru book says ST_ROOT = 1 (root directory, not currently used)
* but some programs really expect 2 from root dir..
@@ -3196,10 +3223,11 @@ static void get_fileinfo(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr
entrytype = aino->dir ? ST_USERDIR : ST_FILE;
xs = aino->aname;
}
- put_long_host(buf + 4, entrytype);
+ put_long (info + 4, entrytype);
/* AmigaOS docs say these have to contain the same value. */
- put_long_host(buf + 120, entrytype);
+ put_long (info + 120, entrytype);
+ TRACE((_T("name=\"%s\"\n"), xs));
x2 = x = ua_fs (xs, -1);
n = strlen (x);
if (n > 107)
@@ -3207,42 +3235,43 @@ static void get_fileinfo(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr
if (n > abs (currprefs.filesys_max_name))
n = abs (currprefs.filesys_max_name);
i = 8;
- put_byte_host(buf + i, n); i++;
+ put_byte (info + i, n); i++;
while (n--)
- put_byte_host(buf + i, *x), i++, x++;
+ put_byte (info + i, *x), i++, x++;
while (i < 108)
- put_byte_host(buf + i, 0), i++;
+ put_byte (info + i, 0), i++;
xfree (x2);
- put_long_host(buf + 116, fsdb_can ? aino->amigaos_mode : fsdb_mode_supported (aino));
+ put_long (info + 116, fsdb_can ? aino->amigaos_mode : fsdb_mode_supported(aino));
if (kickstart_version >= 36) {
- put_word_host(buf + 224, 0); // OwnerUID
- put_word_host(buf + 226, 0); // OwnerGID
+ put_word (info + 224, 0); // OwnerUID
+ put_word (info + 226, 0); // OwnerGID
}
- blocksize = 512;
+ blocksize = (unit->volflags & MYVOLUMEINFO_CDFS) ? 2048 : 512;
numblocks = (statbuf.size + blocksize - 1) / blocksize;
- put_long_host(buf + 128, numblocks > MAXFILESIZE32 ? MAXFILESIZE32 : numblocks);
+ put_long (info + 128, numblocks > MAXFILESIZE32 ? MAXFILESIZE32 : numblocks);
if (longfilesize) {
/* MorphOS 64-bit file length support */
- put_long_host(buf + 124, statbuf.size > MAXFILESIZE32_2G ? 0 : (uae_u32)statbuf.size);
- put_long_host(buf + 228, statbuf.size >> 32);
- put_long_host(buf + 232, (uae_u32)statbuf.size);
- put_long_host(buf + 236, numblocks >> 32);
- put_long_host(buf + 240, (uae_u32)numblocks);
+ put_long (info + 124, statbuf.size > MAXFILESIZE32 ? 0 : (uae_u32)statbuf.size);
+ put_long (info + 228, statbuf.size >> 32);
+ put_long (info + 232, (uae_u32)statbuf.size);
+ put_long (info + 236, numblocks >> 32);
+ put_long (info + 240, (uae_u32)numblocks);
} else {
- put_long_host(buf + 124, statbuf.size > MAXFILESIZE32 ? MAXFILESIZE32 : (uae_u32)statbuf.size);
+ put_long (info + 124, statbuf.size > MAXFILESIZE32 ? MAXFILESIZE32 : (uae_u32)statbuf.size);
}
- timeval_to_amiga (&statbuf.mtime, &days, &mins, &ticks, 50);
- put_long_host(buf + 132, days);
- put_long_host(buf + 136, mins);
- put_long_host(buf + 140, ticks);
+ timeval_to_amiga (&statbuf.mtime, &days, &mins, &ticks);
+ put_long (info + 132, days);
+ put_long (info + 136, mins);
+ put_long (info + 140, ticks);
if (aino->comment == 0 || !fsdb_can)
- put_long_host(buf + 144, 0);
+ put_long (info + 144, 0);
else {
+ TRACE((_T("comment=\"%s\"\n"), aino->comment));
i = 144;
xs = aino->comment;
if (!xs)
@@ -3251,34 +3280,22 @@ static void get_fileinfo(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr
n = strlen (x);
if (n > 78)
n = 78;
- put_byte_host(buf + i, n); i++;
+ put_byte (info + i, n); i++;
while (n--)
- put_byte_host(buf + i, *x), i++, x++;
+ put_byte (info + i, *x), i++, x++;
while (i < 224)
- put_byte_host(buf + i, 0), i++;
+ put_byte (info + i, 0), i++;
xfree (x2);
}
-
- if (buf == buf_array) {
- // Must not write Fib_reserved at the end.
- if (kickstart_version >= 36) {
- // FIB + fib_OwnerUID and fib_OwnerGID
- trap_put_bytes(ctx, buf, info, (sizeof buf_array) - 32);
- } else {
- // FIB only
- trap_put_bytes(ctx, buf, info, (sizeof buf_array) - 36);
- }
- }
-
PUT_PCK_RES1 (packet, DOS_TRUE);
}
-int get_native_path(TrapContext *ctx, uae_u32 lock, TCHAR *out)
+int get_native_path (uae_u32 lock, TCHAR *out)
{
int i = 0;
for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
if (mountinfo.ui[i].self) {
- a_inode *a = aino_from_lock(ctx, mountinfo.ui[i].self, lock << 2);
+ a_inode *a = aino_from_lock (mountinfo.ui[i].self, lock << 2);
if (a) {
_tcscpy (out, a->nname);
return 0;
@@ -3293,7 +3310,7 @@ int get_native_path(TrapContext *ctx, uae_u32 lock, TCHAR *out)
#define REC_SHARED 2
#define REC_SHARED_IMMED 3
-static struct lockrecord *new_record (dpacket *packet, uae_u64 pos, uae_u64 len, uae_u32 mode, uae_u32 timeout, uae_u32 msg)
+static struct lockrecord *new_record (uae_u32 packet, uae_u64 pos, uae_u64 len, uae_u32 mode, uae_u32 timeout, uae_u32 msg)
{
struct lockrecord *lr = xcalloc (struct lockrecord, 1);
lr->packet = packet;
@@ -3331,7 +3348,7 @@ static bool record_hit (Unit *unit, Key *k, uae_u64 pos, uae_u64 len, uae_u32 mo
return false;
}
-static void record_timeout (TrapContext *ctx, Unit *unit)
+static void record_timeout (Unit *unit)
{
bool retry = true;
while (retry) {
@@ -3344,7 +3361,7 @@ static void record_timeout (TrapContext *ctx, Unit *unit)
PUT_PCK_RES1 (lr->packet, DOS_FALSE);
PUT_PCK_RES2 (lr->packet, ERROR_LOCK_TIMEOUT);
// mark packet as complete
- trap_put_long(ctx, lr->msg + 4, 0xfffffffe);
+ put_long (lr->msg + 4, 0xfffffffe);
uae_Signal (get_long (unit->volume + 176 - 32), 1 << 13);
if (prev)
prev->next = lr->next;
@@ -3360,7 +3377,7 @@ static void record_timeout (TrapContext *ctx, Unit *unit)
}
}
-static void record_check_waiting (TrapContext *ctx, Unit *unit)
+static void record_check_waiting (Unit *unit)
{
bool retry = true;
while (retry) {
@@ -3373,9 +3390,9 @@ static void record_check_waiting (TrapContext *ctx, Unit *unit)
prev->next = lr->next;
else
unit->waitingrecords = lr->next;
- write_log (_T("queued record released '%s',%llud,%llu,%d,%d\n"), k->aino->nname, lr->pos, lr->len, lr->mode, lr->timeout);
+ write_log (_T("queued record released '%s',%d,%d,%d,%d\n"), k->aino->nname, lr->pos, lr->len, lr->mode, lr->timeout);
// mark packet as complete
- trap_put_long(ctx, lr->msg + 4, 0xffffffff);
+ put_long (lr->msg + 4, 0xffffffff);
xfree (lr);
retry = true;
break;
@@ -3385,7 +3402,7 @@ static void record_check_waiting (TrapContext *ctx, Unit *unit)
}
}
-static int action_lock_record(TrapContext *ctx, Unit *unit, dpacket *packet, uae_u32 msg)
+static int action_lock_record (Unit *unit, dpacket packet, uae_u32 msg)
{
Key *k = lookup_key (unit, GET_PCK_ARG1 (packet));
uae_u32 pos = GET_PCK_ARG2 (packet);
@@ -3425,7 +3442,7 @@ static int action_lock_record(TrapContext *ctx, Unit *unit, dpacket *packet, uae
return 1;
}
- struct lockrecord *lr = new_record (packet, pos, len, mode, timeout, 0);
+ struct lockrecord *lr = new_record (GET_PCK_ARG1 (packet), pos, len, mode, timeout, 0);
if (k->record) {
lr->next = k->record;
k->record = lr;
@@ -3437,7 +3454,7 @@ static int action_lock_record(TrapContext *ctx, Unit *unit, dpacket *packet, uae
return 1;
}
-static void action_free_record(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void action_free_record (Unit *unit, dpacket packet)
{
Key *k = lookup_key (unit, GET_PCK_ARG1 (packet));
uae_u32 pos = GET_PCK_ARG2 (packet);
@@ -3460,7 +3477,7 @@ static void action_free_record(TrapContext *ctx, Unit *unit, dpacket *packet)
k->record = lr->next;
xfree (lr);
write_log (_T("->OK\n"));
- record_check_waiting(ctx, unit);
+ record_check_waiting (unit);
PUT_PCK_RES1 (packet, DOS_TRUE);
return;
}
@@ -3470,6 +3487,7 @@ static void action_free_record(TrapContext *ctx, Unit *unit, dpacket *packet)
PUT_PCK_RES2 (packet, ERROR_RECORD_NOT_LOCKED);
}
+#define EXALL_DEBUG 0
#define EXALL_END 0xde1111ad
static ExAllKey *getexall (Unit *unit, uaecptr control, int id)
@@ -3495,13 +3513,14 @@ static ExAllKey *getexall (Unit *unit, uaecptr control, int id)
return NULL;
}
-static int exalldo (TrapContext *ctx, uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaecptr control, Unit *unit, a_inode *aino)
+static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaecptr control, Unit *unit, a_inode *aino)
{
uaecptr exp = exalldata;
int i;
int size, size2;
int entrytype;
- const TCHAR *xs = NULL, *commentx = NULL;
+ TCHAR *xs = NULL;
+ const char *commentx = NULL;
uae_u32 flags = 15;
int days, mins, ticks;
struct mystat statbuf;
@@ -3541,7 +3560,7 @@ static int exalldo (TrapContext *ctx, uaecptr exalldata, uae_u32 exalldatasize,
size2 += 4;
}
if (type >= 5) {
- timeval_to_amiga (&statbuf.mtime, &days, &mins, &ticks, 50);
+ timeval_to_amiga (&statbuf.mtime, &days, &mins, &ticks);
size2 += 12;
}
if (type >= 6) {
@@ -3563,52 +3582,57 @@ static int exalldo (TrapContext *ctx, uaecptr exalldata, uae_u32 exalldatasize,
size2 += 8;
}
- i = trap_get_long(ctx, control + 0);
+ i = get_long (control + 0);
while (i > 0) {
- exp = trap_get_long(ctx, exp); /* ed_Next */
+ exp = get_long (exp); /* ed_Next */
i--;
}
if (exalldata + exalldatasize - exp < size + size2)
goto end; /* not enough space */
- trap_put_long(ctx, exp, exp + size + size2); /* ed_Next */
+#if EXALL_DEBUG > 0
+ write_log (_T("ID=%d, %d, %08x: '%s'%s\n"),
+ get_long (control + 4), get_long (control + 0), exp, xs, aino->dir ? _T(" [DIR]") : _T(""));
+#endif
+
+ put_long (exp, exp + size + size2); /* ed_Next */
if (type >= 1) {
- trap_put_long(ctx, exp + 4, exp + size2);
+ put_long (exp + 4, exp + size2);
for (i = 0; i <= strlen (x); i++) {
- trap_put_byte(ctx, exp + size2, x[i]);
+ put_byte (exp + size2, x[i]);
size2++;
}
}
if (type >= 2)
- trap_put_long(ctx, exp + 8, entrytype);
+ put_long (exp + 8, entrytype);
if (type >= 3)
- trap_put_long(ctx, exp + 12, statbuf.size > MAXFILESIZE32 ? MAXFILESIZE32 : statbuf.size);
+ put_long (exp + 12, statbuf.size > MAXFILESIZE32 ? MAXFILESIZE32 : statbuf.size);
if (type >= 4)
- trap_put_long(ctx, exp + 16, flags);
+ put_long (exp + 16, flags);
if (type >= 5) {
- trap_put_long(ctx, exp + 20, days);
- trap_put_long(ctx, exp + 24, mins);
- trap_put_long(ctx, exp + 28, ticks);
+ put_long (exp + 20, days);
+ put_long (exp + 24, mins);
+ put_long (exp + 28, ticks);
}
if (type >= 6) {
- trap_put_long(ctx, exp + 32, exp + size2);
- trap_put_byte(ctx, exp + size2, strlen (comment));
+ put_long (exp + 32, exp + size2);
+ put_byte (exp + size2, strlen (comment));
for (i = 0; i <= strlen (comment); i++) {
- trap_put_byte(ctx, exp + size2, comment[i]);
+ put_byte (exp + size2, comment[i]);
size2++;
}
}
if (type >= 7) {
- trap_put_word(ctx, exp + 36, uid);
- trap_put_word(ctx, exp + 38, gid);
+ put_word (exp + 36, uid);
+ put_word (exp + 38, gid);
}
if (type >= 8) {
- trap_put_long(ctx, exp + 40, statbuf.size >> 32);
- trap_put_long(ctx, exp + 44, (uae_u32)statbuf.size);
+ put_long (exp + 40, statbuf.size >> 32);
+ put_long (exp + 44, (uae_u32)statbuf.size);
}
- trap_put_long(ctx, control + 0, trap_get_long(ctx, control + 0) + 1);
+ put_long (control + 0, get_long (control + 0) + 1);
ret = 1;
end:
xfree (x);
@@ -3621,17 +3645,7 @@ static bool filesys_name_invalid (const TCHAR *fn)
return _tcslen (fn) > currprefs.filesys_max_name;
}
-static int filesys_readdir(struct fs_dirhandle *d, TCHAR *fn, uae_u64 *uniq)
-{
- int ok = 0;
- if (d->fstype == FS_ARCHIVE)
- ok = zfile_readdir_archive (d->zd, fn);
- else if (d->fstype == FS_DIRECTORY)
- ok = my_readdir (d->od, fn);
- return ok;
-}
-
-static int action_examine_all_do (TrapContext *ctx, Unit *unit, uaecptr lock, ExAllKey *eak, uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaecptr control)
+static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaecptr control)
{
a_inode *aino, *base = NULL;
int ok;
@@ -3640,7 +3654,7 @@ static int action_examine_all_do (TrapContext *ctx, Unit *unit, uaecptr lock, Ex
TCHAR fn[MAX_DPATH];
if (lock != 0)
- base = aino_from_lock(ctx, unit, lock);
+ base = aino_from_lock (unit, lock);
if (base == 0)
base = &unit->rootnode;
for (;;) {
@@ -3648,7 +3662,12 @@ static int action_examine_all_do (TrapContext *ctx, Unit *unit, uaecptr lock, Ex
d = eak->dirhandle;
if (!eak->fn) {
do {
- ok = filesys_readdir(d, fn, &uniq);
+ if (d->fstype == FS_ARCHIVE)
+ ok = zfile_readdir_archive (d->zd, fn);
+ else if (d->fstype == FS_DIRECTORY)
+ ok = my_readdir (d->od, fn);
+ else
+ ok = 0;
} while (ok && d->fstype == FS_DIRECTORY && (filesys_name_invalid (fn) || fsdb_name_invalid_dir (fn)));
if (!ok)
return 0;
@@ -3657,12 +3676,12 @@ static int action_examine_all_do (TrapContext *ctx, Unit *unit, uaecptr lock, Ex
xfree (eak->fn);
eak->fn = NULL;
}
- aino = lookup_child_aino_for_exnext (unit, base, fn, &err, uniq, NULL);
+ aino = lookup_child_aino_for_exnext (unit, base, fn, &err, uniq);
if (!aino)
return 0;
eak->id = unit->exallid++;
- trap_put_long(ctx, control + 4, eak->id);
- if (!exalldo (ctx, exalldata, exalldatasize, type, control, unit, aino)) {
+ put_long (control + 4, eak->id);
+ if (!exalldo (exalldata, exalldatasize, type, control, unit, aino)) {
eak->fn = my_strdup (fn); /* no space in exallstruct, save current entry */
break;
}
@@ -3670,7 +3689,7 @@ static int action_examine_all_do (TrapContext *ctx, Unit *unit, uaecptr lock, Ex
return 1;
}
-static int action_examine_all_end(TrapContext *ctx, Unit *unit, dpacket *packet)
+static int action_examine_all_end (Unit *unit, dpacket packet)
{
uae_u32 id;
uae_u32 doserr = 0;
@@ -3679,8 +3698,11 @@ static int action_examine_all_end(TrapContext *ctx, Unit *unit, dpacket *packet)
if (kickstart_version < 36)
return 0;
- id = trap_get_long(ctx, control + 4);
+ id = get_long (control + 4);
eak = getexall (unit, control, id);
+#if EXALL_DEBUG > 0
+ write_log (_T("EXALL_END ID=%d %x\n"), id, eak);
+#endif
if (!eak) {
write_log (_T("FILESYS: EXALL_END non-existing ID %d\n"), id);
doserr = ERROR_OBJECT_WRONG_TYPE;
@@ -3700,7 +3722,7 @@ static int action_examine_all_end(TrapContext *ctx, Unit *unit, dpacket *packet)
return 1;
}
-static int action_examine_all(TrapContext *ctx, Unit *unit, dpacket *packet)
+static int action_examine_all (Unit *unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
uaecptr exalldata = GET_PCK_ARG2 (packet);
@@ -3717,7 +3739,14 @@ static int action_examine_all(TrapContext *ctx, Unit *unit, dpacket *packet)
ok = 0;
- trap_put_long(ctx, control + 0, 0); /* eac_Entries */
+#if EXALL_DEBUG > 0
+ write_log (_T("exall: %08x %08x-%08x %d %d %08x\n"),
+ lock, exalldata, exalldata + exalldatasize, exalldatasize, type, control);
+ write_log (_T("exall: MatchString %08x, MatchFunc %08x\n"),
+ get_long (control + 8), get_long (control + 12));
+#endif
+
+ put_long (control + 0, 0); /* eac_Entries */
/* EXAMINE ALL might use dos.library MatchPatternNoCase() which is >=36 */
if (kickstart_version < 36)
@@ -3729,7 +3758,7 @@ static int action_examine_all(TrapContext *ctx, Unit *unit, dpacket *packet)
}
PUT_PCK_RES1 (packet, DOS_TRUE);
- id = trap_get_long(ctx, control + 4);
+ id = get_long (control + 4);
if (id == EXALL_END) {
write_log (_T("FILESYS: EXALL called twice with ERROR_NO_MORE_ENTRIES\n"));
goto fail; /* already ended exall() */
@@ -3741,9 +3770,9 @@ static int action_examine_all(TrapContext *ctx, Unit *unit, dpacket *packet)
doserr = ERROR_OBJECT_WRONG_TYPE;
goto fail;
}
- if (!action_examine_all_do(ctx, unit, lock, eak, exalldata, exalldatasize, type, control))
+ if (!action_examine_all_do (unit, lock, eak, exalldata, exalldatasize, type, control))
goto fail;
- if (trap_get_long(ctx, control + 0) == 0) {
+ if (get_long (control + 0) == 0) {
/* uh, no space for first entry.. */
doserr = ERROR_NO_FREE_STORE;
goto fail;
@@ -3755,17 +3784,20 @@ static int action_examine_all(TrapContext *ctx, Unit *unit, dpacket *packet)
if (!eak)
goto fail;
if (lock != 0)
- base = aino_from_lock(ctx, unit, lock);
+ base = aino_from_lock (unit, lock);
if (base == 0)
base = &unit->rootnode;
+#if EXALL_DEBUG > 0
+ write_log("exall: ID=%d '%s'\n", eak->id, base->nname);
+#endif
d = fs_opendir (unit, base);
if (!d)
goto fail;
eak->dirhandle = d;
- trap_put_long(ctx, control + 4, eak->id);
- if (!action_examine_all_do (ctx, unit, lock, eak, exalldata, exalldatasize, type, control))
+ put_long (control + 4, eak->id);
+ if (!action_examine_all_do (unit, lock, eak, exalldata, exalldatasize, type, control))
goto fail;
- if (trap_get_long(ctx, control + 0) == 0) {
+ if (get_long (control + 0) == 0) {
/* uh, no space for first entry.. */
doserr = ERROR_NO_FREE_STORE;
goto fail;
@@ -3777,16 +3809,19 @@ static int action_examine_all(TrapContext *ctx, Unit *unit, dpacket *packet)
fail:
/* Clear last ed_Next. This "list" is quite non-Amiga like.. */
exp = exalldata;
- i = trap_get_long(ctx, control + 0);
+ i = get_long (control + 0);
for (;;) {
if (i <= 1) {
if (exp)
- trap_put_long(ctx, exp, 0);
+ put_long (exp, 0);
break;
}
- exp = trap_get_long(ctx, exp); /* ed_Next */
+ exp = get_long (exp); /* ed_Next */
i--;
}
+#if EXALL_DEBUG > 0
+ write_log("ok=%d, err=%d, eac_Entries = %d\n", ok, ok ? -1 : doserr, get_long (control + 0));
+#endif
if (!ok) {
PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -3799,47 +3834,46 @@ fail:
eak->fn = NULL;
}
if (doserr == ERROR_NO_MORE_ENTRIES)
- trap_put_long(ctx, control + 4, EXALL_END);
+ put_long (control + 4, EXALL_END);
}
return 1;
}
-static uae_u32 exall_helper(TrapContext *ctx)
+static uae_u32 exall_helpder(TrapContext *context)
{
int i;
Unit *u;
- uaecptr pck = trap_get_areg(ctx, 4);
-
- dpacket packet;
- readdpacket(ctx, &packet, pck);
-
- uaecptr control = get_long_host(packet.packet_data + dp_Arg5);
- uae_u32 id = trap_get_long(ctx, control + 4);
+ uaecptr packet = m68k_areg (regs, 4);
+ uaecptr control = get_long (packet + dp_Arg5);
+ uae_u32 id = get_long (control + 4);
+#if EXALL_DEBUG > 0
+ write_log (_T("FILESYS: EXALL extra round ID=%d\n"), id);
+#endif
if (id == EXALL_END)
return 1;
for (u = units; u; u = u->next) {
for (i = 0; i < EXALLKEYS; i++) {
if (u->exalls[i].id == id && u->exalls[i].control == control) {
- action_examine_all(ctx, u, &packet);
+ action_examine_all (u, packet);
}
}
}
return 1;
}
-static uae_u32 REGPARAM2 fsmisc_helper (TrapContext *ctx)
+static uae_u32 REGPARAM2 fsmisc_helper (TrapContext *context)
{
- int mode = trap_get_dreg(ctx, 0);
+ int mode = m68k_dreg (regs, 0);
switch (mode)
{
case 0:
- return exall_helper (ctx);
+ return exall_helpder (context);
case 1:
- return filesys_media_change_reply (0);
+ return filesys_media_change_reply (context, 0);
case 2:
- return filesys_media_change_reply (1);
+ return filesys_media_change_reply (context, 1);
case 3:
uae_u32 t = getlocaltime ();
uae_u32 secs = (uae_u32)t - (8 * 365 + 2) * 24 * 60 * 60;
@@ -3848,82 +3882,25 @@ static uae_u32 REGPARAM2 fsmisc_helper (TrapContext *ctx)
return 0;
}
-static void action_examine_object(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void action_examine_object (Unit *unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
uaecptr info = GET_PCK_ARG2 (packet) << 2;
a_inode *aino = 0;
+ TRACE((_T("ACTION_EXAMINE_OBJECT(0x%lx,0x%lx)\n"), lock, info));
+ DUMPLOCK(unit, lock);
+
if (lock != 0)
- aino = aino_from_lock(ctx, unit, lock);
+ aino = aino_from_lock (unit, lock);
if (aino == 0)
aino = &unit->rootnode;
- get_fileinfo(ctx, unit, packet, info, aino, false);
-}
-
-extern unsigned char def_tool[];
-extern unsigned int def_tool_len;
-extern unsigned char def_project[];
-extern unsigned int def_project_len;
-extern unsigned char def_drawer[];
-extern unsigned int def_drawer_len;
-static struct virtualfilesysobject vfso_icon_tool;
-static struct virtualfilesysobject vfso_icon_project;
-static struct virtualfilesysobject vfso_icon_drawer;
-
-static void load_injected_icon(struct virtualfilesysobject *vfso, const TCHAR *fn, uae_u8 *default_data, int default_size)
-{
- uae_u8 *data = NULL;
- int size;
-
- xfree(vfso->data);
- if (fn && fn[0])
- data = zfile_load_file(fn, &size);
- if (!data) {
- vfso->data = xmalloc(uae_u8, default_size);
- memcpy(vfso->data, default_data, default_size);
- vfso->size = default_size;
- return;
- }
- vfso->data = data;
- vfso->size = size;
-}
-
-static void load_injected_icons(void)
-{
- load_injected_icon(&vfso_icon_tool, currprefs.filesys_inject_icons_tool, def_tool, def_tool_len);
- load_injected_icon(&vfso_icon_project, currprefs.filesys_inject_icons_project, def_project, def_project_len);
- load_injected_icon(&vfso_icon_drawer, currprefs.filesys_inject_icons_drawer, def_drawer, def_drawer_len);
-}
-
-static void inject_icons_to_directory(Unit *unit, a_inode *base)
-{
- for (a_inode *aino = base->child; aino; aino = aino->sibling) {
- int len = _tcslen(aino->aname);
- if (len >= 5 && !_tcsicmp(aino->aname + len - 5, _T(".info")))
- continue;
- TCHAR tmp[256];
- _stprintf(tmp, _T("%s.info"), aino->aname);
- bool match = false;
- for (a_inode *aino2 = base->child; aino2; aino2 = aino2->sibling) {
- if (!_tcsicmp(aino2->aname, tmp))
- match = true;
- }
- if (match)
- continue;
- uae_u32 err;
- struct virtualfilesysobject *vfso;
- if (aino->dir) {
- vfso = &vfso_icon_drawer;
- } else {
- if (aino->amigaos_mode & A_FIBF_EXECUTE)
- vfso = &vfso_icon_project;
- else
- vfso = &vfso_icon_tool;
- }
- lookup_child_aino_for_exnext(unit, base, tmp, &err, 0, vfso);
- }
+ get_fileinfo (unit, packet, info, aino, false);
+ if (aino->dir) {
+ put_long (info, 0xFFFFFFFF);
+ } else
+ put_long (info, 0);
}
/* Read a directory's contents, create a_inodes for each file, and
@@ -3945,6 +3922,8 @@ static void populate_directory (Unit *unit, a_inode *base)
base->locked_children++;
unit->total_locked_ainos++;
}
+ TRACE3((_T("Populating directory, child %p, locked_children %d\n"),
+ base->child, base->locked_children));
for (;;) {
uae_u64 uniq = 0;
TCHAR fn[MAX_DPATH];
@@ -3954,124 +3933,119 @@ static void populate_directory (Unit *unit, a_inode *base)
/* Find next file that belongs to the Amiga fs (skipping things
like "..", "." etc. */
do {
- ok = filesys_readdir(d, fn, &uniq);
+ if (d->fstype == FS_ARCHIVE)
+ ok = zfile_readdir_archive(d->zd, fn);
+ else if (d->fstype == FS_DIRECTORY)
+ ok = my_readdir (d->od, fn);
+ else
+ ok = 0;
} while (ok && d->fstype == FS_DIRECTORY && (filesys_name_invalid (fn) || fsdb_name_invalid_dir (fn)));
if (!ok)
break;
/* This calls init_child_aino, which will notice that the parent is
being ExNext()ed, and it will increment the locked counts. */
- aino = lookup_child_aino_for_exnext (unit, base, fn, &err, uniq, NULL);
+ aino = lookup_child_aino_for_exnext (unit, base, fn, &err, uniq);
}
fs_closedir (d);
- if (currprefs.filesys_inject_icons || unit->ui.inject_icons)
- inject_icons_to_directory(unit, base);
}
-static bool do_examine(TrapContext *ctx, Unit *unit, dpacket *packet, a_inode *aino, uaecptr info, bool longfilesize)
+static void do_examine (Unit *unit, dpacket packet, ExamineKey *ek, uaecptr info, bool longfilesize)
{
for (;;) {
TCHAR *name;
- if (!aino)
+ if (ek->curr_file == 0)
break;
- name = aino->nname;
- get_fileinfo (ctx, unit, packet, info, aino, longfilesize);
- if (!aino->vfso && !(unit->volflags & MYVOLUMEINFO_ARCHIVE) && !fsdb_exists(name)) {
- return false;
+ name = ek->curr_file->nname;
+ get_fileinfo (unit, packet, info, ek->curr_file, longfilesize);
+ ek->curr_file = ek->curr_file->sibling;
+ if (!(unit->volflags & MYVOLUMEINFO_ARCHIVE) && !fsdb_exists(name)) {
+ TRACE ((_T("%s orphaned"), name));
+ continue;
}
- return true;
+ TRACE ((_T("curr_file set to %p %s\n"), ek->curr_file,
+ ek->curr_file ? ek->curr_file->aname : _T("NULL")));
+ return;
}
- free_exkey (unit, aino->parent);
+ TRACE((_T("no more entries\n")));
+ free_exkey (unit, ek);
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_NO_MORE_ENTRIES);
- return true;
}
-static void action_examine_next(TrapContext *ctx, Unit *unit, dpacket *packet, bool largefilesize)
+static void action_examine_next (Unit *unit, dpacket packet, bool largefilesize)
{
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
uaecptr info = GET_PCK_ARG2 (packet) << 2;
- a_inode *aino = 0, *daino = 0;
+ a_inode *aino = 0;
+ ExamineKey *ek;
uae_u32 uniq;
- gui_flicker_led (UNIT_LED(unit), unit->unit, 1);
+ TRACE((_T("ACTION_EXAMINE_NEXT(0x%lx,0x%lx,%d)\n"), lock, info, largefilesize));
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 1);
+ DUMPLOCK(unit, lock);
if (lock != 0)
- aino = aino_from_lock(ctx, unit, lock);
+ aino = aino_from_lock (unit, lock);
if (aino == 0)
aino = &unit->rootnode;
- uniq = trap_get_long(ctx, info);
for(;;) {
- if (uniq == aino->uniq) {
- // first exnext
- if (!aino->dir) {
- write_log (_T("ExNext called for a file! %s:%d (Houston?)\n"), aino->nname, uniq);
- goto no_more_entries;
- }
- if (aino->exnext_count++ == 0)
- populate_directory (unit, aino);
- if (!aino->child)
- goto no_more_entries;
- daino = aino->child;
- } else {
- daino = lookup_aino(unit, uniq);
- if (!daino) {
- // deleted? Look for next larger uniq in same directory.
- daino = aino->child;
- while (daino && uniq >= daino->uniq) {
- daino = daino->sibling;
- }
- // didn't find, what about previous?
- if (!daino) {
- daino = aino->child;
- while (daino && uniq >= daino->uniq) {
- if (daino->sibling && daino->sibling->uniq >= uniq) {
- break;
- }
- daino = daino->sibling;
- }
- }
- // didn't find any but there are still entries? restart from beginning.
- if (!daino && aino->child) {
- daino = aino->child;
- }
- } else {
- daino = daino->sibling;
- }
+ uniq = get_long (info);
+ if (uniq == 0) {
+ write_log (_T("ExNext called for a file! (Houston?)\n"));
+ goto no_more_entries;
+ } else if (uniq == 0xFFFFFFFE)
+ goto no_more_entries;
+ else if (uniq == 0xFFFFFFFF) {
+ TRACE((_T("Creating new ExKey\n")));
+ ek = new_exkey (unit, aino);
+ if (ek) {
+ if (aino->exnext_count++ == 0)
+ populate_directory (unit, aino);
+ ek->curr_file = aino->child;
+ TRACE((_T("Initial curr_file: %p %s\n"), ek->curr_file,
+ ek->curr_file ? ek->curr_file->aname : _T("NULL")));
+ }
+ } else {
+ TRACE((_T("Looking up ExKey\n")));
+ ek = lookup_exkey (unit, get_long (info));
}
- if (!daino)
- goto no_more_entries;
- if (daino->parent != aino) {
- write_log(_T("Houston, we have a BIG problem. %s is not parent of %s\n"), daino->nname, aino->nname);
+ if (ek == 0) {
+ write_log (_T("Couldn't find a matching ExKey. Prepare for trouble.\n"));
goto no_more_entries;
}
- uniq = daino->uniq;
- if (daino->mountcount != unit->mountcount)
- continue;
- if (!do_examine(ctx, unit, packet, daino, info, largefilesize))
- continue;
- return;
- }
+ put_long (info, ek->uniq);
+ if (!ek->curr_file || ek->curr_file->mountcount == unit->mountcount)
+ break;
+ ek->curr_file = ek->curr_file->sibling;
+ if (!ek->curr_file)
+ goto no_more_entries;
+ }
+ do_examine (unit, packet, ek, info, largefilesize);
+ return;
no_more_entries:
- free_exkey(unit, aino);
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_NO_MORE_ENTRIES);
}
-static void do_find(TrapContext *ctx, Unit *unit, dpacket *packet, int mode, int create, int fallback)
+static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallback)
{
uaecptr fh = GET_PCK_ARG1 (packet) << 2;
uaecptr lock = GET_PCK_ARG2 (packet) << 2;
uaecptr name = GET_PCK_ARG3 (packet) << 2;
a_inode *aino;
Key *k;
- struct fs_filehandle *fd = NULL;
+ struct fs_filehandle *fd;
int err;
mode_t openmode;
int aino_created = 0;
int isvirtual = unit->volflags & MYVOLUMEINFO_ARCHIVE;
- aino = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err);
+ TRACE((_T("ACTION_FIND_*(0x%08x,0x%08x,\"%s\",%d,%d)\n"), fh, lock, bstr (unit, name), mode, create));
+ TRACE((_T("fh=%x lock=%x name=%x\n"), fh, lock, name));
+ DUMPLOCK(unit, lock);
+
+ aino = find_aino (unit, lock, bstr (unit, name), &err);
if (aino == 0 || (err != 0 && err != ERROR_OBJECT_NOT_AROUND)) {
/* Whatever it is, we can't handle it. */
@@ -4091,25 +4065,20 @@ static void do_find(TrapContext *ctx, Unit *unit, dpacket *packet, int mode, int
PUT_PCK_RES2 (packet, ERROR_OBJECT_IN_USE);
return;
}
- if (create && aino->vfso) {
- PUT_PCK_RES1 (packet, DOS_FALSE);
- PUT_PCK_RES2 (packet, ERROR_DELETE_PROTECTED);
- return;
- }
if (create == 2 && (aino->amigaos_mode & A_FIBF_DELETE) != 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DELETE_PROTECTED);
return;
}
if (create != 2) {
- if ((((mode & aino->amigaos_mode) & A_FIBF_WRITE) != 0 || is_writeprotected(unit))
+ if ((((mode & aino->amigaos_mode) & A_FIBF_WRITE) != 0 || unit->ui.readonly || unit->ui.locked)
&& fallback)
{
mode &= ~A_FIBF_WRITE;
}
/* Kick 1.3 doesn't check read and write access bits - maybe it would be
* simpler just not to do that either. */
- if ((mode & A_FIBF_WRITE) != 0 && is_writeprotected(unit)) {
+ if ((mode & A_FIBF_WRITE) != 0 && (unit->ui.readonly || unit->ui.locked)) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
return;
@@ -4133,7 +4102,7 @@ static void do_find(TrapContext *ctx, Unit *unit, dpacket *packet, int mode, int
return;
} else {
/* Object does not exist. aino points to containing directory. */
- aino = create_child_aino(unit, aino, my_strdup (bstr_cut(ctx, unit, name)), 0);
+ aino = create_child_aino (unit, aino, my_strdup (bstr_cut (unit, name)), 0);
if (aino == 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_IS_FULL); /* best we can do */
@@ -4144,23 +4113,21 @@ static void do_find(TrapContext *ctx, Unit *unit, dpacket *packet, int mode, int
prepare_for_open (aino->nname);
- if (!aino->vfso) {
- openmode = (((mode & A_FIBF_READ) == 0 ? O_WRONLY
- : (mode & A_FIBF_WRITE) == 0 ? O_RDONLY
- : O_RDWR)
- | (create ? O_CREAT : 0)
- | (create == 2 ? O_TRUNC : 0));
-
- fd = fs_openfile (unit, aino, openmode | O_BINARY);
- if (fd == NULL) {
- if (aino_created)
- delete_aino (unit, aino);
- PUT_PCK_RES1 (packet, DOS_FALSE);
- /* archive and fd == NULL = corrupt archive or out of memory */
- PUT_PCK_RES2 (packet, isvirtual ? ERROR_OBJECT_NOT_AROUND : dos_errno ());
- return;
- }
- }
+ openmode = (((mode & A_FIBF_READ) == 0 ? O_WRONLY
+ : (mode & A_FIBF_WRITE) == 0 ? O_RDONLY
+ : O_RDWR)
+ | (create ? O_CREAT : 0)
+ | (create == 2 ? O_TRUNC : 0));
+
+ fd = fs_openfile (unit, aino, openmode | O_BINARY);
+ if (fd == NULL) {
+ if (aino_created)
+ delete_aino (unit, aino);
+ PUT_PCK_RES1 (packet, DOS_FALSE);
+ /* archive and fd == NULL = corrupt archive or out of memory */
+ PUT_PCK_RES2 (packet, isvirtual ? ERROR_OBJECT_NOT_AROUND : dos_errno ());
+ return;
+ }
k = new_key (unit);
k->fd = fd;
@@ -4172,7 +4139,7 @@ static void do_find(TrapContext *ctx, Unit *unit, dpacket *packet, int mode, int
if (create && isvirtual)
fsdb_set_file_attrs (aino);
- trap_put_long(ctx, fh + 36, k->uniq);
+ put_long (fh+36, k->uniq);
if (create == 2) {
aino->elock = 1;
// clear comment if file already existed
@@ -4185,11 +4152,11 @@ static void do_find(TrapContext *ctx, Unit *unit, dpacket *packet, int mode, int
aino->shlock++;
}
de_recycle_aino (unit, aino);
-
PUT_PCK_RES1 (packet, DOS_TRUE);
}
-static void action_fh_from_lock(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_fh_from_lock (Unit *unit, dpacket packet)
{
uaecptr fh = GET_PCK_ARG1 (packet) << 2;
uaecptr lock = GET_PCK_ARG2 (packet) << 2;
@@ -4199,13 +4166,16 @@ static void action_fh_from_lock(TrapContext *ctx, Unit *unit, dpacket *packet)
mode_t openmode;
int mode;
+ TRACE((_T("ACTION_FH_FROM_LOCK(0x%lx,0x%lx)\n"), fh, lock));
+ DUMPLOCK(unit,lock);
+
if (!lock) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, 0);
return;
}
- aino = aino_from_lock(ctx, unit, lock);
+ aino = aino_from_lock (unit, lock);
if (aino == 0)
aino = &unit->rootnode;
@@ -4213,12 +4183,13 @@ static void action_fh_from_lock(TrapContext *ctx, Unit *unit, dpacket *packet)
prepare_for_open (aino->nname);
+ TRACE ((_T(" mode is %d\n"), mode));
openmode = (((mode & A_FIBF_READ) ? O_WRONLY
: (mode & A_FIBF_WRITE) ? O_RDONLY
: O_RDWR));
/* the files on CD really can have the write-bit set. */
- if (is_writeprotected(unit))
+ if (unit->ui.readonly || unit->ui.locked)
openmode = O_RDONLY;
fd = fs_openfile (unit, aino, openmode | O_BINARY);
@@ -4232,39 +4203,42 @@ static void action_fh_from_lock(TrapContext *ctx, Unit *unit, dpacket *packet)
k->fd = fd;
k->aino = aino;
- trap_put_long(ctx, fh + 36, k->uniq);
+ put_long (fh+36, k->uniq);
/* I don't think I need to play with shlock count here, because I'm
opening from an existing lock ??? */
de_recycle_aino (unit, aino);
- free_lock (ctx, unit, lock); /* lock must be unlocked */
+ free_lock (unit, lock); /* lock must be unlocked */
PUT_PCK_RES1 (packet, DOS_TRUE);
/* PUT_PCK_RES2 (packet, k->uniq); - this shouldn't be necessary, try without it */
}
-static void action_find_input(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_find_input (Unit *unit, dpacket packet)
{
- do_find(ctx, unit, packet, A_FIBF_READ | A_FIBF_WRITE, 0, 1);
+ do_find(unit, packet, A_FIBF_READ|A_FIBF_WRITE, 0, 1);
}
-static void action_find_output(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_find_output (Unit *unit, dpacket packet)
{
- if (is_writeprotected(unit)) {
+ if (unit->ui.readonly || unit->ui.locked) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
return;
}
- do_find(ctx, unit, packet, A_FIBF_READ | A_FIBF_WRITE, 2, 0);
+ do_find(unit, packet, A_FIBF_READ|A_FIBF_WRITE, 2, 0);
}
-static void action_find_write(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_find_write (Unit *unit, dpacket packet)
{
- if (is_writeprotected(unit)) {
+ if (unit->ui.readonly || unit->ui.locked) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
return;
}
- do_find(ctx, unit, packet, A_FIBF_READ | A_FIBF_WRITE, 1, 0);
+ do_find(unit, packet, A_FIBF_READ|A_FIBF_WRITE, 1, 0);
}
/* change file/dir's parent dir modification time */
@@ -4283,14 +4257,16 @@ static void updatedirtime (a_inode *a1, int now)
}
}
-static void action_end(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_end (Unit *unit, dpacket packet)
{
Key *k;
+ TRACE((_T("ACTION_END(0x%lx)\n"), GET_PCK_ARG1 (packet)));
k = lookup_key (unit, GET_PCK_ARG1 (packet));
if (k != 0) {
if (k->notifyactive) {
- notify_check(ctx, unit, k->aino);
+ notify_check (unit, k->aino);
updatedirtime (k->aino, 1);
}
if (k->aino->elock)
@@ -4304,7 +4280,8 @@ static void action_end(TrapContext *ctx, Unit *unit, dpacket *packet)
PUT_PCK_RES2 (packet, 0);
}
-static void action_read(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_read (Unit *unit, dpacket packet)
{
Key *k = lookup_key (unit, GET_PCK_ARG1 (packet));
uaecptr addr = GET_PCK_ARG2 (packet);
@@ -4316,25 +4293,17 @@ static void action_read(TrapContext *ctx, Unit *unit, dpacket *packet)
/* PUT_PCK_RES2 (packet, EINVAL); */
return;
}
- gui_flicker_led (UNIT_LED(unit), unit->unit, 1);
+ TRACE((_T("ACTION_READ(%s,0x%lx,%ld)\n"), k->aino->nname, addr, size));
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 1);
if (size == 0) {
PUT_PCK_RES1 (packet, 0);
PUT_PCK_RES2 (packet, 0);
- } else if (k->aino->vfso) {
- uae_s64 filesize = k->aino->vfso->size;
- for (int i = 0; i < size && k->file_pos < filesize; i++) {
- trap_put_byte(ctx, addr + i, k->aino->vfso->data[k->file_pos]);
- k->file_pos++;
- actual++;
- }
- PUT_PCK_RES1 (packet, actual);
- size = 0;
- } else {
+ } else if (!valid_address (addr, size)) {
/* check if filesize < size */
uae_s64 filesize, cur;
- filesize = key_filesize(k);
+ filesize = fs_fsize64 (k->fd);
cur = k->file_pos;
if (size > filesize - cur)
size = filesize - cur;
@@ -4342,13 +4311,14 @@ static void action_read(TrapContext *ctx, Unit *unit, dpacket *packet)
if (size == 0) {
PUT_PCK_RES1 (packet, 0);
PUT_PCK_RES2 (packet, 0);
- } else if (!trap_valid_address(ctx, addr, size)) {
+ } else if (!valid_address (addr, size)) {
/* it really crosses memory boundary */
uae_u8 *buf;
+ write_log (_T("unixfs warning: Bad pointer passed for read: %08x, size %d\n"), addr, size);
/* ugh this is inefficient but easy */
- if (key_seek(k, k->file_pos, SEEK_SET) < 0) {
+ if (fs_lseek64 (k->fd, k->file_pos, SEEK_SET) < 0) {
PUT_PCK_RES1 (packet, 0);
PUT_PCK_RES2 (packet, dos_errno ());
return;
@@ -4360,32 +4330,32 @@ static void action_read(TrapContext *ctx, Unit *unit, dpacket *packet)
PUT_PCK_RES2 (packet, ERROR_NO_FREE_STORE);
return;
}
-
actual = fs_read (k->fd, buf, size);
if ((uae_s32)actual == -1) {
PUT_PCK_RES1 (packet, 0);
PUT_PCK_RES2 (packet, dos_errno());
} else {
+ int i;
PUT_PCK_RES1 (packet, actual);
- trap_put_bytes(ctx, buf, addr, actual);
+ for (i = 0; i < actual; i++)
+ put_byte(addr + i, buf[i]);
k->file_pos += actual;
}
xfree (buf);
size = 0;
}
}
-
if (size) {
+ /* normal fast read */
+ uae_u8 *realpt = get_real_address (addr);
- if (key_seek(k, k->file_pos, SEEK_SET) < 0) {
+ if (fs_lseek64 (k->fd, k->file_pos, SEEK_SET) < 0) {
PUT_PCK_RES1 (packet, 0);
PUT_PCK_RES2 (packet, dos_errno ());
return;
}
- /* normal fast read */
- uae_u8 *realpt = get_real_address (addr);
actual = fs_read (k->fd, realpt, size);
if (actual == 0) {
@@ -4399,15 +4369,18 @@ static void action_read(TrapContext *ctx, Unit *unit, dpacket *packet)
k->file_pos += actual;
}
}
+ TRACE((_T("=%d\n"), actual));
}
-static void action_write(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_write (Unit *unit, dpacket packet)
{
Key *k = lookup_key (unit, GET_PCK_ARG1 (packet));
uaecptr addr = GET_PCK_ARG2 (packet);
uae_u32 size = GET_PCK_ARG3 (packet);
uae_u32 actual;
uae_u8 *buf;
+ int i;
if (k == 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -4415,35 +4388,34 @@ static void action_write(TrapContext *ctx, Unit *unit, dpacket *packet)
return;
}
- gui_flicker_led (UNIT_LED(unit), unit->unit, 2);
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 2);
+ TRACE((_T("ACTION_WRITE(%s,0x%lx,%ld)\n"), k->aino->nname, addr, size));
- if (is_writeprotected(unit) || k->aino->vfso) {
+ if (unit->ui.readonly || unit->ui.locked) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
return;
}
if (size == 0) {
-
actual = 0;
PUT_PCK_RES1 (packet, 0);
PUT_PCK_RES2 (packet, 0);
+ } else if (valid_address (addr, size)) {
+ uae_u8 *realpt = get_real_address (addr);
- } else if (trap_valid_address(ctx, addr, size)) {
-
- if (key_seek(k, k->file_pos, SEEK_SET) < 0) {
+ if (fs_lseek64 (k->fd, k->file_pos, SEEK_SET) < 0) {
PUT_PCK_RES1 (packet, 0);
PUT_PCK_RES2 (packet, dos_errno ());
return;
}
- uae_u8 *realpt = get_real_address (addr);
actual = fs_write (k->fd, realpt, size);
-
} else {
+ write_log (_T("unixfs warning: Bad pointer passed for write: %08x, size %d\n"), addr, size);
/* ugh this is inefficient but easy */
- if (key_seek(k, k->file_pos, SEEK_SET) < 0) {
+ if (fs_lseek64 (k->fd, k->file_pos, SEEK_SET) < 0) {
PUT_PCK_RES1 (packet, 0);
PUT_PCK_RES2 (packet, dos_errno ());
return;
@@ -4456,12 +4428,14 @@ static void action_write(TrapContext *ctx, Unit *unit, dpacket *packet)
return;
}
- trap_get_bytes(ctx, buf, addr, size);
+ for (i = 0; i < size; i++)
+ buf[i] = get_byte(addr + i);
actual = fs_write(k->fd, buf, size);
xfree (buf);
}
+ TRACE((_T("=%d\n"), actual));
PUT_PCK_RES1 (packet, actual);
if (actual != size)
PUT_PCK_RES2 (packet, dos_errno ());
@@ -4471,11 +4445,12 @@ static void action_write(TrapContext *ctx, Unit *unit, dpacket *packet)
k->notifyactive = 1;
}
-static void action_seek(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_seek (Unit *unit, dpacket packet)
{
Key *k = lookup_key (unit, GET_PCK_ARG1 (packet));
- int pos = (uae_s32)GET_PCK_ARG2 (packet);
- int mode = (uae_s32)GET_PCK_ARG3 (packet);
+ long pos = (uae_s32)GET_PCK_ARG2 (packet);
+ long mode = (uae_s32)GET_PCK_ARG3 (packet);
uae_s64 res;
uae_s64 cur;
int whence = SEEK_CUR;
@@ -4493,9 +4468,11 @@ static void action_seek(TrapContext *ctx, Unit *unit, dpacket *packet)
whence = SEEK_SET;
cur = k->file_pos;
- gui_flicker_led (UNIT_LED(unit), unit->unit, 1);
+ TRACE((_T("ACTION_SEEK(%s,%d,%d)=%d\n"), k->aino->nname, pos, mode, cur));
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 1);
+
+ filesize = fs_fsize64 (k->fd);
- filesize = key_filesize(k);
if (whence == SEEK_CUR)
temppos = cur + pos;
if (whence == SEEK_SET)
@@ -4508,18 +4485,19 @@ static void action_seek(TrapContext *ctx, Unit *unit, dpacket *packet)
return;
}
- res = key_seek(k, pos, whence);
+ res = fs_lseek64 (k->fd, pos, whence);
if (-1 == res || cur > MAXFILESIZE32) {
PUT_PCK_RES1 (packet, -1);
PUT_PCK_RES2 (packet, ERROR_SEEK_ERROR);
- key_seek(k, cur, SEEK_SET);
+ fs_lseek64 (k->fd, cur, SEEK_SET);
} else {
PUT_PCK_RES1 (packet, cur);
- k->file_pos = key_seek(k, 0, SEEK_CUR);
+ k->file_pos = fs_lseek64 (k->fd, 0, SEEK_CUR);
}
}
-static void action_set_protect(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_set_protect (Unit *unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG2 (packet) << 2;
uaecptr name = GET_PCK_ARG3 (packet) << 2;
@@ -4527,13 +4505,15 @@ static void action_set_protect(TrapContext *ctx, Unit *unit, dpacket *packet)
a_inode *a;
int err;
- if (is_writeprotected(unit)) {
+ TRACE((_T("ACTION_SET_PROTECT(0x%lx,\"%s\",0x%lx)\n"), lock, bstr (unit, name), mask));
+
+ if (unit->ui.readonly || unit->ui.locked) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
return;
}
- a = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err);
+ a = find_aino (unit, lock, bstr (unit, name), &err);
if (err != 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, err);
@@ -4550,11 +4530,11 @@ static void action_set_protect(TrapContext *ctx, Unit *unit, dpacket *packet)
} else {
PUT_PCK_RES1 (packet, DOS_TRUE);
}
- notify_check(ctx, unit, a);
- gui_flicker_led (UNIT_LED(unit), unit->unit, 2);
+ notify_check (unit, a);
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 2);
}
-static void action_set_comment(TrapContext *ctx, Unit * unit, dpacket *packet)
+static void action_set_comment (Unit * unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG2 (packet) << 2;
uaecptr name = GET_PCK_ARG3 (packet) << 2;
@@ -4563,14 +4543,14 @@ static void action_set_comment(TrapContext *ctx, Unit * unit, dpacket *packet)
a_inode *a;
int err;
- if (is_writeprotected(unit)) {
+ if (unit->ui.readonly || unit->ui.locked) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
return;
}
if (fsdb_cando (unit)) {
- commented = bstr(ctx, unit, comment);
+ commented = bstr (unit, comment);
if (_tcslen (commented) > 80) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_COMMENT_TOO_BIG);
@@ -4585,8 +4565,9 @@ static void action_set_comment(TrapContext *ctx, Unit * unit, dpacket *packet)
commented = NULL;
}
}
+ TRACE ((_T("ACTION_SET_COMMENT(0x%lx,\"%s\")\n"), lock, commented));
- a = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err);
+ a = find_aino (unit, lock, bstr (unit, name), &err);
if (err != 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, err);
@@ -4607,37 +4588,43 @@ static void action_set_comment(TrapContext *ctx, Unit * unit, dpacket *packet)
xfree (a->comment);
a->comment = commented;
fsdb_set_file_attrs (a);
- notify_check(ctx, unit, a);
- gui_flicker_led (UNIT_LED(unit), unit->unit, 2);
+ notify_check (unit, a);
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 2);
}
-static void action_same_lock(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_same_lock (Unit *unit, dpacket packet)
{
uaecptr lock1 = GET_PCK_ARG1 (packet) << 2;
uaecptr lock2 = GET_PCK_ARG2 (packet) << 2;
+ TRACE((_T("ACTION_SAME_LOCK(0x%lx,0x%lx)\n"), lock1, lock2));
+ DUMPLOCK(unit, lock1); DUMPLOCK(unit, lock2);
+
if (!lock1 || !lock2) {
PUT_PCK_RES1 (packet, lock1 == lock2 ? DOS_TRUE : DOS_FALSE);
} else {
- PUT_PCK_RES1 (packet, trap_get_long(ctx, lock1 + 4) == trap_get_long(ctx, lock2 + 4) ? DOS_TRUE : DOS_FALSE);
+ PUT_PCK_RES1 (packet, get_long (lock1 + 4) == get_long (lock2 + 4) ? DOS_TRUE : DOS_FALSE);
}
}
-static void action_change_mode(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_change_mode (Unit *unit, dpacket packet)
{
#define CHANGE_LOCK 0
#define CHANGE_FH 1
/* will be CHANGE_FH or CHANGE_LOCK value */
- int type = GET_PCK_ARG1 (packet);
+ long type = GET_PCK_ARG1 (packet);
/* either a file-handle or lock */
uaecptr object = GET_PCK_ARG2 (packet) << 2;
/* will be EXCLUSIVE_LOCK/SHARED_LOCK if CHANGE_LOCK,
* or MODE_OLDFILE/MODE_NEWFILE/MODE_READWRITE if CHANGE_FH *
* Above is wrong, it is always *_LOCK. TW. */
- int mode = GET_PCK_ARG3 (packet);
+ long mode = GET_PCK_ARG3 (packet);
unsigned long uniq;
a_inode *a = NULL, *olda = NULL;
int err = 0;
+ TRACE((_T("ACTION_CHANGE_MODE(0x%lx,%d,%d)\n"), object, type, mode));
if (! object || (type != CHANGE_FH && type != CHANGE_LOCK)) {
PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -4646,9 +4633,9 @@ static void action_change_mode(TrapContext *ctx, Unit *unit, dpacket *packet)
}
if (type == CHANGE_LOCK) {
- uniq = trap_get_long(ctx, object + 4);
+ uniq = get_long (object + 4);
} else {
- Key *k = lookup_key (unit, trap_get_long(ctx, object + 36));
+ Key *k = lookup_key (unit, get_long (object + 36));
if (!k) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND);
@@ -4684,7 +4671,8 @@ static void action_change_mode(TrapContext *ctx, Unit *unit, dpacket *packet)
}
}
-static void action_parent_common(TrapContext *ctx, Unit *unit, dpacket *packet, unsigned long uniq)
+static void
+ action_parent_common (Unit *unit, dpacket packet, unsigned long uniq)
{
a_inode *olda = lookup_aino (unit, uniq);
if (olda == 0) {
@@ -4705,10 +4693,11 @@ static void action_parent_common(TrapContext *ctx, Unit *unit, dpacket *packet,
}
olda->parent->shlock++;
de_recycle_aino (unit, olda->parent);
- PUT_PCK_RES1 (packet, make_lock (ctx, unit, olda->parent->uniq, -2) >> 2);
+ PUT_PCK_RES1 (packet, make_lock (unit, olda->parent->uniq, -2) >> 2);
}
-static void action_parent_fh(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_parent_fh (Unit *unit, dpacket packet)
{
Key *k = lookup_key (unit, GET_PCK_ARG1 (packet));
if (!k) {
@@ -4716,35 +4705,42 @@ static void action_parent_fh(TrapContext *ctx, Unit *unit, dpacket *packet)
PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND);
return;
}
- action_parent_common (ctx, unit, packet, k->aino->uniq);
+ action_parent_common (unit, packet, k->aino->uniq);
}
-static void action_parent(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_parent (Unit *unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
+ TRACE((_T("ACTION_PARENT(0x%lx)\n"),lock));
+
if (!lock) {
PUT_PCK_RES1 (packet, 0);
PUT_PCK_RES2 (packet, 0);
} else {
- action_parent_common(ctx, unit, packet, trap_get_long(ctx, lock + 4));
+ action_parent_common (unit, packet, get_long (lock + 4));
}
+ TRACE((_T("=%x %d\n"), GET_PCK_RES1 (packet), GET_PCK_RES2 (packet)));
}
-static void action_create_dir(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_create_dir (Unit *unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
uaecptr name = GET_PCK_ARG2 (packet) << 2;
a_inode *aino;
int err;
- if (is_writeprotected(unit)) {
+ TRACE((_T("ACTION_CREATE_DIR(0x%lx,\"%s\")\n"), lock, bstr (unit, name)));
+
+ if (unit->ui.readonly || unit->ui.locked) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
return;
}
- aino = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err);
+ aino = find_aino (unit, lock, bstr (unit, name), &err);
if (aino == 0 || (err != 0 && err != ERROR_OBJECT_NOT_AROUND)) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, err);
@@ -4757,7 +4753,7 @@ static void action_create_dir(TrapContext *ctx, Unit *unit, dpacket *packet)
return;
}
/* Object does not exist. aino points to containing directory. */
- aino = create_child_aino(unit, aino, my_strdup (bstr_cut(ctx, unit, name)), 1);
+ aino = create_child_aino (unit, aino, my_strdup (bstr_cut (unit, name)), 1);
if (aino == 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_IS_FULL); /* best we can do */
@@ -4772,36 +4768,45 @@ static void action_create_dir(TrapContext *ctx, Unit *unit, dpacket *packet)
aino->shlock = 1;
fsdb_set_file_attrs (aino);
de_recycle_aino (unit, aino);
- notify_check(ctx, unit, aino);
+ notify_check (unit, aino);
updatedirtime (aino, 0);
- PUT_PCK_RES1(packet, make_lock(ctx, unit, aino->uniq, -2) >> 2);
- gui_flicker_led (UNIT_LED(unit), unit->unit, 2);
+ PUT_PCK_RES1 (packet, make_lock (unit, aino->uniq, -2) >> 2);
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 2);
}
-static void action_examine_fh(TrapContext *ctx, Unit *unit, dpacket *packet, bool largefilesize)
+static void
+ action_examine_fh (Unit *unit, dpacket packet, bool largefilesize)
{
Key *k;
a_inode *aino = 0;
uaecptr info = GET_PCK_ARG2 (packet) << 2;
+ TRACE((_T("ACTION_EXAMINE_FH(0x%lx,0x%lx,%d)\n"),
+ GET_PCK_ARG1 (packet), GET_PCK_ARG2 (packet), largefilesize ));
+
k = lookup_key (unit, GET_PCK_ARG1 (packet));
if (k != 0)
aino = k->aino;
if (aino == 0)
aino = &unit->rootnode;
- get_fileinfo(ctx, unit, packet, info, aino, largefilesize);
+ get_fileinfo (unit, packet, info, aino, largefilesize);
+ if (aino->dir)
+ put_long (info, 0xFFFFFFFF);
+ else
+ put_long (info, 0);
}
/* For a nice example of just how contradictory documentation can be, see the
* Autodoc for DOS:SetFileSize and the Packets.txt description of this packet...
* This implementation tries to mimic the behaviour of the Kick 3.1 ramdisk
* (which seems to match the Autodoc description). */
-static void action_set_file_size(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_set_file_size (Unit *unit, dpacket packet)
{
Key *k, *k1;
off_t offset = GET_PCK_ARG2 (packet);
- int mode = (uae_s32)GET_PCK_ARG3 (packet);
+ long mode = (uae_s32)GET_PCK_ARG3 (packet);
int whence = SEEK_CUR;
if (mode > 0)
@@ -4809,26 +4814,23 @@ static void action_set_file_size(TrapContext *ctx, Unit *unit, dpacket *packet)
if (mode < 0)
whence = SEEK_SET;
+ TRACE((_T("ACTION_SET_FILE_SIZE(0x%lx, %d, 0x%x)\n"), GET_PCK_ARG1 (packet), offset, mode));
+
k = lookup_key (unit, GET_PCK_ARG1 (packet));
if (k == 0) {
PUT_PCK_RES1 (packet, DOS_TRUE);
PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND);
return;
}
- if (k->aino->vfso) {
- PUT_PCK_RES1 (packet, DOS_FALSE);
- PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
- return;
- }
/* Fail if file is >=2G, it is not safe operation. */
- if (key_filesize(k) > MAXFILESIZE32_2G) {
+ if (fs_fsize64 (k->fd) > MAXFILESIZE32) {
PUT_PCK_RES1 (packet, DOS_TRUE);
PUT_PCK_RES2 (packet, ERROR_BAD_NUMBER); /* ? */
return;
}
- gui_flicker_led (UNIT_LED(unit), unit->unit, 1);
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 1);
k->notifyactive = 1;
/* If any open files have file pointers beyond this size, truncate only
* so far that these pointers do not become invalid. */
@@ -4904,26 +4906,29 @@ static void relock_re(Unit *unit, a_inode *a1, a_inode *a2, int failed)
write_log (_T("relocking failed '%s' -> '%s'\n"), a1->nname, a2->nname);
free_key (unit, k1);
} else {
- key_seek(k1, k1->file_pos, SEEK_SET);
+ fs_lseek64 (k1->fd, k1->file_pos, SEEK_SET);
}
}
}
}
-static void action_delete_object(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_delete_object (Unit *unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
uaecptr name = GET_PCK_ARG2 (packet) << 2;
a_inode *a;
int err;
- if (is_writeprotected(unit)) {
+ TRACE((_T("ACTION_DELETE_OBJECT(0x%lx,\"%s\")\n"), lock, bstr (unit, name)));
+
+ if (unit->ui.readonly || unit->ui.locked) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
return;
}
- a = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err);
+ a = find_aino (unit, lock, bstr (unit, name), &err);
if (err != 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -4940,24 +4945,23 @@ static void action_delete_object(TrapContext *ctx, Unit *unit, dpacket *packet)
PUT_PCK_RES2 (packet, ERROR_OBJECT_IN_USE);
return;
}
- if (!a->vfso) {
- if (a->dir) {
- /* This should take care of removing the fsdb if no files remain. */
- fsdb_dir_writeback (a);
- if (my_rmdir (a->nname) == -1) {
- PUT_PCK_RES1 (packet, DOS_FALSE);
- PUT_PCK_RES2 (packet, dos_errno());
- return;
- }
- } else {
- if (my_unlink (a->nname) == -1) {
- PUT_PCK_RES1 (packet, DOS_FALSE);
- PUT_PCK_RES2 (packet, dos_errno());
- return;
- }
- }
- }
- notify_check(ctx, unit, a);
+ if (a->dir) {
+ /* This should take care of removing the fsdb if no files remain. */
+ fsdb_dir_writeback (a);
+ if (my_rmdir (a->nname) == -1) {
+ PUT_PCK_RES1 (packet, DOS_FALSE);
+ PUT_PCK_RES2 (packet, dos_errno());
+ return;
+ }
+ } else {
+ if (my_unlink (a->nname) == -1) {
+ PUT_PCK_RES1 (packet, DOS_FALSE);
+ PUT_PCK_RES2 (packet, dos_errno());
+ return;
+ }
+ }
+
+ notify_check (unit, a);
updatedirtime (a, 1);
if (a->child != 0) {
write_log (_T("Serious error in action_delete_object.\n"));
@@ -4966,48 +4970,50 @@ static void action_delete_object(TrapContext *ctx, Unit *unit, dpacket *packet)
delete_aino (unit, a);
}
PUT_PCK_RES1 (packet, DOS_TRUE);
- gui_flicker_led (UNIT_LED(unit), unit->unit, 2);
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 2);
}
-static void action_set_date(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_set_date (Unit *unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG2 (packet) << 2;
uaecptr name = GET_PCK_ARG3 (packet) << 2;
uaecptr date = GET_PCK_ARG4 (packet);
a_inode *a;
struct mytimeval tv;
- int err = 0;
+ int err;
- if (is_writeprotected(unit)) {
+ TRACE((_T("ACTION_SET_DATE(0x%lx,\"%s\")\n"), lock, bstr (unit, name)));
+
+ if (unit->ui.readonly || unit->ui.locked) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
return;
}
- a = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err);
+ a = find_aino (unit, lock, bstr (unit, name), &err);
if (err != 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, err);
return;
}
- if (!a->vfso) {
- amiga_to_timeval (&tv, trap_get_long(ctx, date), trap_get_long(ctx, date + 4), trap_get_long(ctx, date + 8), 50);
- //write_log (_T("%llu.%u (%d,%d,%d) %s\n"), tv.tv_sec, tv.tv_usec, trap_get_long(ctx, date), trap_get_long(ctx, date + 4), trap_get_long(ctx, date + 8), a->nname);
- if (!my_utime (a->nname, &tv))
- err = dos_errno ();
- }
+ amiga_to_timeval (&tv, get_long (date), get_long (date + 4), get_long (date + 8));
+ //write_log (_T("%llu.%u (%d,%d,%d) %s\n"), tv.tv_sec, tv.tv_usec, get_long (date), get_long (date + 4), get_long (date + 8), a->nname);
+ if (!my_utime (a->nname, &tv))
+ err = dos_errno ();
if (err != 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, err);
return;
} else {
- notify_check(ctx, unit, a);
+ notify_check (unit, a);
PUT_PCK_RES1 (packet, DOS_TRUE);
}
- gui_flicker_led (UNIT_LED(unit), unit->unit, 2);
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 2);
}
-static void action_rename_object(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_rename_object (Unit *unit, dpacket packet)
{
uaecptr lock1 = GET_PCK_ARG1 (packet) << 2;
uaecptr name1 = GET_PCK_ARG2 (packet) << 2;
@@ -5018,18 +5024,22 @@ static void action_rename_object(TrapContext *ctx, Unit *unit, dpacket *packet)
Key *k1, *knext;
int wehavekeys = 0;
- if (is_writeprotected(unit)) {
+ TRACE((_T("ACTION_RENAME_OBJECT(0x%lx,\"%s\","), lock1, bstr (unit, name1)));
+ TRACE((_T("0x%lx,\"%s\")\n"), lock2, bstr (unit, name2)));
+
+ if (unit->ui.readonly || unit->ui.locked) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
return;
}
- a1 = find_aino(ctx, unit, lock1, bstr(ctx, unit, name1), &err1);
+ a1 = find_aino (unit, lock1, bstr (unit, name1), &err1);
if (err1 != 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, err1);
return;
}
+
/* rename always fails if file is open for writing */
for (k1 = unit->keys; k1; k1 = knext) {
knext = k1->next;
@@ -5041,13 +5051,12 @@ static void action_rename_object(TrapContext *ctx, Unit *unit, dpacket *packet)
}
/* See whether the other name already exists in the filesystem. */
- a2 = find_aino(ctx, unit, lock2, bstr(ctx, unit, name2), &err2);
-
+ a2 = find_aino (unit, lock2, bstr (unit, name2), &err2);
if (a2 == a1) {
/* Renaming to the same name, but possibly different case. */
- if (_tcscmp (a1->aname, bstr_cut(ctx, unit, name2)) == 0) {
+ if (_tcscmp (a1->aname, bstr_cut (unit, name2)) == 0) {
/* Exact match -> do nothing. */
- notify_check(ctx, unit, a1);
+ notify_check (unit, a1);
updatedirtime (a1, 1);
PUT_PCK_RES1 (packet, DOS_TRUE);
return;
@@ -5059,34 +5068,32 @@ static void action_rename_object(TrapContext *ctx, Unit *unit, dpacket *packet)
return;
}
- a2 = create_child_aino (unit, a2, bstr_cut(ctx, unit, name2), a1->dir);
+ a2 = create_child_aino (unit, a2, bstr_cut (unit, name2), a1->dir);
if (a2 == 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_IS_FULL); /* best we can do */
return;
}
- if (!a1->vfso) {
- if (-1 == my_rename (a1->nname, a2->nname)) {
- int ret = -1;
- /* maybe we have open file handles that caused failure? */
- write_log (_T("rename '%s' -> '%s' failed, trying relocking..\n"), a1->nname, a2->nname);
- wehavekeys = relock_do(unit, a1);
- /* try again... */
- ret = my_rename (a1->nname, a2->nname);
- /* restore locks */
- relock_re(unit, a1, a2, ret == -1 ? 1 : 0);
- if (ret == -1) {
- delete_aino (unit, a2);
- PUT_PCK_RES1 (packet, DOS_FALSE);
- PUT_PCK_RES2 (packet, dos_errno ());
- return;
- }
+ if (-1 == my_rename (a1->nname, a2->nname)) {
+ int ret = -1;
+ /* maybe we have open file handles that caused failure? */
+ write_log (_T("rename '%s' -> '%s' failed, trying relocking..\n"), a1->nname, a2->nname);
+ wehavekeys = relock_do(unit, a1);
+ /* try again... */
+ ret = my_rename (a1->nname, a2->nname);
+ /* restore locks */
+ relock_re(unit, a1, a2, ret == -1 ? 1 : 0);
+ if (ret == -1) {
+ delete_aino (unit, a2);
+ PUT_PCK_RES1 (packet, DOS_FALSE);
+ PUT_PCK_RES2 (packet, dos_errno ());
+ return;
}
- }
+ }
- notify_check(ctx, unit, a1);
- notify_check(ctx, unit, a2);
+ notify_check (unit, a1);
+ notify_check (unit, a2);
a2->comment = a1->comment;
a1->comment = 0;
a2->amigaos_mode = a1->amigaos_mode;
@@ -5096,7 +5103,6 @@ static void action_rename_object(TrapContext *ctx, Unit *unit, dpacket *packet)
a2->has_dbentry = a1->has_dbentry;
a2->db_offset = a1->db_offset;
a2->dirty = 0;
- a2->vfso = a1->vfso;
move_exkeys (unit, a1, a2);
move_aino_children (unit, a1, a2);
delete_aino (unit, a1);
@@ -5108,10 +5114,11 @@ static void action_rename_object(TrapContext *ctx, Unit *unit, dpacket *packet)
if (a2->elock > 0 || a2->shlock > 0 || wehavekeys > 0)
de_recycle_aino (unit, a2);
PUT_PCK_RES1 (packet, DOS_TRUE);
- gui_flicker_led (UNIT_LED(unit), unit->unit, 2);
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 2);
}
-static void action_current_volume(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_current_volume (Unit *unit, dpacket packet)
{
if (filesys_isvolume(unit))
PUT_PCK_RES1 (packet, unit->volume >> 2);
@@ -5119,11 +5126,14 @@ static void action_current_volume(TrapContext *ctx, Unit *unit, dpacket *packet)
PUT_PCK_RES1 (packet, 0);
}
-static void action_rename_disk(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_rename_disk (Unit *unit, dpacket packet)
{
uaecptr name = GET_PCK_ARG1 (packet) << 2;
- if (is_writeprotected(unit)) {
+ TRACE((_T("ACTION_RENAME_DISK(\"%s\")\n"), bstr (unit, name)));
+
+ if (unit->ui.readonly || unit->ui.locked) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED);
return;
@@ -5131,39 +5141,49 @@ static void action_rename_disk(TrapContext *ctx, Unit *unit, dpacket *packet)
/* get volume name */
xfree (unit->ui.volname);
- unit->ui.volname = bstr1(ctx, name);
+ unit->ui.volname = bstr1 (name);
set_volume_name (unit, 0);
PUT_PCK_RES1 (packet, DOS_TRUE);
}
-static void action_is_filesystem(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_is_filesystem (Unit *unit, dpacket packet)
{
+ TRACE((_T("ACTION_IS_FILESYSTEM()\n")));
PUT_PCK_RES1 (packet, DOS_TRUE);
}
-static void action_flush(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_flush (Unit *unit, dpacket packet)
{
+ TRACE((_T("ACTION_FLUSH()\n")));
PUT_PCK_RES1 (packet, DOS_TRUE);
flush_cache(unit, 0);
}
-static void action_more_cache(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_more_cache (Unit *unit, dpacket packet)
{
+ TRACE((_T("ACTION_MORE_CACHE()\n")));
PUT_PCK_RES1 (packet, 50); /* bug but AmigaOS expects it */
if (GET_PCK_ARG1 (packet) != 0)
flush_cache(unit, 0);
}
-static void action_inhibit(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_inhibit (Unit *unit, dpacket packet)
{
PUT_PCK_RES1 (packet, DOS_TRUE);
flush_cache(unit, 0);
unit->inhibited = GET_PCK_ARG1 (packet) != 0;
+ TRACE((_T("ACTION_INHIBIT(%d:%d)\n"), unit->unit, unit->inhibited));
}
-static void action_write_protect(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void
+ action_write_protect (Unit *unit, dpacket packet)
{
+ TRACE((_T("ACTION_WRITE_PROTECT()\n")));
PUT_PCK_RES1 (packet, DOS_TRUE);
if (GET_PCK_ARG1 (packet)) {
if (!unit->ui.locked) {
@@ -5184,88 +5204,11 @@ static void action_write_protect(TrapContext *ctx, Unit *unit, dpacket *packet)
/* OS4 */
-#define TAG_DONE 0
-#define TAG_IGNORE 1
-#define TAG_MORE 2
-#define TAG_SKIP 3
-
-static void action_filesystem_attr(TrapContext *ctx, Unit *unit, dpacket *packet)
-{
- int versize = 0;
- uaecptr verbuffer = 0;
- uaecptr taglist = GET_PCK_ARG1(packet);
- for (;;) {
- uae_u32 tag = trap_get_long(ctx, taglist);
- uae_u32 tagp = taglist + 4;
- if (tag == TAG_DONE)
- break;
- taglist += 8;
- if (tag == TAG_IGNORE)
- continue;
- if (tag == TAG_MORE) {
- uae_u32 val = trap_get_long(ctx, tagp);
- taglist = val;
- continue;
- }
- if (tag == TAG_SKIP) {
- uae_u32 val = trap_get_long(ctx, tagp);
- taglist += val * 8;
- continue;
- }
- uae_u32 retval = 0;
- bool doret = false;
- switch(tag)
- {
- case 0x80002332: // FSA_MaxFileNameLengthR
- retval = currprefs.filesys_max_name;
- doret = true;
- break;
- case 0x80002334: // FSA_VersionNumberR
- retval = (0 << 16) | (5 << 0);
- doret = true;
- break;
- case 0x80002335: // FSA_DOSTypeR
- retval = get_long(unit->volume + 32);
- doret = true;
- break;
- case 0x80002336: // FSA_ActivityFlushTimeoutR
- case 0x80002338: // FSA_InactivityFlushTimeoutR
- retval = 0;
- doret = true;
- break;
- case 0x8000233a: // FSA_MaxRecycledEntriesR
- case 0x8000233c: // FSA_HasRecycledEntriesR
- retval = 0;
- doret = true;
- break;
- case 0x8000233d: // FSA_VersionStringR
- verbuffer = trap_get_long(ctx, tagp);
- break;
- case 0x8000233e: // FSA_VersionStringR_BufSize
- versize = trap_get_long(ctx, tagp);
- break;
- default:
- write_log(_T("action_filesystem_attr unknown tag %08x\n"), tag);
- PUT_PCK64_RES1(packet, DOS_FALSE);
- PUT_PCK64_RES2(packet, ERROR_NOT_IMPLEMENTED);
- return;
- }
- if (doret)
- trap_put_long(ctx, trap_get_long(ctx, tagp), retval);
-
- }
- if (verbuffer && versize) {
- trap_put_string(ctx, UAEFS_VERSION, verbuffer, versize);
- }
- PUT_PCK_RES1(packet, TRUE);
- PUT_PCK_RES2(packet, 0);
-}
-
-static void action_change_file_position64(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void action_change_file_position64 (Unit *unit, dpacket packet)
{
Key *k = lookup_key (unit, GET_PCK64_ARG1 (packet));
uae_s64 pos = GET_PCK64_ARG2 (packet);
- int mode = (uae_s32)GET_PCK64_ARG3 (packet);
+ long mode = GET_PCK64_ARG3 (packet);
long whence = SEEK_CUR;
uae_s64 res, cur;
@@ -5282,12 +5225,13 @@ static void action_change_file_position64(TrapContext *ctx, Unit *unit, dpacket
if (mode < 0)
whence = SEEK_SET;
- gui_flicker_led (UNIT_LED(unit), unit->unit, 1);
+ TRACE((_T("ACTION_CHANGE_FILE_POSITION64(%s,%lld,%d)\n"), k->aino->nname, pos, mode));
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 1);
cur = k->file_pos;
{
uae_s64 temppos;
- uae_s64 filesize = key_filesize(k);
+ uae_s64 filesize = fs_fsize64 (k->fd);
if (whence == SEEK_CUR)
temppos = cur + pos;
@@ -5302,7 +5246,7 @@ static void action_change_file_position64(TrapContext *ctx, Unit *unit, dpacket
return;
}
}
- res = key_seek(k, pos, whence);
+ res = fs_lseek64 (k->fd, pos, whence);
if (-1 == res) {
PUT_PCK64_RES1 (packet, DOS_FALSE);
@@ -5310,11 +5254,13 @@ static void action_change_file_position64(TrapContext *ctx, Unit *unit, dpacket
} else {
PUT_PCK64_RES1 (packet, TRUE);
PUT_PCK64_RES2 (packet, 0);
- k->file_pos = key_seek(k, 0, SEEK_CUR);
+ k->file_pos = fs_lseek64 (k->fd, 0, SEEK_CUR);
}
+ TRACE((_T("= oldpos %lld newpos %lld\n"), cur, k->file_pos));
+
}
-static void action_get_file_position64(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void action_get_file_position64 (Unit *unit, dpacket packet)
{
Key *k = lookup_key (unit, GET_PCK64_ARG1 (packet));
@@ -5325,15 +5271,16 @@ static void action_get_file_position64(TrapContext *ctx, Unit *unit, dpacket *pa
PUT_PCK64_RES2 (packet, ERROR_INVALID_LOCK);
return;
}
+ TRACE((_T("ACTION_GET_FILE_POSITION64(%s)=%lld\n"), k->aino->nname, k->file_pos));
PUT_PCK64_RES1 (packet, k->file_pos);
PUT_PCK64_RES2 (packet, 0);
}
-static void action_change_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void action_change_file_size64 (Unit *unit, dpacket packet)
{
Key *k, *k1;
uae_s64 offset = GET_PCK64_ARG2 (packet);
- int mode = (uae_s32)GET_PCK64_ARG3 (packet);
+ long mode = (uae_s32)GET_PCK64_ARG3 (packet);
int whence = SEEK_CUR;
PUT_PCK64_RES0 (packet, DP64_INIT);
@@ -5343,6 +5290,8 @@ static void action_change_file_size64(TrapContext *ctx, Unit *unit, dpacket *pac
if (mode < 0)
whence = SEEK_SET;
+ TRACE((_T("ACTION_CHANGE_FILE_SIZE64(0x%lx, %lld, 0x%x)\n"), GET_PCK64_ARG1 (packet), offset, mode));
+
k = lookup_key (unit, GET_PCK64_ARG1 (packet));
if (k == 0) {
PUT_PCK64_RES1 (packet, DOS_FALSE);
@@ -5350,7 +5299,7 @@ static void action_change_file_size64(TrapContext *ctx, Unit *unit, dpacket *pac
return;
}
- gui_flicker_led (UNIT_LED(unit), unit->unit, 1);
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 1);
k->notifyactive = 1;
/* If any open files have file pointers beyond this size, truncate only
* so far that these pointers do not become invalid. */
@@ -5363,11 +5312,11 @@ static void action_change_file_size64(TrapContext *ctx, Unit *unit, dpacket *pac
/* Write one then truncate: that should give the right size in all cases. */
fs_lseek (k->fd, offset, whence);
- offset = key_seek(k, offset, whence);
+ offset = fs_lseek64 (k->fd, offset, whence);
fs_write (k->fd, /* whatever */(uae_u8*)&k1, 1);
if (k->file_pos > offset)
k->file_pos = offset;
- key_seek(k, k->file_pos, SEEK_SET);
+ fs_lseek64 (k->fd, k->file_pos, SEEK_SET);
if (my_truncate (k->aino->nname, offset) == -1) {
PUT_PCK64_RES1 (packet, DOS_FALSE);
@@ -5379,7 +5328,7 @@ static void action_change_file_size64(TrapContext *ctx, Unit *unit, dpacket *pac
PUT_PCK64_RES2 (packet, 0);
}
-static void action_get_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void action_get_file_size64 (Unit *unit, dpacket packet)
{
Key *k = lookup_key (unit, GET_PCK64_ARG1 (packet));
uae_s64 filesize;
@@ -5391,7 +5340,8 @@ static void action_get_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet
PUT_PCK64_RES2 (packet, ERROR_INVALID_LOCK);
return;
}
- filesize = key_filesize(k);
+ filesize = fs_fsize64 (k->fd);
+ TRACE((_T("ACTION_GET_FILE_SIZE64(%s)=%lld\n"), k->aino->nname, filesize));
if (filesize >= 0) {
PUT_PCK64_RES1 (packet, filesize);
PUT_PCK64_RES2 (packet, 0);
@@ -5403,25 +5353,32 @@ static void action_get_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet
/* MOS */
-static void action_examine_object64(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void action_examine_object64(Unit *unit, dpacket packet)
{
uaecptr lock = GET_PCK_ARG1 (packet) << 2;
uaecptr info = GET_PCK_ARG2 (packet) << 2;
a_inode *aino = 0;
+ TRACE((_T("ACTION_EXAMINE_OBJECT(0x%lx,0x%lx)\n"), lock, info));
+ DUMPLOCK(unit, lock);
+
if (lock != 0)
- aino = aino_from_lock(ctx, unit, lock);
+ aino = aino_from_lock (unit, lock);
if (aino == 0)
aino = &unit->rootnode;
- get_fileinfo(ctx, unit, packet, info, aino, true);
+ get_fileinfo (unit, packet, info, aino, true);
+ if (aino->dir) {
+ put_long (info, 0xFFFFFFFF);
+ } else
+ put_long (info, 0);
}
-static void action_set_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void action_set_file_size64(Unit *unit, dpacket packet)
{
Key *k, *k1;
- uae_s64 offset = get_quadp(ctx, GET_PCK_ARG2 (packet));
- int mode = (uae_s32)GET_PCK_ARG3 (packet);
+ uae_s64 offset = get_quadp(GET_PCK_ARG2 (packet));
+ long mode = (uae_s32)GET_PCK_ARG3 (packet);
int whence = SEEK_CUR;
if (mode > 0)
@@ -5429,6 +5386,8 @@ static void action_set_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet
if (mode < 0)
whence = SEEK_SET;
+ TRACE((_T("ACTION_SET_FILE_SIZE64(0x%lx, %lld, 0x%x)\n"), GET_PCK_ARG1 (packet), offset, mode));
+
k = lookup_key (unit, GET_PCK_ARG1 (packet));
if (k == 0) {
PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -5436,7 +5395,7 @@ static void action_set_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet
return;
}
- gui_flicker_led (UNIT_LED(unit), unit->unit, 1);
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 1);
k->notifyactive = 1;
/* If any open files have file pointers beyond this size, truncate only
* so far that these pointers do not become invalid. */
@@ -5449,11 +5408,11 @@ static void action_set_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet
/* Write one then truncate: that should give the right size in all cases. */
fs_lseek (k->fd, offset, whence);
- offset = key_seek(k, offset, whence);
+ offset = fs_lseek64 (k->fd, offset, whence);
fs_write (k->fd, /* whatever */(uae_u8*)&k1, 1);
if (k->file_pos > offset)
k->file_pos = offset;
- key_seek(k, k->file_pos, SEEK_SET);
+ fs_lseek64 (k->fd, k->file_pos, SEEK_SET);
if (my_truncate (k->aino->nname, offset) == -1) {
PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -5462,14 +5421,14 @@ static void action_set_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet
}
PUT_PCK_RES1 (packet, DOS_TRUE);
- set_quadp(ctx, GET_PCK_ARG4(packet), offset);
+ set_quadp(GET_PCK_ARG4(packet), offset);
}
-static void action_seek64(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void action_seek64(Unit *unit, dpacket packet)
{
Key *k = lookup_key(unit, GET_PCK_ARG1(packet));
- uae_s64 pos = get_quadp(ctx, GET_PCK64_ARG2(packet));
- int mode = GET_PCK_ARG3(packet);
+ uae_s64 pos = get_quadp(GET_PCK64_ARG2(packet));
+ long mode = GET_PCK_ARG3(packet);
long whence = SEEK_CUR;
uae_s64 res, cur;
@@ -5484,12 +5443,13 @@ static void action_seek64(TrapContext *ctx, Unit *unit, dpacket *packet)
if (mode < 0)
whence = SEEK_SET;
- gui_flicker_led (UNIT_LED(unit), unit->unit, 1);
+ TRACE((_T("ACTION_SEEK64(%s,%lld,%d)\n"), k->aino->nname, pos, mode));
+ gui_flicker_led(UNIT_LED(unit), unit->unit, 1);
cur = k->file_pos;
{
uae_s64 temppos;
- uae_s64 filesize = key_filesize(k);
+ uae_s64 filesize = fs_fsize64 (k->fd);
if (whence == SEEK_CUR)
temppos = cur + pos;
@@ -5504,23 +5464,24 @@ static void action_seek64(TrapContext *ctx, Unit *unit, dpacket *packet)
return;
}
}
- res = key_seek(k, pos, whence);
+ res = fs_lseek64 (k->fd, pos, whence);
if (-1 == res) {
PUT_PCK_RES1 (packet, DOS_FALSE);
PUT_PCK_RES2 (packet, ERROR_SEEK_ERROR);
} else {
PUT_PCK_RES1 (packet, TRUE);
- set_quadp(ctx, GET_PCK_ARG3(packet), cur);
- k->file_pos = key_seek(k, 0, SEEK_CUR);
+ set_quadp(GET_PCK_ARG3(packet), cur);
+ k->file_pos = fs_lseek64 (k->fd, 0, SEEK_CUR);
}
+ TRACE((_T("= oldpos %lld newpos %lld\n"), cur, k->file_pos));
}
-static int action_lock_record64(TrapContext *ctx, Unit *unit, dpacket *packet, uae_u32 msg)
+static int action_lock_record64(Unit *unit, dpacket packet, uae_u32 msg)
{
Key *k = lookup_key(unit, GET_PCK_ARG1(packet));
- uae_u64 pos = get_quadp(ctx, GET_PCK_ARG2(packet));
- uae_u64 len = get_quadp(ctx, GET_PCK_ARG3(packet));
+ uae_u64 pos = get_quadp(GET_PCK_ARG2(packet));
+ uae_u64 len = get_quadp(GET_PCK_ARG3(packet));
uae_u32 mode = GET_PCK_ARG4(packet);
uae_u32 timeout = GET_PCK_ARG5(packet);
@@ -5556,7 +5517,7 @@ static int action_lock_record64(TrapContext *ctx, Unit *unit, dpacket *packet, u
return 1;
}
- struct lockrecord *lr = new_record(packet, pos, len, mode, timeout, 0);
+ struct lockrecord *lr = new_record (GET_PCK_ARG1(packet), pos, len, mode, timeout, 0);
if (k->record) {
lr->next = k->record;
k->record = lr;
@@ -5568,11 +5529,11 @@ static int action_lock_record64(TrapContext *ctx, Unit *unit, dpacket *packet, u
return 1;
}
-static void action_free_record64(TrapContext *ctx, Unit *unit, dpacket *packet)
+static void action_free_record64(Unit *unit, dpacket packet)
{
Key *k = lookup_key(unit, GET_PCK_ARG1(packet));
- uae_u64 pos = get_quadp(ctx, GET_PCK_ARG2(packet));
- uae_u64 len = get_quadp(ctx, GET_PCK_ARG3 (packet));
+ uae_u64 pos = get_quadp(GET_PCK_ARG2(packet));
+ uae_u64 len = get_quadp(GET_PCK_ARG3 (packet));
write_log (_T("action_free_record('%s',%lld,%lld)\n"), k ? k->aino->nname : _T("null"), pos, len);
@@ -5591,7 +5552,7 @@ static void action_free_record64(TrapContext *ctx, Unit *unit, dpacket *packet)
k->record = lr->next;
xfree (lr);
write_log (_T("->OK\n"));
- record_check_waiting(ctx, unit);
+ record_check_waiting (unit);
PUT_PCK_RES1 (packet, DOS_TRUE);
return;
}
@@ -5605,14 +5566,30 @@ static void action_free_record64(TrapContext *ctx, Unit *unit, dpacket *packet)
* know whether AmigaOS takes care of that, but this does. */
static uae_sem_t singlethread_int_sem = 0;
-static uae_u32 REGPARAM2 exter_int_helper (TrapContext *ctx)
+static uae_u32 REGPARAM2 exter_int_helper (TrapContext *context)
{
UnitInfo *uip = mountinfo.ui;
uaecptr port;
- int n = trap_get_dreg(ctx, 0);
+ int n = m68k_dreg (regs, 0);
static int unit_no;
- if (n == 1) {
+ switch (n) {
+ case 0:
+ /* Determine whether a given EXTER interrupt is for us. */
+ if (uae_int_requested & 1) {
+ if (uae_sem_trywait (&singlethread_int_sem) != 0)
+ /* Pretend it isn't for us. We might get it again later. */
+ return 0;
+ /* Clear the interrupt flag _before_ we do any processing.
+ * That way, we can get too many interrupts, but never not
+ * enough. */
+ filesys_in_interrupt++;
+ uae_int_requested &= ~1;
+ unit_no = 0;
+ return 1;
+ }
+ return 0;
+ case 1:
/* Release a message_lock. This is called as soon as the message is
* received by the assembly code. We use the opportunity to check
* whether we have some locks that we can give back to the assembler
@@ -5622,43 +5599,32 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *ctx)
*/
#ifdef UAE_FILESYS_THREADS
{
- Unit *unit = find_unit(trap_get_areg(ctx, 5));
- uaecptr msg = trap_get_areg(ctx, 4);
+ Unit *unit = find_unit (m68k_areg (regs, 5));
+ uaecptr msg = m68k_areg (regs, 4);
unit->cmds_complete = unit->cmds_acked;
while (comm_pipe_has_data (unit->ui.back_pipe)) {
- uaecptr locks, lockend, lockv;
+ uaecptr locks, lockend;
int cnt = 0;
locks = read_comm_pipe_int_blocking (unit->ui.back_pipe);
lockend = locks;
- while ((lockv = trap_get_long(ctx, lockend)) != 0) {
- if (lockv == lockend) {
+ while (get_long (lockend) != 0) {
+ if (get_long (lockend) == lockend) {
write_log (_T("filesystem lock queue corrupted!\n"));
break;
}
- lockend = lockv;
+ lockend = get_long (lockend);
cnt++;
}
- trap_put_long(ctx, lockend, trap_get_long(ctx, trap_get_areg(ctx, 3)));
- trap_put_long(ctx, trap_get_areg(ctx, 3), locks);
+ TRACE3((_T("message_lock: %d %x %x %x\n"), cnt, locks, lockend, m68k_areg (regs, 3)));
+ put_long (lockend, get_long (m68k_areg (regs, 3)));
+ put_long (m68k_areg (regs, 3), locks);
}
}
#else
write_log (_T("exter_int_helper should not be called with arg 1!\n"));
#endif
- return 0;
- }
-
- if(n == 10) {
- if (uae_sem_trywait (&singlethread_int_sem) != 0) {
- /* Pretend it isn't for us. We might get it again later. */
- do_uae_int_requested();
- return 0;
- }
- filesys_in_interrupt++;
- unit_no = 0;
- }
- if (n >= 10) {
-
+ break;
+ case 2:
/* Find work that needs to be done:
* return d0 = 0: none
* d0 = 1: PutMsg(), port in a0, message in a1
@@ -5674,26 +5640,26 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *ctx)
int cmd = read_comm_pipe_int_blocking (&native2amiga_pending);
switch (cmd) {
case 0: /* Signal() */
- trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending));
- trap_set_dreg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending));
+ m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
+ m68k_dreg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
return 2;
case 1: /* PutMsg() */
- trap_set_areg(ctx, 0, read_comm_pipe_u32_blocking(&native2amiga_pending));
- trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending));
+ m68k_areg (regs, 0) = read_comm_pipe_u32_blocking (&native2amiga_pending);
+ m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
return 1;
case 2: /* ReplyMsg() */
- trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending));
+ m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
return 3;
case 3: /* Cause() */
- trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending));
+ m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
return 4;
case 4: /* NotifyHack() */
- trap_set_areg(ctx, 0, read_comm_pipe_u32_blocking(&native2amiga_pending));
- trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending));
+ m68k_areg (regs, 0) = read_comm_pipe_u32_blocking (&native2amiga_pending);
+ m68k_areg (regs, 1) = read_comm_pipe_u32_blocking (&native2amiga_pending);
return 5;
default:
@@ -5709,7 +5675,7 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *ctx)
* startup packet sent. */
for (;;) {
if (unit_no >= MAX_FILESYSTEM_UNITS)
- goto end;
+ return 0;
if (uip[unit_no].open > 0 && uip[unit_no].self != 0
&& uip[unit_no].self->cmds_acked == uip[unit_no].self->cmds_complete
@@ -5720,26 +5686,35 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *ctx)
uip[unit_no].self->cmds_acked = uip[unit_no].self->cmds_sent;
port = uip[unit_no].self->port;
if (port) {
- trap_set_areg(ctx, 0, port);
- trap_set_areg(ctx, 1, find_unit(port)->dummy_message);
+ m68k_areg (regs, 0) = port;
+ m68k_areg (regs, 1) = find_unit (port)->dummy_message;
unit_no++;
return 1;
}
-
-end:
+ break;
+ case 3:
+ uae_sem_wait (&singlethread_int_sem);
+ break;
+ case 4:
/* Exit the interrupt, and release the single-threading lock. */
filesys_in_interrupt--;
uae_sem_post (&singlethread_int_sem);
+ break;
+
+ default:
+ write_log (_T("Shouldn't happen in exter_int_helper.\n"));
+ break;
}
return 0;
}
-static int handle_packet(TrapContext *ctx, Unit *unit, dpacket *pck, uae_u32 msg, int isvolume)
+static int handle_packet (Unit *unit, dpacket pck, uae_u32 msg)
{
uae_s32 type = GET_PCK_TYPE (pck);
PUT_PCK_RES2 (pck, 0);
- if (unit->inhibited && isvolume
+ TRACE((_T("unit=%x packet=%d\n"), unit, type));
+ if (unit->inhibited && filesys_isvolume(unit)
&& type != ACTION_INHIBIT && type != ACTION_MORE_CACHE
&& type != ACTION_DISK_INFO) {
PUT_PCK_RES1 (pck, DOS_FALSE);
@@ -5749,72 +5724,71 @@ static int handle_packet(TrapContext *ctx, Unit *unit, dpacket *pck, uae_u32 msg
if (type != ACTION_INHIBIT && type != ACTION_CURRENT_VOLUME
&& type != ACTION_IS_FILESYSTEM && type != ACTION_MORE_CACHE
&& type != ACTION_WRITE_PROTECT && type != ACTION_DISK_INFO
- && !isvolume) {
+ && !filesys_isvolume(unit)) {
PUT_PCK_RES1 (pck, DOS_FALSE);
PUT_PCK_RES2 (pck, unit->ui.unknown_media ? ERROR_NOT_A_DOS_DISK : ERROR_NO_DISK);
return 1;
}
switch (type) {
- case ACTION_LOCATE_OBJECT: action_lock (ctx, unit, pck); break;
- case ACTION_FREE_LOCK: action_free_lock (ctx, unit, pck); break;
- case ACTION_COPY_DIR: action_dup_lock (ctx, unit, pck); break;
- case ACTION_DISK_INFO: action_disk_info (ctx, unit, pck); break;
- case ACTION_INFO: action_info (ctx, unit, pck); break;
- case ACTION_EXAMINE_OBJECT: action_examine_object (ctx, unit, pck); break;
- case ACTION_EXAMINE_NEXT: action_examine_next (ctx, unit, pck, false); break;
- case ACTION_FIND_INPUT: action_find_input (ctx, unit, pck); break;
- case ACTION_FIND_WRITE: action_find_write (ctx, unit, pck); break;
- case ACTION_FIND_OUTPUT: action_find_output (ctx, unit, pck); break;
- case ACTION_END: action_end (ctx, unit, pck); break;
- case ACTION_READ: action_read (ctx, unit, pck); break;
- case ACTION_WRITE: action_write (ctx, unit, pck); break;
- case ACTION_SEEK: action_seek (ctx, unit, pck); break;
- case ACTION_SET_PROTECT: action_set_protect (ctx, unit, pck); break;
- case ACTION_SET_COMMENT: action_set_comment (ctx, unit, pck); break;
- case ACTION_SAME_LOCK: action_same_lock (ctx, unit, pck); break;
- case ACTION_PARENT: action_parent (ctx, unit, pck); break;
- case ACTION_CREATE_DIR: action_create_dir (ctx, unit, pck); break;
- case ACTION_DELETE_OBJECT: action_delete_object (ctx, unit, pck); break;
- case ACTION_RENAME_OBJECT: action_rename_object (ctx, unit, pck); break;
- case ACTION_SET_DATE: action_set_date (ctx, unit, pck); break;
- case ACTION_CURRENT_VOLUME: action_current_volume (ctx, unit, pck); break;
- case ACTION_RENAME_DISK: action_rename_disk (ctx, unit, pck); break;
- case ACTION_IS_FILESYSTEM: action_is_filesystem (ctx, unit, pck); break;
- case ACTION_FLUSH: action_flush (ctx, unit, pck); break;
- case ACTION_MORE_CACHE: action_more_cache (ctx, unit, pck); break;
- case ACTION_INHIBIT: action_inhibit (ctx, unit, pck); break;
- case ACTION_WRITE_PROTECT: action_write_protect (ctx, unit, pck); break;
+ case ACTION_LOCATE_OBJECT: action_lock (unit, pck); break;
+ case ACTION_FREE_LOCK: action_free_lock (unit, pck); break;
+ case ACTION_COPY_DIR: action_dup_lock (unit, pck); break;
+ case ACTION_DISK_INFO: action_disk_info (unit, pck); break;
+ case ACTION_INFO: action_info (unit, pck); break;
+ case ACTION_EXAMINE_OBJECT: action_examine_object (unit, pck); break;
+ case ACTION_EXAMINE_NEXT: action_examine_next (unit, pck, false); break;
+ case ACTION_FIND_INPUT: action_find_input (unit, pck); break;
+ case ACTION_FIND_WRITE: action_find_write (unit, pck); break;
+ case ACTION_FIND_OUTPUT: action_find_output (unit, pck); break;
+ case ACTION_END: action_end (unit, pck); break;
+ case ACTION_READ: action_read (unit, pck); break;
+ case ACTION_WRITE: action_write (unit, pck); break;
+ case ACTION_SEEK: action_seek (unit, pck); break;
+ case ACTION_SET_PROTECT: action_set_protect (unit, pck); break;
+ case ACTION_SET_COMMENT: action_set_comment (unit, pck); break;
+ case ACTION_SAME_LOCK: action_same_lock (unit, pck); break;
+ case ACTION_PARENT: action_parent (unit, pck); break;
+ case ACTION_CREATE_DIR: action_create_dir (unit, pck); break;
+ case ACTION_DELETE_OBJECT: action_delete_object (unit, pck); break;
+ case ACTION_RENAME_OBJECT: action_rename_object (unit, pck); break;
+ case ACTION_SET_DATE: action_set_date (unit, pck); break;
+ case ACTION_CURRENT_VOLUME: action_current_volume (unit, pck); break;
+ case ACTION_RENAME_DISK: action_rename_disk (unit, pck); break;
+ case ACTION_IS_FILESYSTEM: action_is_filesystem (unit, pck); break;
+ case ACTION_FLUSH: action_flush (unit, pck); break;
+ case ACTION_MORE_CACHE: action_more_cache (unit, pck); break;
+ case ACTION_INHIBIT: action_inhibit (unit, pck); break;
+ case ACTION_WRITE_PROTECT: action_write_protect (unit, pck); break;
/* 2.0+ packet types */
- case ACTION_SET_FILE_SIZE: action_set_file_size (ctx, unit, pck); break;
- case ACTION_EXAMINE_FH: action_examine_fh (ctx, unit, pck, false); break;
- case ACTION_FH_FROM_LOCK: action_fh_from_lock (ctx, unit, pck); break;
- case ACTION_COPY_DIR_FH: action_lock_from_fh (ctx, unit, pck); break;
- case ACTION_CHANGE_MODE: action_change_mode (ctx, unit, pck); break;
- case ACTION_PARENT_FH: action_parent_fh (ctx, unit, pck); break;
- case ACTION_ADD_NOTIFY: action_add_notify (ctx, unit, pck); break;
- case ACTION_REMOVE_NOTIFY: action_remove_notify (ctx, unit, pck); break;
- case ACTION_EXAMINE_ALL: return action_examine_all (ctx, unit, pck);
- case ACTION_EXAMINE_ALL_END: return action_examine_all_end (ctx, unit, pck);
- case ACTION_LOCK_RECORD: return action_lock_record (ctx, unit, pck, msg); break;
- case ACTION_FREE_RECORD: action_free_record (ctx, unit, pck); break;
+ case ACTION_SET_FILE_SIZE: action_set_file_size (unit, pck); break;
+ case ACTION_EXAMINE_FH: action_examine_fh (unit, pck, false); break;
+ case ACTION_FH_FROM_LOCK: action_fh_from_lock (unit, pck); break;
+ case ACTION_COPY_DIR_FH: action_lock_from_fh (unit, pck); break;
+ case ACTION_CHANGE_MODE: action_change_mode (unit, pck); break;
+ case ACTION_PARENT_FH: action_parent_fh (unit, pck); break;
+ case ACTION_ADD_NOTIFY: action_add_notify (unit, pck); break;
+ case ACTION_REMOVE_NOTIFY: action_remove_notify (unit, pck); break;
+ case ACTION_EXAMINE_ALL: return action_examine_all (unit, pck);
+ case ACTION_EXAMINE_ALL_END: return action_examine_all_end (unit, pck);
+ case ACTION_LOCK_RECORD: return action_lock_record (unit, pck, msg); break;
+ case ACTION_FREE_RECORD: action_free_record (unit, pck); break;
/* OS4 packet types */
- case ACTION_FILESYSTEM_ATTR: action_filesystem_attr(ctx, unit, pck); break;
- case ACTION_CHANGE_FILE_POSITION64: action_change_file_position64 (ctx, unit, pck); break;
- case ACTION_GET_FILE_POSITION64: action_get_file_position64 (ctx, unit, pck); break;
- case ACTION_CHANGE_FILE_SIZE64: action_change_file_size64 (ctx, unit, pck); break;
- case ACTION_GET_FILE_SIZE64: action_get_file_size64 (ctx, unit, pck); break;
+ case ACTION_CHANGE_FILE_POSITION64: action_change_file_position64 (unit, pck); break;
+ case ACTION_GET_FILE_POSITION64: action_get_file_position64 (unit, pck); break;
+ case ACTION_CHANGE_FILE_SIZE64: action_change_file_size64 (unit, pck); break;
+ case ACTION_GET_FILE_SIZE64: action_get_file_size64 (unit, pck); break;
/* MOS packet types */
- case ACTION_SEEK64: action_seek64(ctx, unit, pck); break;
- case ACTION_SET_FILE_SIZE64: action_set_file_size64(ctx, unit, pck); break;
- case ACTION_EXAMINE_OBJECT64: action_examine_object64(ctx, unit, pck); break;
- case ACTION_EXAMINE_NEXT64: action_examine_next(ctx, unit, pck, true); break;
- case ACTION_EXAMINE_FH64: action_examine_fh(ctx, unit, pck, true); break;
- case ACTION_LOCK_RECORD64: return action_lock_record64(ctx, unit, pck, msg); break;
- case ACTION_FREE_RECORD64: action_free_record64(ctx, unit, pck); break;
+ case ACTION_SEEK64: action_seek64(unit, pck); break;
+ case ACTION_SET_FILE_SIZE64: action_set_file_size64(unit, pck); break;
+ case ACTION_EXAMINE_OBJECT64: action_examine_object64(unit, pck); break;
+ case ACTION_EXAMINE_NEXT64: action_examine_next(unit, pck, true); break;
+ case ACTION_EXAMINE_FH64: action_examine_fh(unit, pck, true); break;
+ case ACTION_LOCK_RECORD64: return action_lock_record64(unit, pck, msg); break;
+ case ACTION_FREE_RECORD64: action_free_record64(unit, pck); break;
/* unsupported packets */
case ACTION_MAKE_LINK:
@@ -5833,12 +5807,10 @@ static int handle_packet(TrapContext *ctx, Unit *unit, dpacket *pck, uae_u32 msg
static int filesys_iteration(UnitInfo *ui)
{
- uaecptr pck;
+ dpacket pck;
uaecptr msg;
uae_u32 morelocks;
- TrapContext *ctx = NULL;
- ctx = (TrapContext*)read_comm_pipe_pvoid_blocking(ui->unit_pipe);
pck = read_comm_pipe_u32_blocking (ui->unit_pipe);
msg = read_comm_pipe_u32_blocking (ui->unit_pipe);
morelocks = (uae_u32)read_comm_pipe_int_blocking (ui->unit_pipe);
@@ -5852,65 +5824,25 @@ static int filesys_iteration(UnitInfo *ui)
return 0;
}
- dpacket packet;
- readdpacket(ctx, &packet, pck);
-
- int isvolume = 0;
-#if TRAPMD
- trapmd md[] = {
- { TRAPCMD_GET_LONG, { morelocks }, 2, 0 },
- { TRAPCMD_GET_LONG, { ui->self->locklist }, 2, 1 },
- { TRAPCMD_PUT_LONG },
- { TRAPCMD_PUT_LONG, { ui->self->locklist, morelocks }},
- { ui->self->volume ? TRAPCMD_GET_BYTE : TRAPCMD_NOP, { ui->self->volume + 64 }},
- };
- trap_multi(ctx, md, sizeof md / sizeof(struct trapmd));
-
- if (ui->self->volume) {
- isvolume = md[4].params[0] || ui->self->ui.unknown_media;
- }
-#else
- trap_put_long(ctx, trap_get_long(ctx, morelocks), trap_get_long(ctx, ui->self->locklist));
- trap_put_long(ctx, ui->self->locklist, morelocks);
- if (ui->self->volume) {
- isvolume = trap_get_byte(ctx, ui->self->volume + 64) || ui->self->ui.unknown_media;
- }
-#endif
-
- int ret = handle_packet(ctx, ui->self, &packet, msg, isvolume);
+ put_long (get_long (morelocks), get_long (ui->self->locklist));
+ put_long (ui->self->locklist, morelocks);
+ int ret = handle_packet (ui->self, pck, msg);
if (!ret) {
- PUT_PCK_RES1 (&packet, DOS_FALSE);
- PUT_PCK_RES2 (&packet, ERROR_ACTION_NOT_KNOWN);
+ PUT_PCK_RES1 (pck, DOS_FALSE);
+ PUT_PCK_RES2 (pck, ERROR_ACTION_NOT_KNOWN);
}
- writedpacket(ctx, &packet);
-
- trapmd md2[] = {
- { TRAPCMD_PUT_LONG, { msg + 4, 0xffffffff } },
- { TRAPCMD_GET_LONG, { ui->self->locklist } },
- { TRAPCMD_PUT_LONG, { ui->self->locklist, 0 } }
- };
- struct trapmd *mdp;
- int mdcnt;
if (ret >= 0) {
- mdp = &md2[0];
- mdcnt = 3;
/* Mark the packet as processed for the list scan in the assembly code. */
- //trap_put_long(ctx, msg + 4, 0xffffffff);
- } else {
- mdp = &md2[1];
- mdcnt = 2;
+ put_long (msg + 4, 0xffffffff);
}
/* Acquire the message lock, so that we know we can safely send the message. */
ui->self->cmds_sent++;
-
- /* Send back the locks. */
- trap_multi(ctx, mdp, mdcnt);
- if (md2[1].params[0] != 0)
- write_comm_pipe_int(ui->back_pipe, (int)md2[1].params[0], 0);
-
/* The message is sent by our interrupt handler, so make sure an interrupt happens. */
do_uae_int_requested();
-
+ /* Send back the locks. */
+ if (get_long (ui->self->locklist) != 0)
+ write_comm_pipe_int (ui->back_pipe, (int)(get_long (ui->self->locklist)), 0);
+ put_long (ui->self->locklist, 0);
return 1;
}
@@ -5930,18 +5862,17 @@ static void *filesys_thread (void *unit_v)
#endif
/* Talk about spaghetti code... */
-static uae_u32 REGPARAM2 filesys_handler (TrapContext *ctx)
+static uae_u32 REGPARAM2 filesys_handler (TrapContext *context)
{
- bool packet_valid = false;
- Unit *unit = find_unit(trap_get_areg(ctx, 5));
- uaecptr packet_addr = trap_get_dreg(ctx, 3);
- uaecptr message_addr = trap_get_areg(ctx, 4);
-
- if (!trap_valid_address(ctx, packet_addr, 36) || !trap_valid_address(ctx, message_addr, 14)) {
+ Unit *unit = find_unit (m68k_areg (regs, 5));
+ uaecptr packet_addr = m68k_dreg (regs, 3);
+ uaecptr message_addr = m68k_areg (regs, 4);
+ if (! valid_address (packet_addr, 36) || ! valid_address (message_addr, 14)) {
write_log (_T("FILESYS: Bad address %x/%x passed for packet.\n"), packet_addr, message_addr);
goto error2;
}
+ put_long (message_addr + 4, 0xffffffff);
if (!unit || !unit->volume) {
write_log (_T("FILESYS: was not initialized.\n"));
goto error;
@@ -5952,40 +5883,12 @@ static uae_u32 REGPARAM2 filesys_handler (TrapContext *ctx)
if (!unit->ui.unit_pipe)
goto error;
/* Get two more locks and hand them over to the other thread. */
-
-#if TRAPMD
- struct trapmd md[] = {
- // morelocks = trap_get_long(ctx, trap_get_areg(ctx, 3));
- /* 0 */ { TRAPCMD_GET_LONG, { trap_get_areg(ctx, 3) }, 1, 0 },
- // morelocksptr = trap_get_long(ctx, morelocks)
- /* 1 */ { TRAPCMD_GET_LONG, { 0 } },
- // result 1 to index 4
- /* 2 */ { TRAPCMD_NOP, { 0 }, 4, 0 },
- // result 1 to index 6
- /* 3 */ { TRAPCMD_NOP, { 0 }, 6, 0 },
- // trap_get_long(ctx, morelocksptr)
- /* 4 */ { TRAPCMD_GET_LONG, { 0 }, 5, 1 },
- // trap_put_long(ctx, trap_get_areg(ctx, 3), result 4
- /* 5 */ { TRAPCMD_PUT_LONG, { trap_get_areg(ctx, 3) } },
- // trap_put_long(ctx, morelocksptr, 0);
- /* 6 */ { TRAPCMD_PUT_LONG, { 0, 0 } },
- // trap_put_long(ctx, message_addr + 4, 0);
- /* 7 */ { TRAPCMD_PUT_LONG, { message_addr + 4, 0 } }
- };
- trap_multi(ctx, md, sizeof md / sizeof(struct trapmd));
- morelocks = md[0].params[0];
-#else
- uae_u32 morelocksptr;
- morelocks = trap_get_long(ctx, trap_get_areg(ctx, 3));
- morelocksptr = trap_get_long(ctx, morelocks);
- trap_put_long(ctx, trap_get_areg(ctx, 3), trap_get_long(ctx, morelocksptr));
- trap_put_long(ctx, morelocksptr, 0);
+ morelocks = get_long (m68k_areg (regs, 3));
+ put_long (m68k_areg (regs, 3), get_long (get_long (morelocks)));
+ put_long (get_long (morelocks), 0);
/* The packet wasn't processed yet. */
- trap_put_long(ctx, message_addr + 4, 0);
-#endif
-
- write_comm_pipe_pvoid(unit->ui.unit_pipe, ctx, 0);
+ put_long (message_addr + 4, 0);
write_comm_pipe_u32 (unit->ui.unit_pipe, packet_addr, 0);
write_comm_pipe_u32 (unit->ui.unit_pipe, message_addr, 0);
write_comm_pipe_int (unit->ui.unit_pipe, (int)morelocks, 1);
@@ -5994,26 +5897,31 @@ static uae_u32 REGPARAM2 filesys_handler (TrapContext *ctx)
}
#endif
- dpacket packet;
- readdpacket(ctx, &packet, packet_addr);
- packet_valid = true;
-
- if (! handle_packet(ctx, unit, &packet, 0, filesys_isvolume(unit))) {
+ if (! handle_packet (unit, packet_addr, 0)) {
error:
- if (!packet_valid)
- readdpacket(ctx, &packet, packet_addr);
- PUT_PCK_RES1 (&packet, DOS_FALSE);
- PUT_PCK_RES2 (&packet, ERROR_ACTION_NOT_KNOWN);
+ PUT_PCK_RES1 (packet_addr, DOS_FALSE);
+ PUT_PCK_RES2 (packet_addr, ERROR_ACTION_NOT_KNOWN);
}
-
- writedpacket(ctx, &packet);
+ TRACE((_T("reply: %8lx, %ld\n"), GET_PCK_RES1 (packet_addr), GET_PCK_RES2 (packet_addr)));
error2:
- trap_put_long(ctx, message_addr + 4, 0xffffffff);
return 0;
}
+static void init_filesys_diagentry (void)
+{
+ put_long_host(baseaddr + 0x2100, EXPANSION_explibname);
+ put_long_host(baseaddr + 0x2104, filesys_configdev);
+ put_long_host(baseaddr + 0x2108, EXPANSION_doslibname);
+ put_word_host(baseaddr + 0x210c, 0);
+ put_word_host(baseaddr + 0x210e, nr_units());
+ put_word_host(baseaddr + 0x2110, 0);
+ put_word_host(baseaddr + 0x2112, 1 | (currprefs.uae_hide_autoconfig || currprefs.uaeboard > 1 ? 16 : 0));
+
+ native2amiga_startup();
+}
+
void filesys_start_threads (void)
{
int i;
@@ -6027,6 +5935,20 @@ void filesys_start_threads (void)
}
}
+void filesys_cleanup (void)
+{
+ filesys_prepare_reset();
+ free_mountinfo ();
+
+ if(singlethread_int_sem != 0)
+ uae_sem_destroy(&singlethread_int_sem);
+ singlethread_int_sem = 0;
+
+ filesys_in_interrupt = 0;
+ mountertask = 0;
+ automountunit = -1;
+}
+
void filesys_free_handles(void)
{
Unit *u, *u1;
@@ -6075,7 +5997,6 @@ void filesys_reset (void)
{
if (isrestore ())
return;
- load_injected_icons();
filesys_reset2 ();
initialize_mountinfo();
}
@@ -6083,6 +6004,7 @@ void filesys_reset (void)
static void filesys_prepare_reset2 (void)
{
UnitInfo *uip;
+// Unit *u;
int i;
uip = mountinfo.ui;
@@ -6092,12 +6014,10 @@ static void filesys_prepare_reset2 (void)
uae_sem_init (&uip[i].reset_sync_sem, 0, 0);
uip[i].reset_state = FS_GO_DOWN;
/* send death message */
- write_comm_pipe_pvoid(uip[i].unit_pipe, NULL, 0);
write_comm_pipe_int (uip[i].unit_pipe, 0, 0);
write_comm_pipe_int (uip[i].unit_pipe, 0, 0);
write_comm_pipe_int (uip[i].unit_pipe, 0, 1);
uae_sem_wait (&uip[i].reset_sync_sem);
- uae_end_thread (&uip[i].tid);
uae_sem_destroy(&uip[i].reset_sync_sem);
uip[i].reset_sync_sem = 0;
destroy_comm_pipe(uip[i].unit_pipe);
@@ -6110,6 +6030,15 @@ static void filesys_prepare_reset2 (void)
}
#endif
filesys_free_handles();
+#if 0
+ u = units;
+ while (u != 0) {
+ free_all_ainos (u, &u->rootnode);
+ u->rootnode.next = u->rootnode.prev = &u->rootnode;
+ u->aino_cache_size = 0;
+ u = u->next;
+ }
+#endif
}
void filesys_prepare_reset (void)
@@ -6119,6 +6048,75 @@ void filesys_prepare_reset (void)
filesys_prepare_reset2 ();
}
+static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *context)
+{
+ uaecptr resaddr = m68k_areg (regs, 2) + 0x10;
+ uaecptr expansion = m68k_areg (regs, 5);
+ uaecptr start = resaddr;
+ uaecptr residents, tmp;
+
+ write_log (_T("filesystem: diagentry called: %x\n"), resaddr);
+
+ filesys_configdev = m68k_areg (regs, 3);
+ init_filesys_diagentry ();
+
+ if (ROM_hardfile_resid != 0) {
+ /* Build a struct Resident. This will set up and initialize
+ * the uae.device */
+ put_word (resaddr + 0x0, 0x4AFC);
+ put_long (resaddr + 0x2, resaddr);
+ put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */
+ put_word (resaddr + 0xA, 0x8101); /* RTF_AUTOINIT|RTF_COLDSTART; Version 1 */
+ put_word (resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */
+ put_long (resaddr + 0xE, ROM_hardfile_resname);
+ put_long (resaddr + 0x12, ROM_hardfile_resid);
+ put_long (resaddr + 0x16, ROM_hardfile_init); /* calls filesys_init */
+ }
+ resaddr += 0x1A;
+ tmp = resaddr;
+
+ /* The good thing about this function is that it always gets called
+ * when we boot. So we could put all sorts of stuff that wants to be done
+ * here.
+ * We can simply add more Resident structures here. Although the Amiga OS
+ * only knows about the one at address DiagArea + 0x10, we scan for other
+ * Resident structures and call InitResident() for them at the end of the
+ * diag entry. */
+
+ resaddr = uaeres_startup (resaddr);
+#ifdef BSDSOCKET
+ resaddr = bsdlib_startup (resaddr);
+#endif
+
+ /* scan for Residents and return pointer to array of them */
+ residents = resaddr;
+ while (tmp < residents && tmp > start) {
+ if (get_word (tmp) == 0x4AFC &&
+ get_long (tmp + 0x2) == tmp) {
+ put_word (resaddr, 0x227C); /* move.l #tmp,a1 */
+ put_long (resaddr + 2, tmp);
+ put_word (resaddr + 6, 0x7200); /* moveq #0,d1 */
+ put_long (resaddr + 8, 0x4EAEFF9A); /* jsr -$66(a6) ; InitResident */
+ resaddr += 12;
+ tmp = get_long (tmp + 0x6);
+ } else {
+ tmp += 2;
+ }
+ }
+ /* call setup_exter */
+ put_word (resaddr + 0, 0x2079);
+ put_long (resaddr + 2, rtarea_base + bootrom_header + 4 + 5 * 4); /* move.l RTAREA_BASE+setup_exter,a0 */
+ put_word (resaddr + 6, 0xd1fc);
+ put_long (resaddr + 8, rtarea_base + bootrom_header); /* add.l #RTAREA_BASE+bootrom_header,a0 */
+ put_word (resaddr + 12, 0x4e90); /* jsr (a0) */
+
+ put_word (resaddr + 14, 0x7001); /* moveq #1,d0 */
+ put_word (resaddr + 16, RTS);
+
+ m68k_areg (regs, 0) = residents;
+ return 1;
+}
+
/* don't forget filesys.asm! */
#define PP_MAXSIZE 4 * 96
#define PP_FSSIZE 400
@@ -6126,357 +6124,17 @@ void filesys_prepare_reset (void)
#define PP_ADDTOFSRES 408
#define PP_FSRES 412
#define PP_FSRES_CREATED 416
-#define PP_DEVICEPROC 420
-#define PP_EXPLIB 424
-#define PP_FSHDSTART 428
+#define PP_EXPLIB 420
+#define PP_FSHDSTART 424
-static int trackdisk_hack_state;
-static int putmsg_hack_state;
-static int putmsg_hack_filesystemtask;
-static uae_u32 ks12hack_deviceproc;
-
-static bool bcplonlydos(void)
+static uae_u32 REGPARAM2 filesys_dev_bootfilesys (TrapContext *context)
{
- return kickstart_version && kickstart_version < 33;
-}
-
-static const uae_u8 bootblock_ofs[] = {
- 0x44,0x4f,0x53,0x00,0xc0,0x20,0x0f,0x19,0x00,0x00,0x03,0x70,0x43,0xfa,0x00,0x18,
- 0x4e,0xae,0xff,0xa0,0x4a,0x80,0x67,0x0a,0x20,0x40,0x20,0x68,0x00,0x16,0x70,0x00,
- 0x4e,0x75,0x70,0xff,0x60,0xfa,0x64,0x6f,0x73,0x2e,0x6c,0x69,0x62,0x72,0x61,0x72,
- 0x79
-};
-static uae_u32 REGPARAM2 filesys_putmsg_return(TrapContext *ctx)
-{
- uaecptr message = trap_get_areg(ctx, 1);
- uaecptr dospacket = trap_get_long(ctx, message + 10);
- UnitInfo *uip = mountinfo.ui;
- if (!ks12hack_deviceproc && uip[0].parmpacket)
- ks12hack_deviceproc = trap_get_long(ctx, uip[0].parmpacket + PP_DEVICEPROC);
- if (ks12hack_deviceproc) {
- uae_u32 port = ks12hack_deviceproc;
- if (port) {
- uaecptr proc = trap_get_long(ctx, trap_get_long(ctx, 4) + 276); // ThisTask
- trap_put_long(ctx, proc + 168, port); // pr_FileSystemTask
- trap_set_areg(ctx, 0, port);
- write_log(_T("Pre-KS 1.3 automount hack: patch boot handler process. DP=%08x Proc %08x pr_FileSystemTask=%08x.\n"), dospacket, proc, port);
- }
- }
- return trap_get_dreg(ctx, 0);
-}
-
-static uae_u32 REGPARAM2 filesys_putmsg(TrapContext *ctx)
-{
- trap_set_areg(ctx, 7, trap_get_areg(ctx, 7) - 4);
- trap_put_long(ctx, trap_get_areg(ctx, 7), trap_get_long(ctx, ROM_filesys_putmsg_original));
- if (putmsg_hack_state) {
- uaecptr message = trap_get_areg(ctx, 1);
- uaecptr dospacket = trap_get_long(ctx, message + 10);
- if (dospacket && !(dospacket & 3) && trap_valid_address(ctx, dospacket, 48)) {
- int type = trap_get_long(ctx, dospacket + 8);
-// write_log(_T("Port=%08x Msg=%08x DP=%08x dp_Link=%08x dp_Port=%08x dp_Type=%d\n"),
-// m68k_areg(regs, 0), m68k_areg(regs, 1), dospacket, get_long(dospacket), get_long(dospacket + 4), type);
- if (type == ACTION_LOCATE_OBJECT) {
- write_log(_T("Pre-KS 1.3 automount hack: init drives.\n"));
- putmsg_hack_state = 0;
- if (putmsg_hack_filesystemtask) {
- trap_set_areg(ctx, 7, trap_get_areg(ctx, 7) - 4);
- trap_put_long(ctx, trap_get_areg(ctx, 7), ROM_filesys_putmsg_return);
- }
- trap_set_areg(ctx, 7, trap_get_areg(ctx, 7) - 4);
- trap_put_long(ctx, trap_get_areg(ctx, 7), filesys_initcode);
- trap_set_areg(ctx, 7, trap_get_areg(ctx, 7) - 4);
- trap_put_long(ctx, trap_get_areg(ctx, 7), ROM_filesys_hack_remove);
- return trap_get_dreg(ctx, 0);
- }
- }
- }
- return trap_get_dreg(ctx, 0);
-}
-
-static uae_u32 REGPARAM2 filesys_doio(TrapContext *ctx)
-{
- uaecptr ioreq = trap_get_areg(ctx, 1);
- uaecptr unit = trap_get_long(ctx, ioreq + 24); // io_Unit
- if (trackdisk_hack_state && unit && trap_valid_address(ctx, unit, 14)) {
- uaecptr name = trap_get_long(ctx, unit + 10); // ln_Name
- if (name && trap_valid_address(ctx, name, 20)) {
- uae_u8 *addr = get_real_address(name);
- if (!memcmp(addr, "trackdisk.device", 17)) {
- int cmd = trap_get_word(ctx, ioreq + 28); // io_Command
- uaecptr data = trap_get_long(ctx, ioreq + 40);
- int len = trap_get_long(ctx, ioreq + 36);
- //write_log(_T("%08x %d\n"), ioreq, cmd);
- switch (cmd)
- {
- case 2: // CMD_READ
- {
- // trackdisk.device reading boot block
- uae_u8 *d = get_real_address(data);
- memset(d, 0, 1024);
- memcpy(d, bootblock_ofs, sizeof bootblock_ofs);
- trap_put_long(ctx, ioreq + 32, len); // io_Actual
- trackdisk_hack_state = 0;
- write_log(_T("Pre-KS 1.3 automount hack: DF0: boot block faked.\n"));
- }
- break;
- case 9: // TD_MOTOR
- trap_put_long(ctx, ioreq + 32, trackdisk_hack_state < 0 ? 0 : 1);
- trackdisk_hack_state = len ? 1 : -1;
- break;
- case 13: // TD_CHANGENUM
- trap_put_long(ctx, ioreq + 32, 1); // io_Actual
- break;
- case 14: // TD_CHANGESTATE
- trap_put_long(ctx, ioreq + 32, 0);
- break;
- }
- return 0;
- }
- }
- }
- trap_set_areg(ctx, 7, trap_get_areg(ctx, 7) - 4);
- trap_put_long(ctx, trap_get_areg(ctx, 7), trap_get_long(ctx, ROM_filesys_doio_original));
- return 0;
-}
-
-static uaecptr add_resident(TrapContext *ctx, uaecptr resaddr, uaecptr myres)
-{
- uaecptr sysbase, reslist, prevjmp, resptr;
-
- uae_s8 myrespri = trap_get_byte(ctx, myres + 13); // rt_Pri
-
- sysbase = trap_get_long(ctx, 4);
- prevjmp = 0;
- reslist = trap_get_long(ctx, sysbase + 300); // ResModules
- for (;;) {
- resptr = trap_get_long(ctx, reslist);
- if (!resptr)
- break;
- if (resptr & 0x80000000) {
- prevjmp = reslist;
- reslist = resptr & 0x7fffffff;
- continue;
- }
- uae_s8 respri = trap_get_byte(ctx, resptr + 13); // rt_Pri
- uaecptr resname = trap_get_long(ctx, resptr + 14); // rt_Name
- if (resname) {
- uae_char resnamebuf[256];
- trap_get_string(ctx, resnamebuf, resname, sizeof resnamebuf);
- if (myrespri >= respri)
- break;
- }
- prevjmp = 0;
- reslist += 4;
- }
- if (prevjmp) {
- trap_put_long(ctx, prevjmp, 0x80000000 | resaddr);
- } else {
- trap_put_long(ctx, reslist, 0x80000000 | resaddr);
- }
- trap_put_long(ctx, resaddr, myres);
- trap_put_long(ctx, resaddr + 4, resptr);
- trap_put_long(ctx, resaddr + 8, 0x80000000 | (reslist + 4));
- resaddr += 3 * 4;
- return resaddr;
-}
-
-static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *ctx)
-{
- UnitInfo *uip = mountinfo.ui;
- uaecptr resaddr = trap_get_areg(ctx, 2);
- uaecptr expansion = trap_get_areg(ctx, 5);
- uaecptr first_resident, last_resident, tmp;
- uaecptr resaddr_hack = 0;
- uae_u8 *baseaddr;
-
- filesys_configdev = trap_get_areg(ctx, 3);
-
- baseaddr = filesys_bank.baseaddr;
- resaddr += 0x10;
-
- put_long_host(baseaddr + 0x2100, EXPANSION_explibname);
- put_long_host(baseaddr + 0x2104, filesys_configdev);
- put_long_host(baseaddr + 0x2108, EXPANSION_doslibname);
- put_word_host(baseaddr + 0x210c, 0);
- put_word_host(baseaddr + 0x210e, nr_units());
- put_word_host(baseaddr + 0x2110, 0);
- put_word_host(baseaddr + 0x2112, 1);
-
- native2amiga_startup();
-
- write_log (_T("filesystem: diagentry %08x configdev %08x\n"), resaddr, filesys_configdev);
-
- first_resident = resaddr;
- if (ROM_hardfile_resid != 0) {
- /* Build a struct Resident. This will set up and initialize
- * the uae.device */
- trap_put_word(ctx, resaddr + 0x0, 0x4AFC);
- trap_put_long(ctx, resaddr + 0x2, resaddr);
- trap_put_long(ctx, resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */
- trap_put_word(ctx, resaddr + 0xA, 0x8132); /* RTF_AUTOINIT|RTF_COLDSTART; Version 50 */
- trap_put_word(ctx, resaddr + 0xC, 0x0305); /* NT_DEVICE; pri 05 */
- trap_put_long(ctx, resaddr + 0xE, ROM_hardfile_resname);
- trap_put_long(ctx, resaddr + 0x12, ROM_hardfile_resid);
- trap_put_long(ctx, resaddr + 0x16, ROM_hardfile_init); /* calls filesys_init */
- }
- resaddr += 0x1A;
- if (!KS12_BOOT_HACK || expansion)
- first_resident = resaddr;
- /* The good thing about this function is that it always gets called
- * when we boot. So we could put all sorts of stuff that wants to be done
- * here.
- * We can simply add more Resident structures here. Although the Amiga OS
- * only knows about the one at address DiagArea + 0x10, we scan for other
- * Resident structures and inject them to ResList in priority order
- */
-
- if (kickstart_version >= 37) {
- trap_put_word(ctx, resaddr + 0x0, 0x4afc);
- trap_put_long(ctx, resaddr + 0x2, resaddr);
- trap_put_long(ctx, resaddr + 0x6, resaddr + 0x1A);
- trap_put_word(ctx, resaddr + 0xA, 0x0432); /* RTF_AFTERDOS; Version 50 */
- trap_put_word(ctx, resaddr + 0xC, 0x0000 | AFTERDOS_INIT_PRI); /* NT_UNKNOWN; pri */
- trap_put_long(ctx, resaddr + 0xE, afterdos_name);
- trap_put_long(ctx, resaddr + 0x12, afterdos_id);
- trap_put_long(ctx, resaddr + 0x16, afterdos_initcode);
- resaddr += 0x1A;
- }
-
- resaddr = uaeres_startup (ctx, resaddr);
-#ifdef BSDSOCKET
- resaddr = bsdlib_startup(ctx, resaddr);
-#endif
-
- last_resident = resaddr;
-
- /* call setup_exter */
- trap_put_word(ctx, resaddr + 0, 0x7000 | 1); /* moveq #x,d0 */
- trap_put_word(ctx, resaddr + 2, 0x2079); /* move.l RTAREA_BASE+setup_exter,a0 */
- trap_put_long(ctx, resaddr + 4, rtarea_base + bootrom_header + 4 + 5 * 4);
- trap_put_word(ctx, resaddr + 8, 0xd1fc); /* add.l #RTAREA_BASE+bootrom_header,a0 */
- trap_put_long(ctx, resaddr + 10, rtarea_base + bootrom_header);
- trap_put_word(ctx, resaddr + 14, 0x4e90); /* jsr (a0) */
- resaddr += 16;
-
- trackdisk_hack_state = 0;
- putmsg_hack_state = 0;
- putmsg_hack_filesystemtask = 0;
- ks12hack_deviceproc = 0;
-
- if (KS12_BOOT_HACK && nr_units() && filesys_configdev == 0) {
- resaddr_hack = resaddr;
- putmsg_hack_state = -1;
- if (uip[0].bootpri > -128) {
- resaddr += 2 * 22;
- trackdisk_hack_state = -1;
- putmsg_hack_filesystemtask = 1;
- } else {
- resaddr += 1 * 22;
- }
- }
-
- trap_put_word(ctx, resaddr + 0, 0x7001); /* moveq #1,d0 */
- trap_put_word(ctx, resaddr + 2, RTS);
- resaddr += 4;
-
- ROM_filesys_doio_original = resaddr;
- ROM_filesys_putmsg_original = resaddr + 4;
- resaddr += 8;
- ROM_filesys_hack_remove = resaddr;
-
- if (putmsg_hack_state) {
-
- // remove patches
- put_long(resaddr + 0, 0x48e7fffe); // movem.l d0-d7/a0-a6,-(sp)
- put_word(resaddr + 4, 0x224e); // move.l a6,a1
- resaddr += 6;
- if (trackdisk_hack_state) {
- put_word(resaddr + 0, 0x307c); // move.w #x,a0
- put_word(resaddr + 2, -0x1c8);
- put_word(resaddr + 4, 0x2039); // move.l x,d0
- put_long(resaddr + 6, ROM_filesys_doio_original);
- put_word(resaddr + 10, 0x4eae); // jsr x(a6)
- put_word(resaddr + 12, -0x1a4);
- resaddr += 14;
- }
- put_word(resaddr + 0, 0x307c); // move.w #x,a0
- put_word(resaddr + 2, -0x16e);
- put_word(resaddr + 4, 0x2039); // move.l x,d0
- put_long(resaddr + 6, ROM_filesys_putmsg_original);
- put_word(resaddr + 10, 0x4eae); // jsr x(a6)
- put_word(resaddr + 12, -0x1a4);
- resaddr += 14;
- put_long(resaddr + 0, 0x4cdf7fff); // movem.l (sp)+,d0-d7/a0-a6
- resaddr += 4;
-
- uaecptr temp = here();
- org(filesys_initcode_ptr);
- dl(resaddr);
- org(temp);
-
- put_word(resaddr, 0x4e75); // rts
- resaddr += 2;
-
- uaecptr resaddr_tmp = resaddr;
-
- resaddr = resaddr_hack;
-
- if (trackdisk_hack_state) {
- // Pre-KS 1.3 trackdisk.device boot block injection hack. Patch DoIO()
- put_word(resaddr + 0, 0x224e); // move.l a6,a1
- put_word(resaddr + 2, 0x307c); // move.w #x,a0
- put_word(resaddr + 4, -0x1c8);
- put_word(resaddr + 6, 0x203c); // move.l #x,d0
- put_long(resaddr + 8, ROM_filesys_doio);
- put_word(resaddr + 12, 0x4eae); // jsr x(a6)
- put_word(resaddr + 14, -0x1a4);
- put_word(resaddr + 16, 0x23c0); // move.l d0,x
- put_long(resaddr + 18, ROM_filesys_doio_original);
- resaddr += 22;
- }
-
- // Pre-KS 1.3 automount hack. Patch PutMsg()
- put_word(resaddr + 0, 0x224e); // move.l a6,a1
- put_word(resaddr + 2, 0x307c); // move.w #x,a0
- put_word(resaddr + 4, -0x16e);
- put_word(resaddr + 6, 0x203c); // move.l #x,d0
- put_long(resaddr + 8, ROM_filesys_putmsg);
- put_word(resaddr + 12, 0x4eae); // jsr x(a6)
- put_word(resaddr + 14, -0x1a4);
- put_word(resaddr + 16, 0x23c0); // move.l d0,x
- put_long(resaddr + 18, ROM_filesys_putmsg_original);
- resaddr += 22;
-
- // filesys.asm make_dev D7
- put_word_host(baseaddr + 0x2112, 1 | 2 | 8 | 16);
-
- resaddr = resaddr_tmp;
- }
-
- trap_set_areg(ctx, 0, last_resident);
-
- tmp = first_resident;
- while (tmp < last_resident && tmp >= first_resident) {
- if (trap_get_word(ctx, tmp) == 0x4AFC && trap_get_long(ctx, tmp + 0x2) == tmp) {
- resaddr = add_resident(ctx, resaddr, tmp);
- tmp = trap_get_long(ctx, tmp + 0x6);
- } else {
- tmp += 2;
- }
- }
-
- return 1;
-}
-
-static uae_u32 REGPARAM2 filesys_dev_bootfilesys (TrapContext *ctx)
-{
- uaecptr devicenode = trap_get_areg(ctx, 3);
- uaecptr parmpacket = trap_get_areg(ctx, 1);
- uaecptr fsres = trap_get_long(ctx, parmpacket + PP_FSRES);
+ uaecptr devicenode = m68k_areg (regs, 3);
+ uaecptr parmpacket = m68k_areg (regs, 1);
+ uaecptr fsres = get_long (parmpacket + PP_FSRES);
uaecptr fsnode;
uae_u32 dostype, dostype2;
- int no = trap_get_dreg(ctx, 6) & 0x7fffffff;
+ int no = m68k_dreg (regs, 6) & 0x7fffffff;
int unit_no = no & 65535;
UnitInfo *uip = &mountinfo.ui[unit_no];
int type;
@@ -6484,119 +6142,58 @@ static uae_u32 REGPARAM2 filesys_dev_bootfilesys (TrapContext *ctx)
type = is_hardfile (unit_no);
if (type == FILESYS_VIRTUAL) {
- if (!trap_get_long(ctx, devicenode + 16))
- trap_put_long(ctx, devicenode + 16, fshandlername);
+ if (!get_long (devicenode + 16))
+ put_long (devicenode + 16, fshandlername);
return 0;
}
- dostype = trap_get_long(ctx, parmpacket + 80);
- if (trap_get_long(ctx, parmpacket + PP_FSPTR) && !trap_get_long(ctx, parmpacket + PP_ADDTOFSRES)) {
- uaecptr fsptr = trap_get_long(ctx, parmpacket + PP_FSPTR);
+ if (get_long (parmpacket + PP_FSPTR) && !get_long (parmpacket + PP_ADDTOFSRES)) {
+ uaecptr fsptr = get_long (parmpacket + PP_FSPTR);
uip->filesysseg = fsptr;
// filesystem but was not added to fs.resource
- uae_u32 pf = trap_get_long(ctx, parmpacket + PP_FSHDSTART + 8); // fse_PatchFlags
+ uae_u32 pf = get_long (parmpacket + PP_FSHDSTART + 8); // fse_PatchFlags
for (int i = 0; i < 32; i++) {
if (pf & (1 << i))
- trap_put_long(ctx, devicenode + 4 + i * 4, trap_get_long(ctx, parmpacket + PP_FSHDSTART + 8 + 4 + i * 4));
+ put_long (devicenode + 4 + i * 4, get_long (parmpacket + PP_FSHDSTART + 8 + 4 + i * 4));
}
- uaecptr seglist = fsptr >> 2;
- if (bcplonlydos()) {
- trap_put_long(ctx, devicenode + 4 + 3 * 4, seglist);
- seglist = (trap_get_long(ctx, rtarea_base + bootrom_header + 4 + 6 * 4) + rtarea_base + bootrom_header) >> 2;
- }
- trap_put_long(ctx, devicenode + 4 + 7 * 4, seglist);
+ put_long (devicenode + 4 + 7 * 4, fsptr >> 2); // seglist
return 1;
}
- fsnode = trap_get_long(ctx, fsres + 18);
- while (trap_get_long(ctx, fsnode)) {
- dostype2 = trap_get_long(ctx, fsnode + 14);
+ dostype = get_long (parmpacket + 80);
+ fsnode = get_long (fsres + 18);
+ while (get_long (fsnode)) {
+ dostype2 = get_long (fsnode + 14);
if (dostype2 == dostype) {
- uae_u32 pf = trap_get_long(ctx, fsnode + 22); // fse_PatchFlags
+ uae_u32 pf = get_long (fsnode + 22); // fse_PatchFlags
for (int i = 0; i < 32; i++) {
- if (pf & (1 << i)) {
- uae_u32 data = trap_get_long(ctx, fsnode + 22 + 4 + i * 4);
- if (i == 7 && bcplonlydos()) { // seglist
- // point seglist to bcpl wrapper and put original seglist in dn_Handler
- trap_put_long(ctx, devicenode + 4 + 3 * 4, trap_get_long(ctx, fsnode + 22 + 4 + 7 * 4));
- data = (trap_get_long(ctx, rtarea_base + bootrom_header + 4 + 6 * 4) + rtarea_base + bootrom_header) >> 2;
- }
- trap_put_long(ctx, devicenode + 4 + i * 4, data);
- }
+ if (pf & (1 << i))
+ put_long (devicenode + 4 + i * 4, get_long (fsnode + 22 + 4 + i * 4));
}
return 1;
}
- fsnode = trap_get_long(ctx, fsnode);
+ fsnode = get_long (fsnode);
}
if (type == FILESYS_HARDFILE) {
- uae_u32 pf = trap_get_long(ctx, parmpacket + PP_FSHDSTART + 8); // fse_PatchFlags
+ uae_u32 pf = get_long (parmpacket + PP_FSHDSTART + 8); // fse_PatchFlags
for (int i = 0; i < 32; i++) {
if (pf & (1 << i))
- trap_put_long(ctx, devicenode + 4 + i * 4, trap_get_long(ctx, parmpacket + PP_FSHDSTART + 8 + 4 + i * 4));
+ put_long (devicenode + 4 + i * 4, get_long (parmpacket + PP_FSHDSTART + 8 + 4 + i * 4));
}
- trap_put_long(ctx, devicenode + 4 + 7 * 4, 0); // seglist
+ put_long (devicenode + 4 + 7 * 4, 0); // seglist
}
-
- uaecptr file_system_proc = trap_get_dreg(ctx, 1);
- if (bcplonlydos() && file_system_proc && trap_get_long(ctx, devicenode + 4 + 7 * 4) == 0) {
- // 1.1 or older, seglist == 0: get ROM OFS seglist from "File System" process.
- // 1.2 and newer automatically use ROM OFS if seglist is zero.
- // d1 = "File System" process pointer.
- uaecptr p = trap_get_long(ctx, file_system_proc + 0x80) << 2; // pr_SegList
- if (p) {
- uae_u32 cnt = trap_get_long(ctx, p);
- if (cnt > 0 && cnt < 16) {
- uaecptr handlerseg = trap_get_long(ctx, p + cnt * 4);
- write_log(_T("Pre-KS 1.2 handler segment %08x.\n"), handlerseg << 2);
- trap_put_long(ctx, devicenode + 4 + 7 * 4, handlerseg);
- }
- }
- }
-
return 0;
}
-// called from bcplwrapper
-static uae_u32 REGPARAM2 filesys_bcpl_wrapper(TrapContext *ctx)
-{
- const int patches[] = { 0x782, 0x7b8, 0x159c, 0x15b4, 0 };
- uaecptr devicenode = trap_get_long(ctx, trap_get_dreg(ctx, 1) + 0x1c) << 2;
- // fetch original seglist from dn_Handler
- uaecptr seglist = trap_get_long(ctx, devicenode + 4 + 3 * 4) << 2;
- uaecptr patchfunc = trap_get_areg(ctx, 1);
- seglist += 4;
- trap_set_areg(ctx, 0, seglist);
- for (int i = 0; patches[i]; i++) {
- int offset = patches[i];
- if (get_long(seglist + offset + 2) != 0x4eaefd90) {
- write_log(_T("FFS patch failed, comparison mismatch.\n"));
- return 0;
- }
- }
- for (int i = 0; patches[i]; i++) {
- int offset = patches[i];
- trap_put_word(ctx, seglist + offset, 0x4eb9);
- trap_put_long(ctx, seglist + offset + 2, patchfunc);
- patchfunc += 4;
- }
- uae_u16 ver = trap_get_word(ctx, trap_get_areg(ctx, 6) + 20);
- if (ver < 31) {
- // OpenLibrary -> OldOpenLibrary
- trap_put_word(ctx, seglist + 0x7f4, -0x198);
- trap_put_word(ctx, seglist + 0x2a6e, -0x198);
- }
- write_log(_T("FFS pre-1.2 patched\n"));
- return 0;
-}
-
-static uae_u32 REGPARAM2 filesys_init_storeinfo (TrapContext *ctx)
+extern void picasso96_alloc (TrapContext*);
+static uae_u32 REGPARAM2 filesys_init_storeinfo (TrapContext *context)
{
int ret = -1;
- switch (trap_get_dreg(ctx, 1))
+ switch (m68k_dreg (regs, 1))
{
case 1:
- mountertask = trap_get_areg(ctx, 1);
+ mountertask = m68k_areg (regs, 1);
#ifdef PICASSO96
- picasso96_alloc (ctx);
+ picasso96_alloc (context);
#endif
break;
case 2:
@@ -6611,14 +6208,15 @@ static uae_u32 REGPARAM2 filesys_init_storeinfo (TrapContext *ctx)
/* Remember a pointer AmigaOS gave us so we can later use it to identify
* which unit a given startup message belongs to. */
-static uae_u32 REGPARAM2 filesys_dev_remember (TrapContext *ctx)
+static uae_u32 REGPARAM2 filesys_dev_remember (TrapContext *context)
{
- int no = trap_get_dreg(ctx, 6) & 0x7fffffff;
+ int no = m68k_dreg (regs, 6) & 0x7fffffff;
int unit_no = no & 65535;
int sub_no = no >> 16;
UnitInfo *uip = &mountinfo.ui[unit_no];
- uaecptr devicenode = trap_get_areg(ctx, 3);
- uaecptr parmpacket = trap_get_areg(ctx, 1);
+ int i;
+ uaecptr devicenode = m68k_areg (regs, 3);
+ uaecptr parmpacket = m68k_areg (regs, 1);
int fssize;
uae_u8 *fs;
@@ -6627,16 +6225,16 @@ static uae_u32 REGPARAM2 filesys_dev_remember (TrapContext *ctx)
fs = uip->rdb_filesysstore;
/* copy filesystem loaded from RDB */
- if (trap_get_long(ctx, parmpacket + PP_FSPTR)) {
- uaecptr addr = trap_get_long(ctx, parmpacket + PP_FSPTR);
- trap_put_bytes(ctx, fs, addr, fssize);
+ if (get_long (parmpacket + PP_FSPTR)) {
+ for (i = 0; i < fssize; i++)
+ put_byte (get_long (parmpacket + PP_FSPTR) + i, fs[i]);
}
xfree (fs);
uip->rdb_filesysstore = 0;
uip->rdb_filesyssize = 0;
- if (trap_get_dreg(ctx, 3) >= 0)
- uip->startup = trap_get_long(ctx, devicenode + 28);
+ if (m68k_dreg (regs, 3) >= 0)
+ uip->startup = get_long (devicenode + 28);
return devicenode;
}
@@ -6655,7 +6253,7 @@ static uae_u32 rl (uae_u8 *p)
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3]);
}
-static int rdb_checksum (const uae_char *id, uae_u8 *p, int block)
+int rdb_checksum (const char *id, uae_u8 *p, int block)
{
uae_u32 sum = 0;
int i, blocksize;
@@ -6677,30 +6275,28 @@ static int rdb_checksum (const uae_char *id, uae_u8 *p, int block)
return 1;
}
-static int device_isdup (TrapContext *ctx, uaecptr expbase, TCHAR *devname)
+static int device_isdup (uaecptr expbase, TCHAR *devname)
{
uaecptr bnode, dnode, name;
int len, i;
TCHAR dname[256];
- if (!expbase)
- return 0;
- bnode = trap_get_long(ctx, expbase + 74); /* expansion.library bootnode list */
- while (trap_get_long(ctx, bnode)) {
- dnode = trap_get_long(ctx, bnode + 16); /* device node */
- name = trap_get_long(ctx, dnode + 40) << 2; /* device name BSTR */
- len = trap_get_byte(ctx, name);
+ bnode = get_long (expbase + 74); /* expansion.library bootnode list */
+ while (get_long (bnode)) {
+ dnode = get_long (bnode + 16); /* device node */
+ name = get_long (dnode + 40) << 2; /* device name BSTR */
+ len = get_byte (name);
for (i = 0; i < len; i++)
- dname[i] = trap_get_byte(ctx, name + 1 + i);
+ dname[i] = get_byte (name + 1 + i);
dname[len] = 0;
if (!_tcsicmp (devname, dname))
return 1;
- bnode = trap_get_long(ctx, bnode);
+ bnode = get_long (bnode);
}
return 0;
}
-static TCHAR *device_dupfix (TrapContext *ctx, uaecptr expbase, TCHAR *devname)
+static TCHAR *device_dupfix (uaecptr expbase, TCHAR *devname)
{
int modified;
TCHAR newname[256];
@@ -6709,7 +6305,7 @@ static TCHAR *device_dupfix (TrapContext *ctx, uaecptr expbase, TCHAR *devname)
modified = 1;
while (modified) {
modified = 0;
- if (device_isdup (ctx, expbase, newname)) {
+ if (device_isdup (expbase, newname)) {
if (_tcslen (newname) > 2 && newname[_tcslen (newname) - 2] == '_') {
newname[_tcslen (newname) - 1]++;
} else {
@@ -6721,8 +6317,9 @@ static TCHAR *device_dupfix (TrapContext *ctx, uaecptr expbase, TCHAR *devname)
return my_strdup (newname);
}
-static const TCHAR *dostypes(TCHAR *dt, uae_u32 dostype)
+static const TCHAR *dostypes (uae_u32 dostype)
{
+ static TCHAR dt[32];
int j;
j = 0;
@@ -6742,10 +6339,9 @@ static const TCHAR *dostypes(TCHAR *dt, uae_u32 dostype)
#define rdbmnt write_log (_T("Mounting uaehf.device %d (%d) (size=%llu):\n"), unit_no, partnum, hfd->virtsize);
-static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacket)
+static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacket)
{
int lastblock = 63, blocksize, readblocksize, badblock, driveinitblock;
- TCHAR dt[32];
uae_u8 bufrdb[FILESYS_MAX_BLOCKSIZE], *buf = 0;
uae_u8 *fsmem = 0;
int rdblock, partblock, fileblock, lsegblock, i;
@@ -6757,7 +6353,7 @@ static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum,
int oldversion, oldrevision;
int newversion, newrevision;
TCHAR *s;
- int cnt = 0;
+ bool showdebug = partnum == 0;
write_log (_T("%s:\n"), uip->rootdir);
if (hfd->drive_empty) {
@@ -6801,20 +6397,32 @@ static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum,
}
blocksize = rl (bufrdb + 16);
readblocksize = blocksize > hfd->ci.blocksize ? blocksize : hfd->ci.blocksize;
-
badblock = rl (bufrdb + 24);
if (badblock != -1) {
- write_log (_T("RDB: badblock list %08x\n"), badblock);
+ rdbmnt
+ write_log (_T("RDB: badblock list is not yet supported. Contact the author.\n"));
+ return -2;
}
-
driveinitblock = rl (bufrdb + 36);
if (driveinitblock != -1) {
- write_log (_T("RDB: driveinit = %08x\n"), driveinitblock);
+ rdbmnt
+ write_log (_T("RDB: driveinit is not yet supported. Contact the author.\n"));
+ return -2;
}
-
hfd->rdbcylinders = rl (bufrdb + 64);
hfd->rdbsectors = rl (bufrdb + 68);
hfd->rdbheads = rl (bufrdb + 72);
+#if 0
+ {
+ int cyls, secs, heads;
+ getchsgeometry_hdf (hfd, hfd->virtsize, &cyls, &secs, &heads);
+ if (cyls * secs * heads > hfd->cylinders * hfd->sectors * hfd->heads) {
+ hfd->cylinders = cyls;
+ hfd->sectors = secs;
+ hfd->heads = heads;
+ }
+ }
+#endif
fileblock = rl (bufrdb + 32);
buf = xmalloc (uae_u8, readblocksize);
@@ -6832,12 +6440,11 @@ static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum,
hdf_read (hfd, buf, partblock * hfd->ci.blocksize, readblocksize);
if (!rdb_checksum ("PART", buf, partblock)) {
err = -2;
- write_log(_T("RDB: checksum error in PART block %d\n"), partblock);
goto error;
}
}
- rdbmnt;
+ rdbmnt
flags = rl (buf + 20);
if ((flags & 2) || uip->bootpri <= -129) { /* do not mount */
err = -1;
@@ -6846,19 +6453,19 @@ static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum,
}
if (!(flags & 1) || uip->bootpri <= -128) /* not bootable */
- trap_set_dreg(ctx, 7, trap_get_dreg(ctx, 7) & ~1);
+ m68k_dreg (regs, 7) = m68k_dreg (regs, 7) & ~1;
buf[37 + buf[36]] = 0; /* zero terminate BSTR */
s = au ((char*)buf + 37);
- uip->rdb_devname_amiga[partnum] = ds(device_dupfix(ctx, trap_get_long(ctx, parmpacket + PP_EXPLIB), s));
+ uip->rdb_devname_amiga[partnum] = ds (device_dupfix (get_long (parmpacket + PP_EXPLIB), s));
xfree (s);
- trap_put_long(ctx, parmpacket, uip->rdb_devname_amiga[partnum]); /* name */
- trap_put_long(ctx, parmpacket + 4, ROM_hardfile_resname);
- trap_put_long(ctx, parmpacket + 8, uip->devno);
- trap_put_long(ctx, parmpacket + 12, 0); /* Device flags */
+ put_long (parmpacket, uip->rdb_devname_amiga[partnum]); /* name */
+ put_long (parmpacket + 4, ROM_hardfile_resname);
+ put_long (parmpacket + 8, uip->devno);
+ put_long (parmpacket + 12, 0); /* Device flags */
for (i = 0; i < PP_MAXSIZE; i++)
- trap_put_byte(ctx, parmpacket + 16 + i, buf[128 + i]);
- dostype = trap_get_long(ctx, parmpacket + 80);
+ put_byte (parmpacket + 16 + i, buf[128 + i]);
+ dostype = get_long (parmpacket + 80);
uip->rdb_dostype = dostype;
if (dostype == 0) {
@@ -6876,21 +6483,21 @@ static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum,
if (fileblock == -1 || !legalrdbblock (uip, fileblock))
goto error;
- fsres = trap_get_long(ctx, parmpacket + PP_FSRES);
+ fsres = get_long (parmpacket + PP_FSRES);
if (!fsres) {
write_log (_T("RDB: FileSystem.resource not found, this shouldn't happen!\n"));
goto error;
}
- fsnode = trap_get_long(ctx, fsres + 18);
- while (trap_get_long(ctx, fsnode)) {
- if (trap_get_long(ctx, fsnode + 14) == dostype)
+ fsnode = get_long (fsres + 18);
+ while (get_long (fsnode)) {
+ if (get_long (fsnode + 14) == dostype)
break;
- fsnode = trap_get_long(ctx, fsnode);
+ fsnode = get_long (fsnode);
}
oldversion = oldrevision = -1;
- if (trap_get_long(ctx, fsnode)) {
- oldversion = trap_get_word(ctx, fsnode + 18);
- oldrevision = trap_get_word(ctx, fsnode + 20);
+ if (get_long (fsnode)) {
+ oldversion = get_word (fsnode + 18);
+ oldrevision = get_word (fsnode + 20);
} else {
fsnode = 0;
}
@@ -6898,7 +6505,7 @@ static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum,
for (;;) {
if (fileblock == -1) {
if (!fsnode)
- write_log (_T("RDB: FS %08X (%s) not in FileSystem.resource or in RDB\n"), dostype, dostypes (dt, dostype));
+ write_log (_T("RDB: FS %08X (%s) not in FileSystem.resource or in RDB\n"), dostype, dostypes (dostype));
goto error;
}
if (!legalrdbblock (uip, fileblock)) {
@@ -6913,15 +6520,15 @@ static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum,
}
fileblock = rl (buf + 16);
uae_u32 rdbdostype = rl (buf + 32);
- if (((dostype >> 8) == (rdbdostype >> 8) && (dostype != DISK_TYPE_DOS && (dostype & 0xffffff00) == DISK_TYPE_DOS)) || (dostype == rdbdostype))
+ if (((dostype >> 8) == (rdbdostype >> 8) && (dostype != 0x444f5300 && (dostype & 0xffffff00) == 0x444f5300)) || (dostype == rdbdostype))
break;
}
newversion = (buf[36] << 8) | buf[37];
newrevision = (buf[38] << 8) | buf[39];
- write_log (_T("RDB: RDB filesystem %08X (%s) version %d.%d\n"), dostype, dostypes (dt, dostype), newversion, newrevision);
+ write_log (_T("RDB: RDB filesystem %08X (%s) version %d.%d\n"), dostype, dostypes (dostype), newversion, newrevision);
if (fsnode) {
- write_log (_T("RDB: %08X (%s) in FileSystem.resource version %d.%d\n"), dostype, dostypes (dt, dostype), oldversion, oldrevision);
+ write_log (_T("RDB: %08X (%s) in FileSystem.resource version %d.%d\n"), dostype, dostypes (dostype), oldversion, oldrevision);
}
if (newversion * 65536 + newrevision <= oldversion * 65536 + oldrevision && oldversion >= 0) {
write_log (_T("RDB: FS in FileSystem.resource is newer or same, ignoring RDB filesystem\n"));
@@ -6929,36 +6536,35 @@ static int rdb_mount (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum,
}
for (i = 0; i < 140; i++)
- trap_put_byte(ctx, parmpacket + PP_FSHDSTART + i, buf[32 + i]);
- trap_put_long(ctx, parmpacket + PP_FSHDSTART, dostype);
+ put_byte (parmpacket + PP_FSHDSTART + i, buf[32 + i]);
+ put_long (parmpacket + PP_FSHDSTART, dostype);
/* we found required FSHD block */
fsmem = xmalloc (uae_u8, 262144);
lsegblock = rl (buf + 72);
+ i = 0;
for (;;) {
int pb = lsegblock;
if (!legalrdbblock (uip, lsegblock))
goto error;
memset (buf, 0, readblocksize);
hdf_read (hfd, buf, lsegblock * hfd->ci.blocksize, readblocksize);
- if (!rdb_checksum ("LSEG", buf, lsegblock)) {
- write_log(_T("RDB: checksum error in LSEG block %d\n"), lsegblock);
+ if (!rdb_checksum ("LSEG", buf, lsegblock))
goto error;
- }
lsegblock = rl (buf + 16);
if (lsegblock == pb)
goto error;
- if ((cnt + 1) * (blocksize - 20) >= 262144)
+ if ((i + 1) * (blocksize - 20) >= 262144)
goto error;
- memcpy (fsmem + cnt * (blocksize - 20), buf + 20, blocksize - 20);
- cnt++;
+ memcpy (fsmem + i * (blocksize - 20), buf + 20, blocksize - 20);
+ i++;
if (lsegblock == -1)
break;
}
- write_log (_T("RDB: Filesystem loaded, %d bytes\n"), cnt * (blocksize - 20));
- trap_put_long(ctx, parmpacket + PP_FSSIZE, cnt * (blocksize - 20)); /* RDB filesystem size hack */
- trap_put_long(ctx, parmpacket + PP_ADDTOFSRES, -1);
+ write_log (_T("RDB: Filesystem loaded, %d bytes\n"), i * (blocksize - 20));
+ put_long (parmpacket + PP_FSSIZE, i * (blocksize - 20)); /* RDB filesystem size hack */
+ put_long (parmpacket + PP_ADDTOFSRES, -1);
uip->rdb_filesysstore = fsmem;
- uip->rdb_filesyssize = cnt * (blocksize - 20);
+ uip->rdb_filesyssize = i * (blocksize - 20);
xfree (buf);
return 2;
error:
@@ -6967,33 +6573,33 @@ error:
return err;
}
-static void addfakefilesys (TrapContext *ctx, uaecptr parmpacket, uae_u32 dostype, int ver, int rev, struct uaedev_config_info *ci)
+static void addfakefilesys (uaecptr parmpacket, uae_u32 dostype, int ver, int rev, struct uaedev_config_info *ci)
{
int i;
uae_u32 flags;
flags = 0x180;
for (i = 0; i < 140; i++)
- trap_put_byte(ctx, parmpacket + PP_FSHDSTART + i, 0);
+ put_byte (parmpacket + PP_FSHDSTART + i, 0);
if (dostype) {
- trap_put_long(ctx, parmpacket + 80, dostype);
- trap_put_long(ctx, parmpacket + PP_FSHDSTART, dostype);
+ put_long (parmpacket + 80, dostype);
+ put_long (parmpacket + PP_FSHDSTART, dostype);
}
if (ver >= 0 && rev >= 0)
- trap_put_long(ctx, parmpacket + PP_FSHDSTART + 4, (ver << 16) | rev);
+ put_long (parmpacket + PP_FSHDSTART + 4, (ver << 16) | rev);
- trap_put_long(ctx, parmpacket + PP_FSHDSTART + 12 + 4 * 4, ci->stacksize);
+ put_long (parmpacket + PP_FSHDSTART + 12 + 4 * 4, ci->stacksize);
flags |= 0x10;
if (ci->priority != -129) {
- trap_put_long(ctx, parmpacket + PP_FSHDSTART + 12 + 5 * 4, ci->priority);
+ put_long (parmpacket + PP_FSHDSTART + 12 + 5 * 4, ci->priority);
flags |= 0x20;
}
- trap_put_long(ctx, parmpacket + PP_FSHDSTART + 12 + 8 * 4, dostype == DISK_TYPE_DOS || bcplonlydos() ? 0 : -1); // globvec
+ put_long (parmpacket + PP_FSHDSTART + 12 + 8 * 4, dostype == 0x444f5300 ? 0 : -1); // globvec
// if OFS = seglist -> NULL
- if (dostype == DISK_TYPE_DOS)
+ if (dostype == 0x444f5300)
flags &= ~0x080;
- trap_put_long(ctx, parmpacket + PP_FSHDSTART + 8, flags); // patchflags
+ put_long (parmpacket + PP_FSHDSTART + 8, flags); // patchflags
}
static uaecptr getfakefilesysseg (UnitInfo *uip)
@@ -7012,11 +6618,10 @@ static uaecptr getfakefilesysseg (UnitInfo *uip)
return 0;
}
-static int dofakefilesys (TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, struct uaedev_config_info *ci)
+static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket, struct uaedev_config_info *ci)
{
int i, size;
TCHAR tmp[MAX_DPATH];
- TCHAR dt[32];
uae_u8 buf[512];
struct zfile *zf;
int ver = -1, rev = -1;
@@ -7028,9 +6633,9 @@ static int dofakefilesys (TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, s
uaecptr seg = getfakefilesysseg (uip);
if (seg) {
// yes, re-use it.
- trap_put_long(ctx, parmpacket + PP_FSSIZE, 0);
- trap_put_long(ctx, parmpacket + PP_FSPTR, seg);
- trap_put_long(ctx, parmpacket + PP_ADDTOFSRES, 0);
+ put_long (parmpacket + PP_FSSIZE, 0);
+ put_long (parmpacket + PP_FSPTR, seg);
+ put_long (parmpacket + PP_ADDTOFSRES, 0);
write_log (_T("RDB: faked RDB filesystem '%s' reused\n"), uip->filesysdir);
return FILESYS_HARDFILE;
}
@@ -7044,10 +6649,10 @@ static int dofakefilesys (TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, s
dostype = ci->dostype;
}
if (dostype == 0) {
- addfakefilesys(ctx, parmpacket, dostype, ver, rev, ci);
+ addfakefilesys (parmpacket, dostype, ver, rev, ci);
return FILESYS_HARDFILE;
}
- if (dostype == DISK_TYPE_DOS && (!uip->filesysdir || !uip->filesysdir[0])) {
+ if (dostype == 0x444f5300 && (!uip->filesysdir || !uip->filesysdir[0])) {
write_log (_T("RDB: OFS, using ROM default FS.\n"));
return FILESYS_HARDFILE;
}
@@ -7055,7 +6660,7 @@ static int dofakefilesys (TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, s
tmp[0] = 0;
if (uip->filesysdir && _tcslen (uip->filesysdir) > 0) {
_tcscpy (tmp, uip->filesysdir);
- } else if ((dostype & 0xffffff00) == DISK_TYPE_DOS) {
+ } else if ((dostype & 0xffffff00) == 0x444f5300) {
_tcscpy (tmp, currprefs.romfile);
i = _tcslen (tmp);
while (i > 0 && tmp[i - 1] != '/' && tmp[i - 1] != '\\')
@@ -7064,17 +6669,17 @@ static int dofakefilesys (TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, s
autofs = true;
}
if (tmp[0] == 0) {
- write_log (_T("RDB: no filesystem for dostype 0x%08X (%s)\n"), dostype, dostypes (dt, dostype));
- addfakefilesys (ctx, parmpacket, dostype, ver, rev, ci);
- if ((dostype & 0xffffff00) == DISK_TYPE_DOS)
+ write_log (_T("RDB: no filesystem for dostype 0x%08X (%s)\n"), dostype, dostypes (dostype));
+ addfakefilesys (parmpacket, dostype, ver, rev, ci);
+ if ((dostype & 0xffffff00) == 0x444f5300)
return FILESYS_HARDFILE;
write_log (_T("RDB: mounted without filesys\n"));
return FILESYS_HARDFILE;
}
- write_log (_T("RDB: fakefilesys, trying to load '%s', dostype 0x%08X (%s)\n"), tmp, dostype, dostypes (dt, dostype));
+ write_log (_T("RDB: fakefilesys, trying to load '%s', dostype 0x%08X (%s)\n"), tmp, dostype, dostypes (dostype));
zf = zfile_fopen (tmp, _T("rb"), ZFD_NORMAL);
if (!zf) {
- addfakefilesys(ctx, parmpacket, dostype, ver, rev, ci);
+ addfakefilesys (parmpacket, dostype, ver, rev, ci);
write_log (_T("RDB: filesys not found, mounted without forced filesys\n"));
return FILESYS_HARDFILE;
}
@@ -7082,22 +6687,22 @@ static int dofakefilesys (TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, s
uae_u32 fsres, fsnode;
int oldversion = -1;
int oldrevision = -1;
- fsres = trap_get_long(ctx, parmpacket + PP_FSRES);
- fsnode = trap_get_long(ctx, fsres + 18);
- while (trap_get_long(ctx, fsnode)) {
- uae_u32 fsdostype = trap_get_long(ctx, fsnode + 14);
+ fsres = get_long (parmpacket + PP_FSRES);
+ fsnode = get_long (fsres + 18);
+ while (get_long (fsnode)) {
+ uae_u32 fsdostype = get_long (fsnode + 14);
if (fsdostype == dostype) {
- oldversion = trap_get_word(ctx, fsnode + 18);
- oldrevision = trap_get_word(ctx, fsnode + 20);
- write_log (_T("RDB: %08X (%s) in FileSystem.resource version %d.%d\n"), dostype, dostypes(dt, dostype), oldversion, oldrevision);
+ oldversion = get_word (fsnode + 18);
+ oldrevision = get_word (fsnode + 20);
+ write_log (_T("RDB: %08X (%s) in FileSystem.resource version %d.%d\n"), dostype, dostypes (dostype), oldversion, oldrevision);
break;
}
- fsnode = trap_get_long(ctx, fsnode);
+ fsnode = get_long (fsnode);
}
// if automatically found FastFileSystem, do not replace matching FileSystem.resource FS
if (autofs && oldversion >= 0) {
zfile_fclose (zf);
- addfakefilesys(ctx, parmpacket, dostype, ver, rev, ci);
+ addfakefilesys (parmpacket, dostype, ver, rev, ci);
write_log (_T("RDB: not replacing FileSystem.resource\n"));
return FILESYS_HARDFILE;
}
@@ -7149,31 +6754,31 @@ static int dofakefilesys (TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, s
uip->rdb_filesyssize = size;
// DOS\0 is not in fs.resource and fs.resource already existed?
- if (dostype == DISK_TYPE_DOS && oldversion < 0)
+ if (dostype == 0x444f5300 && oldversion < 0)
oldversion = 0;
- trap_put_long(ctx, parmpacket + PP_FSSIZE, uip->rdb_filesyssize);
- trap_put_long(ctx, parmpacket + PP_ADDTOFSRES, oldversion < 0 ? -1 : 0);
- addfakefilesys (ctx, parmpacket, dostype, ver, rev, ci);
- write_log (_T("RDB: faked RDB filesystem %08X (%s %d.%d) loaded. ADD2FS=%d\n"), dostype, dostypes (dt, dostype), ver, rev, oldversion < 0 ? 1 : 0);
+ put_long (parmpacket + PP_FSSIZE, uip->rdb_filesyssize);
+ put_long (parmpacket + PP_ADDTOFSRES, oldversion < 0 ? -1 : 0);
+ addfakefilesys (parmpacket, dostype, ver, rev, ci);
+ write_log (_T("RDB: faked RDB filesystem %08X (%s %d.%d) loaded. ADD2FS=%d\n"), dostype, dostypes (dostype), ver, rev, oldversion < 0 ? 1 : 0);
return FILESYS_HARDFILE;
}
-static void get_new_device (TrapContext *ctx, int type, uaecptr parmpacket, TCHAR **devname, uaecptr *devname_amiga, int unit_no)
+static void get_new_device (int type, uaecptr parmpacket, TCHAR **devname, uaecptr *devname_amiga, int unit_no)
{
TCHAR buffer[80];
- uaecptr expbase = trap_get_long(ctx, parmpacket + PP_EXPLIB);
+ uaecptr expbase = get_long (parmpacket + PP_EXPLIB);
if (*devname == 0 || _tcslen (*devname) == 0) {
int un = unit_no;
for (;;) {
_stprintf (buffer, _T("DH%d"), un++);
- if (!device_isdup(ctx, expbase, buffer))
+ if (!device_isdup (expbase, buffer))
break;
}
} else {
_tcscpy (buffer, *devname);
}
- *devname_amiga = ds (device_dupfix(ctx, expbase, buffer));
+ *devname_amiga = ds (device_dupfix (expbase, buffer));
if (type == FILESYS_VIRTUAL)
write_log (_T("FS: mounted virtual unit %s (%s)\n"), buffer, mountinfo.ui[unit_no].rootdir);
else
@@ -7184,152 +6789,171 @@ static void get_new_device (TrapContext *ctx, int type, uaecptr parmpacket, TCHA
}
/* Fill in per-unit fields of a parampacket */
-static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *ctx)
+static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context)
{
- UnitInfo *uip = mountinfo.ui;
- int no = trap_get_dreg(ctx, 6) & 0x7fffffff;
- int unit_no = no & 65535;
- int sub_no = no >> 16;
- int type;
- uaecptr parmpacket = trap_get_areg(ctx, 0);
+ UnitInfo *uip = mountinfo.ui;
+ int no = m68k_dreg(regs, 6) & 0x7fffffff;
+ int unit_no = no & 65535;
+ int sub_no = no >> 16;
+ int iscd = (m68k_dreg(regs, 6) & 0x80000000) != 0 || uip[unit_no].unit_type == UNIT_CDFS;
+ int type;
+ uaecptr parmpacket = m68k_areg(regs, 0);
struct uaedev_config_info *ci = &uip[unit_no].hf.ci;
- uip[unit_no].parmpacket = parmpacket;
- if (!ks12hack_deviceproc)
- ks12hack_deviceproc = trap_get_long(ctx, parmpacket + PP_DEVICEPROC);
- trap_put_long(ctx, parmpacket + PP_DEVICEPROC, 0);
- trap_put_long(ctx, parmpacket + PP_ADDTOFSRES, 0);
- trap_put_long(ctx, parmpacket + PP_FSSIZE, 0);
+ put_long (parmpacket + PP_ADDTOFSRES, 0);
+ put_long (parmpacket + PP_FSSIZE, 0);
+ //TODO
+ //if (iscd) {
+ // TCHAR *cdname = NULL;
+ // uaecptr cdname_amiga;
+ // int cd_unit_no = unit_no - cd_unit_offset;
- gui_flicker_led (LED_HD, unit_no, 0);
- type = is_hardfile (unit_no);
- if (type == FILESYS_HARDFILE_RDB) {
+ // if (sub_no)
+ // return -2;
+
+ // type = FILESYS_CD;
+ // get_new_device(type, parmpacket, &uip[unit_no].devname, &uip[unit_no].devname_amiga, cd_unit_no);
+ // cdname_amiga = uip[unit_no].devname_amiga;
+ // uip[unit_no].devno = unit_no;
+ // type = FILESYS_VIRTUAL;
+ // gui_flicker_led(LED_CD, cd_unit_no, 0);
+
+ // write_log(_T("Mounting uaescsi.device %d: (%d)\n"), cd_unit_no, unit_no);
+ // put_long(parmpacket + 0, cdname_amiga);
+ // put_long(parmpacket + 4, cdfs_devname);
+ // put_long(parmpacket + 8, cd_unit_no);
+ // put_long(parmpacket + 12, 0); /* Device flags */
+ // put_long(parmpacket + 16, 19); /* Env. size */
+ // put_long(parmpacket + 20, 2048 >> 2); /* longwords per block */
+ // put_long(parmpacket + 24, 0); /* unused */
+ // put_long(parmpacket + 28, 1); /* heads */
+ // put_long(parmpacket + 32, 1); /* sectors per block */
+ // put_long(parmpacket + 36, 1); /* sectors per track */
+ // put_long(parmpacket + 40, 0); /* reserved blocks */
+ // put_long(parmpacket + 44, 0); /* unused */
+ // put_long(parmpacket + 48, 0); /* interleave */
+ // put_long(parmpacket + 52, 0); /* lowCyl */
+ // put_long(parmpacket + 56, 0); /* hiCyl */
+ // put_long(parmpacket + 60, 50); /* Number of buffers */
+ // put_long(parmpacket + 64, 1); /* Buffer mem type */
+ // put_long(parmpacket + 68, 0x7FFFFFFE); /* largest transfer */
+ // put_long(parmpacket + 72, 0xFFFFFFFE); /* dma mask */
+ // put_long(parmpacket + 76, scsi_get_cd_drive_media_mask() & (1 << cd_unit_no) ? -127 : -128); /* bootPri */
+ // put_long(parmpacket + 80, CDFS_DOSTYPE | (((cd_unit_no / 10) + '0') << 8) | ((cd_unit_no % 10) + '0'));
+ // put_long(parmpacket + 84, 0); /* baud */
+ // put_long(parmpacket + 88, 0); /* control */
+ // put_long(parmpacket + 92, 0); /* bootblocks */
+ // return type;
+
+ //}
+
+ gui_flicker_led(LED_HD, unit_no, 0);
+ type = is_hardfile(unit_no);
+ if (type == FILESYS_HARDFILE_RDB || type == FILESYS_HARDDRIVE) {
/* RDB hardfile */
uip[unit_no].devno = unit_no;
- return rdb_mount (ctx, &uip[unit_no], unit_no, sub_no, parmpacket);
+ return rdb_mount(&uip[unit_no], unit_no, sub_no, parmpacket);
}
- if (sub_no)
- return -2;
- write_log(_T("Mounting uaehf.device %d (%d):\n"), unit_no, sub_no);
- get_new_device(ctx, type, parmpacket, &uip[unit_no].devname, &uip[unit_no].devname_amiga, unit_no);
- uip[unit_no].devno = unit_no;
- trap_put_long(ctx, parmpacket, uip[unit_no].devname_amiga);
- trap_put_long(ctx, parmpacket + 8, uip[unit_no].devno);
- trap_put_long(ctx, parmpacket + 12, 0); /* Device flags */
- trap_put_long(ctx, parmpacket + 16, 16); /* Env. size */
- trap_put_long(ctx, parmpacket + 24, 0); /* unused */
- trap_put_long(ctx, parmpacket + 44, 0); /* unused */
- trap_put_long(ctx, parmpacket + 48, 0); /* interleave */
- trap_put_long(ctx, parmpacket + 60, 50); /* Number of buffers */
- trap_put_long(ctx, parmpacket + 64, 1); /* Buffer mem type */
- trap_put_long(ctx, parmpacket + 68, 0x7FFFFFFE); /* largest transfer */
- trap_put_long(ctx, parmpacket + 72, 0xFFFFFFFE); /* dma mask */
- trap_put_long(ctx, parmpacket + 76, uip[unit_no].bootpri); /* bootPri */
+ if (sub_no)
+ return -2;
+ write_log(_T("Mounting uaehf.device %d (%d):\n"), unit_no, sub_no);
+ get_new_device(type, parmpacket, &uip[unit_no].devname, &uip[unit_no].devname_amiga, unit_no);
+ uip[unit_no].devno = unit_no;
+ put_long(parmpacket, uip[unit_no].devname_amiga);
+ put_long(parmpacket + 8, uip[unit_no].devno);
+ put_long(parmpacket + 12, 0); /* Device flags */
+ put_long(parmpacket + 16, 16); /* Env. size */
+ put_long(parmpacket + 24, 0); /* unused */
+ put_long(parmpacket + 44, 0); /* unused */
+ put_long(parmpacket + 48, 0); /* interleave */
+ put_long(parmpacket + 60, 50); /* Number of buffers */
+ put_long(parmpacket + 64, 1); /* Buffer mem type */
+ put_long(parmpacket + 68, 0x7FFFFFFE); /* largest transfer */
+ put_long(parmpacket + 72, 0xFFFFFFFE); /* dma mask */
+ put_long(parmpacket + 76, uip[unit_no].bootpri); /* bootPri */
+ put_long(parmpacket + 80, DISK_TYPE_DOS); /* DOS\0 */
if (type == FILESYS_VIRTUAL) {
- // generate some sane-looking geometry if some program really cares..
- uae_s64 hicyl = 100;
- uae_u32 heads = 16;
- if (currprefs.filesys_limit) {
- hicyl = ((currprefs.filesys_limit * 1024) / 512) / (heads * 127);
- } else {
- struct fs_usage fsu;
- if (!get_fs_usage(uip[unit_no].rootdir, 0, &fsu)) {
- for (;;) {
- hicyl = (fsu.total / 512) / (heads * 127);
- if (hicyl < 65536 || heads == 64)
- break;
- heads *= 2;
- }
- }
- }
- trap_put_long(ctx, parmpacket + 4, fsdevname);
- trap_put_long(ctx, parmpacket + 20, 512 >> 2); /* longwords per block */
- trap_put_long(ctx, parmpacket + 28, heads); /* heads */
- trap_put_long(ctx, parmpacket + 32, 1); /* sectors per block */
- trap_put_long(ctx, parmpacket + 36, 127); /* sectors per track */
- trap_put_long(ctx, parmpacket + 40, 2); /* reserved blocks */
- trap_put_long(ctx, parmpacket + 52, 1); /* lowCyl */
- trap_put_long(ctx, parmpacket + 56, (uae_u32)hicyl); /* hiCyl */
- trap_put_long(ctx, parmpacket + 80, DISK_TYPE_DOS); /* DOS\0 */
- } else {
- uae_u8 buf[512];
- trap_put_long(ctx, parmpacket + 4, ROM_hardfile_resname);
- trap_put_long(ctx, parmpacket + 20, ci->blocksize >> 2); /* longwords per block */
- trap_put_long(ctx, parmpacket + 28, ci->surfaces); /* heads */
- trap_put_long(ctx, parmpacket + 32, ci->sectorsperblock); /* sectors per block */
- trap_put_long(ctx, parmpacket + 36, ci->sectors); /* sectors per track */
- trap_put_long(ctx, parmpacket + 40, ci->reserved); /* reserved blocks */
- trap_put_long(ctx, parmpacket + 52, ci->lowcyl); /* lowCyl */
- trap_put_long(ctx, parmpacket + 56, ci->highcyl <= 0 ? ci->cyls - 1 : ci->highcyl - 1); /* hiCyl */
- trap_put_long(ctx, parmpacket + 48, ci->interleave); /* interleave */
- trap_put_long(ctx, parmpacket + 60, ci->buffers); /* Number of buffers */
- trap_put_long(ctx, parmpacket + 64, ci->bufmemtype); /* Buffer mem type */
- trap_put_long(ctx, parmpacket + 68, ci->maxtransfer); /* largest transfer */
- trap_put_long(ctx, parmpacket + 72, ci->mask); /* dma mask */
- trap_put_long(ctx, parmpacket + 80, DISK_TYPE_DOS); /* DOS\0 */
- memset(buf, 0, sizeof buf);
- if (ci->dostype) { // forced dostype?
- trap_put_long(ctx, parmpacket + 80, ci->dostype); /* dostype */
- } else if (hdf_read (&uip[unit_no].hf, buf, 0, sizeof buf)) {
- uae_u32 dt = rl (buf);
- if (dt != 0x00000000 && dt != 0xffffffff)
- trap_put_long(ctx, parmpacket + 80, dt);
- }
- memset(buf, 0, sizeof buf);
+ put_long(parmpacket + 4, fsdevname);
+ put_long(parmpacket + 20, 512 >> 2); /* longwords per block */
+ put_long(parmpacket + 28, 15); /* heads */
+ put_long(parmpacket + 32, 1); /* sectors per block */
+ put_long(parmpacket + 36, 127); /* sectors per track */
+ put_long(parmpacket + 40, 2); /* reserved blocks */
+ put_long(parmpacket + 52, 0); /* lowCyl */
+ put_long(parmpacket + 56, 1); /* hiCyl */
+ }
+ else {
+ uae_u8 buf[512] = { 0 };
char *s = ua_fs(uip[unit_no].devname, -1);
buf[36] = strlen(s);
for (int i = 0; i < buf[36]; i++)
buf[37 + i] = s[i];
xfree(s);
+ put_long(parmpacket + 4, ROM_hardfile_resname);
+ put_long(parmpacket + 20, ci->blocksize >> 2); /* longwords per block */
+ put_long(parmpacket + 28, ci->surfaces); /* heads */
+ put_long(parmpacket + 32, ci->sectorsperblock); /* sectors per block */
+ put_long(parmpacket + 36, ci->sectors); /* sectors per track */
+ put_long(parmpacket + 40, ci->reserved); /* reserved blocks */
+ put_long(parmpacket + 52, ci->lowcyl); /* lowCyl */
+ put_long(parmpacket + 56, ci->highcyl <= 0 ? ci->cyls - 1 : ci->highcyl - 1); /* hiCyl */
+ put_long(parmpacket + 48, ci->interleave); /* interleave */
+ put_long(parmpacket + 60, ci->buffers); /* Number of buffers */
+ put_long(parmpacket + 64, ci->bufmemtype); /* Buffer mem type */
+ put_long(parmpacket + 68, ci->maxtransfer); /* largest transfer */
+ put_long(parmpacket + 72, ci->mask); /* dma mask */
+ if (ci->dostype) { // forced dostype?
+ put_long(parmpacket + 80, ci->dostype); /* dostype */
+ }
+ else if (hdf_read(&uip[unit_no].hf, buf, 0, sizeof buf)) {
+ uae_u32 dt = rl(buf);
+ if (dt != 0x00000000 && dt != 0xffffffff)
+ put_long(parmpacket + 80, dt);
+ }
for (int i = 0; i < 80; i++)
- buf[i + 128] = trap_get_byte(ctx, parmpacket + 16 + i);
+ buf[i + 128] = get_byte(parmpacket + 16 + i);
}
if (type == FILESYS_HARDFILE)
- type = dofakefilesys (ctx, &uip[unit_no], parmpacket, ci);
- if (uip[unit_no].bootpri < -127 || (type == FILESYS_HARDFILE && ci->rootdir[0] == 0))
- trap_set_dreg(ctx, 7, trap_get_dreg(ctx, 7) & ~1); /* do not boot */
- if (uip[unit_no].bootpri < -128)
- return -1; /* do not mount */
- return type;
+ type = dofakefilesys(&uip[unit_no], parmpacket, ci);
+ if (uip[unit_no].bootpri < -127 || (type == FILESYS_HARDFILE && ci->rootdir[0] == 0))
+ m68k_dreg(regs, 7) = m68k_dreg(regs, 7) & ~1; /* do not boot */
+ if (uip[unit_no].bootpri < -128)
+ return -1; /* do not mount */
+ return type;
}
-static uae_u32 REGPARAM2 mousehack_done (TrapContext *ctx)
+static uae_u32 REGPARAM2 mousehack_done (TrapContext *context)
{
- int mode = trap_get_dreg(ctx, 1);
+ int mode = m68k_dreg (regs, 1);
if (mode < 10) {
- uaecptr diminfo = trap_get_areg(ctx, 2);
- uaecptr dispinfo = trap_get_areg(ctx, 3);
- uaecptr vp = trap_get_areg(ctx, 4);
- return input_mousehack_status(ctx, mode, diminfo, dispinfo, vp, trap_get_dreg(ctx, 2));
+ uaecptr diminfo = m68k_areg (regs, 2);
+ uaecptr dispinfo = m68k_areg (regs, 3);
+ uaecptr vp = m68k_areg (regs, 4);
+ return input_mousehack_status (mode, diminfo, dispinfo, vp, m68k_dreg (regs, 2));
} else if (mode == 10) {
+ amiga_clipboard_die ();
} else if (mode == 11) {
+ amiga_clipboard_got_data (m68k_areg (regs, 2), m68k_dreg (regs, 2), m68k_dreg (regs, 0) + 8);
} else if (mode == 12) {
- return 0;
+ return amiga_clipboard_want_data ();
} else if (mode == 13) {
- return 0;
+ return amiga_clipboard_proc_start ();
} else if (mode == 14) {
+ amiga_clipboard_task_start (m68k_dreg (regs, 0));
} else if (mode == 15) {
+ amiga_clipboard_init ();
} else if (mode == 16) {
- uaecptr a2 = trap_get_areg(ctx, 2);
+ uaecptr a2 = m68k_areg (regs, 2);
input_mousehack_mouseoffset (a2);
} else if (mode == 17) {
- return 0;
+ uae_u32 v = 0;
+ return v;
} else if (mode == 18) {
- put_long_host(rtarea_bank.baseaddr + RTAREA_EXTERTASK, trap_get_dreg(ctx, 0));
- put_long_host(rtarea_bank.baseaddr + RTAREA_TRAPTASK, trap_get_dreg(ctx, 2));
return rtarea_base + RTAREA_HEARTBEAT;
- } else if (mode == 19) {
- // boot rom copy
- // d2 = ram address
- return 0;
- } else if (mode == 20) {
- // boot rom copy done
- return 0;
- } else if (mode == 21) {
- // keymap hook (nur für Retroplatform relevant)
- return 1;
} else if (mode == 101) {
} else if (mode == 102) {
+ uaecptr ret = 0;
+ put_long (m68k_areg (regs, 7) + 4 * 4, ret);
} else {
write_log (_T("Unknown mousehack hook %d\n"), mode);
}
@@ -7338,15 +6962,17 @@ static uae_u32 REGPARAM2 mousehack_done (TrapContext *ctx)
void filesys_vsync (void)
{
- TrapContext *ctx = NULL;
Unit *u;
- if (uae_boot_rom_type <= 0)
- return;
- if (heartbeat == get_long_host(rtarea_bank.baseaddr + RTAREA_HEARTBEAT)) {
+ if (uae_boot_rom_type <= 0)
+ return;
+
+ if (heartbeat == get_long (rtarea_base + RTAREA_HEARTBEAT)) {
+ if (heartbeat_count > 0)
+ heartbeat_count--;
return;
}
- heartbeat = get_long_host(rtarea_bank.baseaddr + RTAREA_HEARTBEAT);
+ heartbeat = get_long (rtarea_base + RTAREA_HEARTBEAT);
for (u = units; u; u = u->next) {
if (u->reinsertdelay > 0) {
@@ -7359,7 +6985,7 @@ void filesys_vsync (void)
u->newrootdir = NULL;
}
}
- record_timeout (ctx, u);
+ record_timeout (u);
}
for (int i = 0; i < currprefs.mountitems; i++) {
@@ -7374,58 +7000,39 @@ void filesys_vsync (void)
}
}
}
-}
-void filesys_cleanup (void)
-{
- filesys_free_handles();
- free_mountinfo ();
-
- if(singlethread_int_sem != 0)
- uae_sem_destroy(&singlethread_int_sem);
- singlethread_int_sem = 0;
-
- filesys_in_interrupt = 0;
- mountertask = 0;
- automountunit = -1;
+ if (heartbeat_count <= 0)
+ return;
+
+ if (heartbeat_task & 1) {
+ setsystime_vblank ();
+ heartbeat_task &= ~1;
+ }
}
void filesys_install (void)
{
uaecptr loop;
+ TRACEI ((_T("Installing filesystem\n")));
+
uae_sem_init (&singlethread_int_sem, 0, 1);
- ROM_filesys_resname = ds_ansi ("UAEfs.resource");
- ROM_filesys_resid = ds_ansi (UAEFS_VERSION);
+ ROM_filesys_resname = ds_ansi ("UAEunixfs.resource");
+ ROM_filesys_resid = ds_ansi ("UAE unixfs 0.4");
fsdevname = ds_ansi ("uae.device"); /* does not really exist */
fshandlername = ds_bstr_ansi ("uaefs");
-
- afterdos_name = ds_ansi("UAE afterdos");
- afterdos_id = ds_ansi("UAE afterdos 0.1");
-
ROM_filesys_diagentry = here();
calltrap (deftrap2 (filesys_diagentry, 0, _T("filesys_diagentry")));
dw(0x4ED0); /* JMP (a0) - jump to code that inits Residents */
- ROM_filesys_doio = here();
- calltrap(deftrap2(filesys_doio, 0, _T("filesys_doio")));
- dw(RTS);
-
- ROM_filesys_putmsg = here();
- calltrap(deftrap2(filesys_putmsg, 0, _T("filesys_putmsg")));
- dw(RTS);
-
- ROM_filesys_putmsg_return = here();
- calltrap(deftrap2(filesys_putmsg_return, 0, _T("filesys_putmsg_return")));
- dw(RTS);
-
- loop = here ();
+ loop = here ();
org (rtarea_base + RTAREA_HEARTBEAT);
dl (0);
heartbeat = 0;
+ heartbeat_task = 0;
org (rtarea_base + 0xFF18);
calltrap (deftrap2 (filesys_dev_bootfilesys, 0, _T("filesys_dev_bootfilesys")));
@@ -7438,7 +7045,7 @@ void filesys_install (void)
org (rtarea_base + 0xFF28);
calltrap (deftrap2 (filesys_dev_storeinfo, 0, _T("filesys_dev_storeinfo")));
- dw (RTS);
+ dw (RTS);
org (rtarea_base + 0xFF30);
calltrap (deftrap2 (filesys_handler, 0, _T("filesys_handler")));
@@ -7464,14 +7071,6 @@ void filesys_install (void)
calltrap (deftrap2 (fsmisc_helper, 0, _T("fsmisc_helper")));
dw (RTS);
- org(rtarea_base + 0xFF68);
- calltrap(deftrap2(filesys_bcpl_wrapper, 0, _T("filesys_bcpl_wrapper")));
- dw(RTS);
-
- org(rtarea_base + 0xFF78);
- calltrap(deftrap2(debugger_helper, 0, _T("debugger_helper")));
- dw(RTS);
-
org (loop);
}
@@ -7484,76 +7083,71 @@ void filesys_install_code (void)
{
uae_u32 b, items;
- bootrom_header = 3 * 4;
- align(4);
- bootrom_start = here ();
- #include "filesys_bootrom.cpp"
+ bootrom_header = 3 * 4;
+ align(4);
+ bootrom_start = here();
+#include "filesys_bootrom.cpp"
- items = dlg (bootrom_start + 8) & 0xffff;
- /* The last offset comes from the code itself, look for it near the top. */
+ items = dlg(bootrom_start + 8) & 0xffff;
+ /* The last offset comes from the code itself, look for it near the top. */
EXPANSION_bootcode = bootrom_start + bootrom_header + items * 4 - 4;
b = bootrom_start + bootrom_header + 3 * 4 - 4;
- filesys_initcode = bootrom_start + dlg (b) + bootrom_header - 4;
- afterdos_initcode = filesys_get_entry(8);
+ filesys_initcode = bootrom_start + dlg(b) + bootrom_header - 4;
}
-#ifdef _WIN32_
-#include "od-win32/win32_filesys.cpp"
-#endif
-
-static uae_u8 *restore_filesys_hardfile (UnitInfo *ui, uae_u8 *src)
+static uae_u8 *restore_filesys_hardfile(UnitInfo *ui, uae_u8 *src)
{
- struct hardfiledata *hfd = &ui->hf;
- TCHAR *s;
+ struct hardfiledata *hfd = &ui->hf;
+ TCHAR *s;
- hfd->virtsize = restore_u64();
- hfd->offset = restore_u64();
- hfd->ci.highcyl = restore_u32 ();
- hfd->ci.sectors = restore_u32 ();
- hfd->ci.surfaces = restore_u32 ();
- hfd->ci.reserved = restore_u32 ();
- hfd->ci.blocksize = restore_u32 ();
- hfd->ci.readonly = restore_u32 () != 0;
- hfd->flags = restore_u32();
- hfd->rdbcylinders = restore_u32 ();
- hfd->rdbsectors = restore_u32 ();
- hfd->rdbheads = restore_u32 ();
- s = restore_string();
- _tcscpy (hfd->vendor_id, s);
- xfree(s);
- s = restore_string();
- _tcscpy (hfd->product_id, s);
- xfree(s);
- s = restore_string();
- _tcscpy (hfd->product_rev, s);
- xfree(s);
- s = restore_string();
- _tcscpy (hfd->ci.devname, s);
- xfree(s);
- return src;
+ hfd->virtsize = restore_u64();
+ hfd->offset = restore_u64();
+ hfd->ci.highcyl = restore_u32();
+ hfd->ci.sectors = restore_u32();
+ hfd->ci.surfaces = restore_u32();
+ hfd->ci.reserved = restore_u32();
+ hfd->ci.blocksize = restore_u32();
+ hfd->ci.readonly = restore_u32() != 0;
+ hfd->flags = restore_u32();
+ hfd->rdbcylinders = restore_u32();
+ hfd->rdbsectors = restore_u32();
+ hfd->rdbheads = restore_u32();
+ s = restore_string();
+ _tcscpy(hfd->vendor_id, s);
+ xfree(s);
+ s = restore_string();
+ _tcscpy(hfd->product_id, s);
+ xfree(s);
+ s = restore_string();
+ _tcscpy(hfd->product_rev, s);
+ xfree(s);
+ s = restore_string();
+ _tcscpy(hfd->ci.devname, s);
+ xfree(s);
+ return src;
}
-static uae_u8 *save_filesys_hardfile (UnitInfo *ui, uae_u8 *dst)
+static uae_u8 *save_filesys_hardfile(UnitInfo *ui, uae_u8 *dst)
{
- struct hardfiledata *hfd = &ui->hf;
+ struct hardfiledata *hfd = &ui->hf;
- save_u64 (hfd->virtsize);
- save_u64 (hfd->offset);
- save_u32 (hfd->ci.highcyl);
- save_u32 (hfd->ci.sectors);
- save_u32 (hfd->ci.surfaces);
- save_u32 (hfd->ci.reserved);
- save_u32 (hfd->ci.blocksize);
- save_u32 (hfd->ci.readonly);
- save_u32 (hfd->flags);
- save_u32 (hfd->rdbcylinders);
- save_u32 (hfd->rdbsectors);
- save_u32 (hfd->rdbheads);
- save_string (hfd->vendor_id);
- save_string (hfd->product_id);
- save_string (hfd->product_rev);
- save_string (hfd->ci.devname);
- return dst;
+ save_u64(hfd->virtsize);
+ save_u64(hfd->offset);
+ save_u32(hfd->ci.highcyl);
+ save_u32(hfd->ci.sectors);
+ save_u32(hfd->ci.surfaces);
+ save_u32(hfd->ci.reserved);
+ save_u32(hfd->ci.blocksize);
+ save_u32(hfd->ci.readonly);
+ save_u32(hfd->flags);
+ save_u32(hfd->rdbcylinders);
+ save_u32(hfd->rdbsectors);
+ save_u32(hfd->rdbheads);
+ save_string(hfd->vendor_id);
+ save_string(hfd->product_id);
+ save_string(hfd->product_rev);
+ save_string(hfd->ci.devname);
+ return dst;
}
static a_inode *restore_filesys_get_base (Unit *u, TCHAR *npath)
@@ -7573,6 +7167,7 @@ static a_inode *restore_filesys_get_base (Unit *u, TCHAR *npath)
cnt = 1;
for (;;) {
_tcscpy (path, npath);
+ _tcscat (path, _T("/"));
p = path;
for (i = 0; i < cnt ;i++) {
if (i > 0)
@@ -7688,10 +7283,9 @@ static uae_u8 *restore_aino(UnitInfo *ui, Unit *u, uae_u8 *src)
pn = makenativepath(ui, p);
a->nname = pn;
a->aname = my_strdup(p2);
- /* create path to parent dir */
- if (p2 != p)
- p2[0] = 0;
/* find parent of a->aname (Already restored previously. I hope..) */
+ if (p2 != p)
+ p2[-1] = 0;
base = restore_filesys_get_base(u, p);
xfree(p);
if (flags & 2) {
@@ -7791,14 +7385,14 @@ static uae_u8 *restore_key(UnitInfo *ui, Unit *u, uae_u8 *src)
missing = 1;
} else {
uae_s64 s;
- s = key_filesize(k);
+ s = fs_fsize64 (k->fd);
if (s != savedsize)
write_log (_T("FS: restored file '%s' size changed! orig=%llu, now=%lld!!\n"), p, savedsize, s);
if (k->file_pos > s) {
write_log (_T("FS: restored filepos larger than size of file '%s'!! %llu > %lld\n"), p, k->file_pos, s);
k->file_pos = s;
}
- key_seek(k, k->file_pos, SEEK_SET);
+ fs_lseek64 (k->fd, k->file_pos, SEEK_SET);
}
}
xfree (p);
@@ -7845,7 +7439,7 @@ static uae_u8 *restore_exkey(UnitInfo *ui, Unit *u, uae_u8 *src)
static uae_u8 *restore_filesys_virtual (UnitInfo *ui, uae_u8 *src, int num)
{
- Unit *u = startup_create_unit (NULL, ui, num);
+ Unit *u = startup_create_unit (ui, num);
int cnt;
u->dosbase = restore_u32 ();
@@ -7888,11 +7482,11 @@ static TCHAR *getfullaname(a_inode *a)
TCHAR *p;
int first = 1;
- p = xcalloc (TCHAR, MAX_DPATH);
+ p = xcalloc (TCHAR, 2000);
while (a) {
int len = _tcslen (a->aname);
memmove (p + len + 1, p, (_tcslen (p) + 1) * sizeof (TCHAR));
- memcpy (p, a->aname, len * sizeof (TCHAR));
+ memcpy (p, a->aname, _tcslen (a->aname) * sizeof (TCHAR));
if (!first)
p[len] = '/';
first = 0;
@@ -8094,6 +7688,8 @@ uae_u8 *save_filesys (int num, int *len)
save_path (ui->rootdir, SAVESTATE_PATH_VDIR);
else if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB)
save_path (ui->rootdir, SAVESTATE_PATH_HDF);
+ else if (type == FILESYS_HARDDRIVE)
+ save_path (ui->rootdir, SAVESTATE_PATH_HD);
else
save_path (ui->rootdir, SAVESTATE_PATH);
save_string (ui->devname);
@@ -8130,6 +7726,8 @@ uae_u8 *restore_filesys (uae_u8 *src)
rootdir = restore_path (SAVESTATE_PATH_VDIR);
} else if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB) {
rootdir = restore_path (SAVESTATE_PATH_HDF);
+ } else if (type == FILESYS_HARDDRIVE) {
+ rootdir = restore_path (SAVESTATE_PATH_HD);
} else {
rootdir = restore_path (SAVESTATE_PATH);
}
diff --git a/src/genblitter.cpp b/src/genblitter.cpp
index bb2e550f..5ba6dc63 100644
--- a/src/genblitter.cpp
+++ b/src/genblitter.cpp
@@ -16,174 +16,255 @@
/* 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
+ 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");
+ int minterm;
+ printf("STATIC_INLINE uae_u32 blit_func(uae_u32 srca, uae_u32 srcb, uae_u32 srcc, 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 \"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");
+ unsigned int i;
+ printf("#include \"sysconfig.h\"\n");
+ printf("#include \"sysdeps.h\"\n");
+ printf("#include \"options.h\"\n");
+ printf("#include \"custom.h\"\n");
+ printf("#include \"memory.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_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");
+ 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 0
+ printf("if (currprefs.blits_32bit_enabled && b->hblitsize > 1");
+ if (a_is_on) printf(" && !b->blitashift && b->bltafwm==0xffff && b->bltalwm==0xffff");
+ if (b_is_on) printf(" && !b->blitbshift");
+ printf(") {\n");
+ if (a_is_on) printf("uae_u32 srca=((uae_u32)b->bltadat << 16) | b->bltadat;\n");
+ if (b_is_on) printf("uae_u32 srcb=((uae_u32)b->bltbdat << 16) | b->bltbdat;\n");
+ if (c_is_on) printf("uae_u32 srcc=((uae_u32)b->bltcdat << 16) | b->bltcdat;\n");
+ printf("uae_u32 dest;\n");
+ printf("int count=b->hblitsize/2, oddword=b->hblitsize&1;\n");
+ printf("for (j=0;jvblitsize;j++) {\n");
+ printf("\tfor(i=0;ibltamod;\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 (a_is_on) printf("if (pta) b->bltadat = (*(pta-b->bltamod-2) << 8) | *(pta - b->bltamod - 1);\n"); /* Maybe not necessary, but I don't want problems */
+ if (b_is_on) printf("if (ptb) b->bltbdat = (*(ptb-b->bltbmod-2) << 8) | *(ptb - b->bltbmod - 1);\n");
+ if (c_is_on) printf("if (ptc) b->bltcdat = (*(ptc-b->bltcmod-2) << 8) | *(ptc - b->bltcmod - 1);\n");
+ printf("if (ptd) b->bltddat = (*(ptd-b->bltdmod-2) << 8) | *(ptd - b->bltdmod - 1);\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");
+ printf("} else {\n");
+#endif
+ if (a_is_on) printf("uae_u32 preva = 0;\n");
+ if (b_is_on) printf("uae_u32 prevb = 0, 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 = chipmem_wget_indirect (ptc); ptc += 2; }\n");
+ if (b_is_on) printf("\t\tif (ptb) {\n\t\t\tuae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb += 2;\n");
+ if (b_is_on) printf("\t\t\tsrcb = (((uae_u32)prevb << 16) | bltbdat) >> b->blitbshift;\n");
+ if (b_is_on) printf("\t\t\tprevb = bltbdat;\n\t\t}\n");
+ if (a_is_on) printf("\t\tif (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta += 2; } else { bltadat = blt_info.bltadat; }\n");
+ if (a_is_on) printf("\t\tbltadat &= blit_masktable[i];\n");
+ if (a_is_on) printf("\t\tsrca = (((uae_u32)preva << 16) | bltadat) >> b->blitashift;\n");
+ if (a_is_on) printf("\t\tpreva = bltadat;\n");
+ printf("\t\tif (dstp) chipmem_wput_indirect (dstp, dstd);\n");
+ printf("\t\tdstd = (%s) & 0xFFFF;\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) chipmem_wput_indirect (dstp, dstd);\n");
+#if 0
+ printf("}\n");
+#endif
+ printf("if (totald != 0) b->blitzero = 0;\n");
+ printf("}\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");
- }
+ 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 0
+ printf("if (currprefs.blits_32bit_enabled && b->hblitsize > 1");
+ if (a_is_on) printf(" && !b->blitashift && b->bltafwm==0xffff && b->bltalwm==0xffff");
+ if (b_is_on) printf(" && !b->blitbshift");
+ printf(") {\n");
+ if (a_is_on) printf("uae_u32 srca = ((uae_u32)b->bltadat << 16) | b->bltadat;\n");
+ if (b_is_on) printf("uae_u32 srcb = ((uae_u32)b->bltbdat << 16) | b->bltbdat;\n");
+ if (c_is_on) printf("uae_u32 srcc = ((uae_u32)b->bltcdat << 16) | b->bltcdat;\n");
+ printf("uae_u32 dest;\n");
+ printf("int count=b->hblitsize/2, oddword=b->hblitsize&1;\n");
+ printf("for (j=0;jvblitsize;j++) {\n");
+ printf("\tfor(i=0;ibltamod;\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 (a_is_on) printf("if (pta) b->bltadat = (*(pta + b->bltamod + 2) << 8) | *(pta + b->bltamod + 1);\n"); /* Maybe not necessary, but I don't want problems */
+ if (b_is_on) printf("if (ptb) b->bltbdat = (*(ptb + b->bltbmod + 2) << 8) | *(ptb + b->bltbmod + 1);\n");
+ if (c_is_on) printf("if (ptc) b->bltcdat = (*(ptc + b->bltcmod + 2) << 8) | *(ptc + b->bltcmod + 1);\n");
+ printf("if (ptd) b->bltddat = (*(ptd + b->bltdmod + 2) << 8) | *(ptd + b->bltdmod + 1);\n");
+
+ printf("} else {\n");
+#endif
+ if (a_is_on) printf("uae_u32 preva = 0;\n");
+ if (b_is_on) printf("uae_u32 prevb = 0, 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 = chipmem_wget_indirect (ptc); ptc -= 2; }\n");
+ if (b_is_on) printf("\t\tif (ptb) {\n\t\t\tuae_u32 bltbdat = blt_info.bltbdat = chipmem_wget_indirect (ptb); ptb -= 2;\n");
+ if (b_is_on) printf("\t\t\tsrcb = ((bltbdat << 16) | prevb) >> b->blitdownbshift;\n");
+ if (b_is_on) printf("\t\t\tprevb = bltbdat;\n\t\t}\n");
+ if (a_is_on) printf("\t\tif (pta) { bltadat = blt_info.bltadat = chipmem_wget_indirect (pta); pta -= 2; } else { bltadat = blt_info.bltadat; }\n");
+ if (a_is_on) printf("\t\tbltadat &= blit_masktable[i];\n");
+ if (a_is_on) printf("\t\tsrca = (((uae_u32)bltadat << 16) | preva) >> b->blitdownashift;\n");
+ if (a_is_on) printf("\t\tpreva = bltadat;\n");
+ printf("\t\tif (dstp) chipmem_wput_indirect (dstp, dstd);\n");
+ printf("\t\tdstd = (%s) & 0xFFFF;\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) chipmem_wput_indirect (dstp, dstd);\n");
+#if 0
+ printf("}\n");
+#endif
+ printf("if (totald != 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 \"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]) {
+ unsigned int index = 0;
+ unsigned int i;
+ printf("#include \"sysconfig.h\"\n");
+ printf("#include \"sysdeps.h\"\n");
+ printf("#include \"options.h\"\n");
+ printf("#include \"custom.h\"\n");
+ printf("#include \"memory.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");
+ }
+ 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]) {
+ 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");
+ }
+ 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]);
- }
+ 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';
+ 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;
+ 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/genlinetoscr.cpp b/src/genlinetoscr.cpp
new file mode 100644
index 00000000..5ad25657
--- /dev/null
+++ b/src/genlinetoscr.cpp
@@ -0,0 +1,605 @@
+/*
+* 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..0ef8fda8 100644
--- a/src/gfxboard.cpp
+++ b/src/gfxboard.cpp
@@ -11,15 +11,24 @@
#include "sysdeps.h"
#include "options.h"
+#include "uae.h"
+#include "include/memory.h"
+#include "debug.h"
+#include "custom.h"
+#include "newcpu.h"
+#include "picasso96.h"
+#include "statusline.h"
+#include "rommgr.h"
+#include "zfile.h"
#include "gfxboard.h"
-const TCHAR *gfxboard_get_name(int type)
+bool gfxboard_is_z3 (int type)
{
if (type == GFXBOARD_UAE_Z2)
- return _T("UAE Zorro II");
+ return false;
if (type == GFXBOARD_UAE_Z3)
- return _T("UAE Zorro III (*)");
- return NULL;
+ return true;
+ return false;
}
const TCHAR *gfxboard_get_configname(int type)
@@ -28,15 +37,5 @@ const TCHAR *gfxboard_get_configname(int type)
return _T("ZorroII");
if (type == GFXBOARD_UAE_Z3)
return _T("ZorroIII");
- return NULL;
-}
-
-int gfxboard_get_configtype(struct rtgboardconfig *rbc)
-{
- int type = rbc->rtgmem_type;
- if (type == GFXBOARD_UAE_Z2)
- return 2;
- if (type == GFXBOARD_UAE_Z3)
- return 3;
- return 0;
-}
+ //return boards[type - GFXBOARD_HARDWARE].configname;
+}
\ No newline at end of file
diff --git a/src/gfxutil.cpp b/src/gfxutil.cpp
index cc1b171d..d743d022 100644
--- a/src/gfxutil.cpp
+++ b/src/gfxutil.cpp
@@ -13,24 +13,68 @@
#include "rtgmodes.h"
#include "xwin.h"
-#define RED 0
+double getvsyncrate(double hz, int *mult)
+{
+ struct apmode *ap = picasso_on ? &currprefs.gfx_apmode[1] : &currprefs.gfx_apmode[0];
+
+ if (hz < 0)
+ return 0;
+ if (hz > 85) {
+ *mult = -1;
+ return hz / 2;
+ }
+ if (hz < 35 && hz > 0) {
+ if (ap->gfx_interlaced)
+ *mult = 0;
+ else
+ *mult = 1;
+ return hz * 2;
+ }
+ *mult = 0;
+ return hz;
+}
+
+#define RED 0
#define GRN 1
#define BLU 2
unsigned int doMask (int p, int bits, int shift)
{
- /* scale to 0..255, shift to align msb with mask, and apply mask */
- uae_u32 val;
+ /* p is a value from 0 to 15 (Amiga color value)
+ * scale to 0..255, shift to align msb with mask, and apply mask */
+ uae_u32 val;
+ //uae_u32 val = p * 0x11111111UL;
val = p << 24;
- if (!bits)
- return 0;
- val >>= (32 - bits);
- val <<= shift;
+ if (!bits)
+ return 0;
+ val >>= (32 - bits);
+ val <<= shift;
- return val;
+ return val;
}
+int bits_in_mask(unsigned long mask)
+{
+ int n = 0;
+ while (mask) {
+ n += mask & 1;
+ mask >>= 1;
+ }
+ return n;
+}
+
+int mask_shift(unsigned long mask)
+{
+ int n = 0;
+ if (!mask)
+ return 0;
+ while (!(mask & 1)) {
+ n++;
+ mask >>= 1;
+ }
+ return n;
+}
unsigned int doMask256 (int p, int bits, int shift)
{
@@ -48,15 +92,135 @@ unsigned int doMask256 (int p, int bits, int shift)
static unsigned int doColor(int i, int bits, int shift)
{
- int shift2;
+ int shift2;
- if(bits >= 8)
- shift2 = 0;
- else
- shift2 = 8 - bits;
- return (i >> shift2) << shift;
+ if (bits >= 8)
+ shift2 = 0;
+ else
+ shift2 = 8 - bits;
+ return (i >> shift2) << shift;
}
+static unsigned int doAlpha(int alpha, int bits, int shift)
+{
+ return (alpha & ((1 << bits) - 1)) << shift;
+}
+
+static float video_gamma(float value, float gamma, float bri, float con)
+{
+ double factor;
+ float ret;
+
+ value += bri;
+ value *= con;
+
+ if (value <= 0.0f)
+ return 0.0f;
+
+ factor = pow(255.0f, 1.0f - gamma);
+ ret = float(factor * pow(value, gamma));
+
+ if (ret < 0.0f)
+ ret = 0.0f;
+
+ return ret;
+}
+
+static uae_u32 Gamma[256 * 3][3];
+static int lf, hf;
+
+//static void video_calc_gammatable(void)
+//{
+// float bri, con, gam, gams[3];
+//
+// bri = ((float)(currprefs.gfx_luminance)) * (128.0f / 1000.0f);
+// con = ((float)(currprefs.gfx_contrast + 1000)) / 1000.0f;
+// gam = ((float)(1000 - currprefs.gfx_gamma)) / 1000.0f - 1.0;
+// gams[0] = gam + ((float)(1000 - currprefs.gfx_gamma_ch[0])) / 1000.0f;
+// gams[1] = gam + ((float)(1000 - currprefs.gfx_gamma_ch[1])) / 1000.0f;
+// gams[2] = gam + ((float)(1000 - currprefs.gfx_gamma_ch[2])) / 1000.0f;
+//
+// lf = 64 * currprefs.gf[picasso_on].gfx_filter_blur / 1000;
+// hf = 256 - lf * 2;
+//
+// for (int i = 0; i < (256 * 3); i++) {
+// for (int j = 0; j < 3; j++) {
+// float val = i - 256;
+// float v;
+//
+// if (currprefs.gfx_threebitcolors == 2) {
+// val *= 2;
+// }
+// else if (currprefs.gfx_threebitcolors == 3) {
+// val = (val * 252.0) / 119.0;
+// }
+// else if (currprefs.gfx_threebitcolors == 1) {
+// val = (val * 252.0) / 238.0;
+// }
+//
+// if (currprefs.gfx_luminance == 0 && currprefs.gfx_contrast == 0 && currprefs.gfx_gamma == 0 &&
+// currprefs.gfx_gamma_ch[0] == 0 && currprefs.gfx_gamma_ch[1] == 0 && currprefs.gfx_gamma_ch[2] == 0) {
+// v = val;
+// }
+// else {
+// v = video_gamma(val, gams[j], bri, con);
+// }
+//
+// if (v < 0.0)
+// v = 0.0;
+// if (v > 255.0)
+// v = 255.0;
+//
+// gamma[i][j] = (uae_u32)(v + 0.5);
+// }
+// }
+//}
+
+static uae_u32 limit256(double v)
+{
+ v = v * double(currprefs.gf[picasso_on].gfx_filter_contrast + 1000) / 1000.0 + currprefs.gf[picasso_on].gfx_filter_luminance / 10.0;
+ if (v < 0)
+ v = 0;
+ if (v > 255)
+ v = 255;
+ return uae_u32(v) & 0xff;
+}
+static uae_u32 limit256rb(double v)
+{
+ v *= double(currprefs.gf[picasso_on].gfx_filter_saturation + 1000) / 1000.0;
+ if (v < -128)
+ v = -128;
+ if (v > 127)
+ v = 127;
+ return uae_u32(v) & 0xff;
+}
+static double get_y(int r, int g, int b)
+{
+ return 0.2989f * r + 0.5866f * g + 0.1145f * b;
+}
+static uae_u32 get_yh(int r, int g, int b)
+{
+ return limit256(get_y(r, g, b) * hf / 256);
+}
+static uae_u32 get_yl(int r, int g, int b)
+{
+ return limit256(get_y(r, g, b) * lf / 256);
+}
+static uae_u32 get_cb(int r, int g, int b)
+{
+ return limit256rb(-0.168736f * r - 0.331264f * g + 0.5f * b);
+}
+static uae_u32 get_cr(int r, int g, int b)
+{
+ return limit256rb(0.5f * r - 0.418688f * g - 0.081312f * b);
+}
+
+extern uae_s32 tyhrgb[65536];
+extern uae_s32 tylrgb[65536];
+extern uae_s32 tcbrgb[65536];
+extern uae_s32 tcrrgb[65536];
+extern uae_u32 redc[3 * 256], grec[3 * 256], bluc[3 * 256];
+
static uae_u32 lowbits (int v, int shift, int lsize)
{
v >>= shift;
@@ -64,25 +228,128 @@ static uae_u32 lowbits (int v, int shift, int lsize)
return v;
}
-#ifndef ARMV6_ASSEMBLY
-void alloc_colors_rgb (int rw, int gw, int bw, int rs, int gs, int bs, int byte_swap,
+void alloc_colors_picasso(int rw, int gw, int bw, int rs, int gs, int bs, int rgbfmt)
+{
+#ifdef PICASSO96
+ int byte_swap = 0;
+ int i;
+ int red_bits = 0, green_bits, blue_bits;
+ int red_shift, green_shift, blue_shift;
+ int bpp = rw + gw + bw;
+
+ switch (rgbfmt)
+ {
+ case RGBFB_R5G6B5PC:
+ red_bits = 5;
+ green_bits = 6;
+ blue_bits = 5;
+ red_shift = 11;
+ green_shift = 5;
+ blue_shift = 0;
+ break;
+ case RGBFB_R5G5B5PC:
+ red_bits = green_bits = blue_bits = 5;
+ red_shift = 10;
+ green_shift = 5;
+ blue_shift = 0;
+ break;
+ case RGBFB_R5G6B5:
+ red_bits = 5;
+ green_bits = 6;
+ blue_bits = 5;
+ red_shift = 11;
+ green_shift = 5;
+ blue_shift = 0;
+ byte_swap = 1;
+ break;
+ case RGBFB_R5G5B5:
+ red_bits = green_bits = blue_bits = 5;
+ red_shift = 10;
+ green_shift = 5;
+ blue_shift = 0;
+ byte_swap = 1;
+ break;
+ case RGBFB_B5G6R5PC:
+ red_bits = 5;
+ green_bits = 6;
+ blue_bits = 5;
+ red_shift = 0;
+ green_shift = 5;
+ blue_shift = 11;
+ break;
+ case RGBFB_B5G5R5PC:
+ red_bits = green_bits = blue_bits = 5;
+ red_shift = 0;
+ green_shift = 5;
+ blue_shift = 10;
+ break;
+ default:
+ red_bits = rw;
+ green_bits = gw;
+ blue_bits = bw;
+ red_shift = rs;
+ green_shift = gs;
+ blue_shift = bs;
+ break;
+ }
+
+#ifdef WORDS_BIGENDIAN
+ byte_swap = !byte_swap;
+#endif
+
+ memset(p96_rgbx16, 0, sizeof p96_rgbx16);
+
+ if (red_bits) {
+ int lrbits = 8 - red_bits;
+ int lgbits = 8 - green_bits;
+ int lbbits = 8 - blue_bits;
+ int lrmask = (1 << red_bits) - 1;
+ int lgmask = (1 << green_bits) - 1;
+ int lbmask = (1 << blue_bits) - 1;
+ for (i = 65535; i >= 0; i--) {
+ uae_u32 r, g, b, c;
+ uae_u32 j = byte_swap ? bswap_16(i) : i;
+ r = (((j >> red_shift) & lrmask) << lrbits) | lowbits(j, red_shift, lrbits);
+ g = (((j >> green_shift) & lgmask) << lgbits) | lowbits(j, green_shift, lgbits);
+ b = (((j >> blue_shift) & lbmask) << lbbits) | lowbits(j, blue_shift, lbbits);
+ c = doMask(r, rw, rs) | doMask(g, gw, gs) | doMask(b, bw, bs);
+ if (bpp <= 16)
+ c *= 0x00010001;
+ p96_rgbx16[i] = c;
+ }
+ }
+#endif
+}
+
+void alloc_colors_rgb(int rw, int gw, int bw, int rs, int gs, int bs, int aw, int as, int alpha, int byte_swap,
uae_u32 *rc, uae_u32 *gc, uae_u32 *bc)
{
- int bpp = rw + gw + bw;
+ int bpp = rw + gw + bw + aw;
int i;
- for(i = 0; i < 256; i++) {
- rc[i] = doColor (i, rw, rs);
- gc[i] = doColor (i, gw, gs);
- bc[i] = doColor (i, bw, bs);
+ for (i = 0; i < 256; i++) {
+ int j;
+
+ if (currprefs.gfx_blackerthanblack) {
+ j = i * 15 / 16 + 15;
+ }
+ else {
+ j = i;
+ }
+ j += 256;
+
+ rc[i] = doColor(Gamma[j][0], rw, rs) | doAlpha(alpha, aw, as);
+ gc[i] = doColor(Gamma[j][1], gw, gs) | doAlpha(alpha, aw, as);
+ bc[i] = doColor(Gamma[j][2], bw, bs) | doAlpha(alpha, aw, as);
if (byte_swap) {
if (bpp <= 16) {
- rc[i] = bswap_16 (rc[i]);
- gc[i] = bswap_16 (gc[i]);
- bc[i] = bswap_16 (bc[i]);
- } else {
- rc[i] = bswap_32 (rc[i]);
- gc[i] = bswap_32 (gc[i]);
- bc[i] = bswap_32 (bc[i]);
+ rc[i] = bswap_16(rc[i]);
+ gc[i] = bswap_16(gc[i]);
+ bc[i] = bswap_16(bc[i]);
+ }
+ else {
+ rc[i] = bswap_32(rc[i]);
+ gc[i] = bswap_32(gc[i]);
+ bc[i] = bswap_32(bc[i]);
}
}
if (bpp <= 16) {
@@ -94,21 +361,119 @@ void alloc_colors_rgb (int rw, int gw, int bw, int rs, int gs, int bs, int byte_
}
}
}
-#endif
-void alloc_colors64k (int rw, int gw, int bw, int rs, int gs, int bs, int byte_swap)
+void alloc_colors64k (int rw, int gw, int bw, int rs, int gs, int bs, int aw, int as, int alpha, int byte_swap)
{
- int i;
+ int bpp = rw + gw + bw + aw;
+ int i, j;
+
+ //video_calc_gammatable();
+ j = 256;
for (i = 0; i < 4096; i++) {
int r = ((i >> 8) << 4) | (i >> 8);
int g = (((i >> 4) & 0xf) << 4) | ((i >> 4) & 0x0f);
int b = ((i & 0xf) << 4) | (i & 0x0f);
- xcolors[i] = doMask(r, rw, rs) | doMask(g, gw, gs) | doMask(b, bw, bs);
- /* Fill upper 16 bits of each colour value
- * with a copy of the colour. */
- xcolors[i] = xcolors[i] * 0x00010001;
+ r = Gamma[r + j][0];
+ g = Gamma[g + j][1];
+ b = Gamma[b + j][2];
+ xcolors[i] = doMask(r, rw, rs) | doMask(g, gw, gs) | doMask(b, bw, bs) | doAlpha(alpha, aw, as);
+ if (byte_swap) {
+ if (bpp <= 16) {
+ xcolors[i] = bswap_16(xcolors[i]);
+ }
+ else {
+ xcolors[i] = bswap_32(xcolors[i]);
+ }
+ }
+ if (bpp <= 16) {
+ /* Fill upper 16 bits of each colour value
+ * with a copy of the colour. */
+ xcolors[i] |= xcolors[i] * 0x00010001;
+ }
+ }
+#if defined(AGA) || defined(GFXFILTER)
+ alloc_colors_rgb(rw, gw, bw, rs, gs, bs, aw, as, alpha, byte_swap, xredcolors, xgreencolors, xbluecolors);
+ /* copy original color table */
+ //for (i = 0; i < 256; i++) {
+ // redc[0 * 256 + i] = xredcolors[0];
+ // grec[0 * 256 + i] = xgreencolors[0];
+ // bluc[0 * 256 + i] = xbluecolors[0];
+ // redc[1 * 256 + i] = xredcolors[i];
+ // grec[1 * 256 + i] = xgreencolors[i];
+ // bluc[1 * 256 + i] = xbluecolors[i];
+ // redc[2 * 256 + i] = xredcolors[255];
+ // grec[2 * 256 + i] = xgreencolors[255];
+ // bluc[2 * 256 + i] = xbluecolors[255];
+ //}
+#ifdef GFXFILTER
+ if (usedfilter && usedfilter->yuv) {
+ /* create internal 5:6:5 color tables */
+ for (i = 0; i < 256; i++) {
+ j = i + 256;
+ xredcolors[i] = doColor(gamma[j][0], 5, 11);
+ xgreencolors[i] = doColor(gamma[j][1], 6, 5);
+ xbluecolors[i] = doColor(gamma[j][2], 5, 0);
+ if (bpp <= 16) {
+ /* Fill upper 16 bits of each colour value with
+ * a copy of the colour. */
+ xredcolors[i] = xredcolors[i] * 0x00010001;
+ xgreencolors[i] = xgreencolors[i] * 0x00010001;
+ xbluecolors[i] = xbluecolors[i] * 0x00010001;
+ }
+ }
+ for (i = 0; i < 4096; i++) {
+ int r = ((i >> 8) << 4) | (i >> 8);
+ int g = (((i >> 4) & 0xf) << 4) | ((i >> 4) & 0x0f);
+ int b = ((i & 0xf) << 4) | (i & 0x0f);
+ r = gamma[r + 256][0];
+ g = gamma[g + 256][1];
+ b = gamma[b + 256][2];
+ xcolors[i] = doMask(r, 5, 11) | doMask(g, 6, 5) | doMask(b, 5, 0);
+ if (byte_swap) {
+ if (bpp <= 16)
+ xcolors[i] = bswap_16(xcolors[i]);
+ else
+ xcolors[i] = bswap_32(xcolors[i]);
+ }
+ if (bpp <= 16) {
+ /* Fill upper 16 bits of each colour value
+ * with a copy of the colour. */
+ xcolors[i] |= xcolors[i] * 0x00010001;
+ }
+ }
+
+ /* create RGB 5:6:5 -> YUV tables */
+ for (i = 0; i < 65536; i++) {
+ uae_u32 r, g, b;
+ r = (((i >> 11) & 31) << 3) | lowbits(i, 11, 3);
+ r = gamma[r + 256][0];
+ g = (((i >> 5) & 63) << 2) | lowbits(i, 5, 2);
+ g = gamma[g + 256][1];
+ b = (((i >> 0) & 31) << 3) | lowbits(i, 0, 3);
+ b = gamma[b + 256][2];
+ tyhrgb[i] = get_yh(r, g, b) * 256 * 256;
+ tylrgb[i] = get_yl(r, g, b) * 256 * 256;
+ tcbrgb[i] = ((uae_s8)get_cb(r, g, b)) * 256;
+ tcrrgb[i] = ((uae_s8)get_cr(r, g, b)) * 256;
+ }
}
-#ifndef ARMV6_ASSEMBLY
- alloc_colors_rgb (rw, gw, bw, rs, gs, bs, byte_swap, xredcolors, xgreencolors, xbluecolors);
#endif
+
+#endif
+ xredcolor_b = rw;
+ xgreencolor_b = gw;
+ xbluecolor_b = bw;
+ xredcolor_s = rs;
+ xgreencolor_s = gs;
+ xbluecolor_s = bs;
+ xredcolor_m = ((1 << rw) - 1) << xredcolor_s;
+ xgreencolor_m = ((1 << gw) - 1) << xgreencolor_s;
+ xbluecolor_m = ((1 << bw) - 1) << xbluecolor_s;
+
+ /* create AGA color tables */
+ for(i=0; i<256; i++) {
+ xredcolors[i] = doColor(i, rw, rs);
+ xgreencolors[i] = doColor(i, gw, gs);
+ xbluecolors[i] = doColor(i, bw, bs);
+ }
}
diff --git a/src/guisan/Makefile b/src/guisan/Makefile
index ca953757..847d4424 100644
--- a/src/guisan/Makefile
+++ b/src/guisan/Makefile
@@ -6,8 +6,8 @@ DIRS =$(shell find ./src -maxdepth 3 -type d)
SOURCE = $(foreach dir,$(DIRS),$(wildcard $(dir)/*.cpp))
OBJS = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCE)))
-INCLUDE =-I./include `sdl2-config --cflags`
-CFLAGS = -g -w -O3 $(INCLUDE)
+INCLUDE =-I./include `sdl2-config --cflags --libs`
+CFLAGS =-g -w -O3 $(INCLUDE)
CXXFLAGS= $(CFLAGS)
diff --git a/src/hardfile.cpp b/src/hardfile.cpp
index abaf6268..414354b4 100644
--- a/src/hardfile.cpp
+++ b/src/hardfile.cpp
@@ -1,11 +1,11 @@
- /*
- * UAE - The Un*x Amiga Emulator
- *
- * Hardfile emulation
- *
- * Copyright 1995 Bernd Schmidt
- * 2002 Toni Wilen (scsi emulation, 64-bit support)
- */
+/*
+* UAE - The Un*x Amiga Emulator
+*
+* Hardfile emulation
+*
+* Copyright 1995 Bernd Schmidt
+* 2002 Toni Wilen (scsi emulation, 64-bit support)
+*/
#include "sysconfig.h"
#include "sysdeps.h"
@@ -24,12 +24,16 @@
#include "gui.h"
#include "uae.h"
#include "scsi.h"
-#include "gayle.h"
+//#include "gayle.h"
#include "execio.h"
#include "zfile.h"
-#include "ide.h"
-#undef DEBUGME
+#ifdef WITH_CHD
+#include "archivers/chd/chdtypes.h"
+#include "archivers/chd/chd.h"
+#endif
+
+//#undef DEBUGME
#define hf_log(fmt, ...)
#define hf_log2(fmt, ...)
#define scsi_log(fmt, ...)
@@ -53,53 +57,51 @@
#define ASYNC_REQUEST_CHANGEINT 10
struct hardfileprivdata {
- uaecptr d_request[MAX_ASYNC_REQUESTS];
- uae_u8 *d_request_iobuf[MAX_ASYNC_REQUESTS];
- int d_request_type[MAX_ASYNC_REQUESTS];
- uae_u32 d_request_data[MAX_ASYNC_REQUESTS];
- smp_comm_pipe requests;
- int thread_running;
- uae_thread_id thread_id;
- uae_sem_t sync_sem;
- uaecptr base;
- int changenum;
- uaecptr changeint;
- struct scsi_data *sd;
+ volatile uaecptr d_request[MAX_ASYNC_REQUESTS];
+ volatile int d_request_type[MAX_ASYNC_REQUESTS];
+ volatile uae_u32 d_request_data[MAX_ASYNC_REQUESTS];
+ smp_comm_pipe requests;
+ int thread_running;
+ uae_sem_t sync_sem;
+ uaecptr base;
+ int changenum;
+ uaecptr changeint;
};
#define HFD_VHD_DYNAMIC 3
#define HFD_VHD_FIXED 2
+#define HFD_CHD 1
-STATIC_INLINE uae_u32 gl (uae_u8 *p)
+STATIC_INLINE uae_u32 gl(uae_u8 *p)
{
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3] << 0);
}
-static uae_sem_t change_sem = 0;
+static uae_sem_t change_sem;
static struct hardfileprivdata hardfpd[MAX_FILESYSTEM_UNITS];
static uae_u32 nscmd_cmd;
-static void wl (uae_u8 *p, int v)
+static void wl(uae_u8 *p, int v)
{
p[0] = v >> 24;
p[1] = v >> 16;
p[2] = v >> 8;
p[3] = v;
}
-static void ww (uae_u8 *p, int v)
+static void ww(uae_u8 *p, int v)
{
p[0] = v >> 8;
p[1] = v;
}
-static int rl (uae_u8 *p)
+static int rl(uae_u8 *p)
{
return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3]);
}
-static void getchs2 (struct hardfiledata *hfd, int *cyl, int *cylsec, int *head, int *tracksec)
+static void getchs2(struct hardfiledata *hfd, int *cyl, int *cylsec, int *head, int *tracksec)
{
unsigned int total = (unsigned int)(hfd->virtsize / 1024);
int heads;
@@ -138,15 +140,15 @@ static void getchs2 (struct hardfiledata *hfd, int *cyl, int *cylsec, int *head,
*head = heads;
}
-static void getchsx (struct hardfiledata *hfd, int *cyl, int *cylsec, int *head, int *tracksec)
+static void getchsx(struct hardfiledata *hfd, int *cyl, int *cylsec, int *head, int *tracksec)
{
- getchs2 (hfd, cyl, cylsec, head, tracksec);
- hf_log (_T("CHS: %08X-%08X %d %d %d %d %d\n"),
- (uae_u32)(hfd->virtsize >> 32),(uae_u32)hfd->virtsize,
+ getchs2(hfd, cyl, cylsec, head, tracksec);
+ hf_log(_T("CHS: %08X-%08X %d %d %d %d %d\n"),
+ (uae_u32)(hfd->virtsize >> 32), (uae_u32)hfd->virtsize,
*cyl, *cylsec, *head, *tracksec);
}
-static void getchsgeometry2 (uae_u64 size, int *pcyl, int *phead, int *psectorspertrack, int mode)
+static void getchsgeometry2(uae_u64 size, int *pcyl, int *phead, int *psectorspertrack, int mode)
{
int sptt[4];
int i, spt, head, cyl;
@@ -158,7 +160,8 @@ static void getchsgeometry2 (uae_u64 size, int *pcyl, int *phead, int *psectorsp
spt = 32;
cyl = total / (head * spt);
- } else {
+ }
+ else {
sptt[0] = 63;
sptt[1] = 127;
@@ -166,14 +169,14 @@ static void getchsgeometry2 (uae_u64 size, int *pcyl, int *phead, int *psectorsp
sptt[3] = -1;
for (i = 0; sptt[i] >= 0; i++) {
- int maxhead = sptt[i] < 255 ? 16 : 255;
spt = sptt[i];
- for (head = 4; head <= maxhead; head++) {
+ for (head = 4; head <= 16; head++) {
cyl = total / (head * spt);
if (size <= 512 * 1024 * 1024) {
if (cyl <= 1023)
break;
- } else {
+ }
+ else {
if (cyl < 16383)
break;
if (cyl < 32767 && head >= 5)
@@ -181,30 +184,24 @@ static void getchsgeometry2 (uae_u64 size, int *pcyl, int *phead, int *psectorsp
if (cyl <= 65535)
break;
}
- if (maxhead > 16) {
- head *= 2;
- head--;
- }
}
if (head <= 16)
break;
}
}
- if (head > 16)
- head--;
*pcyl = cyl;
*phead = head;
*psectorspertrack = spt;
}
-void getchsgeometry (uae_u64 size, int *pcyl, int *phead, int *psectorspertrack)
+void getchsgeometry(uae_u64 size, int *pcyl, int *phead, int *psectorspertrack)
{
- getchsgeometry2 (size, pcyl, phead, psectorspertrack, 0);
+ getchsgeometry2(size, pcyl, phead, psectorspertrack, 0);
}
-void getchsgeometry_hdf (struct hardfiledata *hfd, uae_u64 size, int *pcyl, int *phead, int *psectorspertrack)
+void getchsgeometry_hdf(struct hardfiledata *hfd, uae_u64 size, int *pcyl, int *phead, int *psectorspertrack)
{
uae_u8 block[512];
int i;
@@ -214,33 +211,33 @@ void getchsgeometry_hdf (struct hardfiledata *hfd, uae_u64 size, int *pcyl, int
*phead = 1;
*psectorspertrack = 32;
}
- memset (block, 0, sizeof block);
+ memset(block, 0, sizeof block);
if (hfd) {
- hdf_read (hfd, block, 0, 512);
+ hdf_read(hfd, block, 0, 512);
if (block[0] == 'D' && block[1] == 'O' && block[2] == 'S') {
int mode;
for (mode = 0; mode < 2; mode++) {
uae_u32 rootblock;
uae_u32 chk = 0;
- getchsgeometry2 (size, pcyl, phead, psectorspertrack, mode);
+ getchsgeometry2(size, pcyl, phead, psectorspertrack, mode);
rootblock = (2 + ((*pcyl) * (*phead) * (*psectorspertrack) - 1)) / 2;
- memset (block, 0, sizeof block);
- hdf_read (hfd, block, (uae_u64)rootblock * 512, 512);
+ memset(block, 0, sizeof block);
+ hdf_read(hfd, block, (uae_u64)rootblock * 512, 512);
for (i = 0; i < 512; i += 4)
chk += (block[i] << 24) | (block[i + 1] << 16) | (block[i + 2] << 8) | (block[i + 3] << 0);
if (!chk && block[0] == 0 && block[1] == 0 && block[2] == 0 && block[3] == 2 &&
- block[4] == 0 && block[5] == 0 && block[6] == 0 && block[7] == 0 &&
- block[8] == 0 && block[9] == 0 && block[10] == 0 && block[11] == 0 &&
+ block[4] == 0 && block[5] == 0 && block[6] == 0 && block[7] == 0 &&
+ block[8] == 0 && block[9] == 0 && block[10] == 0 && block[11] == 0 &&
block[508] == 0 && block[509] == 0 && block[510] == 0 && block[511] == 1) {
- return;
+ return;
}
}
}
}
- getchsgeometry2 (size, pcyl, phead, psectorspertrack, size <= minsize ? 1 : 2);
+ getchsgeometry2(size, pcyl, phead, psectorspertrack, size <= minsize ? 1 : 2);
}
-void getchspgeometry (uae_u64 total, int *pcyl, int *phead, int *psectorspertrack, bool idegeometry)
+void getchspgeometry(uae_u64 total, int *pcyl, int *phead, int *psectorspertrack, bool idegeometry)
{
uae_u64 blocks = total / 512;
@@ -257,16 +254,16 @@ void getchspgeometry (uae_u64 total, int *pcyl, int *phead, int *psectorspertrac
*pcyl = blocks / ((*psectorspertrack) * (*phead));
return;
}
- getchsgeometry (total, pcyl, phead, psectorspertrack);
+ getchsgeometry(total, pcyl, phead, psectorspertrack);
}
-static void getchshd (struct hardfiledata *hfd, int *pcyl, int *phead, int *psectorspertrack)
+static void getchshd(struct hardfiledata *hfd, int *pcyl, int *phead, int *psectorspertrack)
{
- getchspgeometry (hfd->virtsize, pcyl, phead, psectorspertrack, false);
+ getchspgeometry(hfd->virtsize, pcyl, phead, psectorspertrack, false);
}
-static void pl (uae_u8 *p, int off, uae_u32 v)
+static void pl(uae_u8 *p, int off, uae_u32 v)
{
p += off * 4;
p[0] = v >> 24;
@@ -275,34 +272,34 @@ static void pl (uae_u8 *p, int off, uae_u32 v)
p[3] = v >> 0;
}
-static void rdb_crc (uae_u8 *p)
+static void rdb_crc(uae_u8 *p)
{
uae_u32 sum;
int i, blocksize;
- sum =0;
- blocksize = rl (p + 1 * 4);
+ sum = 0;
+ blocksize = rl(p + 1 * 4);
for (i = 0; i < blocksize; i++)
- sum += rl (p + i * 4);
+ sum += rl(p + i * 4);
sum = -sum;
- pl (p, 2, sum);
+ pl(p, 2, sum);
}
-static void create_virtual_rdb (struct hardfiledata *hfd)
+static void create_virtual_rdb(struct hardfiledata *hfd)
{
uae_u8 *rdb, *part, *denv;
int cyl = hfd->ci.surfaces * hfd->ci.sectors;
int cyls = 262144 / (cyl * 512);
int size = cyl * cyls * 512;
- rdb = xcalloc (uae_u8, size);
+ rdb = xcalloc(uae_u8, size);
hfd->virtual_rdb = rdb;
hfd->virtual_size = size;
part = rdb + 512;
pl(rdb, 0, 0x5244534b);
pl(rdb, 1, 64);
pl(rdb, 2, 0); // chksum
- pl(rdb, 3, 7); // hostid
+ pl(rdb, 3, 0); // hostid
pl(rdb, 4, 512); // blockbytes
pl(rdb, 5, 0); // flags
pl(rdb, 6, -1); // badblock
@@ -339,10 +336,10 @@ static void create_virtual_rdb (struct hardfiledata *hfd)
pl(rdb, 37, 0); // autopark
pl(rdb, 38, 2); // highrdskblock
pl(rdb, 39, -1); // res
- ua_copy ((char*)rdb + 40 * 4, 8, hfd->vendor_id);
- ua_copy ((char*)rdb + 42 * 4, 16, hfd->product_id);
- ua_copy ((char*)rdb + 46 * 4, 4, _T("UAE"));
- rdb_crc (rdb);
+ ua_copy((char*)rdb + 40 * 4, -1, hfd->vendor_id);
+ ua_copy((char*)rdb + 42 * 4, -1, hfd->product_id);
+ ua_copy((char*)rdb + 46 * 4, -1, _T("UAE"));
+ rdb_crc(rdb);
pl(part, 0, 0x50415254);
pl(part, 1, 64);
@@ -353,8 +350,8 @@ static void create_virtual_rdb (struct hardfiledata *hfd)
pl(part, 6, -1);
pl(part, 7, -1);
pl(part, 8, 0); // devflags
- part[9 * 4] = _tcslen (hfd->ci.devname);
- ua_copy ((char*)part + 9 * 4 + 1, 30, hfd->ci.devname);
+ part[9 * 4] = _tcslen(hfd->ci.devname);
+ ua_copy((char*)part + 9 * 4 + 1, 30, hfd->ci.devname);
denv = part + 128;
pl(denv, 0, 80);
@@ -374,45 +371,47 @@ static void create_virtual_rdb (struct hardfiledata *hfd)
pl(denv, 14, hfd->ci.mask);
pl(denv, 15, hfd->ci.bootpri);
pl(denv, 16, hfd->ci.dostype);
- rdb_crc (part);
+ rdb_crc(part);
hfd->virtsize += size;
}
-void hdf_hd_close (struct hd_hardfiledata *hfd)
+void hdf_hd_close(struct hd_hardfiledata *hfd)
{
if (!hfd)
return;
- hdf_close (&hfd->hfd);
+ hdf_close(&hfd->hfd);
}
-int hdf_hd_open (struct hd_hardfiledata *hfd)
+int hdf_hd_open(struct hd_hardfiledata *hfd)
{
struct uaedev_config_info *ci = &hfd->hfd.ci;
- if (hdf_open (&hfd->hfd) <= 0)
+ if (!hdf_open(&hfd->hfd))
return 0;
- if (ci->physical_geometry) {
+ if (ci->pcyls && ci->pheads && ci->psecs) {
hfd->cyls = ci->pcyls;
hfd->heads = ci->pheads;
hfd->secspertrack = ci->psecs;
- } else if (ci->highcyl && ci->surfaces && ci->sectors) {
+ }
+ else if (ci->highcyl && ci->surfaces && ci->sectors) {
hfd->cyls = ci->highcyl;
hfd->heads = ci->surfaces;
hfd->secspertrack = ci->sectors;
- } else {
- getchshd (&hfd->hfd, &hfd->cyls, &hfd->heads, &hfd->secspertrack);
+ }
+ else {
+ getchshd(&hfd->hfd, &hfd->cyls, &hfd->heads, &hfd->secspertrack);
}
hfd->cyls_def = hfd->cyls;
hfd->secspertrack_def = hfd->secspertrack;
hfd->heads_def = hfd->heads;
if (ci->surfaces && ci->sectors) {
uae_u8 buf[512] = { 0 };
- hdf_read (&hfd->hfd, buf, 0, 512);
- if (buf[0] != 0 && memcmp (buf, _T("RDSK"), 4)) {
+ hdf_read(&hfd->hfd, buf, 0, 512);
+ if (buf[0] != 0 && memcmp(buf, _T("RDSK"), 4)) {
ci->highcyl = (hfd->hfd.virtsize / ci->blocksize) / (ci->sectors * ci->surfaces);
- ci->dostype = rl (buf);
- create_virtual_rdb (&hfd->hfd);
+ ci->dostype = rl(buf);
+ create_virtual_rdb(&hfd->hfd);
while (ci->highcyl * ci->surfaces * ci->sectors > hfd->cyls_def * hfd->secspertrack_def * hfd->heads_def) {
hfd->cyls_def++;
}
@@ -422,22 +421,44 @@ int hdf_hd_open (struct hd_hardfiledata *hfd)
return 1;
}
-static int hdf_write2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
-static int hdf_read2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
-
-static int hdf_cache_read (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
+static uae_u32 vhd_checksum(uae_u8 *p, int offset)
{
- return hdf_read2 (hfd, buffer, offset, len);
+ int i;
+ uae_u32 sum;
+
+ sum = 0;
+ for (i = 0; i < 512; i++) {
+ if (offset >= 0 && i >= offset && i < offset + 4)
+ continue;
+ sum += p[i];
+ }
+ return ~sum;
}
-static int hdf_cache_write (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
+static int hdf_write2(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
+static int hdf_read2(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
+
+static void hdf_init_cache(struct hardfiledata *hfd)
+{
+}
+static void hdf_flush_cache(struct hardfiledata *hdf)
{
- return hdf_write2 (hfd, buffer, offset, len);
}
-int hdf_open (struct hardfiledata *hfd, const TCHAR *pname)
+static int hdf_cache_read(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
- int ret;
+ return hdf_read2(hfd, buffer, offset, len);
+}
+
+static int hdf_cache_write(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
+{
+ return hdf_write2(hfd, buffer, offset, len);
+}
+
+int hdf_open(struct hardfiledata *hfd, const TCHAR *pname)
+{
+ uae_u8 tmp[512], tmp2[512];
+ uae_u32 v;
if ((!pname || pname[0] == 0) && hfd->ci.rootdir[0] == 0)
return 0;
@@ -446,59 +467,546 @@ int hdf_open (struct hardfiledata *hfd, const TCHAR *pname)
hfd->hfd_type = 0;
if (!pname)
pname = hfd->ci.rootdir;
- ret = hdf_open_target (hfd, pname);
- if (ret <= 0)
- return ret;
+#ifdef WITH_CHD
+ TCHAR nametmp[MAX_DPATH];
+ _tcscpy(nametmp, pname);
+ TCHAR *ext = _tcsrchr(nametmp, '.');
+ if (ext && !_tcsicmp(ext, _T(".chd"))) {
+ struct zfile *zf = zfile_fopen(nametmp, _T("rb"));
+ if (zf) {
+ int err;
+ chd_file *cf = new chd_file();
+ err = cf->open(zf, false, NULL);
+ if (err != CHDERR_NONE) {
+ zfile_fclose(zf);
+ goto nonvhd;
+ }
+ hfd->chd_handle = cf;
+ hfd->ci.readonly = true;
+ hfd->hfd_type = HFD_CHD;
+ hfd->handle_valid = -1;
+ hfd->virtsize = cf->logical_bytes();
+ goto nonvhd;
+ }
+ }
+#endif
+ if (!hdf_open_target(hfd, pname))
+ return 0;
+ if (hdf_read_target(hfd, tmp, 0, 512) != 512)
+ goto nonvhd;
+ v = gl(tmp + 8); // features
+ if ((v & 3) != 2)
+ goto nonvhd;
+ v = gl(tmp + 8 + 4); // version
+ if ((v >> 16) != 1)
+ goto nonvhd;
+ hfd->hfd_type = gl(tmp + 8 + 4 + 4 + 8 + 4 + 4 + 4 + 4 + 8 + 8 + 4);
+ if (hfd->hfd_type != HFD_VHD_FIXED && hfd->hfd_type != HFD_VHD_DYNAMIC)
+ goto nonvhd;
+ v = gl(tmp + 8 + 4 + 4 + 8 + 4 + 4 + 4 + 4 + 8 + 8 + 4 + 4);
+ if (v == 0)
+ goto nonvhd;
+ if (vhd_checksum(tmp, 8 + 4 + 4 + 8 + 4 + 4 + 4 + 4 + 8 + 8 + 4 + 4) != v)
+ goto nonvhd;
+ if (hdf_read_target(hfd, tmp2, hfd->physsize - sizeof tmp2, 512) != 512)
+ goto end;
+ if (memcmp(tmp, tmp2, sizeof tmp))
+ goto nonvhd;
+ hfd->vhd_footerblock = hfd->physsize - 512;
+ hfd->virtsize = (uae_u64)(gl(tmp + 8 + 4 + 4 + 8 + 4 + 4 + 4 + 4 + 8)) << 32;
+ hfd->virtsize |= gl(tmp + 8 + 4 + 4 + 8 + 4 + 4 + 4 + 4 + 8 + 4);
+ if (hfd->hfd_type == HFD_VHD_DYNAMIC) {
+ uae_u32 size;
+ hfd->vhd_bamoffset = gl(tmp + 8 + 4 + 4 + 4);
+ if (hfd->vhd_bamoffset == 0 || hfd->vhd_bamoffset >= hfd->physsize)
+ goto end;
+ if (hdf_read_target(hfd, tmp, hfd->vhd_bamoffset, 512) != 512)
+ goto end;
+ v = gl(tmp + 8 + 8 + 8 + 4 + 4 + 4);
+ if (vhd_checksum(tmp, 8 + 8 + 8 + 4 + 4 + 4) != v)
+ goto end;
+ v = gl(tmp + 8 + 8 + 8);
+ if ((v >> 16) != 1)
+ goto end;
+ hfd->vhd_blocksize = gl(tmp + 8 + 8 + 8 + 4 + 4);
+ hfd->vhd_bamoffset = gl(tmp + 8 + 8 + 4);
+ hfd->vhd_bamsize = (((hfd->virtsize + hfd->vhd_blocksize - 1) / hfd->vhd_blocksize) * 4 + 511) & ~511;
+ size = hfd->vhd_bamoffset + hfd->vhd_bamsize;
+ hfd->vhd_header = xmalloc(uae_u8, size);
+ if (hdf_read_target(hfd, hfd->vhd_header, 0, size) != size)
+ goto end;
+ hfd->vhd_sectormap = xmalloc(uae_u8, 512);
+ hfd->vhd_sectormapblock = -1;
+ hfd->vhd_bitmapsize = ((hfd->vhd_blocksize / (8 * 512)) + 511) & ~511;
+ }
+ write_log(_T("HDF is VHD %s image, virtual size=%lldK\n"),
+ hfd->hfd_type == HFD_VHD_FIXED ? _T("fixed") : _T("dynamic"),
+ hfd->virtsize / 1024);
+ hdf_init_cache(hfd);
+ return 1;
+nonvhd:
+ return 1;
+end:
+ hdf_close_target(hfd);
+ return 0;
+}
+int hdf_open(struct hardfiledata *hfd)
+{
+ return hdf_open(hfd, NULL);
+}
+
+void hdf_close(struct hardfiledata *hfd)
+{
+ hdf_flush_cache(hfd);
+ hdf_close_target(hfd);
+#ifdef WITH_CHD
+ if (hfd->chd_handle) {
+ chd_file *cf = (chd_file*)hfd->chd_handle;
+ cf->close();
+ hfd->chd_handle = NULL;
+ }
+#endif
hfd->hfd_type = 0;
+ xfree(hfd->vhd_header);
+ hfd->vhd_header = NULL;
+ xfree(hfd->vhd_sectormap);
+ hfd->vhd_sectormap = NULL;
+}
+
+//int hdf_dup(struct hardfiledata *dhfd, const struct hardfiledata *shfd)
+//{
+// return hdf_dup_target(dhfd, shfd);
+//}
+
+//extern int get_guid_target(uae_u8 *out);
+
+static uae_u64 vhd_read(struct hardfiledata *hfd, void *v, uae_u64 offset, uae_u64 len)
+{
+ uae_u64 read;
+ uae_u8 *dataptr = (uae_u8*)v;
+
+ //write_log (_T("%08x %08x\n"), (uae_u32)offset, (uae_u32)len);
+ read = 0;
+ if (offset & 511)
+ return read;
+ if (len & 511)
+ return read;
+ while (len > 0) {
+ uae_u32 bamoffset = (offset / hfd->vhd_blocksize) * 4 + hfd->vhd_bamoffset;
+ uae_u32 sectoroffset = gl(hfd->vhd_header + bamoffset);
+ if (sectoroffset == 0xffffffff) {
+ memset(dataptr, 0, 512);
+ read += 512;
+ }
+ else {
+ int bitmapoffsetbits;
+ int bitmapoffsetbytes;
+ uae_u64 sectormapblock;
+
+ bitmapoffsetbits = (offset / 512) % (hfd->vhd_blocksize / 512);
+ bitmapoffsetbytes = bitmapoffsetbits / 8;
+ sectormapblock = sectoroffset * (uae_u64)512 + (bitmapoffsetbytes & ~511);
+ if (hfd->vhd_sectormapblock != sectormapblock) {
+ // read sector bitmap
+ //write_log (_T("BM %08x\n"), sectormapblock);
+ if (hdf_read_target(hfd, hfd->vhd_sectormap, sectormapblock, 512) != 512) {
+ write_log(_T("vhd_read: bitmap read error\n"));
+ return read;
+ }
+ hfd->vhd_sectormapblock = sectormapblock;
+ }
+ // block allocated in bitmap?
+ if (hfd->vhd_sectormap[bitmapoffsetbytes & 511] & (1 << (7 - (bitmapoffsetbits & 7)))) {
+ // read data block
+ uae_u64 block = sectoroffset * (uae_u64)512 + hfd->vhd_bitmapsize + bitmapoffsetbits * 512;
+ //write_log (_T("DB %08x\n"), block);
+ if (hdf_read_target(hfd, dataptr, block, 512) != 512) {
+ write_log(_T("vhd_read: data read error\n"));
+ return read;
+ }
+ }
+ else {
+ memset(dataptr, 0, 512);
+ }
+ read += 512;
+ }
+ len -= 512;
+ dataptr += 512;
+ offset += 512;
+ }
+ return read;
+}
+
+static int vhd_write_enlarge(struct hardfiledata *hfd, uae_u32 bamoffset)
+{
+ uae_u8 *buf, *p;
+ int len;
+ uae_u32 block;
+ int v;
+
+ len = hfd->vhd_blocksize + hfd->vhd_bitmapsize + 512;
+ buf = xcalloc(uae_u8, len);
+ if (!hdf_resize_target(hfd, hfd->physsize + len - 512)) {
+ write_log(_T("vhd_enlarge: failure\n"));
+ return 0;
+ }
+ // add footer (same as 512 byte header)
+ memcpy(buf + len - 512, hfd->vhd_header, 512);
+ v = hdf_write_target(hfd, buf, hfd->vhd_footerblock, len);
+ xfree(buf);
+ if (v != len) {
+ write_log(_T("vhd_enlarge: footer write error\n"));
+ return 0;
+ }
+ // write new offset to BAM
+ p = hfd->vhd_header + bamoffset;
+ block = hfd->vhd_footerblock / 512;
+ p[0] = block >> 24;
+ p[1] = block >> 16;
+ p[2] = block >> 8;
+ p[3] = block >> 0;
+ // write to disk
+ if (hdf_write_target(hfd, hfd->vhd_header + hfd->vhd_bamoffset, hfd->vhd_bamoffset, hfd->vhd_bamsize) != hfd->vhd_bamsize) {
+ write_log(_T("vhd_enlarge: bam write error\n"));
+ return 0;
+ }
+ hfd->vhd_footerblock += len - 512;
return 1;
}
-int hdf_open (struct hardfiledata *hfd)
+
+static uae_u64 vhd_write(struct hardfiledata *hfd, void *v, uae_u64 offset, uae_u64 len)
{
- return hdf_open (hfd, NULL);
+ uae_u64 written;
+ uae_u8 *dataptr = (uae_u8*)v;
+
+ //write_log (_T("%08x %08x\n"), (uae_u32)offset, (uae_u32)len);
+ written = 0;
+ if (offset & 511)
+ return written;
+ if (len & 511)
+ return written;
+ while (len > 0) {
+ uae_u32 bamoffset = (offset / hfd->vhd_blocksize) * 4 + hfd->vhd_bamoffset;
+ uae_u32 sectoroffset = gl(hfd->vhd_header + bamoffset);
+ if (sectoroffset == 0xffffffff) {
+ if (!vhd_write_enlarge(hfd, bamoffset))
+ return written;
+ continue;
+ }
+ else {
+ int bitmapoffsetbits;
+ int bitmapoffsetbytes;
+
+ bitmapoffsetbits = (offset / 512) % (hfd->vhd_blocksize / 512);
+ bitmapoffsetbytes = bitmapoffsetbits / 8;
+ uae_u64 sectormapblock = sectoroffset * (uae_u64)512 + (bitmapoffsetbytes & ~511);
+ if (hfd->vhd_sectormapblock != sectormapblock) {
+ // read sector bitmap
+ if (hdf_read_target(hfd, hfd->vhd_sectormap, sectormapblock, 512) != 512) {
+ write_log(_T("vhd_write: bitmap read error\n"));
+ return written;
+ }
+ hfd->vhd_sectormapblock = sectormapblock;
+ }
+ // write data
+ if (hdf_write_target(hfd, dataptr, sectoroffset * (uae_u64)512 + hfd->vhd_bitmapsize + bitmapoffsetbits * 512, 512) != 512) {
+ write_log(_T("vhd_write: data write error\n"));
+ return written;
+ }
+ // block already allocated in bitmap?
+ if (!(hfd->vhd_sectormap[bitmapoffsetbytes & 511] & (1 << (7 - (bitmapoffsetbits & 7))))) {
+ // no, we need to mark it allocated and write the modified bitmap back to the disk
+ hfd->vhd_sectormap[bitmapoffsetbytes & 511] |= (1 << (7 - (bitmapoffsetbits & 7)));
+ if (hdf_write_target(hfd, hfd->vhd_sectormap, sectormapblock, 512) != 512) {
+ write_log(_T("vhd_write: bam write error\n"));
+ return written;
+ }
+ }
+ written += 512;
+ }
+ len -= 512;
+ dataptr += 512;
+ offset += 512;
+ }
+ return written;
}
-void hdf_close (struct hardfiledata *hfd)
+
+int vhd_create(const TCHAR *name, uae_u64 size, uae_u32 dostype)
{
- hdf_close_target (hfd);
- hfd->hfd_type = 0;
+ struct hardfiledata hfd;
+ struct zfile *zf;
+ uae_u8 *b;
+ int cyl, cylsec, head, tracksec;
+ uae_u32 crc, blocksize, batsize, batentrysize;
+ int ret, i;
+ time_t tm;
+
+ if (size >= (uae_u64)10 * 1024 * 1024 * 1024)
+ blocksize = 2 * 1024 * 1024;
+ else
+ blocksize = 512 * 1024;
+ batsize = (size + blocksize - 1) / blocksize;
+ batentrysize = batsize;
+ batsize *= 4;
+ batsize += 511;
+ batsize &= ~511;
+ ret = 0;
+ b = NULL;
+ zf = zfile_fopen(name, _T("wb"), 0);
+ if (!zf)
+ goto end;
+ b = xcalloc(uae_u8, 512 + 1024 + batsize + 512);
+ if (zfile_fwrite(b, 512 + 1024 + batsize + 512, 1, zf) != 1)
+ goto end;
+
+ memset(&hfd, 0, sizeof hfd);
+ hfd.virtsize = hfd.physsize = size;
+ hfd.ci.blocksize = 512;
+ strcpy((char*)b, "conectix"); // cookie
+ b[0x0b] = 2; // features
+ b[0x0d] = 1; // version
+ b[0x10 + 6] = 2; // data offset
+ // time stamp
+ tm = time(NULL) - 946684800;
+ b[0x18] = tm >> 24;
+ b[0x19] = tm >> 16;
+ b[0x1a] = tm >> 8;
+ b[0x1b] = tm >> 0;
+ strcpy((char*)b + 0x1c, "vpc "); // creator application
+ b[0x21] = 5; // creator version
+ strcpy((char*)b + 0x24, "Wi2k"); // creator host os
+ // original and current size
+ b[0x28] = b[0x30] = size >> 56;
+ b[0x29] = b[0x31] = size >> 48;
+ b[0x2a] = b[0x32] = size >> 40;
+ b[0x2b] = b[0x33] = size >> 32;
+ b[0x2c] = b[0x34] = size >> 24;
+ b[0x2d] = b[0x35] = size >> 16;
+ b[0x2e] = b[0x36] = size >> 8;
+ b[0x2f] = b[0x37] = size >> 0;
+ getchs2(&hfd, &cyl, &cylsec, &head, &tracksec);
+ // cylinders
+ b[0x38] = cyl >> 8;
+ b[0x39] = cyl;
+ // heads
+ b[0x3a] = head;
+ // sectors per track
+ b[0x3b] = tracksec;
+ // disk type
+ b[0x3c + 3] = HFD_VHD_DYNAMIC;
+ //get_guid_target(b + 0x44);
+ crc = vhd_checksum(b, -1);
+ b[0x40] = crc >> 24;
+ b[0x41] = crc >> 16;
+ b[0x42] = crc >> 8;
+ b[0x43] = crc >> 0;
+
+ // write header
+ zfile_fseek(zf, 0, SEEK_SET);
+ zfile_fwrite(b, 512, 1, zf);
+ // write footer
+ zfile_fseek(zf, 512 + 1024 + batsize, SEEK_SET);
+ zfile_fwrite(b, 512, 1, zf);
+
+ // dynamic disk header
+ memset(b, 0, 1024);
+ // cookie
+ strcpy((char*)b, "cxsparse");
+ // data offset
+ for (i = 0; i < 8; i++)
+ b[0x08 + i] = 0xff;
+ // table offset (bat)
+ b[0x10 + 6] = 0x06;
+ // version
+ b[0x19] = 1;
+ // max table entries
+ b[0x1c] = batentrysize >> 24;
+ b[0x1d] = batentrysize >> 16;
+ b[0x1e] = batentrysize >> 8;
+ b[0x1f] = batentrysize >> 0;
+ b[0x20] = blocksize >> 24;
+ b[0x21] = blocksize >> 16;
+ b[0x22] = blocksize >> 8;
+ b[0x23] = blocksize >> 0;
+ crc = vhd_checksum(b, -1);
+ b[0x24] = crc >> 24;
+ b[0x25] = crc >> 16;
+ b[0x26] = crc >> 8;
+ b[0x27] = crc >> 0;
+
+ // write dynamic header
+ zfile_fseek(zf, 512, SEEK_SET);
+ zfile_fwrite(b, 1024, 1, zf);
+
+ // bat
+ memset(b, 0, batsize);
+ memset(b, 0xff, batentrysize * 4);
+ zfile_fwrite(b, batsize, 1, zf);
+
+ zfile_fclose(zf);
+ zf = NULL;
+
+ if (dostype) {
+ uae_u8 bootblock[512] = { 0 };
+ bootblock[0] = dostype >> 24;
+ bootblock[1] = dostype >> 16;
+ bootblock[2] = dostype >> 8;
+ bootblock[3] = dostype >> 0;
+ if (hdf_open(&hfd, name)) {
+ vhd_write(&hfd, bootblock, 0, 512);
+ hdf_close(&hfd);
+ }
+ }
+
+ ret = 1;
+
+end:
+ xfree(b);
+ zfile_fclose(zf);
+ return ret;
}
-static int hdf_read2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
+static int hdf_read2(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
- return hdf_read_target (hfd, buffer, offset, len);
+ if (hfd->hfd_type == HFD_VHD_DYNAMIC)
+ return vhd_read(hfd, buffer, offset, len);
+ else if (hfd->hfd_type == HFD_VHD_FIXED)
+ return hdf_read_target(hfd, buffer, offset + 512, len);
+#ifdef WITH_CHD
+ else if (hfd->hfd_type == HFD_CHD) {
+ chd_file *cf = (chd_file*)hfd->chd_handle;
+ if (cf->read_bytes(offset, buffer, len) == CHDERR_NONE)
+ return len;
+ return 0;
+ }
+#endif
+ else
+ return hdf_read_target(hfd, buffer, offset, len);
}
-static int hdf_write2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
+static int hdf_write2(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
- return hdf_write_target (hfd, buffer, offset, len);
+ if (hfd->hfd_type == HFD_VHD_DYNAMIC)
+ return vhd_write(hfd, buffer, offset, len);
+ else if (hfd->hfd_type == HFD_VHD_FIXED)
+ return hdf_write_target(hfd, buffer, offset + 512, len);
+#ifdef WITH_CHD
+ else if (hfd->hfd_type == HFD_CHD)
+ return 0;
+#endif
+ else
+ return hdf_write_target(hfd, buffer, offset, len);
}
-static void adide_decode (void *v, int len)
+static void adide_decode(void *v, int len)
{
int i;
uae_u8 *buffer = (uae_u8*)v;
for (i = 0; i < len; i += 2) {
- uae_u8 *b = buffer + i;
+ uae_u8 *b = buffer + i;
uae_u16 w = (b[0] << 8) | (b[1] << 0);
- uae_u16 o = adide_decode_word(w);
+ uae_u16 o = 0;
+
+ if (w & 0x8000)
+ o |= 0x0001;
+ if (w & 0x0001)
+ o |= 0x0002;
+
+ if (w & 0x4000)
+ o |= 0x0004;
+ if (w & 0x0002)
+ o |= 0x0008;
+
+ if (w & 0x2000)
+ o |= 0x0010;
+ if (w & 0x0004)
+ o |= 0x0020;
+
+ if (w & 0x1000)
+ o |= 0x0040;
+ if (w & 0x0008)
+ o |= 0x0080;
+
+ if (w & 0x0800)
+ o |= 0x0100;
+ if (w & 0x0010)
+ o |= 0x0200;
+
+ if (w & 0x0400)
+ o |= 0x0400;
+ if (w & 0x0020)
+ o |= 0x0800;
+
+ if (w & 0x0200)
+ o |= 0x1000;
+ if (w & 0x0040)
+ o |= 0x2000;
+
+ if (w & 0x0100)
+ o |= 0x4000;
+ if (w & 0x0080)
+ o |= 0x8000;
+
b[0] = o >> 8;
b[1] = o >> 0;
}
}
-static void adide_encode (void *v, int len)
+static void adide_encode(void *v, int len)
{
int i;
uae_u8 *buffer = (uae_u8*)v;
for (i = 0; i < len; i += 2) {
- uae_u8 *b = buffer + i;
+ uae_u8 *b = buffer + i;
uae_u16 w = (b[0] << 8) | (b[1] << 0);
- uae_u16 o = adide_encode_word(w);
+ uae_u16 o = 0;
+
+ if (w & 0x0001)
+ o |= 0x8000;
+ if (w & 0x0002)
+ o |= 0x0001;
+
+ if (w & 0x0004)
+ o |= 0x4000;
+ if (w & 0x0008)
+ o |= 0x0002;
+
+ if (w & 0x0010)
+ o |= 0x2000;
+ if (w & 0x0020)
+ o |= 0x0004;
+
+ if (w & 0x0040)
+ o |= 0x1000;
+ if (w & 0x0080)
+ o |= 0x0008;
+
+ if (w & 0x0100)
+ o |= 0x0800;
+ if (w & 0x0200)
+ o |= 0x0010;
+
+ if (w & 0x0400)
+ o |= 0x0400;
+ if (w & 0x0800)
+ o |= 0x0020;
+
+ if (w & 0x1000)
+ o |= 0x0200;
+ if (w & 0x2000)
+ o |= 0x0040;
+
+ if (w & 0x4000)
+ o |= 0x0100;
+ if (w & 0x8000)
+ o |= 0x0080;
+
b[0] = o >> 8;
b[1] = o >> 0;
}
}
-static void hdf_byteswap (void *v, int len)
+static void hdf_byteswap(void *v, int len)
{
int i;
uae_u8 *b = (uae_u8*)v;
@@ -510,1646 +1018,1238 @@ static void hdf_byteswap (void *v, int len)
}
}
-int hdf_read_rdb (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
+int hdf_read_rdb(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
int v;
- v = hdf_read (hfd, buffer, offset, len);
- if (v > 0 && offset < 16 * 512 && !hfd->byteswap && !hfd->adide) {
+ v = hdf_read(hfd, buffer, offset, len);
+ if (v > 0 && offset < 16 * 512 && !hfd->byteswap && !hfd->adide) {
uae_u8 *buf = (uae_u8*)buffer;
bool changed = false;
if (buf[0] == 0x39 && buf[1] == 0x10 && buf[2] == 0xd3 && buf[3] == 0x12) { // AdIDE encoded "CPRM"
hfd->adide = 1;
changed = true;
- write_log (_T("HDF: adide scrambling detected\n"));
- } else if (!memcmp (buf, "DRKS", 4)) {
+ write_log(_T("HDF: adide scrambling detected\n"));
+ }
+ else if (!memcmp(buf, "DRKS", 4)) {
hfd->byteswap = 1;
changed = true;
- write_log (_T("HDF: byteswapped RDB detected\n"));
+ write_log(_T("HDF: byteswapped RDB detected\n"));
}
if (changed)
- v = hdf_read (hfd, buffer, offset, len);
+ v = hdf_read(hfd, buffer, offset, len);
}
return v;
}
-int hdf_read (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
+int hdf_read(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
int v;
- hf_log3 (_T("cmd_read: %p %04x-%08x (%d) %08x (%d)\n"),
+ hf_log3(_T("cmd_read: %p %04x-%08x (%d) %08x (%d)\n"),
buffer, (uae_u32)(offset >> 32), (uae_u32)offset, (uae_u32)(offset / hfd->ci.blocksize), (uae_u32)len, (uae_u32)(len / hfd->ci.blocksize));
if (!hfd->adide) {
- v = hdf_cache_read (hfd, buffer, offset, len);
- } else {
+ v = hdf_cache_read(hfd, buffer, offset, len);
+ }
+ else {
offset += 512;
- v = hdf_cache_read (hfd, buffer, offset, len);
- adide_decode (buffer, len);
+ v = hdf_cache_read(hfd, buffer, offset, len);
+ adide_decode(buffer, len);
}
if (hfd->byteswap)
- hdf_byteswap (buffer, len);
+ hdf_byteswap(buffer, len);
return v;
}
-int hdf_write (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
+int hdf_write(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
{
int v;
- hf_log3 (_T("cmd_write: %p %04x-%08x (%d) %08x (%d)\n"),
+ hf_log3(_T("cmd_write: %p %04x-%08x (%d) %08x (%d)\n"),
buffer, (uae_u32)(offset >> 32), (uae_u32)offset, (uae_u32)(offset / hfd->ci.blocksize), (uae_u32)len, (uae_u32)(len / hfd->ci.blocksize));
if (hfd->byteswap)
- hdf_byteswap (buffer, len);
+ hdf_byteswap(buffer, len);
if (!hfd->adide) {
- v = hdf_cache_write (hfd, buffer, offset, len);
- } else {
+ v = hdf_cache_write(hfd, buffer, offset, len);
+ }
+ else {
offset += 512;
- adide_encode (buffer, len);
- v = hdf_cache_write (hfd, buffer, offset, len);
- adide_decode (buffer, len);
+ adide_encode(buffer, len);
+ v = hdf_cache_write(hfd, buffer, offset, len);
+ adide_decode(buffer, len);
}
if (hfd->byteswap)
- hdf_byteswap (buffer, len);
+ hdf_byteswap(buffer, len);
return v;
}
-static uae_u64 cmd_readx (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len)
+static uae_u64 cmd_readx(struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len)
{
- gui_flicker_led (LED_HD, hfd->unitnum, 1);
- return hdf_read (hfd, dataptr, offset, len);
+ gui_flicker_led(LED_HD, hfd->unitnum, 1);
+ return hdf_read(hfd, dataptr, offset, len);
}
-static uae_u64 cmd_read(TrapContext *ctx, struct hardfiledata *hfd, uaecptr dataptr, uae_u64 offset, uae_u64 len)
+static uae_u64 cmd_read(struct hardfiledata *hfd, uaecptr dataptr, uae_u64 offset, uae_u64 len)
{
- if (!len)
+ addrbank *bank_data = &get_mem_bank(dataptr);
+ if (!len || !bank_data || !bank_data->check(dataptr, len))
return 0;
- if (!ctx) {
- addrbank *bank_data = &get_mem_bank (dataptr);
- if (!bank_data || !bank_data->check (dataptr, len))
- return 0;
- uae_u8 *buffer = bank_data->xlateaddr (dataptr);
- return cmd_readx (hfd, buffer, offset, len);
- }
- int total = 0;
- while (len > 0) {
- uae_u8 buf[RTAREA_TRAP_DATA_EXTRA_SIZE];
- int max = RTAREA_TRAP_DATA_EXTRA_SIZE & ~511;
- int size = len > max ? max : len;
- if (cmd_readx(hfd, buf, offset, size) != size)
- break;
- trap_put_bytes(ctx, buf, dataptr, size);
- offset += size;
- dataptr += size;
- len -= size;
- total += size;
- }
- return total;
+ return cmd_readx(hfd, bank_data->xlateaddr(dataptr), offset, len);
}
-static uae_u64 cmd_writex (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len)
+static uae_u64 cmd_writex(struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len)
{
- gui_flicker_led (LED_HD, hfd->unitnum, 2);
- return hdf_write (hfd, dataptr, offset, len);
+ gui_flicker_led(LED_HD, hfd->unitnum, 2);
+ return hdf_write(hfd, dataptr, offset, len);
}
-static uae_u64 cmd_write(TrapContext *ctx, struct hardfiledata *hfd, uaecptr dataptr, uae_u64 offset, uae_u64 len)
+static uae_u64 cmd_write(struct hardfiledata *hfd, uaecptr dataptr, uae_u64 offset, uae_u64 len)
{
- if (!len)
+ addrbank *bank_data = &get_mem_bank(dataptr);
+ if (!len || !bank_data || !bank_data->check(dataptr, len))
return 0;
- if (!ctx) {
- addrbank *bank_data = &get_mem_bank (dataptr);
- if (!bank_data || !bank_data->check (dataptr, len))
- return 0;
- uae_u8 *buffer = bank_data->xlateaddr (dataptr);
- return cmd_writex (hfd, buffer, offset, len);
- }
- int total = 0;
- while (len > 0) {
- uae_u8 buf[RTAREA_TRAP_DATA_EXTRA_SIZE];
- int max = RTAREA_TRAP_DATA_EXTRA_SIZE & ~511;
- int size = len > max ? max : len;
- trap_get_bytes(ctx, buf, dataptr, size);
- if (cmd_writex(hfd, buf, offset, size) != size)
- break;
- offset += size;
- dataptr += size;
- len -= size;
- total += size;
- }
- return total;
+ return cmd_writex(hfd, bank_data->xlateaddr(dataptr), offset, len);
}
-static int checkbounds (struct hardfiledata *hfd, uae_u64 offset, uae_u64 len, int mode)
+static int checkbounds(struct hardfiledata *hfd, uae_u64 offset, uae_u64 len)
{
- uae_u64 max = hfd->virtsize;
- if (offset >= max || offset + len > max || (offset > 0xffffffff && (uae_s64)offset < 0)) {
- return -1;
- }
+ if (offset >= hfd->virtsize)
+ return 0;
+ if (offset + len > hfd->virtsize)
+ return 0;
+ return 1;
+}
+
+static int nodisk(struct hardfiledata *hfd)
+{
+ if (hfd->drive_empty)
+ return 1;
return 0;
}
-static bool is_writeprotected(struct hardfiledata *hfd)
-{
- return hfd->ci.readonly || hfd->dangerous || currprefs.harddrive_read_only;
-}
-
-static int nodisk (struct hardfiledata *hfd)
-{
- if (hfd->drive_empty)
- return 1;
- return 0;
-}
-
-static void setdrivestring(const TCHAR *s, uae_u8 *d, int start, int length)
-{
- int i = 0;
- uae_char *ss = ua(s);
- while (i < length && ss[i]) {
- d[start + i] = ss[i];
- i++;
- }
- while (i > 0) {
- uae_char c = d[start + i - 1];
- if (c != '_')
- break;
- i--;
- }
- while (i < length) {
- d[start + i] = 32;
- i++;
- }
- xfree (ss);
-}
-
-static const uae_u8 sasi_commands[] =
-{
- 0x00, 0x01, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x12,
- 0xe0, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
- 0xff
-};
-static const uae_u8 sasi_commands2[] =
-{
- 0x12,
- 0xff
-};
-
-static uae_u64 get_scsi_6_offset(struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u8 *cmdbuf, uae_u64 *lba)
-{
- bool chs = hfd->ci.unit_feature_level == HD_LEVEL_SASI_CHS;
- uae_u64 offset;
- if (chs) {
- int cyl, cylsec, head, tracksec;
- if (hdhfd) {
- cyl = hdhfd->cyls;
- head = hdhfd->heads;
- tracksec = hdhfd->secspertrack;
- cylsec = 0;
- } else {
- getchsx(hfd, &cyl, &cylsec, &head, &tracksec);
- }
- int d_head = cmdbuf[1] & 31;
- int d_cyl = cmdbuf[3] | ((cmdbuf[2] >> 6) << 8) | ((cmdbuf[1] >> 7) << 10);
- int d_sec = cmdbuf[2] & 63;
-
- *lba = ((cmdbuf[1] & (0x1f | 0x80 | 0x40)) << 16) | (cmdbuf[2] << 8) || cmdbuf[3];
- if (d_cyl >= cyl || d_head >= head || d_sec >= tracksec)
- return ~0;
- offset = d_cyl * head * tracksec + d_head * tracksec + d_sec;
- } else {
- offset = ((cmdbuf[1] & 31) << 16) | (cmdbuf[2] << 8) | cmdbuf[3];
- }
- return offset;
-}
-
-int scsi_hd_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u8 *cmdbuf, int scsi_cmd_len,
+int scsi_hd_emulate(struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u8 *cmdbuf, int scsi_cmd_len,
uae_u8 *scsi_data, int *data_len, uae_u8 *r, int *reply_len, uae_u8 *s, int *sense_len)
{
- TrapContext *ctx = NULL;
- if (cmdbuf == NULL)
- return 0;
-
uae_u64 len, offset;
int lr = 0, ls = 0;
- int chkerr;
int scsi_len = -1;
int status = 0;
- int lun;
- uae_u8 cmd;
- bool sasi = hfd->ci.unit_feature_level >= HD_LEVEL_SASI && hfd->ci.unit_feature_level <= HD_LEVEL_SASI_ENHANCED;
- bool sasie = hfd->ci.unit_feature_level == HD_LEVEL_SASI_ENHANCED;
- bool omti = hfd->ci.unit_feature_level == HD_LEVEL_SASI_CHS;
- uae_u8 sasi_sense = 0;
- uae_u64 current_lba = ~0;
-
- cmd = cmdbuf[0];
-
- /* REQUEST SENSE */
- if (cmd == 0x03) {
- return 0;
- }
+ int i, lun;
+ char *ss;
*reply_len = *sense_len = 0;
lun = cmdbuf[1] >> 5;
- if (sasi || omti) {
- lun = lun & 1;
- if (lun)
- goto nodisk;
- }
- if (cmd != 0x03 && cmd != 0x12 && lun) {
+ if (cmdbuf[0] != 0x03 && cmdbuf[0] != 0x12 && lun) {
status = 2; /* CHECK CONDITION */
s[0] = 0x70;
s[2] = 5; /* ILLEGAL REQUEST */
s[12] = 0x25; /* INVALID LUN */
ls = 0x12;
- write_log (_T("UAEHF: CMD=%02X LUN=%d ignored\n"), cmdbuf[0], lun);
- goto scsi_done;
+ goto err;
}
-
- if (sasi || omti) {
- int i;
- for (i = 0; sasi_commands[i] != 0xff; i++) {
- if (sasi_commands[i] == cmdbuf[0])
- break;
- }
- if (sasi_commands[i] == 0xff) {
- if (sasie) {
- for (i = 0; sasi_commands2[i] != 0xff; i++) {
- if (sasi_commands2[i] == cmdbuf[0])
- break;
- }
- if (sasi_commands2[i] == 0xff)
- goto errreq;
- } else {
- goto errreq;
- }
- }
- switch (cmdbuf[0])
- {
- case 0x05: /* READ VERIFY */
- if (nodisk(hfd))
- goto nodisk;
- offset = get_scsi_6_offset(hfd, hdhfd, cmdbuf, ¤t_lba);
- if (offset == ~0) {
- chkerr = 1;
- goto checkfail;
- }
- current_lba = offset;
- offset *= hfd->ci.blocksize;
- chkerr = checkbounds(hfd, offset, hfd->ci.blocksize, 1);
- if (chkerr) {
- current_lba = offset;
- goto checkfail;
- }
- scsi_len = 0;
- goto scsi_done;
- case 0x0c: /* INITIALIZE DRIVE CHARACTERISTICS */
- scsi_len = 8;
- write_log(_T("INITIALIZE DRIVE CHARACTERISTICS: "));
- write_log(_T("Heads: %d Cyls: %d Secs: %d\n"),
- (scsi_data[1] >> 4) | ((scsi_data[0] & 0xc0) << 4),
- ((scsi_data[1] & 15) << 8) | (scsi_data[2]),
- scsi_data[5]);
- for (int i = 0; i < 8; i++) {
- write_log(_T("%02X "), scsi_data[i]);
- }
- write_log(_T("\n"));
- goto scsi_done;
- case 0x12: /* INQUIRY */
- {
- int cyl, cylsec, head, tracksec;
- int alen = cmdbuf[4];
- if (nodisk(hfd))
- goto nodisk;
- if (hdhfd) {
- cyl = hdhfd->cyls;
- head = hdhfd->heads;
- tracksec = hdhfd->secspertrack;
- cylsec = 0;
- } else {
- getchsx(hfd, &cyl, &cylsec, &head, &tracksec);
- }
- r[0] = 0;
- r[1] = 11;
- r[9] = cyl >> 8;
- r[10] = cyl;
- r[11] = head;
- scsi_len = lr = alen > 12 ? 12 : alen;
- goto scsi_done;
- }
- break;
- }
- }
-
- switch (cmdbuf[0])
- {
- case 0x12: /* INQUIRY */
- {
- if ((cmdbuf[1] & 1) || cmdbuf[2] != 0)
- goto err;
- int alen = (cmdbuf[3] << 8) | cmdbuf[4];
- if (lun != 0) {
- r[0] = 0x7f;
- } else {
- r[0] = 0;
- }
- r[2] = 2; /* supports SCSI-2 */
- r[3] = 2; /* response data format */
- r[4] = 32; /* additional length */
- r[7] = 0;
- lr = alen < 36 ? alen : 36;
- if (hdhfd) {
- r[2] = hdhfd->ansi_version;
- r[3] = hdhfd->ansi_version >= 2 ? 2 : 0;
- }
- setdrivestring(hfd->vendor_id, r, 8, 8);
- setdrivestring(hfd->product_id, r, 16, 16);
- setdrivestring(hfd->product_rev, r, 32, 4);
- if (lun == 0 && hfd->drive_empty) {
- r[0] |= 0x20; // not present
- r[1] |= 0x80; // removable..
- }
- scsi_len = lr;
- }
- goto scsi_done;
- case 0x1b: /* START/STOP UNIT */
- scsi_len = 0;
- hfd->unit_stopped = (cmdbuf[4] & 1) == 0;
- goto scsi_done;
- }
-
- if (hfd->unit_stopped) {
- status = 2; /* CHECK CONDITION */
- s[0] = 0x70;
- s[2] = 2; /* NOT READY */
- s[12] = 4; /* not ready */
- s[13] = 2; /* need initialise command */
- ls = 0x12;
- goto scsi_done;
- }
-
switch (cmdbuf[0])
{
case 0x00: /* TEST UNIT READY */
- if (nodisk (hfd))
- goto nodisk;
- scsi_len = 0;
- break;
- case 0x01: /* REZERO UNIT */
- if (nodisk (hfd))
- goto nodisk;
- scsi_len = 0;
- break;
- case 0x04: /* FORMAT UNIT */
- // do nothing
- if (nodisk (hfd))
- goto nodisk;
- if (is_writeprotected(hfd))
- goto readprot;
- scsi_len = 0;
- break;
- case 0x05: /* VERIFY TRACK */
- // do nothing
- if (nodisk (hfd))
- goto nodisk;
- scsi_len = 0;
- break;
- case 0x06: /* FORMAT TRACK */
- // do nothing
- if (nodisk (hfd))
- goto nodisk;
- if (is_writeprotected(hfd))
- goto readprot;
- scsi_len = 0;
- break;
- case 0x09: /* READ VERIFY */
if (nodisk(hfd))
goto nodisk;
- offset = get_scsi_6_offset(hfd, hdhfd, cmdbuf, ¤t_lba);
- if (offset == ~0) {
- chkerr = 1;
- goto checkfail;
- }
- current_lba = offset;
- offset *= hfd->ci.blocksize;
- chkerr = checkbounds(hfd, offset, hfd->ci.blocksize, 1);
- if (chkerr) {
- current_lba = offset;
- goto checkfail;
- }
scsi_len = 0;
break;
- case 0x0b: /* SEEK (6) */
- if (nodisk (hfd))
- goto nodisk;
- offset = get_scsi_6_offset(hfd, hdhfd, cmdbuf, ¤t_lba);
- if (offset == ~0) {
- chkerr = 1;
- goto checkfail;
- }
- current_lba = offset;
- offset *= hfd->ci.blocksize;
- chkerr = checkbounds(hfd, offset, hfd->ci.blocksize, 3);
- if (chkerr)
- goto checkfail;
- scsi_len = 0;
+ case 0x03: /* REQUEST SENSE */
+ scsi_len = cmdbuf[4] > MAX_SCSI_SENSE ? MAX_SCSI_SENSE : cmdbuf[4];
+ memcpy(r, hfd->scsi_sense, scsi_len);
+ memset(hfd->scsi_sense, 0, MAX_SCSI_SENSE);
break;
case 0x08: /* READ (6) */
- if (nodisk (hfd))
+ if (nodisk(hfd))
goto nodisk;
- offset = get_scsi_6_offset(hfd, hdhfd, cmdbuf, ¤t_lba);
- if (offset == ~0) {
- chkerr = 1;
- goto checkfail;
- }
- current_lba = offset;
+ offset = ((cmdbuf[1] & 31) << 16) | (cmdbuf[2] << 8) | cmdbuf[3];
offset *= hfd->ci.blocksize;
len = cmdbuf[4];
if (!len)
len = 256;
len *= hfd->ci.blocksize;
- chkerr = checkbounds(hfd, offset, len, 1);
- if (chkerr)
- goto checkfail;
+ if (!checkbounds(hfd, offset, len))
+ goto outofbounds;
scsi_len = (uae_u32)cmd_readx(hfd, scsi_data, offset, len);
break;
- case 0x0f: /* WRITE SECTOR BUFFER */
- scsi_len = hfd->ci.blocksize;
- break;
case 0x0a: /* WRITE (6) */
- if (nodisk (hfd))
+ if (nodisk(hfd))
goto nodisk;
- if (is_writeprotected(hfd))
+ if (hfd->ci.readonly || hfd->dangerous)
goto readprot;
- offset = get_scsi_6_offset(hfd, hdhfd, cmdbuf, ¤t_lba);
- if (offset == ~0) {
- chkerr = 1;
- goto checkfail;
- }
- current_lba = offset;
+ offset = ((cmdbuf[1] & 31) << 16) | (cmdbuf[2] << 8) | cmdbuf[3];
offset *= hfd->ci.blocksize;
len = cmdbuf[4];
if (!len)
len = 256;
len *= hfd->ci.blocksize;
- chkerr = checkbounds(hfd, offset, len, 2);
- if (chkerr)
- goto checkfail;
+ if (!checkbounds(hfd, offset, len))
+ goto outofbounds;
scsi_len = (uae_u32)cmd_writex(hfd, scsi_data, offset, len);
break;
- case 0x5a: // MODE SENSE(10)
- case 0x1a: /* MODE SENSE(6) */
- {
- uae_u8 *p;
- bool pcodeloop = false;
- bool sense10 = cmdbuf[0] == 0x5a;
- int pc = cmdbuf[2] >> 6;
- int pcode = cmdbuf[2] & 0x3f;
- int dbd = cmdbuf[1] & 8;
- int cyl, head, tracksec;
- int totalsize, bdsize, alen;
-
- if (nodisk (hfd))
- goto nodisk;
- if (hdhfd) {
- cyl = hdhfd->cyls;
- head = hdhfd->heads;
- tracksec = hdhfd->secspertrack;
- } else {
- int cylsec;
- getchsx (hfd, &cyl, &cylsec, &head, &tracksec);
- }
- //write_log (_T("MODE SENSE PC=%d CODE=%d DBD=%d\n"), pc, pcode, dbd);
- p = r;
-
- if (sense10) {
- totalsize = 8 - 2;
- alen = (cmdbuf[7] << 8) | cmdbuf[8];
- p[2] = 0;
- p[3] = is_writeprotected(hfd) ? 0x80 : 0x00;
- p[4] = 0;
- p[5] = 0;
- p[6] = 0;
- p[7] = 0;
- p += 8;
- } else {
- totalsize = 4 - 1;
- alen = cmdbuf[4];
- p[1] = 0;
- p[2] = is_writeprotected(hfd) ? 0x80 : 0x00;
- p[3] = 0;
- p += 4;
- }
-
- bdsize = 0;
- if (!dbd) {
- uae_u32 blocks = (uae_u32)(hfd->virtsize / hfd->ci.blocksize);
- wl(p + 0, blocks < 0x01000000 ? blocks : 0);
- wl(p + 4, hfd->ci.blocksize);
- bdsize = 8;
- p += bdsize;
- }
-
- if (pcode == 0x3f) {
- pcode = 1; // page = 0 must be last
- pcodeloop = true;
- }
- for (;;) {
- int psize = 0;
- if (pcode == 0) {
- p[0] = 0;
- p[1] = 0;
- p[2] = 0x20;
- p[3] = 0;
- psize = 4;
- } else if (pcode == 1) {
- // error recovery page
- p[0] = 1;
- p[1] = 0x0a;
- psize = p[1] + 2;
- // return defaults (0)
- } else if (pcode == 3) {
- // format parameters
- p[0] = 3;
- p[1] = 22;
- p[3] = 1;
- p[10] = tracksec >> 8;
- p[11] = tracksec;
- p[12] = hfd->ci.blocksize >> 8;
- p[13] = hfd->ci.blocksize;
- p[15] = 1; // interleave
- p[20] = 0x80;
- psize = p[1] + 2;
- } else if (pcode == 4) {
- // rigid drive geometry
- p[0] = 4;
- wl(p + 1, cyl);
- p[1] = 22;
- p[5] = head;
- wl(p + 13, cyl);
- ww(p + 20, 5400);
- psize = p[1] + 2;
- } else {
- if (!pcodeloop)
- goto err;
- }
- totalsize += psize;
- p += psize;
- if (!pcodeloop)
- break;
- if (pcode == 0)
- break;
- pcode++;
- if (pcode == 0x3f)
- pcode = 0;
- }
-
- if (sense10) {
- totalsize += bdsize;
- r[6] = bdsize >> 8;
- r[7] = bdsize & 0xff;
- r[0] = totalsize >> 8;
- r[1] = totalsize & 0xff;
- } else {
- totalsize += bdsize;
- r[3] = (uae_u8)bdsize;
- r[0] = (uae_u8)totalsize;
- }
-
- scsi_len = lr = totalsize + 1;
- if (scsi_len > alen)
- scsi_len = alen;
- if (lr > alen)
- lr = alen;
- break;
+ case 0x12: /* INQUIRY */
+ {
+ if ((cmdbuf[1] & 1) || cmdbuf[2] != 0)
+ goto err;
+ int alen = (cmdbuf[3] << 8) | cmdbuf[4];
+ if (lun != 0) {
+ r[0] = 0x7f;
}
+ else {
+ r[0] = 0;
+ if (hfd->drive_empty) {
+ r[1] |= 0x80; // removable..
+ r[0] |= 0x20; // not present
+ }
+ }
+ r[2] = 2; /* supports SCSI-2 */
+ r[3] = 2; /* response data format */
+ r[4] = 32; /* additional length */
+ r[7] = 0x20; /* 16 bit bus */
+ scsi_len = lr = alen < 36 ? alen : 36;
+ if (hdhfd) {
+ r[2] = hdhfd->ansi_version;
+ r[3] = hdhfd->ansi_version >= 2 ? 2 : 0;
+ }
+ ss = ua(hfd->vendor_id);
+ i = 0; /* vendor id */
+ while (i < 8 && ss[i]) {
+ r[8 + i] = ss[i];
+ i++;
+ }
+ while (i < 8) {
+ r[8 + i] = 32;
+ i++;
+ }
+ xfree(ss);
+ ss = ua(hfd->product_id);
+ i = 0; /* product id */
+ while (i < 16 && ss[i]) {
+ r[16 + i] = ss[i];
+ i++;
+ }
+ while (i < 16) {
+ r[16 + i] = 32;
+ i++;
+ }
+ xfree(ss);
+ ss = ua(hfd->product_rev);
+ i = 0; /* product revision */
+ while (i < 4 && ss[i]) {
+ r[32 + i] = ss[i];
+ i++;
+ }
+ while (i < 4) {
+ r[32 + i] = 32;
+ i++;
+ }
+ xfree(ss);
+ }
+ break;
+ case 0x1a: /* MODE SENSE(6) */
+ {
+ uae_u8 *p;
+ int pc = cmdbuf[2] >> 6;
+ int pcode = cmdbuf[2] & 0x3f;
+ int dbd = cmdbuf[1] & 8;
+ int alen = cmdbuf[4];
+ int cyl, cylsec, head, tracksec;
+ if (nodisk(hfd))
+ goto nodisk;
+ if (hdhfd) {
+ cyl = hdhfd->cyls;
+ head = hdhfd->heads;
+ tracksec = hdhfd->secspertrack;
+ cylsec = 0;
+ }
+ else {
+ getchsx(hfd, &cyl, &cylsec, &head, &tracksec);
+ }
+ //write_log (_T("MODE SENSE PC=%d CODE=%d DBD=%d\n"), pc, pcode, dbd);
+ p = r;
+ p[0] = 4 - 1;
+ p[1] = 0;
+ p[2] = (hfd->ci.readonly || hfd->dangerous) ? 0x80 : 0x00;
+ p[3] = 0;
+ p += 4;
+ if (!dbd) {
+ if (alen >= r[0] + 1 + 8) {
+ uae_u32 blocks = (uae_u32)(hfd->virtsize / hfd->ci.blocksize);
+ p[-1] = 8;
+ wl(p + 0, blocks);
+ wl(p + 4, hfd->ci.blocksize);
+ p += 8;
+ }
+ }
+ if (pcode == 0) {
+ if (alen >= r[0] + 1 + r[3] + 4) {
+ p[0] = 0;
+ p[1] = 3;
+ p[2] = 0x20;
+ p[3] = 0;
+ r[0] += p[1];
+ }
+ }
+ else if (pcode == 3) {
+ // format parameters
+ if (alen >= r[0] + 1 + r[3] + 24) {
+ p[0] = 3;
+ p[1] = 24;
+ p[3] = 1;
+ p[10] = tracksec >> 8;
+ p[11] = tracksec;
+ p[12] = hfd->ci.blocksize >> 8;
+ p[13] = hfd->ci.blocksize;
+ p[15] = 1; // interleave
+ p[20] = 0x80;
+ r[0] += p[1];
+ }
+ }
+ else if (pcode == 4) {
+ // rigid drive geometry
+ if (alen >= r[0] + 1 + r[3] + 16) {
+ p[0] = 4;
+ wl(p + 1, cyl);
+ p[1] = 24;
+ p[5] = head;
+ wl(p + 13, cyl);
+ ww(p + 20, 5400);
+ r[0] += p[1];
+ }
+ }
+ else {
+ goto err;
+ }
+ r[0] += r[3];
+ scsi_len = lr = r[0] + 1;
+ if (scsi_len > alen)
+ scsi_len = alen;
break;
+ }
+ break;
case 0x1d: /* SEND DIAGNOSTICS */
break;
- case 0x25: /* READ CAPACITY */
- {
- int pmi = cmdbuf[8] & 1;
- uae_u32 lba = (cmdbuf[2] << 24) | (cmdbuf[3] << 16) | (cmdbuf[4] << 8) | cmdbuf[5];
- uae_u32 blocks;
- int cyl, head, tracksec;
- if (nodisk (hfd))
- goto nodisk;
- blocks = (uae_u32)(hfd->virtsize / hfd->ci.blocksize);
- if (hdhfd) {
- cyl = hdhfd->cyls;
- head = hdhfd->heads;
- tracksec = hdhfd->secspertrack;
- } else {
- int cylsec;
- getchsx (hfd, &cyl, &cylsec, &head, &tracksec);
- }
- if (pmi == 0 && lba != 0)
- goto errreq;
- if (pmi) {
- lba += tracksec * head;
- lba /= tracksec * head;
- lba *= tracksec * head;
- if (lba > blocks)
- lba = blocks;
- blocks = lba;
- }
- wl (r, blocks - 1);
- wl (r + 4, hfd->ci.blocksize);
- scsi_len = lr = 8;
+ case 0x25: /* READ_CAPACITY */
+ {
+ int pmi = cmdbuf[8] & 1;
+ uae_u32 lba = (cmdbuf[2] << 24) | (cmdbuf[3] << 16) | (cmdbuf[4] << 8) | cmdbuf[5];
+ uae_u32 blocks;
+ int cyl, cylsec, head, tracksec;
+ if (nodisk(hfd))
+ goto nodisk;
+ blocks = (uae_u32)(hfd->virtsize / hfd->ci.blocksize - 1);
+ if (hdhfd) {
+ cyl = hdhfd->cyls;
+ head = hdhfd->heads;
+ tracksec = hdhfd->secspertrack;
+ cylsec = 0;
}
- break;
- case 0x2b: /* SEEK (10) */
- if (nodisk (hfd))
- goto nodisk;
- offset = rl (cmdbuf + 2);
- current_lba = offset;
- offset *= hfd->ci.blocksize;
- chkerr = checkbounds(hfd, offset, hfd->ci.blocksize, 3);
- if (chkerr)
- goto checkfail;
- scsi_len = 0;
- break;
+ else {
+ getchsx(hfd, &cyl, &cylsec, &head, &tracksec);
+ }
+ if (pmi == 0 && lba != 0)
+ goto errreq;
+ if (pmi) {
+ lba += tracksec * head;
+ lba /= tracksec * head;
+ lba *= tracksec * head;
+ if (lba > blocks)
+ lba = blocks;
+ blocks = lba;
+ }
+ wl(r, blocks);
+ wl(r + 4, hfd->ci.blocksize);
+ scsi_len = lr = 8;
+ }
+ break;
case 0x28: /* READ (10) */
- if (nodisk (hfd))
+ if (nodisk(hfd))
goto nodisk;
- offset = rl (cmdbuf + 2);
- current_lba = offset;
+ offset = rl(cmdbuf + 2);
offset *= hfd->ci.blocksize;
- len = rl (cmdbuf + 7 - 2) & 0xffff;
+ len = rl(cmdbuf + 7 - 2) & 0xffff;
len *= hfd->ci.blocksize;
- chkerr = checkbounds(hfd, offset, len, 1);
- if (chkerr)
- goto checkfail;
- scsi_len = (uae_u32)cmd_readx (hfd, scsi_data, offset, len);
+ if (!checkbounds(hfd, offset, len))
+ goto outofbounds;
+ scsi_len = (uae_u32)cmd_readx(hfd, scsi_data, offset, len);
break;
case 0x2a: /* WRITE (10) */
- if (nodisk (hfd))
+ if (nodisk(hfd))
goto nodisk;
- if (is_writeprotected(hfd))
+ if (hfd->ci.readonly || hfd->dangerous)
goto readprot;
- offset = rl (cmdbuf + 2);
- current_lba = offset;
+ offset = rl(cmdbuf + 2);
offset *= hfd->ci.blocksize;
- len = rl (cmdbuf + 7 - 2) & 0xffff;
+ len = rl(cmdbuf + 7 - 2) & 0xffff;
len *= hfd->ci.blocksize;
- chkerr = checkbounds(hfd, offset, len, 2);
- if (chkerr)
- goto checkfail;
- scsi_len = (uae_u32)cmd_writex (hfd, scsi_data, offset, len);
+ if (!checkbounds(hfd, offset, len))
+ goto outofbounds;
+ scsi_len = (uae_u32)cmd_writex(hfd, scsi_data, offset, len);
break;
case 0x2f: /* VERIFY (10) */
- {
- int bytchk = cmdbuf[1] & 2;
- if (nodisk (hfd))
- goto nodisk;
- if (bytchk) {
- offset = rl (cmdbuf + 2);
- current_lba = offset;
- offset *= hfd->ci.blocksize;
- len = rl (cmdbuf + 7 - 2) & 0xffff;
- len *= hfd->ci.blocksize;
- chkerr = checkbounds (hfd, offset, len, 1);
- if (chkerr)
- goto checkfail;
- uae_u8 *vb = xmalloc(uae_u8, hfd->ci.blocksize);
+ {
+ int bytchk = cmdbuf[1] & 2;
+ if (nodisk(hfd))
+ goto nodisk;
+ if (bytchk) {
+ offset = rl(cmdbuf + 2);
+ offset *= hfd->ci.blocksize;
+ len = rl(cmdbuf + 7 - 2) & 0xffff;
+ len *= hfd->ci.blocksize;
+ uae_u8 *vb = xmalloc(uae_u8, hfd->ci.blocksize);
+ if (checkbounds(hfd, offset, len)) {
while (len > 0) {
- int readlen = cmd_readx (hfd, vb, offset, hfd->ci.blocksize);
- if (readlen != hfd->ci.blocksize || memcmp (vb, scsi_data, hfd->ci.blocksize)) {
- xfree (vb);
+ int readlen = cmd_readx(hfd, vb, offset, hfd->ci.blocksize);
+ if (readlen != hfd->ci.blocksize || memcmp(vb, scsi_data, hfd->ci.blocksize)) {
+ xfree(vb);
goto miscompare;
}
scsi_data += hfd->ci.blocksize;
offset += hfd->ci.blocksize;
len -= hfd->ci.blocksize;
}
- xfree (vb);
}
- scsi_len = 0;
+ xfree(vb);
}
- break;
+ scsi_len = 0;
+ }
+ break;
case 0x35: /* SYNCRONIZE CACHE (10) */
- if (nodisk (hfd))
+ if (nodisk(hfd))
goto nodisk;
scsi_len = 0;
break;
case 0xa8: /* READ (12) */
- if (nodisk (hfd))
+ if (nodisk(hfd))
goto nodisk;
- offset = rl (cmdbuf + 2);
- current_lba = offset;
+ offset = rl(cmdbuf + 2);
offset *= hfd->ci.blocksize;
- len = rl (cmdbuf + 6);
+ len = rl(cmdbuf + 6);
len *= hfd->ci.blocksize;
- chkerr = checkbounds(hfd, offset, len, 1);
- if (chkerr)
- goto checkfail;
- scsi_len = (uae_u32)cmd_readx (hfd, scsi_data, offset, len);
+ if (!checkbounds(hfd, offset, len))
+ goto outofbounds;
+ scsi_len = (uae_u32)cmd_readx(hfd, scsi_data, offset, len);
break;
case 0xaa: /* WRITE (12) */
- if (nodisk (hfd))
+ if (nodisk(hfd))
goto nodisk;
- if (is_writeprotected(hfd))
+ if (hfd->ci.readonly || hfd->dangerous)
goto readprot;
- offset = rl (cmdbuf + 2);
- current_lba = offset;
+ offset = rl(cmdbuf + 2);
offset *= hfd->ci.blocksize;
- len = rl (cmdbuf + 6);
+ len = rl(cmdbuf + 6);
len *= hfd->ci.blocksize;
- chkerr = checkbounds(hfd, offset, len, 2);
- if (chkerr)
- goto checkfail;
- scsi_len = (uae_u32)cmd_writex (hfd, scsi_data, offset, len);
+ if (!checkbounds(hfd, offset, len))
+ goto outofbounds;
+ scsi_len = (uae_u32)cmd_writex(hfd, scsi_data, offset, len);
break;
case 0x37: /* READ DEFECT DATA */
- if (nodisk (hfd))
+ if (nodisk(hfd))
goto nodisk;
- scsi_len = lr = 4;
- r[0] = 0;
- r[1] = cmdbuf[1] & 0x1f;
- r[2] = 0;
- r[3] = 0;
+ status = 2; /* CHECK CONDITION */
+ s[0] = 0x70;
+ s[2] = 0; /* NO SENSE */
+ s[12] = 0x1c; /* DEFECT LIST NOT FOUND */
+ ls = 0x12;
break;
- case 0xe0: /* RAM DIAGNOSTICS */
- case 0xe3: /* DRIVE DIAGNOSTIC */
- case 0xe4: /* CONTROLLER INTERNAL DIAGNOSTICS */
+ case 0x1b: /* START/STOP UNIT */
scsi_len = 0;
break;
-readprot:
+ readprot:
status = 2; /* CHECK CONDITION */
s[0] = 0x70;
s[2] = 7; /* DATA PROTECT */
s[12] = 0x27; /* WRITE PROTECTED */
ls = 0x12;
- sasi_sense = 0x03; // write fault
break;
-nodisk:
+ nodisk:
status = 2; /* CHECK CONDITION */
s[0] = 0x70;
s[2] = 2; /* NOT READY */
s[12] = 0x3A; /* MEDIUM NOT PRESENT */
ls = 0x12;
- sasi_sense = 0x04; // drive not ready
break;
default:
-err:
- write_log (_T("UAEHF: unsupported scsi command 0x%02X LUN=%d\n"), cmdbuf[0], lun);
-errreq:
+ err:
+ write_log(_T("UAEHF: unsupported scsi command 0x%02X LUN=%d\n"), cmdbuf[0], lun);
+ errreq:
+ lr = -1;
status = 2; /* CHECK CONDITION */
s[0] = 0x70;
s[2] = 5; /* ILLEGAL REQUEST */
s[12] = 0x24; /* ILLEGAL FIELD IN CDB */
ls = 0x12;
- sasi_sense = 0x22; // invalid parameter
break;
-checkfail:
+ outofbounds:
+ lr = -1;
status = 2; /* CHECK CONDITION */
- s[0] = 0x70 | ((current_lba != ~0) ? 0x80 : 0x00);
- if (chkerr < 0) {
- s[2] = 5; /* ILLEGAL REQUEST */
- s[12] = 0x21; /* LOGICAL BLOCK OUT OF RANGE */
- sasi_sense = 0x21; // illegal disk address
- } else {
- s[2] = 3; /* MEDIUM ERROR */
- if (chkerr == 1) {
- s[12] = 0x11; /* Unrecovered Read Error */
- sasi_sense = 0x11; // uncorrectable data error
- }
- if (chkerr == 2) {
- s[12] = 0x0c; /* Write Error */
- sasi_sense = 0x03; // write fault
- }
- }
+ s[0] = 0x70;
+ s[2] = 5; /* ILLEGAL REQUEST */
+ s[12] = 0x21; /* LOGICAL BLOCK OUT OF RANGE */
ls = 0x12;
break;
-miscompare:
+ miscompare:
+ lr = -1;
status = 2; /* CHECK CONDITION */
- s[0] = 0x70 | ((current_lba != ~0) ? 0x80 : 0x00);
+ s[0] = 0x70;
s[2] = 5; /* ILLEGAL REQUEST */
s[12] = 0x1d; /* MISCOMPARE DURING VERIFY OPERATION */
ls = 0x12;
- sasi_sense = 0x11; // uncorrectable data error
break;
}
-scsi_done:
-
- if (ls > 7)
- s[7] = ls - 8;
-
*data_len = scsi_len;
*reply_len = lr;
- if (ls > 0) {
- if (omti || sasi) {
- if (sasi_sense != 0) {
- bool islba = (s[0] & 0x80) != 0;
- ls = 4;
- s[0] = sasi_sense | (islba ? 0x80 : 0x00);
- s[1] = (lun & 1) << 5;
- s[2] = 0;
- s[3] = 0;
- if (islba) {
- s[1] |= (current_lba >> 16) & 31;
- s[2] = (current_lba >> 8) & 255;
- s[3] = (current_lba >> 0) & 255;
- }
- }
- } else {
- if (s[0] & 0x80) {
- s[3] = (current_lba >> 24) & 255;
- s[4] = (current_lba >> 16) & 255;
- s[5] = (current_lba >> 8) & 255;
- s[6] = (current_lba >> 0) & 255;
- }
- }
- memset (hfd->scsi_sense, 0, MAX_SCSI_SENSE);
- memcpy (hfd->scsi_sense, s, ls);
- }
*sense_len = ls;
+ if (ls > 0) {
+ memset(hfd->scsi_sense, 0, MAX_SCSI_SENSE);
+ memcpy(hfd->scsi_sense, s, ls);
+ }
return status;
}
-static int handle_scsi (TrapContext *ctx, uae_u8 *iobuf, uaecptr request, struct hardfiledata *hfd, struct scsi_data *sd)
+static int handle_scsi(uaecptr request, struct hardfiledata *hfd)
{
- int ret = 0;
+ uae_u32 acmd = get_long(request + 40);
+ uaecptr scsi_data = get_long(acmd + 0);
+ int scsi_len = get_long(acmd + 4);
+ uaecptr scsi_cmd = get_long(acmd + 12);
+ uae_u16 scsi_cmd_len = get_word(acmd + 16);
+ uae_u8 scsi_flags = get_byte(acmd + 20);
+ uaecptr scsi_sense = get_long(acmd + 22);
+ uae_u16 scsi_sense_len = get_word(acmd + 26);
+ uae_u8 cmd = get_byte(scsi_cmd);
+ uae_u8 cmdbuf[256];
+ int status, ret = 0, reply_len, sense_len;
+ uae_u32 i;
+ uae_u8 reply[256], sense[256];
+ uae_u8 *scsi_data_ptr = NULL;
+ addrbank *bank_data = &get_mem_bank(scsi_data);
- uae_u32 scsicmdaddr = get_long_host(iobuf + 40);
-
- uae_u8 scsicmd[30];
- trap_get_bytes(ctx, scsicmd, scsicmdaddr, sizeof scsicmd);
-
- uaecptr scsi_data = get_long_host(scsicmd + 0);
- int scsi_len = get_long_host(scsicmd + 4);
- uaecptr scsi_cmd = get_long_host(scsicmd + 12);
- uae_u16 scsi_cmd_len = get_word_host(scsicmd + 16);
- uae_u8 scsi_flags = get_byte_host(scsicmd + 20);
- uaecptr scsi_sense = get_long_host(scsicmd + 22);
- uae_u16 scsi_sense_len = get_word_host(scsicmd + 26);
- uae_u8 cmd = trap_get_byte(ctx, scsi_cmd);
-
- scsi_sense_len = (scsi_flags & 4) ? 4 : /* SCSIF_OLDAUTOSENSE */
+ if (bank_data && bank_data->check(scsi_data, scsi_len))
+ scsi_data_ptr = bank_data->xlateaddr(scsi_data);
+ scsi_sense_len = (scsi_flags & 4) ? 4 : /* SCSIF_OLDAUTOSENSE */
(scsi_flags & 2) ? scsi_sense_len : /* SCSIF_AUTOSENSE */
32;
- scsi_log (_T("hdf scsiemu: cmd=%02X,%d flags=%02X sense=%p,%d data=%p,%d\n"),
+ status = 0;
+ memset(reply, 0, sizeof reply);
+ reply_len = 0; sense_len = 0;
+ scsi_log(_T("hdf scsiemu: cmd=%02X,%d flags=%02X sense=%p,%d data=%p,%d\n"),
cmd, scsi_cmd_len, scsi_flags, scsi_sense, scsi_sense_len, scsi_data, scsi_len);
-
- sd->cmd_len = scsi_cmd_len;
- sd->data_len = scsi_len;
-
- trap_get_bytes(ctx, sd->cmd, scsi_cmd, sd->cmd_len);
- for (int i = 0; i < sd->cmd_len; i++) {
- scsi_log (_T("%02X%c"), cmdbuf[i], i < sd->cmd_len - 1 ? '.' : ' ');
+ for (i = 0; i < scsi_cmd_len; i++) {
+ cmdbuf[i] = get_byte(scsi_cmd + i);
+ scsi_log(_T("%02X%c"), get_byte(scsi_cmd + i), i < scsi_cmd_len - 1 ? '.' : ' ');
}
- scsi_log (_T("\n"));
+ scsi_log(_T("\n"));
- scsi_emulate_analyze(sd);
- scsi_start_transfer(sd);
- if (sd->direction > 0) {
- trap_get_bytes(ctx, sd->buffer, scsi_data, sd->data_len);
- scsi_emulate_cmd(sd);
- } else {
- scsi_emulate_cmd(sd);
- if (sd->direction < 0)
- trap_put_bytes(ctx, sd->buffer, scsi_data, sd->data_len);
- }
+ status = scsi_hd_emulate(hfd, NULL, cmdbuf, scsi_cmd_len, scsi_data_ptr, &scsi_len, reply, &reply_len, sense, &sense_len);
- put_word_host(scsicmd + 18, sd->status != 0 ? 0 : sd->cmd_len); /* fake scsi_CmdActual */
- put_byte_host(scsicmd + 21, sd->status); /* scsi_Status */
- if (sd->reply_len > 0) {
- trap_put_bytes(ctx, sd->reply, scsi_data, sd->reply_len);
- scsi_log (_T("RD:"));
- int i = 0;
- while (i < sd->reply_len && i < 24) {
- scsi_log (_T("%02X%c"), reply[i], i < reply_len - 1 ? '.' : ' ');
+ put_word(acmd + 18, status != 0 ? 0 : scsi_cmd_len); /* fake scsi_CmdActual */
+ put_byte(acmd + 21, status); /* scsi_Status */
+ if (reply_len > 0) {
+ scsi_log(_T("RD:"));
+ i = 0;
+ while (i < reply_len) {
+ if (i < 24) {
+ scsi_log(_T("%02X%c"), reply[i], i < reply_len - 1 ? '.' : ' ');
+ }
+ put_byte(scsi_data + i, reply[i]);
i++;
}
- scsi_log (_T("\n"));
+ scsi_log(_T("\n"));
}
+ i = 0;
if (scsi_sense) {
- trap_put_bytes(ctx, sd->sense, scsi_sense, sd->sense_len < scsi_sense_len ? sd->sense_len : scsi_sense_len);
- if (scsi_sense_len > sd->sense_len) {
- trap_set_bytes(ctx, scsi_sense + sd->sense_len, 0, scsi_sense_len - sd->sense_len);
+ while (i < sense_len && i < scsi_sense_len) {
+ put_byte(scsi_sense + i, sense[i]);
+ i++;
}
}
- if (sd->data_len < 0) {
- put_long_host(scsicmd + 8, 0); /* scsi_Actual */
- ret = 20;
- } else {
- put_long_host(scsicmd + 8, sd->data_len); /* scsi_Actual */
+ while (i < scsi_sense_len && scsi_sense) {
+ put_byte(scsi_sense + i, 0);
+ i++;
+ }
+ if (scsi_len < 0) {
+ put_long(acmd + 8, 0); /* scsi_Actual */
+ ret = 20;
+ }
+ else {
+ put_long(acmd + 8, scsi_len); /* scsi_Actual */
}
-
- trap_put_bytes(ctx, scsicmd, scsicmdaddr, sizeof scsicmd);
return ret;
}
-void hardfile_send_disk_change (struct hardfiledata *hfd, bool insert)
+void hardfile_send_disk_change(struct hardfiledata *hfd, bool insert)
{
int newstate = insert ? 0 : 1;
- uae_sem_wait (&change_sem);
+ uae_sem_wait(&change_sem);
hardfpd[hfd->unitnum].changenum++;
- write_log (_T("uaehf.device:%d media status=%d changenum=%d\n"), hfd->unitnum, insert, hardfpd[hfd->unitnum].changenum);
+ write_log(_T("uaehf.device:%d media status=%d changenum=%d\n"), hfd->unitnum, insert, hardfpd[hfd->unitnum].changenum);
hfd->drive_empty = newstate;
int j = 0;
while (j < MAX_ASYNC_REQUESTS) {
if (hardfpd[hfd->unitnum].d_request_type[j] == ASYNC_REQUEST_CHANGEINT) {
- uae_Cause (hardfpd[hfd->unitnum].d_request_data[j]);
+ uae_Cause(hardfpd[hfd->unitnum].d_request_data[j]);
}
j++;
}
if (hardfpd[hfd->unitnum].changeint)
- uae_Cause (hardfpd[hfd->unitnum].changeint);
- uae_sem_post (&change_sem);
+ uae_Cause(hardfpd[hfd->unitnum].changeint);
+ uae_sem_post(&change_sem);
}
-void hardfile_do_disk_change (struct uaedev_config_data *uci, bool insert)
+void hardfile_do_disk_change(struct uaedev_config_data *uci, bool insert)
{
- int fsid = uci->configoffset;
- struct hardfiledata *hfd;
+ int fsid = uci->configoffset;
+ struct hardfiledata *hfd;
if (uci->ci.controller_type == HD_CONTROLLER_TYPE_PCMCIA) {
if (uci->ci.controller_type_unit == 0) {
- gayle_modify_pcmcia_sram_unit (&uci->ci, insert);
- } else {
- gayle_modify_pcmcia_ide_unit (&uci->ci, insert);
+ //gayle_modify_pcmcia_sram_unit(&uci->ci, insert);
+ }
+ else {
+ //gayle_modify_pcmcia_ide_unit(&uci->ci, insert);
}
return;
}
- hfd = get_hardfile_data (fsid);
- if (!hfd)
- return;
- hardfile_send_disk_change (hfd, insert);
+ hfd = get_hardfile_data(fsid);
+ if (!hfd)
+ return;
+ hardfile_send_disk_change(hfd, insert);
}
-static int add_async_request (struct hardfileprivdata *hfpd, uae_u8 *iobuf, uaecptr request, int type, uae_u32 data)
+static int add_async_request(struct hardfileprivdata *hfpd, uaecptr request, int type, uae_u32 data)
{
- int i;
+ int i;
- i = 0;
- while (i < MAX_ASYNC_REQUESTS) {
- if (hfpd->d_request[i] == request) {
- hfpd->d_request_type[i] = type;
- hfpd->d_request_data[i] = data;
- hf_log (_T("old async request %p (%d) added\n"), request, type);
- return 0;
- }
- i++;
- }
- i = 0;
- while (i < MAX_ASYNC_REQUESTS) {
- if (hfpd->d_request[i] == 0) {
- hfpd->d_request[i] = request;
- hfpd->d_request_iobuf[i] = iobuf;
- hfpd->d_request_type[i] = type;
- hfpd->d_request_data[i] = data;
- hf_log (_T("async request %p (%d) added (total=%d)\n"), request, type, i);
- return 0;
- }
- i++;
- }
- hf_log (_T("async request overflow %p!\n"), request);
- return -1;
+ i = 0;
+ while (i < MAX_ASYNC_REQUESTS) {
+ if (hfpd->d_request[i] == request) {
+ hfpd->d_request_type[i] = type;
+ hfpd->d_request_data[i] = data;
+ hf_log(_T("old async request %p (%d) added\n"), request, type);
+ return 0;
+ }
+ i++;
+ }
+ i = 0;
+ while (i < MAX_ASYNC_REQUESTS) {
+ if (hfpd->d_request[i] == 0) {
+ hfpd->d_request[i] = request;
+ hfpd->d_request_type[i] = type;
+ hfpd->d_request_data[i] = data;
+ hf_log(_T("async request %p (%d) added (total=%d)\n"), request, type, i);
+ return 0;
+ }
+ i++;
+ }
+ hf_log(_T("async request overflow %p!\n"), request);
+ return -1;
}
-static int release_async_request (struct hardfileprivdata *hfpd, uaecptr request)
+static int release_async_request(struct hardfileprivdata *hfpd, uaecptr request)
{
- int i = 0;
+ int i = 0;
- while (i < MAX_ASYNC_REQUESTS) {
- if (hfpd->d_request[i] == request) {
- int type = hfpd->d_request_type[i];
- hfpd->d_request[i] = 0;
- xfree(hfpd->d_request_iobuf[i]);
- hfpd->d_request_iobuf[i] = 0;
- hfpd->d_request_data[i] = 0;
- hfpd->d_request_type[i] = 0;
- hf_log (_T("async request %p removed\n"), request);
- return type;
- }
- i++;
- }
- hf_log (_T("tried to remove non-existing request %p\n"), request);
- return -1;
+ while (i < MAX_ASYNC_REQUESTS) {
+ if (hfpd->d_request[i] == request) {
+ int type = hfpd->d_request_type[i];
+ hfpd->d_request[i] = 0;
+ hfpd->d_request_data[i] = 0;
+ hfpd->d_request_type[i] = 0;
+ hf_log(_T("async request %p removed\n"), request);
+ return type;
+ }
+ i++;
+ }
+ hf_log(_T("tried to remove non-existing request %p\n"), request);
+ return -1;
}
-static void abort_async (struct hardfileprivdata *hfpd, uaecptr request, int errcode, int type)
+static void abort_async(struct hardfileprivdata *hfpd, uaecptr request, int errcode, int type)
{
- int i;
- hf_log (_T("aborting async request %p\n"), request);
- i = 0;
- while (i < MAX_ASYNC_REQUESTS) {
- if (hfpd->d_request[i] == request && hfpd->d_request_type[i] == ASYNC_REQUEST_TEMP) {
- /* ASYNC_REQUEST_TEMP = request is processing */
- sleep_millis (1);
- i = 0;
- continue;
- }
- i++;
- }
- i = release_async_request (hfpd, request);
+ int i;
+ hf_log(_T("aborting async request %p\n"), request);
+ i = 0;
+ while (i < MAX_ASYNC_REQUESTS) {
+ if (hfpd->d_request[i] == request && hfpd->d_request_type[i] == ASYNC_REQUEST_TEMP) {
+ /* ASYNC_REQUEST_TEMP = request is processing */
+ sleep_millis(1);
+ i = 0;
+ continue;
+ }
+ i++;
+ }
+ i = release_async_request(hfpd, request);
if (i >= 0) {
- hf_log (_T("asyncronous request=%08X aborted, error=%d\n"), request, errcode);
+ hf_log(_T("asyncronous request=%08X aborted, error=%d\n"), request, errcode);
}
}
-static void *hardfile_thread (void *devs);
-static int start_thread (TrapContext *ctx, int unit)
+static void *hardfile_thread(void *devs);
+static int start_thread(TrapContext *context, int unit)
{
- struct hardfileprivdata *hfpd = &hardfpd[unit];
+ struct hardfileprivdata *hfpd = &hardfpd[unit];
- if (hfpd->thread_running)
- return 1;
- memset (hfpd, 0, sizeof (struct hardfileprivdata));
- hfpd->base = trap_get_areg(ctx, 6);
- init_comm_pipe (&hfpd->requests, 300, 3);
- uae_sem_init (&hfpd->sync_sem, 0, 0);
- uae_start_thread (_T("hardfile"), hardfile_thread, hfpd, &(hfpd->thread_id));
- uae_sem_wait (&hfpd->sync_sem);
- return hfpd->thread_running;
+ if (hfpd->thread_running)
+ return 1;
+ memset(hfpd, 0, sizeof(struct hardfileprivdata));
+ hfpd->base = m68k_areg(regs, 6);
+ init_comm_pipe(&hfpd->requests, 100, 1);
+ uae_sem_init(&hfpd->sync_sem, 0, 0);
+ uae_start_thread(_T("hardfile"), hardfile_thread, hfpd, NULL);
+ uae_sem_wait(&hfpd->sync_sem);
+ return hfpd->thread_running;
}
-static int mangleunit (int unit)
+static int mangleunit(int unit)
{
- if (unit <= 99)
- return unit;
- if (unit == 100)
- return 8;
- if (unit == 110)
- return 9;
- return -1;
+ if (unit <= 99)
+ return unit;
+ if (unit == 100)
+ return 8;
+ if (unit == 110)
+ return 9;
+ return -1;
}
-static uae_u32 REGPARAM2 hardfile_open (TrapContext *ctx)
+static uae_u32 REGPARAM2 hardfile_open(TrapContext *context)
{
- uaecptr ioreq = trap_get_areg (ctx, 1); /* IOReq */
- int unit = mangleunit (trap_get_dreg(ctx, 0));
- int err = IOERR_OPENFAIL;
+ uaecptr ioreq = m68k_areg(regs, 1); /* IOReq */
+ int unit = mangleunit(m68k_dreg(regs, 0));
+ struct hardfileprivdata *hfpd = &hardfpd[unit];
+ int err = IOERR_OPENFAIL;
/* boot device port size == 0!? KS 1.x size = 12???
- * Ignore message size, too many programs do not set it correct
- * int size = get_word (ioreq + 0x12);
- */
- /* Check unit number */
- if (unit >= 0 && unit < MAX_FILESYSTEM_UNITS) {
- struct hardfileprivdata *hfpd = &hardfpd[unit];
- struct hardfiledata *hfd = get_hardfile_data (unit);
- if (hfd && (hfd->handle_valid || hfd->drive_empty) && start_thread (ctx, unit)) {
- trap_put_word(ctx, hfpd->base + 32, trap_get_word(ctx, hfpd->base + 32) + 1);
- trap_put_long(ctx, ioreq + 24, unit); /* io_Unit */
- trap_put_byte(ctx, ioreq + 31, 0); /* io_Error */
- trap_put_byte(ctx, ioreq + 8, 7); /* ln_type = NT_REPLYMSG */
- if (!hfpd->sd)
- hfpd->sd = scsi_alloc_generic(hfd, UAEDEV_HDF);
- hf_log (_T("hardfile_open, unit %d (%d), OK\n"), unit, trap_get_dreg (ctx, 0));
- return 0;
- }
- }
- if (unit < 1000 || is_hardfile(unit) == FILESYS_VIRTUAL)
- err = 50; /* HFERR_NoBoard */
- hf_log (_T("hardfile_open, unit %d (%d), ERR=%d\n"), unit, trap_get_dreg(ctx, 0), err);
- trap_put_long(ctx, ioreq + 20, (uae_u32)err);
- trap_put_byte(ctx, ioreq + 31, (uae_u8)err);
- return (uae_u32)err;
-}
-
-static uae_u32 REGPARAM2 hardfile_close (TrapContext *ctx)
-{
- uaecptr request = trap_get_areg (ctx, 1); /* IOReq */
- int unit = mangleunit (trap_get_long(ctx, request + 24));
- if (unit < 0 || unit >= MAX_FILESYSTEM_UNITS) {
- return 0;
+ * Ignore message size, too many programs do not set it correct
+ * int size = get_word (ioreq + 0x12);
+ */
+ /* Check unit number */
+ if (unit >= 0) {
+ struct hardfiledata *hfd = get_hardfile_data(unit);
+ if (hfd && (hfd->handle_valid || hfd->drive_empty) && start_thread(context, unit)) {
+ put_word(hfpd->base + 32, get_word(hfpd->base + 32) + 1);
+ put_long(ioreq + 24, unit); /* io_Unit */
+ put_byte(ioreq + 31, 0); /* io_Error */
+ put_byte(ioreq + 8, 7); /* ln_type = NT_REPLYMSG */
+ hf_log(_T("hardfile_open, unit %d (%d), OK\n"), unit, m68k_dreg(regs, 0));
+ return 0;
+ }
}
- struct hardfileprivdata *hfpd = &hardfpd[unit];
-
- if (!hfpd)
- return 0;
- trap_put_word(ctx, hfpd->base + 32, trap_get_word(ctx, hfpd->base + 32) - 1);
- if (trap_get_word(ctx, hfpd->base + 32) == 0) {
- scsi_free(hfpd->sd);
- hfpd->sd = NULL;
- write_comm_pipe_pvoid(&hfpd->requests, NULL, 0);
- write_comm_pipe_pvoid(&hfpd->requests, NULL, 0);
- write_comm_pipe_u32 (&hfpd->requests, 0, 1);
- }
- return 0;
+ if (unit < 1000 || is_hardfile(unit) == FILESYS_VIRTUAL || is_hardfile(unit) == FILESYS_CD)
+ err = 50; /* HFERR_NoBoard */
+ hf_log(_T("hardfile_open, unit %d (%d), ERR=%d\n"), unit, m68k_dreg(regs, 0), err);
+ put_long(ioreq + 20, (uae_u32)err);
+ put_byte(ioreq + 31, (uae_u8)err);
+ return (uae_u32)err;
}
-static uae_u32 REGPARAM2 hardfile_expunge (TrapContext *context)
+static uae_u32 REGPARAM2 hardfile_close(TrapContext *context)
{
- return 0; /* Simply ignore this one... */
+ uaecptr request = m68k_areg(regs, 1); /* IOReq */
+ int unit = mangleunit(get_long(request + 24));
+ struct hardfileprivdata *hfpd = &hardfpd[unit];
+
+ if (!hfpd)
+ return 0;
+ put_word(hfpd->base + 32, get_word(hfpd->base + 32) - 1);
+ if (get_word(hfpd->base + 32) == 0)
+ write_comm_pipe_u32(&hfpd->requests, 0, 1);
+ return 0;
}
-static void outofbounds (int cmd, uae_u64 offset, uae_u64 len, uae_u64 max)
+static uae_u32 REGPARAM2 hardfile_expunge(TrapContext *context)
{
- write_log (_T("UAEHF: cmd %d: out of bounds, %08X-%08X + %08X-%08X > %08X-%08X\n"), cmd,
- (uae_u32)(offset >> 32),(uae_u32)offset,(uae_u32)(len >> 32),(uae_u32)len,
- (uae_u32)(max >> 32),(uae_u32)max);
-}
-static void unaligned (int cmd, uae_u64 offset, uae_u64 len, int blocksize)
-{
- write_log (_T("UAEHF: cmd %d: unaligned access, %08X-%08X, %08X-%08X, %08X\n"), cmd,
- (uae_u32)(offset >> 32),(uae_u32)offset,(uae_u32)(len >> 32),(uae_u32)len,
- blocksize);
+ return 0; /* Simply ignore this one... */
}
-static uae_u32 hardfile_do_io (TrapContext *ctx, struct hardfiledata *hfd, struct hardfileprivdata *hfpd, uae_u8 *iobuf, uaecptr request)
+static void outofbounds(int cmd, uae_u64 offset, uae_u64 len, uae_u64 max)
{
- uae_u32 dataptr, offset, actual = 0, cmd;
- uae_u64 offset64;
- int unit;
- uae_u32 error = 0, len;
- int async = 0;
+ write_log(_T("UAEHF: cmd %d: out of bounds, %08X-%08X + %08X-%08X > %08X-%08X\n"), cmd,
+ (uae_u32)(offset >> 32), (uae_u32)offset, (uae_u32)(len >> 32), (uae_u32)len,
+ (uae_u32)(max >> 32), (uae_u32)max);
+}
+static void unaligned(int cmd, uae_u64 offset, uae_u64 len, int blocksize)
+{
+ write_log(_T("UAEHF: cmd %d: unaligned access, %08X-%08X, %08X-%08X, %08X\n"), cmd,
+ (uae_u32)(offset >> 32), (uae_u32)offset, (uae_u32)(len >> 32), (uae_u32)len,
+ blocksize);
+}
+
+static uae_u32 hardfile_do_io(struct hardfiledata *hfd, struct hardfileprivdata *hfpd, uaecptr request)
+{
+ uae_u32 dataptr, offset, actual = 0, cmd;
+ uae_u64 offset64;
+ int unit = get_long(request + 24);
+ uae_u32 error = 0, len;
+ int async = 0;
int bmask = hfd->ci.blocksize - 1;
- unit = get_long_host(iobuf + 24);
- cmd = get_word_host(iobuf + 28); /* io_Command */
- dataptr = get_long_host(iobuf + 40);
- switch (cmd)
- {
+ cmd = get_word(request + 28); /* io_Command */
+ dataptr = get_long(request + 40);
+ switch (cmd)
+ {
case CMD_READ:
- if (nodisk (hfd))
- goto no_disk;
- offset = get_long_host(iobuf + 44);
- len = get_long_host(iobuf + 36); /* io_Length */
+ if (nodisk(hfd))
+ goto no_disk;
+ offset = get_long(request + 44);
+ len = get_long(request + 36); /* io_Length */
if (offset & bmask) {
- unaligned (cmd, offset, len, hfd->ci.blocksize);
- goto bad_command;
- }
- if (len & bmask) {
- unaligned (cmd, offset, len, hfd->ci.blocksize);
- goto bad_len;
- }
- if (len + offset > hfd->virtsize) {
- outofbounds (cmd, offset, len, hfd->virtsize);
- goto bad_len;
- }
- actual = (uae_u32)cmd_read(ctx, hfd, dataptr, offset, len);
- break;
+ unaligned(cmd, offset, len, hfd->ci.blocksize);
+ goto bad_command;
+ }
+ if (len & bmask) {
+ unaligned(cmd, offset, len, hfd->ci.blocksize);
+ goto bad_len;
+ }
+ if (len + offset > hfd->virtsize) {
+ outofbounds(cmd, offset, len, hfd->virtsize);
+ goto bad_len;
+ }
+ actual = (uae_u32)cmd_read(hfd, dataptr, offset, len);
+ break;
case TD_READ64:
case NSCMD_TD_READ64:
- if (nodisk (hfd))
- goto no_disk;
- offset64 = get_long_host(iobuf + 44) | ((uae_u64)get_long_host(iobuf + 32) << 32);
- len = get_long_host(iobuf + 36); /* io_Length */
+ if (nodisk(hfd))
+ goto no_disk;
+ offset64 = get_long(request + 44) | ((uae_u64)get_long(request + 32) << 32);
+ len = get_long(request + 36); /* io_Length */
if (offset64 & bmask) {
- unaligned (cmd, offset64, len, hfd->ci.blocksize);
- goto bad_command;
- }
- if (len & bmask) {
- unaligned (cmd, offset64, len, hfd->ci.blocksize);
- goto bad_len;
- }
- if (len + offset64 > hfd->virtsize || (uae_s64)offset64 < 0) {
- outofbounds (cmd, offset64, len, hfd->virtsize);
- goto bad_len;
- }
- actual = (uae_u32)cmd_read(ctx, hfd, dataptr, offset64, len);
- break;
+ unaligned(cmd, offset64, len, hfd->ci.blocksize);
+ goto bad_command;
+ }
+ if (len & bmask) {
+ unaligned(cmd, offset64, len, hfd->ci.blocksize);
+ goto bad_len;
+ }
+ if (len + offset64 > hfd->virtsize) {
+ outofbounds(cmd, offset64, len, hfd->virtsize);
+ goto bad_len;
+ }
+ actual = (uae_u32)cmd_read(hfd, dataptr, offset64, len);
+ break;
case CMD_WRITE:
case CMD_FORMAT: /* Format */
- if (nodisk (hfd))
- goto no_disk;
- if (is_writeprotected(hfd)) {
- error = 28; /* write protect */
- } else {
- offset = get_long_host(iobuf + 44);
- len = get_long_host(iobuf + 36); /* io_Length */
+ if (nodisk(hfd))
+ goto no_disk;
+ if (hfd->ci.readonly || hfd->dangerous) {
+ error = 28; /* write protect */
+ }
+ else {
+ offset = get_long(request + 44);
+ len = get_long(request + 36); /* io_Length */
if (offset & bmask) {
- unaligned (cmd, offset, len, hfd->ci.blocksize);
- goto bad_command;
- }
- if (len & bmask) {
- unaligned (cmd, offset, len, hfd->ci.blocksize);
- goto bad_len;
- }
- if (len + offset > hfd->virtsize) {
- outofbounds (cmd, offset, len, hfd->virtsize);
- goto bad_len;
- }
- actual = (uae_u32)cmd_write(ctx, hfd, dataptr, offset, len);
- }
- break;
+ unaligned(cmd, offset, len, hfd->ci.blocksize);
+ goto bad_command;
+ }
+ if (len & bmask) {
+ unaligned(cmd, offset, len, hfd->ci.blocksize);
+ goto bad_len;
+ }
+ if (len + offset > hfd->virtsize) {
+ outofbounds(cmd, offset, len, hfd->virtsize);
+ goto bad_len;
+ }
+ actual = (uae_u32)cmd_write(hfd, dataptr, offset, len);
+ }
+ break;
case TD_WRITE64:
case TD_FORMAT64:
case NSCMD_TD_WRITE64:
case NSCMD_TD_FORMAT64:
- if (nodisk (hfd))
- goto no_disk;
- if (is_writeprotected(hfd)) {
- error = 28; /* write protect */
- } else {
- offset64 = get_long_host(iobuf + 44) | ((uae_u64)get_long_host(iobuf + 32) << 32);
- len = get_long_host(iobuf + 36); /* io_Length */
- if (offset64 & bmask) {
- unaligned (cmd, offset64, len, hfd->ci.blocksize);
- goto bad_command;
- }
- if (len & bmask) {
- unaligned (cmd, offset64, len, hfd->ci.blocksize);
- goto bad_len;
- }
- if (len + offset64 > hfd->virtsize || (uae_s64)offset64 < 0) {
- outofbounds (cmd, offset64, len, hfd->virtsize);
- goto bad_len;
- }
- actual = (uae_u32)cmd_write(ctx, hfd, dataptr, offset64, len);
- }
- break;
-
- case NSCMD_DEVICEQUERY:
- trap_put_long(ctx, dataptr + 0, 0);
- trap_put_long(ctx, dataptr + 4, 16); /* size */
- trap_put_word(ctx, dataptr + 8, NSDEVTYPE_TRACKDISK);
- trap_put_word(ctx, dataptr + 10, 0);
- trap_put_long(ctx, dataptr + 12, nscmd_cmd);
- actual = 16;
- break;
-
- case CMD_GETDRIVETYPE:
- actual = DRIVE_NEWSTYLE;
- break;
-
- case CMD_GETNUMTRACKS:
- {
- int cyl, cylsec, head, tracksec;
- getchsx (hfd, &cyl, &cylsec, &head, &tracksec);
- actual = cyl * head;
- break;
+ if (nodisk(hfd))
+ goto no_disk;
+ if (hfd->ci.readonly || hfd->dangerous) {
+ error = 28; /* write protect */
}
-
- case CMD_GETGEOMETRY:
- {
- int cyl, cylsec, head, tracksec;
- uae_u64 size;
- getchsx (hfd, &cyl, &cylsec, &head, &tracksec);
- trap_put_long(ctx, dataptr + 0, hfd->ci.blocksize);
- size = hfd->virtsize / hfd->ci.blocksize;
- if (size > 0x00ffffffff)
- size = 0xffffffff;
- trap_put_long(ctx, dataptr + 4, (uae_u32)size);
- trap_put_long(ctx, dataptr + 8, cyl);
- trap_put_long(ctx, dataptr + 12, cylsec);
- trap_put_long(ctx, dataptr + 16, head);
- trap_put_long(ctx, dataptr + 20, tracksec);
- trap_put_long(ctx, dataptr + 24, 0); /* bufmemtype */
- trap_put_byte(ctx, dataptr + 28, 0); /* type = DG_DIRECT_ACCESS */
- trap_put_byte(ctx, dataptr + 29, 0); /* flags */
+ else {
+ offset64 = get_long(request + 44) | ((uae_u64)get_long(request + 32) << 32);
+ len = get_long(request + 36); /* io_Length */
+ if (offset64 & bmask) {
+ unaligned(cmd, offset64, len, hfd->ci.blocksize);
+ goto bad_command;
+ }
+ if (len & bmask) {
+ unaligned(cmd, offset64, len, hfd->ci.blocksize);
+ goto bad_len;
+ }
+ if (len + offset64 > hfd->virtsize) {
+ outofbounds(cmd, offset64, len, hfd->virtsize);
+ goto bad_len;
+ }
+ actual = (uae_u32)cmd_write(hfd, dataptr, offset64, len);
}
break;
+ case NSCMD_DEVICEQUERY:
+ put_long(dataptr + 0, 0);
+ put_long(dataptr + 4, 16); /* size */
+ put_word(dataptr + 8, NSDEVTYPE_TRACKDISK);
+ put_word(dataptr + 10, 0);
+ put_long(dataptr + 12, nscmd_cmd);
+ actual = 16;
+ break;
+
+ case CMD_GETDRIVETYPE:
+ actual = DRIVE_NEWSTYLE;
+ break;
+
+ case CMD_GETNUMTRACKS:
+ {
+ int cyl, cylsec, head, tracksec;
+ getchsx(hfd, &cyl, &cylsec, &head, &tracksec);
+ actual = cyl * head;
+ break;
+ }
+
+ case CMD_GETGEOMETRY:
+ {
+ int cyl, cylsec, head, tracksec;
+ uae_u64 size;
+ getchsx(hfd, &cyl, &cylsec, &head, &tracksec);
+ put_long(dataptr + 0, hfd->ci.blocksize);
+ size = hfd->virtsize / hfd->ci.blocksize;
+ if (size > 0x00ffffffff)
+ size = 0xffffffff;
+ put_long(dataptr + 4, (uae_u32)size);
+ put_long(dataptr + 8, cyl);
+ put_long(dataptr + 12, cylsec);
+ put_long(dataptr + 16, head);
+ put_long(dataptr + 20, tracksec);
+ put_long(dataptr + 24, 0); /* bufmemtype */
+ put_byte(dataptr + 28, 0); /* type = DG_DIRECT_ACCESS */
+ put_byte(dataptr + 29, 0); /* flags */
+ }
+ break;
+
case CMD_PROTSTATUS:
- if (is_writeprotected(hfd))
- actual = -1;
- else
- actual = 0;
- break;
+ if (hfd->ci.readonly || hfd->dangerous)
+ actual = -1;
+ else
+ actual = 0;
+ break;
case CMD_CHANGESTATE:
- actual = hfd->drive_empty ? 1 :0;
- break;
+ actual = hfd->drive_empty ? 1 : 0;
+ break;
- /* Some commands that just do nothing and return zero */
+ /* Some commands that just do nothing and return zero */
case CMD_UPDATE:
case CMD_CLEAR:
case CMD_MOTOR:
case CMD_SEEK:
case TD_SEEK64:
case NSCMD_TD_SEEK64:
- break;
+ break;
case CMD_REMOVE:
- hfpd->changeint = get_long (request + 40);
- break;
+ hfpd->changeint = get_long(request + 40);
+ break;
case CMD_CHANGENUM:
- actual = hfpd->changenum;
- break;
+ actual = hfpd->changenum;
+ break;
case CMD_ADDCHANGEINT:
- error = add_async_request (hfpd, iobuf, request, ASYNC_REQUEST_CHANGEINT, get_long_host(iobuf + 40));
- if (!error)
- async = 1;
- break;
+ error = add_async_request(hfpd, request, ASYNC_REQUEST_CHANGEINT, get_long(request + 40));
+ if (!error)
+ async = 1;
+ break;
case CMD_REMCHANGEINT:
- release_async_request (hfpd, request);
- break;
-
+ release_async_request(hfpd, request);
+ break;
+
case HD_SCSICMD: /* SCSI */
if (!hfd->ci.sectors && !hfd->ci.surfaces && !hfd->ci.reserved) {
- error = handle_scsi(ctx, iobuf, request, hfd, hfpd->sd);
- } else { /* we don't want users trashing their "partition" hardfiles with hdtoolbox */
- error = IOERR_NOCMD;
- write_log (_T("UAEHF: HD_SCSICMD tried on regular HDF, unit %d\n"), unit);
+ error = handle_scsi(request, hfd);
}
- break;
+ else { /* we don't want users trashing their "partition" hardfiles with hdtoolbox */
+ error = IOERR_NOCMD;
+ write_log(_T("UAEHF: HD_SCSICMD tried on regular HDF, unit %d\n"), unit);
+ }
+ break;
case CD_EJECT:
if (hfd->ci.sectors && hfd->ci.surfaces) {
- int len = get_long_host(iobuf + 36);
+ int len = get_long(request + 36);
if (len) {
if (hfd->drive_empty) {
- hardfile_media_change (hfd, NULL, true, false);
- } else {
- hardfile_media_change (hfd, NULL, false, false);
+ hardfile_media_change(hfd, NULL, true, false);
}
- } else {
- if (hfd->drive_empty) {
- hardfile_media_change (hfd, NULL, true, false);
+ else {
+ hardfile_media_change(hfd, NULL, false, false);
}
}
- } else {
- error = IOERR_NOCMD;
+ else {
+ if (hfd->drive_empty) {
+ hardfile_media_change(hfd, NULL, true, false);
+ }
+ }
+ }
+ else {
+ error = IOERR_NOCMD;
}
break;
-bad_command:
+ bad_command:
error = IOERR_BADADDRESS;
break;
-bad_len:
+ bad_len:
error = IOERR_BADLENGTH;
break;
-no_disk:
+ no_disk:
error = 29; /* no disk */
break;
default:
- /* Command not understood. */
- error = IOERR_NOCMD;
- break;
- }
- put_long_host(iobuf + 32, actual);
- put_byte_host(iobuf + 31, error);
+ /* Command not understood. */
+ error = IOERR_NOCMD;
+ break;
+ }
+ put_long(request + 32, actual);
+ put_byte(request + 31, error);
- hf_log2 (_T("hf: unit=%d, request=%p, cmd=%d offset=%u len=%d, actual=%d error%=%d\n"), unit, request,
- get_word_host(iobuf + 28), get_long_host(iobuf + 44), get_long_host(iobuf + 36), actual, error);
-
- return async;
+ hf_log2(_T("hf: unit=%d, request=%p, cmd=%d offset=%u len=%d, actual=%d error%=%d\n"), unit, request,
+ get_word(request + 28), get_long(request + 44), get_long(request + 36), actual, error);
+
+ return async;
}
-static uae_u32 REGPARAM2 hardfile_abortio (TrapContext *ctx)
+static uae_u32 REGPARAM2 hardfile_abortio(TrapContext *context)
{
- uae_u32 request = trap_get_areg (ctx, 1);
- int unit = mangleunit (trap_get_long(ctx, request + 24));
-struct hardfiledata *hfd = get_hardfile_data (unit);
- struct hardfileprivdata *hfpd = &hardfpd[unit];
+ uae_u32 request = m68k_areg(regs, 1);
+ int unit = mangleunit(get_long(request + 24));
+ struct hardfiledata *hfd = get_hardfile_data(unit);
+ struct hardfileprivdata *hfpd = &hardfpd[unit];
- hf_log2 (_T("uaehf.device abortio "));
- start_thread(ctx, unit);
- if (!hfd || !hfpd || !hfpd->thread_running) {
- trap_put_byte(ctx, request + 31, 32);
- hf_log2 (_T("error\n"));
- return trap_get_byte(ctx, request + 31);
- }
- trap_put_byte(ctx, request + 31, -2);
- hf_log2 (_T("unit=%d, request=%08X\n"), unit, request);
- abort_async (hfpd, request, -2, 0);
- return 0;
+ hf_log2(_T("uaehf.device abortio "));
+ start_thread(context, unit);
+ if (!hfd || !hfpd || !hfpd->thread_running) {
+ put_byte(request + 31, 32);
+ hf_log2(_T("error\n"));
+ return get_byte(request + 31);
+ }
+ put_byte(request + 31, -2);
+ hf_log2(_T("unit=%d, request=%08X\n"), unit, request);
+ abort_async(hfpd, request, -2, 0);
+ return 0;
}
-static int hardfile_can_quick (uae_u32 command)
+static int hardfile_can_quick(uae_u32 command)
{
- switch (command)
- {
- case CMD_REMCHANGEINT:
- return -1;
- case CMD_RESET:
- case CMD_STOP:
- case CMD_START:
- case CMD_CHANGESTATE:
- case CMD_PROTSTATUS:
- case CMD_MOTOR:
- case CMD_GETDRIVETYPE:
- case CMD_GETGEOMETRY:
- case CMD_GETNUMTRACKS:
- case NSCMD_DEVICEQUERY:
- return 1;
- }
- return 0;
+ switch (command)
+ {
+ case CMD_REMCHANGEINT:
+ return -1;
+ case CMD_RESET:
+ case CMD_STOP:
+ case CMD_START:
+ case CMD_CHANGESTATE:
+ case CMD_PROTSTATUS:
+ case CMD_MOTOR:
+ case CMD_GETDRIVETYPE:
+ case CMD_GETGEOMETRY:
+ case CMD_GETNUMTRACKS:
+ case NSCMD_DEVICEQUERY:
+ return 1;
+ }
+ return 0;
}
-static int hardfile_canquick (TrapContext *ctx, struct hardfiledata *hfd, uae_u8 *iobuf)
+static int hardfile_canquick(struct hardfiledata *hfd, uaecptr request)
{
- uae_u32 command = get_word_host(iobuf + 28);
- return hardfile_can_quick (command);
+ uae_u32 command = get_word(request + 28);
+ return hardfile_can_quick(command);
}
-static uae_u32 REGPARAM2 hardfile_beginio (TrapContext *ctx)
+static uae_u32 REGPARAM2 hardfile_beginio(TrapContext *context)
{
+ uae_u32 request = m68k_areg(regs, 1);
+ uae_u8 flags = get_byte(request + 30);
+ int cmd = get_word(request + 28);
+ int unit = mangleunit(get_long(request + 24));
+ struct hardfiledata *hfd = get_hardfile_data(unit);
+ struct hardfileprivdata *hfpd = &hardfpd[unit];
int canquick;
- uae_u32 request = trap_get_areg(ctx, 1);
- uae_u8 *iobuf = xmalloc(uae_u8, 48);
-
- trap_get_bytes(ctx, iobuf, request, 48);
-
- uae_u8 flags = get_byte_host(iobuf + 30);
- int cmd = get_word_host(iobuf + 28);
- int unit = mangleunit(get_long_host(iobuf + 24));
-
- struct hardfiledata *hfd = get_hardfile_data (unit);
- struct hardfileprivdata *hfpd = &hardfpd[unit];
-
- put_byte_host(iobuf + 8, NT_MESSAGE);
- start_thread(ctx, unit);
- if (!hfd || !hfpd || !hfpd->thread_running) {
- put_byte_host(iobuf + 31, 32);
- uae_u8 v = get_byte_host(iobuf + 31);
- trap_put_bytes(ctx, iobuf + 8, request + 8, 48 - 8);
- xfree(iobuf);
- return v;
- }
- put_byte_host(iobuf + 31, 0);
- canquick = hardfile_canquick(ctx, hfd, iobuf);
+ put_byte(request + 8, NT_MESSAGE);
+ start_thread(context, unit);
+ if (!hfd || !hfpd || !hfpd->thread_running) {
+ put_byte(request + 31, 32);
+ return get_byte(request + 31);
+ }
+ put_byte(request + 31, 0);
+ canquick = hardfile_canquick(hfd, request);
if (((flags & 1) && canquick) || (canquick < 0)) {
- hf_log (_T("hf quickio unit=%d request=%p cmd=%d\n"), unit, request, cmd);
- if (hardfile_do_io(ctx, hfd, hfpd, iobuf, request)) {
- hf_log2 (_T("uaehf.device cmd %d bug with IO_QUICK\n"), cmd);
+ hf_log(_T("hf quickio unit=%d request=%p cmd=%d\n"), unit, request, cmd);
+ if (hardfile_do_io(hfd, hfpd, request)) {
+ hf_log2(_T("uaehf.device cmd %d bug with IO_QUICK\n"), cmd);
}
- uae_u8 v = get_byte_host(iobuf + 31);
- trap_put_bytes(ctx, iobuf + 8, request + 8, 48 - 8);
- xfree(iobuf);
if (!(flags & 1))
- uae_ReplyMsg (request);
- return v;
- } else {
- hf_log2 (_T("hf asyncio unit=%d request=%p cmd=%d\n"), unit, request, cmd);
- add_async_request(hfpd, iobuf, request, ASYNC_REQUEST_TEMP, 0);
- put_byte_host(iobuf + 30, get_byte_host(iobuf + 30) & ~1);
- trap_put_bytes(ctx, iobuf + 8, request + 8, 48 - 8);
- write_comm_pipe_pvoid(&hfpd->requests, ctx, 0);
- write_comm_pipe_pvoid(&hfpd->requests, iobuf, 0);
- write_comm_pipe_u32 (&hfpd->requests, request, 1);
- return 0;
- }
+ uae_ReplyMsg(request);
+ return get_byte(request + 31);
+ }
+ else {
+ hf_log2(_T("hf asyncio unit=%d request=%p cmd=%d\n"), unit, request, cmd);
+ add_async_request(hfpd, request, ASYNC_REQUEST_TEMP, 0);
+ put_byte(request + 30, get_byte(request + 30) & ~1);
+ write_comm_pipe_u32(&hfpd->requests, request, 1);
+ return 0;
+ }
}
-static void *hardfile_thread (void *devs)
+static void *hardfile_thread(void *devs)
{
- struct hardfileprivdata *hfpd = (struct hardfileprivdata *)devs;
+ struct hardfileprivdata *hfpd = (struct hardfileprivdata*)devs;
- uae_set_thread_priority (NULL, 1);
- hfpd->thread_running = 1;
- uae_sem_post (&hfpd->sync_sem);
- for (;;) {
- TrapContext *ctx = (TrapContext*)read_comm_pipe_pvoid_blocking(&hfpd->requests);
- uae_u8 *iobuf = (uae_u8*)read_comm_pipe_pvoid_blocking(&hfpd->requests);
- uaecptr request = (uaecptr)read_comm_pipe_u32_blocking (&hfpd->requests);
- uae_sem_wait (&change_sem);
- if (!request) {
- hfpd->thread_running = 0;
- uae_sem_post (&hfpd->sync_sem);
- uae_sem_post (&change_sem);
- return 0;
- } else if (hardfile_do_io(ctx, get_hardfile_data (hfpd - &hardfpd[0]), hfpd, iobuf, request) == 0) {
- put_byte_host(iobuf + 30, get_byte_host(iobuf + 30) & ~1);
- trap_put_bytes(ctx, iobuf + 8, request + 8, 48 - 8);
- release_async_request (hfpd, request);
- uae_ReplyMsg (request);
- } else {
- hf_log2 (_T("async request %08X\n"), request);
- trap_put_bytes(ctx, iobuf + 8, request + 8, 48 - 8);
- }
- uae_sem_post (&change_sem);
- }
+ uae_set_thread_priority(NULL, 1);
+ hfpd->thread_running = 1;
+ uae_sem_post(&hfpd->sync_sem);
+ for (;;) {
+ uaecptr request = (uaecptr)read_comm_pipe_u32_blocking(&hfpd->requests);
+ uae_sem_wait(&change_sem);
+ if (!request) {
+ hfpd->thread_running = 0;
+ uae_sem_post(&hfpd->sync_sem);
+ uae_sem_post(&change_sem);
+ return 0;
+ }
+ else if (hardfile_do_io(get_hardfile_data(hfpd - &hardfpd[0]), hfpd, request) == 0) {
+ put_byte(request + 30, get_byte(request + 30) & ~1);
+ release_async_request(hfpd, request);
+ uae_ReplyMsg(request);
+ }
+ else {
+ hf_log2(_T("async request %08X\n"), request);
+ }
+ uae_sem_post(&change_sem);
+ }
}
-void hardfile_reset (void)
+void hardfile_reset(void)
{
- int i, j;
- struct hardfileprivdata *hfpd;
+ int i, j;
+ struct hardfileprivdata *hfpd;
- for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
- hfpd = &hardfpd[i];
- if (hfpd->base && valid_address(hfpd->base, 36) && get_word(hfpd->base + 32) > 0) {
- for (j = 0; j < MAX_ASYNC_REQUESTS; j++) {
- uaecptr request;
- if ((request = hfpd->d_request[j]))
- abort_async (hfpd, request, 0, 0);
- }
- }
-
- if(hfpd->thread_running) {
- write_comm_pipe_pvoid(&hfpd->requests, NULL, 0);
- write_comm_pipe_pvoid(&hfpd->requests, NULL, 0);
- write_comm_pipe_u32 (&hfpd->requests, 0, 1);
- while(hfpd->thread_running)
- sleep_millis(10);
- if(hfpd->sync_sem != 0)
- uae_sem_destroy(&hfpd->sync_sem);
- hfpd->sync_sem = 0;
- }
- if(hfpd->requests.size == 300) {
- destroy_comm_pipe(&hfpd->requests);
- hfpd->requests.size = 0;
- }
-
- memset (hfpd, 0, sizeof (struct hardfileprivdata));
- }
+ for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
+ hfpd = &hardfpd[i];
+ if (hfpd->base && valid_address(hfpd->base, 36) && get_word(hfpd->base + 32) > 0) {
+ for (j = 0; j < MAX_ASYNC_REQUESTS; j++) {
+ uaecptr request;
+ if ((request = hfpd->d_request[i]))
+ abort_async(hfpd, request, 0, 0);
+ }
+ }
+ memset(hfpd, 0, sizeof(struct hardfileprivdata));
+ }
}
-void hardfile_install (void)
+void hardfile_install(void)
{
- uae_u32 functable, datatable;
- uae_u32 initcode, openfunc, closefunc, expungefunc;
- uae_u32 beginiofunc, abortiofunc;
+ uae_u32 functable, datatable;
+ uae_u32 initcode, openfunc, closefunc, expungefunc;
+ uae_u32 beginiofunc, abortiofunc;
- if(change_sem != 0) {
- uae_sem_destroy(&change_sem);
- change_sem = 0;
- }
- uae_sem_init (&change_sem, 0, 1);
+ uae_sem_init(&change_sem, 0, 1);
- ROM_hardfile_resname = ds (_T("uaehf.device"));
- ROM_hardfile_resid = ds (_T("UAE hardfile.device 0.4"));
+ ROM_hardfile_resname = ds(_T("uaehf.device"));
+ ROM_hardfile_resid = ds(_T("UAE hardfile.device 0.3"));
- nscmd_cmd = here ();
- dw (NSCMD_DEVICEQUERY);
- dw (CMD_RESET);
- dw (CMD_READ);
- dw (CMD_WRITE);
- dw (CMD_UPDATE);
- dw (CMD_CLEAR);
- dw (CMD_START);
- dw (CMD_STOP);
- dw (CMD_FLUSH);
- dw (CMD_MOTOR);
- dw (CMD_SEEK);
- dw (CMD_FORMAT);
- dw (CMD_REMOVE);
- dw (CMD_CHANGENUM);
- dw (CMD_CHANGESTATE);
- dw (CMD_PROTSTATUS);
- dw (CMD_GETDRIVETYPE);
- dw (CMD_GETGEOMETRY);
- dw (CMD_ADDCHANGEINT);
- dw (CMD_REMCHANGEINT);
- dw (HD_SCSICMD);
- dw (NSCMD_TD_READ64);
- dw (NSCMD_TD_WRITE64);
- dw (NSCMD_TD_SEEK64);
- dw (NSCMD_TD_FORMAT64);
- dw (0);
+ nscmd_cmd = here();
+ dw(NSCMD_DEVICEQUERY);
+ dw(CMD_RESET);
+ dw(CMD_READ);
+ dw(CMD_WRITE);
+ dw(CMD_UPDATE);
+ dw(CMD_CLEAR);
+ dw(CMD_START);
+ dw(CMD_STOP);
+ dw(CMD_FLUSH);
+ dw(CMD_MOTOR);
+ dw(CMD_SEEK);
+ dw(CMD_FORMAT);
+ dw(CMD_REMOVE);
+ dw(CMD_CHANGENUM);
+ dw(CMD_CHANGESTATE);
+ dw(CMD_PROTSTATUS);
+ dw(CMD_GETDRIVETYPE);
+ dw(CMD_GETGEOMETRY);
+ dw(CMD_ADDCHANGEINT);
+ dw(CMD_REMCHANGEINT);
+ dw(HD_SCSICMD);
+ dw(NSCMD_TD_READ64);
+ dw(NSCMD_TD_WRITE64);
+ dw(NSCMD_TD_SEEK64);
+ dw(NSCMD_TD_FORMAT64);
+ dw(0);
- /* initcode */
- initcode = filesys_initcode;
+ /* initcode */
+#if 0
+ initcode = here();
+ calltrap(deftrap(hardfile_init)); dw(RTS);
+#else
+ initcode = filesys_initcode;
+#endif
+ /* Open */
+ openfunc = here();
+ calltrap(deftrap(hardfile_open)); dw(RTS);
- /* Open */
- openfunc = here ();
- calltrap (deftrap (hardfile_open)); dw (RTS);
+ /* Close */
+ closefunc = here();
+ calltrap(deftrap(hardfile_close)); dw(RTS);
- /* Close */
- closefunc = here ();
- calltrap (deftrap (hardfile_close)); dw (RTS);
+ /* Expunge */
+ expungefunc = here();
+ calltrap(deftrap(hardfile_expunge)); dw(RTS);
- /* Expunge */
- expungefunc = here ();
- calltrap (deftrap (hardfile_expunge)); dw (RTS);
+ /* BeginIO */
+ beginiofunc = here();
+ calltrap(deftrap(hardfile_beginio));
+ dw(RTS);
- /* BeginIO */
- beginiofunc = here ();
- calltrap (deftrap (hardfile_beginio));
- dw (RTS);
+ /* AbortIO */
+ abortiofunc = here();
+ calltrap(deftrap(hardfile_abortio)); dw(RTS);
- /* AbortIO */
- abortiofunc = here ();
- calltrap (deftrap (hardfile_abortio)); dw (RTS);
+ /* FuncTable */
+ functable = here();
+ dl(openfunc); /* Open */
+ dl(closefunc); /* Close */
+ dl(expungefunc); /* Expunge */
+ dl(EXPANSION_nullfunc); /* Null */
+ dl(beginiofunc); /* BeginIO */
+ dl(abortiofunc); /* AbortIO */
+ dl(0xFFFFFFFFul); /* end of table */
- /* FuncTable */
- functable = here ();
- dl (openfunc); /* Open */
- dl (closefunc); /* Close */
- dl (expungefunc); /* Expunge */
- dl (EXPANSION_nullfunc); /* Null */
- dl (beginiofunc); /* BeginIO */
- dl (abortiofunc); /* AbortIO */
- dl (0xFFFFFFFFul); /* end of table */
+ /* DataTable */
+ datatable = here();
+ dw(0xE000); /* INITBYTE */
+ dw(0x0008); /* LN_TYPE */
+ dw(0x0300); /* NT_DEVICE */
+ dw(0xC000); /* INITLONG */
+ dw(0x000A); /* LN_NAME */
+ dl(ROM_hardfile_resname);
+ dw(0xE000); /* INITBYTE */
+ dw(0x000E); /* LIB_FLAGS */
+ dw(0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */
+ dw(0xD000); /* INITWORD */
+ dw(0x0014); /* LIB_VERSION */
+ dw(0x0004); /* 0.4 */
+ dw(0xD000);
+ dw(0x0016); /* LIB_REVISION */
+ dw(0x0000);
+ dw(0xC000);
+ dw(0x0018); /* LIB_IDSTRING */
+ dl(ROM_hardfile_resid);
+ dw(0x0000); /* end of table */
- /* DataTable */
- datatable = here ();
- dw (0xE000); /* INITBYTE */
- dw (0x0008); /* LN_TYPE */
- dw (0x0300); /* NT_DEVICE */
- dw (0xC000); /* INITLONG */
- dw (0x000A); /* LN_NAME */
- dl (ROM_hardfile_resname);
- dw (0xE000); /* INITBYTE */
- dw (0x000E); /* LIB_FLAGS */
- dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */
- dw (0xD000); /* INITWORD */
- dw (0x0014); /* LIB_VERSION */
- dw (0x0032); /* 50 */
- dw (0xD000);
- dw (0x0016); /* LIB_REVISION */
- dw (0x0001);
- dw (0xC000);
- dw (0x0018); /* LIB_IDSTRING */
- dl (ROM_hardfile_resid);
- dw (0x0000); /* end of table */
-
- ROM_hardfile_init = here ();
- dl (0x00000100); /* ??? */
- dl (functable);
- dl (datatable);
- filesys_initcode_ptr = here();
- dl (initcode);
+ ROM_hardfile_init = here();
+ dl(0x00000100); /* ??? */
+ dl(functable);
+ dl(datatable);
+ dl(initcode);
}
diff --git a/src/include/akiko.h b/src/include/akiko.h
index 5b102597..899c451d 100644
--- a/src/include/akiko.h
+++ b/src/include/akiko.h
@@ -1,17 +1,14 @@
-#ifndef UAE_AKIKO_H
-#define UAE_AKIKO_H
+#pragma once
#define AKIKO_BASE 0xb80000
#define AKIKO_BASE_END 0xb80100 /* ?? */
-extern void akiko_reset(void);
-extern int akiko_init(void);
-extern void akiko_free(void);
+extern void akiko_reset (void);
+extern int akiko_init (void);
+extern void akiko_free (void);
-extern void AKIKO_hsync_handler(void);
-extern void akiko_mute(int);
+extern void AKIKO_hsync_handler (void);
+extern void akiko_mute (int);
extern bool akiko_ntscmode(void);
-extern void rethink_akiko(void);
-
-#endif /* UAE_AKIKO_H */
+extern void rethink_akiko (void);
diff --git a/src/include/audio.h b/src/include/audio.h
index 7eb9e4d6..f3cc323c 100644
--- a/src/include/audio.h
+++ b/src/include/audio.h
@@ -6,15 +6,12 @@
* Copyright 1995, 1996, 1997 Bernd Schmidt
*/
-#ifndef UAE_AUDIO_H
-#define UAE_AUDIO_H
-
-#include "uae/types.h"
-
+#pragma once
#define PERIOD_MAX ULONG_MAX
#define MAX_EV ~0u
void AUDxDAT(int nr, uae_u16 value);
+void AUDxDAT(int nr, uae_u16 value, uaecptr addr);
void AUDxVOL(int nr, uae_u16 value);
void AUDxPER(int nr, uae_u16 value);
void AUDxLCH(int nr, uae_u16 value);
@@ -23,30 +20,86 @@ void AUDxLEN(int nr, uae_u16 value);
uae_u16 audio_dmal(void);
void audio_state_machine(void);
-void audio_dmal_do(int nr, bool reset);
-
+uaecptr audio_getpt(int nr, bool reset);
int init_audio(void);
void audio_reset(void);
void update_audio(void);
void audio_evhandler(void);
void audio_hsync(void);
void audio_update_adkmasks(void);
-void update_sound(float clk);
+void update_sound(double clk);
+void update_cda_sound(double clk);
void led_filter_audio(void);
void set_audio(void);
int audio_activate(void);
void audio_deactivate(void);
+void audio_vsync(void);
+void audio_sampleripper(int);
+void write_wavheader(struct zfile *wavfile, uae_u32 size, uae_u32 freq);
+
+int audio_is_pull(void);
+int audio_pull_buffer(void);
+bool audio_finish_pull(void);
+bool audio_is_pull_event(void);
+bool audio_is_event_frame_possible(int);
+
+extern int sampleripper_enabled;
+
+typedef void(*CDA_CALLBACK)(int);
+typedef bool(*SOUND_STREAM_CALLBACK)(int);
+
+extern int audio_enable_stream(bool, int, int, SOUND_STREAM_CALLBACK);
+extern void audio_state_stream_state(int, int*, int, unsigned int);
+
+extern void audio_cda_new_buffer(uae_s16 *buffer, int length, int userdata, CDA_CALLBACK next_cd_audio_buffer_callback);
+extern void audio_cda_volume(int left, int right);
extern int sound_cd_volume[2];
+extern int sound_paula_volume[2];
+
+#define AUDIO_CHANNEL_MAX_STREAM_CH 8
+#define AUDIO_CHANNEL_STREAMS 9
#define AUDIO_CHANNELS_PAULA 4
enum {
SND_MONO,
SND_STEREO,
+ SND_4CH_CLONEDSTEREO,
+ SND_4CH,
+ SND_6CH_CLONEDSTEREO,
+ SND_6CH,
SND_NONE
};
+static inline int get_audio_stereomode(int channels)
+{
+ switch (channels)
+ {
+ case 1:
+ return SND_MONO;
+ case 2:
+ return SND_STEREO;
+ case 4:
+ return SND_4CH;
+ case 6:
+ return SND_6CH;
+ }
+ return SND_STEREO;
+}
+
+STATIC_INLINE int get_audio_nativechannels(int stereomode)
+{
+ int ch[] = { 1, 2, 4, 4, 6, 6, 0 };
+ return ch[stereomode];
+}
+
+STATIC_INLINE int get_audio_amigachannels(int stereomode)
+{
+ int ch[] = { 1, 2, 2, 4, 2, 4, 0 };
+ return ch[stereomode];
+}
+
STATIC_INLINE int get_audio_ismono(int stereomode)
{
return stereomode == 0;
@@ -56,5 +109,3 @@ STATIC_INLINE int get_audio_ismono(int stereomode)
#define SOUND_MAX_LOG_DELAY 10
#define MIXED_STEREO_MAX 16
#define MIXED_STEREO_SCALE 32
-
-#endif /* UAE_AUDIO_H */
\ No newline at end of file
diff --git a/src/include/autoconf.h b/src/include/autoconf.h
index 3591c84a..de0b85e5 100644
--- a/src/include/autoconf.h
+++ b/src/include/autoconf.h
@@ -1,15 +1,18 @@
- /*
- * UAE - The Un*x Amiga Emulator
- *
- * Autoconfig device support
- *
- * (c) 1996 Ed Hanway
- */
+/*
+* UAE - The Un*x Amiga Emulator
+*
+* Autoconfig device support
+*
+* (c) 1996 Ed Hanway
+*/
#ifndef UAE_AUTOCONF_H
#define UAE_AUTOCONF_H
-#include "uae/types.h"
+//#include "uae/types.h"
+#include "sysconfig.h"
+#include "traps.h"
+#include "include/memory.h"
#define AFTERDOS_INIT_PRI ((-121) & 0xff)
#define AFTERDOS_PRI ((-122) & 0xff)
@@ -58,23 +61,27 @@
#define UAEBOARD_DATAREGION_START 0x4000
#define UAEBOARD_DATAREGION_SIZE 0xc000
-extern uae_u32 addr (int);
-extern void db (uae_u8);
-extern void dw (uae_u16);
-extern void dl (uae_u32);
-extern uae_u32 ds_ansi (const uae_char*);
-extern uae_u32 ds (const TCHAR*);
-extern uae_u32 ds_bstr_ansi (const uae_char*);
-extern uae_u8 dbg (uaecptr);
-extern void calltrap (uae_u32);
-extern void org (uae_u32);
-extern uae_u32 here (void);
-extern uaecptr makedatatable (uaecptr resid, uaecptr resname, uae_u8 type, uae_s8 priority, uae_u16 ver, uae_u16 rev);
+extern uae_u32 addr(int);
+extern void db(uae_u8);
+extern void dw(uae_u16);
+extern void dl(uae_u32);
+extern uae_u32 ds_ansi(const uae_char*);
+extern uae_u32 ds(const TCHAR*);
+extern uae_u32 ds_bstr_ansi(const uae_char*);
+extern uae_u8 dbg(uaecptr);
+extern void calltrap(uae_u32);
+extern void org(uae_u32);
+extern uae_u32 here(void);
+extern uaecptr makedatatable(uaecptr resid, uaecptr resname, uae_u8 type, uae_s8 priority, uae_u16 ver, uae_u16 rev);
+extern uae_u32 boot_rom_copy(TrapContext*, uaecptr, int);
+extern void add_rom_absolute(uaecptr addr);
+extern void save_rom_absolute(uaecptr addr);
-extern void align (int);
+extern void align(int);
-extern volatile uae_atomic uae_int_requested;
+extern volatile int uae_int_requested;
extern void rtarea_reset(void);
+extern bool rethink_traps(void);
#define RTS 0x4e75
#define RTE 0x4e73
@@ -89,66 +96,77 @@ extern uaecptr ROM_hardfile_resname, ROM_hardfile_resid;
extern uaecptr ROM_hardfile_init;
extern uaecptr filesys_initcode, filesys_initcode_ptr;
-extern int is_hardfile (int unit_no);
-extern int nr_units (void);
-extern int nr_directory_units (struct uae_prefs*);
+extern int is_hardfile(int unit_no);
+extern int nr_units(void);
+extern int nr_directory_units(struct uae_prefs*);
extern uaecptr need_uae_boot_rom(struct uae_prefs*);
struct mountedinfo
{
- uae_s64 size;
- bool ismounted;
- bool ismedia;
+ uae_s64 size;
+ bool ismounted;
+ bool ismedia;
int error;
- int nrcyls;
+ int nrcyls;
TCHAR rootdir[MAX_DPATH];
};
-extern int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo*);
-extern int kill_filesys_unitconfig (struct uae_prefs *p, int nr);
-extern int move_filesys_unitconfig (struct uae_prefs *p, int nr, int to);
-extern TCHAR *validatedevicename (TCHAR *s, const TCHAR *def);
-extern TCHAR *validatevolumename (TCHAR *s, const TCHAR *def);
+extern int get_filesys_unitconfig(struct uae_prefs *p, int index, struct mountedinfo*);
+extern int kill_filesys_unitconfig(struct uae_prefs *p, int nr);
+extern int move_filesys_unitconfig(struct uae_prefs *p, int nr, int to);
+extern TCHAR *validatedevicename(TCHAR *s, const TCHAR *def);
+extern TCHAR *validatevolumename(TCHAR *s, const TCHAR *def);
-int filesys_insert (int nr, const TCHAR *volume, const TCHAR *rootdir, bool readonly, int flags);
-int filesys_eject (int nr);
-int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_config_data *uci);
+int filesys_insert(int nr, const TCHAR *volume, const TCHAR *rootdir, bool readonly, int flags);
+int filesys_eject(int nr);
+int filesys_media_change(const TCHAR *rootdir, int inserted, struct uaedev_config_data *uci);
-extern TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, struct zvolume *zv, const TCHAR *def);
-extern int target_get_volume_name (struct uaedev_mount_info *mtinf, struct uaedev_config_info *ci, bool inserted, bool fullcheck, int cnt);
+extern TCHAR *filesys_createvolname(const TCHAR *volname, const TCHAR *rootdir, struct zvolume *zv, const TCHAR *def);
+extern int target_get_volume_name(struct uaedev_mount_info *mtinf, struct uaedev_config_info *ci, bool inserted, bool fullcheck, int cnt);
-extern int sprintf_filesys_unit (TCHAR *buffer, int num);
+extern int sprintf_filesys_unit(TCHAR *buffer, int num);
-extern void filesys_reset (void);
-extern void filesys_cleanup (void);
-extern void filesys_prepare_reset (void);
-extern void filesys_start_threads (void);
-extern void filesys_flush_cache (void);
-extern void filesys_free_handles (void);
-extern void filesys_vsync (void);
+extern void filesys_reset(void);
+extern void filesys_cleanup(void);
+extern void filesys_prepare_reset(void);
+extern void filesys_start_threads(void);
+extern void filesys_flush_cache(void);
+extern void filesys_free_handles(void);
+extern void filesys_vsync(void);
-extern void filesys_install (void);
-extern void filesys_install_code (void);
+extern void filesys_install(void);
+extern void filesys_install_code(void);
extern uaecptr filesys_get_entry(int);
-extern void filesys_store_devinfo (uae_u8 *);
-extern void hardfile_install (void);
-extern void hardfile_reset (void);
-extern void emulib_install (void);
-extern void expansion_init (void);
-extern void expansion_cleanup (void);
-extern void expansion_clear (void);
+extern void filesys_store_devinfo(uae_u8 *);
+extern void hardfile_install(void);
+extern void hardfile_reset(void);
+extern void emulib_install(void);
+extern uae_u32 uaeboard_demux(uae_u32*);
+extern void expansion_init(void);
+extern void expansion_cleanup(void);
+extern void expansion_clear(void);
extern uaecptr expansion_startaddress(struct uae_prefs*, uaecptr addr, uae_u32 size);
+extern bool expansion_is_next_board_fastram(void);
+extern uaecptr uaeboard_alloc_ram(uae_u32);
extern uae_u8 *uaeboard_map_ram(uaecptr);
extern void expansion_scan_autoconfig(struct uae_prefs*, bool);
extern void expansion_generate_autoconfig_info(struct uae_prefs *p);
+extern struct autoconfig_info *expansion_get_autoconfig_info(struct uae_prefs*, int romtype, int devnum);
+extern struct autoconfig_info *expansion_get_autoconfig_data(struct uae_prefs *p, int index);
extern struct autoconfig_info *expansion_get_autoconfig_by_address(struct uae_prefs *p, uaecptr addr);
+extern void expansion_set_autoconfig_sort(struct uae_prefs *p);
+extern int expansion_autoconfig_move(struct uae_prefs *p, int index, int direction, bool test);
+extern bool expansion_can_move(struct uae_prefs *p, int index);
+extern bool alloc_expansion_bank(addrbank *bank, struct autoconfig_info *aci);
+extern void free_expansion_bank(addrbank *bank);
extern void expansion_map(void);
+extern uae_u32 expansion_board_size(addrbank *ab);
-extern void uaegfx_install_code (uaecptr);
+extern void uaegfx_install_code(uaecptr);
-extern uae_u32 emulib_target_getcpurate (uae_u32, uae_u32*);
+extern uae_u32 emulib_target_getcpurate(uae_u32, uae_u32*);
-typedef bool (*DEVICE_INIT)(struct autoconfig_info*);
+typedef bool(*DEVICE_INIT)(struct autoconfig_info*);
typedef void(*DEVICE_ADD)(int, struct uaedev_config_info*, struct romconfig*);
typedef bool(*E8ACCESS)(int, uae_u32*, int, bool);
typedef void(*DEVICE_MEMORY_CALLBACK)(struct romconfig*, uae_u8*, int);
@@ -179,6 +197,17 @@ struct expansionboardsettings
const TCHAR *configname;
int type;
bool invert;
+ int bitshift;
+};
+struct expansionsubromtype
+{
+ const TCHAR *name;
+ const TCHAR *configname;
+ uae_u32 romtype;
+ int memory_mid, memory_pid;
+ uae_u32 memory_serial;
+ bool memory_after;
+ uae_u8 autoconfig[16];
};
struct expansionromtype
{
@@ -192,11 +221,60 @@ struct expansionromtype
uae_u32 parentromtype;
int zorro;
bool singleonly;
+ const struct expansionsubromtype *subtypes;
+ int defaultsubtype;
+ bool autoboot_jumper;
int deviceflags;
+ int memory_mid, memory_pid;
+ uae_u32 memory_serial;
+ bool memory_after;
+ DEVICE_MEMORY_CALLBACK memory_callback;
+ bool id_jumper;
+ int extrahdports;
const struct expansionboardsettings *settings;
uae_u8 autoconfig[16];
};
extern const struct expansionromtype expansionroms[];
+struct cpuboardsubtype
+{
+ const TCHAR *name;
+ const TCHAR *configname;
+ int romtype, romtype_extra;
+ DEVICE_ADD add;
+ int deviceflags;
+ int memorytype;
+ int maxmemory;
+ int z3extra;
+ DEVICE_INIT init, init2;
+ int initzorro;
+ int initflag;
+ const struct expansionboardsettings *settings;
+ E8ACCESS e8;
+ // if includes Z2 or Z3 RAM
+ int memory_mid, memory_pid;
+ uae_u32 memory_serial;
+ bool memory_after;
+ uae_u8 autoconfig[16];
+};
+struct cpuboardtype
+{
+ int id;
+ const TCHAR *name;
+ const struct cpuboardsubtype *subtypes;
+ int defaultsubtype;
+};
+extern const struct cpuboardtype cpuboards[];
+struct memoryboardtype
+{
+ const TCHAR *man;
+ const TCHAR *name;
+ uae_u8 z;
+ uae_u32 address;
+ uae_u16 manufacturer;
+ uae_u8 product;
+ uae_u8 autoconfig[16];
+};
+extern const struct memoryboardtype memoryboards[];
#endif /* UAE_AUTOCONF_H */
diff --git a/src/include/blit.h b/src/include/blit.h
new file mode 100644
index 00000000..eb620735
--- /dev/null
+++ b/src/include/blit.h
@@ -0,0 +1,518 @@
+STATIC_INLINE uae_u32 blit_func(uae_u32 srca, uae_u32 srcb, uae_u32 srcc, uae_u8 mt)
+{
+switch(mt){
+case 0x0:
+ return 0;
+case 0x1:
+ return ~(srca | srcb | srcc);
+case 0x2:
+ return (srcc & ~(srca | srcb));
+case 0x3:
+ return ~(srca | srcb);
+case 0x4:
+ return (srcb & ~(srca | srcc));
+case 0x5:
+ return ~(srca | srcc);
+case 0x6:
+ return (~srca & (srcb ^ srcc));
+case 0x7:
+ return ~(srca | (srcb & srcc));
+case 0x8:
+ return (~srca & srcb & srcc);
+case 0x9:
+ return ~(srca | (srcb ^ srcc));
+case 0xa:
+ return (~srca & srcc);
+case 0xb:
+ return ~(srca | (srcb & ~srcc));
+case 0xc:
+ return (~srca & srcb);
+case 0xd:
+ return ~(srca | (~srcb & srcc));
+case 0xe:
+ return (~srca & (srcb | srcc));
+case 0xf:
+ return ~srca;
+case 0x10:
+ return (srca & ~(srcb | srcc));
+case 0x11:
+ return ~(srcb | srcc);
+case 0x12:
+ return (~srcb & (srca ^ srcc));
+case 0x13:
+ return ~(srcb | (srca & srcc));
+case 0x14:
+ return (~srcc & (srca ^ srcb));
+case 0x15:
+ return ~(srcc | (srca & srcb));
+case 0x16:
+ return (srca ^ ((srca & srcb) | (srcb ^ srcc)));
+case 0x17:
+ return ~(srca ^ ((srca ^ srcb) & (srca ^ srcc)));
+case 0x18:
+ return ((srca ^ srcb) & (srca ^ srcc));
+case 0x19:
+ return (srcb ^ (~srcc | (srca & srcb)));
+case 0x1a:
+ return (srca ^ (srcc | (srca & srcb)));
+case 0x1b:
+ return (srca ^ (srcc | ~(srca ^ srcb)));
+case 0x1c:
+ return (srca ^ (srcb | (srca & srcc)));
+case 0x1d:
+ return (srca ^ (srcb | ~(srca ^ srcc)));
+case 0x1e:
+ return (srca ^ (srcb | srcc));
+case 0x1f:
+ return ~(srca & (srcb | srcc));
+case 0x20:
+ return (srca & ~srcb & srcc);
+case 0x21:
+ return ~(srcb | (srca ^ srcc));
+case 0x22:
+ return (~srcb & srcc);
+case 0x23:
+ return ~(srcb | (srca & ~srcc));
+case 0x24:
+ return ((srca ^ srcb) & (srcb ^ srcc));
+case 0x25:
+ return (srca ^ (~srcc | (srca & srcb)));
+case 0x26:
+ return (srcb ^ (srcc | (srca & srcb)));
+case 0x27:
+ return ~(srca ^ (srcc & (srca ^ srcb)));
+case 0x28:
+ return (srcc & (srca ^ srcb));
+case 0x29:
+ return ~(srca ^ srcb ^ (srcc | (srca & srcb)));
+case 0x2a:
+ return (srcc & ~(srca & srcb));
+case 0x2b:
+ return ~(srca ^ ((srca ^ srcb) & (srcb ^ srcc)));
+case 0x2c:
+ return (srcb ^ (srca & (srcb | srcc)));
+case 0x2d:
+ return (srca ^ (srcb | ~srcc));
+case 0x2e:
+ return (srca ^ (srcb | (srca ^ srcc)));
+case 0x2f:
+ return ~(srca & (srcb | ~srcc));
+case 0x30:
+ return (srca & ~srcb);
+case 0x31:
+ return ~(srcb | (~srca & srcc));
+case 0x32:
+ return (~srcb & (srca | srcc));
+case 0x33:
+ return ~srcb;
+case 0x34:
+ return (srcb ^ (srca | (srcb & srcc)));
+case 0x35:
+ return (srcb ^ (srca | ~(srcb ^ srcc)));
+case 0x36:
+ return (srcb ^ (srca | srcc));
+case 0x37:
+ return ~(srcb & (srca | srcc));
+case 0x38:
+ return (srca ^ (srcb & (srca | srcc)));
+case 0x39:
+ return (srcb ^ (srca | ~srcc));
+case 0x3a:
+ return (srcb ^ (srca | (srcb ^ srcc)));
+case 0x3b:
+ return ~(srcb & (srca | ~srcc));
+case 0x3c:
+ return (srca ^ srcb);
+case 0x3d:
+ return (srca ^ (srcb | ~(srca | srcc)));
+case 0x3e:
+ return (srca ^ (srcb | (srca ^ (srca | srcc))));
+case 0x3f:
+ return ~(srca & srcb);
+case 0x40:
+ return (srca & srcb & ~srcc);
+case 0x41:
+ return ~(srcc | (srca ^ srcb));
+case 0x42:
+ return ((srca ^ srcc) & (srcb ^ srcc));
+case 0x43:
+ return (srca ^ (~srcb | (srca & srcc)));
+case 0x44:
+ return (srcb & ~srcc);
+case 0x45:
+ return ~(srcc | (srca & ~srcb));
+case 0x46:
+ return (srcc ^ (srcb | (srca & srcc)));
+case 0x47:
+ return ~(srca ^ (srcb & (srca ^ srcc)));
+case 0x48:
+ return (srcb & (srca ^ srcc));
+case 0x49:
+ return ~(srca ^ srcc ^ (srcb | (srca & srcc)));
+case 0x4a:
+ return (srcc ^ (srca & (srcb | srcc)));
+case 0x4b:
+ return (srca ^ (~srcb | srcc));
+case 0x4c:
+ return (srcb & ~(srca & srcc));
+case 0x4d:
+ return (srca ^ ((srca ^ srcb) | ~(srca ^ srcc)));
+case 0x4e:
+ return (srca ^ (srcc | (srca ^ srcb)));
+case 0x4f:
+ return ~(srca & (~srcb | srcc));
+case 0x50:
+ return (srca & ~srcc);
+case 0x51:
+ return ~(srcc | (~srca & srcb));
+case 0x52:
+ return (srcc ^ (srca | (srcb & srcc)));
+case 0x53:
+ return ~(srcb ^ (srca & (srcb ^ srcc)));
+case 0x54:
+ return (~srcc & (srca | srcb));
+case 0x55:
+ return ~srcc;
+case 0x56:
+ return (srcc ^ (srca | srcb));
+case 0x57:
+ return ~(srcc & (srca | srcb));
+case 0x58:
+ return (srca ^ (srcc & (srca | srcb)));
+case 0x59:
+ return (srcc ^ (srca | ~srcb));
+case 0x5a:
+ return (srca ^ srcc);
+case 0x5b:
+ return (srca ^ (srcc | ~(srca | srcb)));
+case 0x5c:
+ return (srcc ^ (srca | (srcb ^ srcc)));
+case 0x5d:
+ return ~(srcc & (srca | ~srcb));
+case 0x5e:
+ return (srca ^ (srcc | (srca ^ (srca | srcb))));
+case 0x5f:
+ return ~(srca & srcc);
+case 0x60:
+ return (srca & (srcb ^ srcc));
+case 0x61:
+ return ~(srcb ^ srcc ^ (srca | (srcb & srcc)));
+case 0x62:
+ return (srcc ^ (srcb & (srca | srcc)));
+case 0x63:
+ return (srcb ^ (~srca | srcc));
+case 0x64:
+ return (srcb ^ (srcc & (srca | srcb)));
+case 0x65:
+ return (srcc ^ (~srca | srcb));
+case 0x66:
+ return (srcb ^ srcc);
+case 0x67:
+ return (srcb ^ (srcc | ~(srca | srcb)));
+case 0x68:
+ return ((srca & srcb) ^ (srcc & (srca | srcb)));
+case 0x69:
+ return ~(srca ^ srcb ^ srcc);
+case 0x6a:
+ return (srcc ^ (srca & srcb));
+case 0x6b:
+ return ~(srca ^ srcb ^ (srcc & (srca | srcb)));
+case 0x6c:
+ return (srcb ^ (srca & srcc));
+case 0x6d:
+ return ~(srca ^ srcc ^ (srcb & (srca | srcc)));
+case 0x6e:
+ return ((~srca & srcb) | (srcb ^ srcc));
+case 0x6f:
+ return (~srca | (srcb ^ srcc));
+case 0x70:
+ return (srca & ~(srcb & srcc));
+case 0x71:
+ return ~(srca ^ ((srca ^ srcb) | (srca ^ srcc)));
+case 0x72:
+ return (srcb ^ (srcc | (srca ^ srcb)));
+case 0x73:
+ return ~(srcb & (~srca | srcc));
+case 0x74:
+ return (srcc ^ (srcb | (srca ^ srcc)));
+case 0x75:
+ return ~(srcc & (~srca | srcb));
+case 0x76:
+ return (srcb ^ (srcc | (srca ^ (srca & srcb))));
+case 0x77:
+ return ~(srcb & srcc);
+case 0x78:
+ return (srca ^ (srcb & srcc));
+case 0x79:
+ return ~(srcb ^ srcc ^ (srca & (srcb | srcc)));
+case 0x7a:
+ return ((srca & ~srcb) | (srca ^ srcc));
+case 0x7b:
+ return (~srcb | (srca ^ srcc));
+case 0x7c:
+ return ((srca ^ srcb) | (srca & ~srcc));
+case 0x7d:
+ return (~srcc | (srca ^ srcb));
+case 0x7e:
+ return ((srca ^ srcb) | (srca ^ srcc));
+case 0x7f:
+ return ~(srca & srcb & srcc);
+case 0x80:
+ return (srca & srcb & srcc);
+case 0x81:
+ return ~((srca ^ srcb) | (srca ^ srcc));
+case 0x82:
+ return (srcc & ~(srca ^ srcb));
+case 0x83:
+ return (srca ^ (~srcb | (srca & ~srcc)));
+case 0x84:
+ return (srcb & ~(srca ^ srcc));
+case 0x85:
+ return (srca ^ (~srcc | (srca & ~srcb)));
+case 0x86:
+ return (srcb ^ srcc ^ (srca & (srcb | srcc)));
+case 0x87:
+ return ~(srca ^ (srcb & srcc));
+case 0x88:
+ return (srcb & srcc);
+case 0x89:
+ return (srcb ^ (~srcc & (~srca | srcb)));
+case 0x8a:
+ return (srcc & (~srca | srcb));
+case 0x8b:
+ return (srca ^ (~srcb | (srca ^ srcc)));
+case 0x8c:
+ return (srcb & (~srca | srcc));
+case 0x8d:
+ return (srca ^ (~srcc | (srca ^ srcb)));
+case 0x8e:
+ return (srca ^ ((srca ^ srcb) | (srca ^ srcc)));
+case 0x8f:
+ return (~srca | (srcb & srcc));
+case 0x90:
+ return (srca & ~(srcb ^ srcc));
+case 0x91:
+ return (srcb ^ (~srcc | (~srca & srcb)));
+case 0x92:
+ return (srca ^ srcc ^ (srcb & (srca | srcc)));
+case 0x93:
+ return ~(srcb ^ (srca & srcc));
+case 0x94:
+ return (srca ^ srcb ^ (srcc & (srca | srcb)));
+case 0x95:
+ return ~(srcc ^ (srca & srcb));
+case 0x96:
+ return (srca ^ srcb ^ srcc);
+case 0x97:
+ return (srca ^ srcb ^ (srcc | ~(srca | srcb)));
+case 0x98:
+ return (srcb ^ (~srcc & (srca | srcb)));
+case 0x99:
+ return ~(srcb ^ srcc);
+case 0x9a:
+ return (srcc ^ (srca & ~srcb));
+case 0x9b:
+ return ~(srcb ^ (srcc & (srca | srcb)));
+case 0x9c:
+ return (srcb ^ (srca & ~srcc));
+case 0x9d:
+ return ~(srcc ^ (srcb & (srca | srcc)));
+case 0x9e:
+ return (srcb ^ srcc ^ (srca | (srcb & srcc)));
+case 0x9f:
+ return ~(srca & (srcb ^ srcc));
+case 0xa0:
+ return (srca & srcc);
+case 0xa1:
+ return (srca ^ (~srcc & (srca | ~srcb)));
+case 0xa2:
+ return (srcc & (srca | ~srcb));
+case 0xa3:
+ return (srcb ^ (~srca | (srcb ^ srcc)));
+case 0xa4:
+ return (srca ^ (~srcc & (srca | srcb)));
+case 0xa5:
+ return ~(srca ^ srcc);
+case 0xa6:
+ return (srcc ^ (~srca & srcb));
+case 0xa7:
+ return ~(srca ^ (srcc & (srca | srcb)));
+case 0xa8:
+ return (srcc & (srca | srcb));
+case 0xa9:
+ return ~(srcc ^ (srca | srcb));
+case 0xaa:
+ return srcc;
+case 0xab:
+ return (srcc | ~(srca | srcb));
+case 0xac:
+ return (srcb ^ (srca & (srcb ^ srcc)));
+case 0xad:
+ return ~(srcc ^ (srca | (srcb & srcc)));
+case 0xae:
+ return (srcc | (~srca & srcb));
+case 0xaf:
+ return (~srca | srcc);
+case 0xb0:
+ return (srca & (~srcb | srcc));
+case 0xb1:
+ return ~(srca ^ (srcc | (srca ^ srcb)));
+case 0xb2:
+ return (srca ^ ((srca ^ srcc) & (srcb ^ srcc)));
+case 0xb3:
+ return (~srcb | (srca & srcc));
+case 0xb4:
+ return (srca ^ (srcb & ~srcc));
+case 0xb5:
+ return ~(srcc ^ (srca & (srcb | srcc)));
+case 0xb6:
+ return (srca ^ srcc ^ (srcb | (srca & srcc)));
+case 0xb7:
+ return ~(srcb & (srca ^ srcc));
+case 0xb8:
+ return (srca ^ (srcb & (srca ^ srcc)));
+case 0xb9:
+ return ~(srcc ^ (srcb | (srca & srcc)));
+case 0xba:
+ return (srcc | (srca & ~srcb));
+case 0xbb:
+ return (~srcb | srcc);
+case 0xbc:
+ return ((srca ^ srcb) | (srca & srcc));
+case 0xbd:
+ return ((srca ^ srcb) | ~(srca ^ srcc));
+case 0xbe:
+ return (srcc | (srca ^ srcb));
+case 0xbf:
+ return (srcc | ~(srca & srcb));
+case 0xc0:
+ return (srca & srcb);
+case 0xc1:
+ return (srca ^ (~srcb & (srca | ~srcc)));
+case 0xc2:
+ return (srca ^ (~srcb & (srca | srcc)));
+case 0xc3:
+ return ~(srca ^ srcb);
+case 0xc4:
+ return (srcb & (srca | ~srcc));
+case 0xc5:
+ return ~(srcb ^ (srca | (srcb ^ srcc)));
+case 0xc6:
+ return (srcb ^ (~srca & srcc));
+case 0xc7:
+ return ~(srca ^ (srcb & (srca | srcc)));
+case 0xc8:
+ return (srcb & (srca | srcc));
+case 0xc9:
+ return ~(srcb ^ (srca | srcc));
+case 0xca:
+ return (srcc ^ (srca & (srcb ^ srcc)));
+case 0xcb:
+ return ~(srcb ^ (srca | (srcb & srcc)));
+case 0xcc:
+ return srcb;
+case 0xcd:
+ return (srcb | ~(srca | srcc));
+case 0xce:
+ return (srcb | (~srca & srcc));
+case 0xcf:
+ return (~srca | srcb);
+case 0xd0:
+ return (srca & (srcb | ~srcc));
+case 0xd1:
+ return ~(srca ^ (srcb | (srca ^ srcc)));
+case 0xd2:
+ return (srca ^ (~srcb & srcc));
+case 0xd3:
+ return ~(srcb ^ (srca & (srcb | srcc)));
+case 0xd4:
+ return (srca ^ ((srca ^ srcb) & (srcb ^ srcc)));
+case 0xd5:
+ return (~srcc | (srca & srcb));
+case 0xd6:
+ return (srca ^ srcb ^ (srcc | (srca & srcb)));
+case 0xd7:
+ return ~(srcc & (srca ^ srcb));
+case 0xd8:
+ return (srca ^ (srcc & (srca ^ srcb)));
+case 0xd9:
+ return ~(srcb ^ (srcc | (srca & srcb)));
+case 0xda:
+ return ((srca & srcb) | (srca ^ srcc));
+case 0xdb:
+ return ~((srca ^ srcb) & (srcb ^ srcc));
+case 0xdc:
+ return (srcb | (srca & ~srcc));
+case 0xdd:
+ return (srcb | ~srcc);
+case 0xde:
+ return (srcb | (srca ^ srcc));
+case 0xdf:
+ return (srcb | ~(srca & srcc));
+case 0xe0:
+ return (srca & (srcb | srcc));
+case 0xe1:
+ return ~(srca ^ (srcb | srcc));
+case 0xe2:
+ return (srcc ^ (srcb & (srca ^ srcc)));
+case 0xe3:
+ return ~(srca ^ (srcb | (srca & srcc)));
+case 0xe4:
+ return (srcb ^ (srcc & (srca ^ srcb)));
+case 0xe5:
+ return ~(srca ^ (srcc | (srca & srcb)));
+case 0xe6:
+ return ((srca & srcb) | (srcb ^ srcc));
+case 0xe7:
+ return ~((srca ^ srcb) & (srca ^ srcc));
+case 0xe8:
+ return (srca ^ ((srca ^ srcb) & (srca ^ srcc)));
+case 0xe9:
+ return (srca ^ srcb ^ (~srcc | (srca & srcb)));
+case 0xea:
+ return (srcc | (srca & srcb));
+case 0xeb:
+ return (srcc | ~(srca ^ srcb));
+case 0xec:
+ return (srcb | (srca & srcc));
+case 0xed:
+ return (srcb | ~(srca ^ srcc));
+case 0xee:
+ return (srcb | srcc);
+case 0xef:
+ return (~srca | srcb | srcc);
+case 0xf0:
+ return srca;
+case 0xf1:
+ return (srca | ~(srcb | srcc));
+case 0xf2:
+ return (srca | (~srcb & srcc));
+case 0xf3:
+ return (srca | ~srcb);
+case 0xf4:
+ return (srca | (srcb & ~srcc));
+case 0xf5:
+ return (srca | ~srcc);
+case 0xf6:
+ return (srca | (srcb ^ srcc));
+case 0xf7:
+ return (srca | ~(srcb & srcc));
+case 0xf8:
+ return (srca | (srcb & srcc));
+case 0xf9:
+ return (srca | ~(srcb ^ srcc));
+case 0xfa:
+ return (srca | srcc);
+case 0xfb:
+ return (srca | ~srcb | srcc);
+case 0xfc:
+ return (srca | srcb);
+case 0xfd:
+ return (srca | srcb | ~srcc);
+case 0xfe:
+ return (srca | srcb | srcc);
+case 0xff:
+ return 0xFFFFFFFF;
+}
+return 0;
+}
diff --git a/src/include/blitter.h b/src/include/blitter.h
index 2d95e7bc..7bc2ed15 100644
--- a/src/include/blitter.h
+++ b/src/include/blitter.h
@@ -6,51 +6,48 @@
* (c) 1995 Bernd Schmidt
*/
-#ifndef UAE_BLITTER_H
-#define UAE_BLITTER_H
-
-#include "uae/types.h"
-
+#pragma once
struct bltinfo {
- int blitzero;
- int blitashift,blitbshift,blitdownashift,blitdownbshift;
- uae_u16 bltadat, bltbdat, bltcdat,bltddat;
- uae_u16 bltaold, bltahold, bltbold, bltbhold, bltafwm, bltalwm;
- int vblitsize,hblitsize;
- int bltamod,bltbmod,bltcmod,bltdmod;
+ int blitzero;
+ int blitashift, blitbshift, blitdownashift, blitdownbshift;
+ uae_u16 bltadat, bltbdat, bltcdat, bltddat;
+ uae_u16 bltahold, bltbhold, bltafwm, bltalwm;
+ int vblitsize, hblitsize;
+ int bltamod, bltbmod, bltcmod, bltdmod;
+ int got_cycle;
};
extern enum blitter_states {
- BLT_done, BLT_init, BLT_read, BLT_work, BLT_write, BLT_next
+ BLT_done, BLT_init, BLT_read, BLT_work, BLT_write, BLT_next
} bltstate;
extern struct bltinfo blt_info;
-extern int blit_interrupt;
+extern int blitter_nasty, blit_interrupt, blitter_dangerous_bpl;
+
+extern void check_is_blit_dangerous(uaecptr *bplpt, int planes, int words);
extern uae_u16 bltsize;
-extern uae_u16 bltcon0,bltcon1;
-extern uae_u32 bltapt,bltbpt,bltcpt,bltdpt;
+extern uae_u16 bltcon0, bltcon1;
+extern uae_u32 bltapt, bltbpt, bltcpt, bltdpt;
+extern uae_u32 bltptx;
+extern int bltptxpos, bltptxc;
+extern int blit_singlechannel;
-extern void maybe_blit2 (int);
-STATIC_INLINE void maybe_blit (int hack)
-{
- if (bltstate == BLT_done)
- return;
-
- if (savestate_state)
- return;
-
- maybe_blit2(hack);
-}
-extern void reset_blit (int);
-extern int blitnasty (void);
-extern void blitter_handler (void);
-extern void build_blitfilltable (void);
-extern void do_blitter (void);
-extern void blitter_done_notify (void);
-extern void blitter_slowdown (int, int, int, int);
-extern void blitter_check_start (void);
+extern void maybe_blit(int, int);
+extern void reset_blit(int);
+extern int blitnasty(void);
+extern int blitnnasty(int);
+extern void blitter_handler(uae_u32);
+extern void build_blitfilltable(void);
+extern void do_blitter(int, int);
+extern void decide_blitter(int hpos);
+extern int blitter_need(int hpos);
+extern void blitter_done_notify(int hpos);
+extern void blitter_slowdown(int, int, int, int);
+extern int blitter_channel_state(void);
+extern void blitter_check_start(void);
+extern void blitter_reset(void);
typedef void blitter_func(uaecptr, uaecptr, uaecptr, uaecptr, struct bltinfo *);
@@ -64,5 +61,3 @@ extern uae_u32 blit_masktable[BLITTER_MAX_WORDS];
#define BLIT_MODE_APPROXIMATE 0
#define BLIT_MODE_COMPATIBLE 1
#define BLIT_MODE_EXACT 2
-
-#endif /* UAE_BLITTER_H */
diff --git a/src/include/cia.h b/src/include/cia.h
index 3f1d0035..4d838469 100644
--- a/src/include/cia.h
+++ b/src/include/cia.h
@@ -1,30 +1,35 @@
- /*
- * UAE - The Un*x Amiga Emulator
- *
- * CIA chip support
- *
- * (c) 1995 Bernd Schmidt
- */
+/*
+ * UAE - The Un*x Amiga Emulator
+ *
+ * CIA chip support
+ *
+ * (c) 1995 Bernd Schmidt
+ */
-#ifndef UAE_CIA_H
-#define UAE_CIA_H
+#pragma once
+extern void CIA_reset(void);
+extern void CIA_vsync_prehandler(void);
+extern void CIA_hsync_prehandler(void);
+extern void CIA_hsync_posthandler(bool, bool);
+extern void CIA_handler(void);
+extern void CIAA_tod_inc(int);
+extern void CIAB_tod_handler(int);
-#include "uae/types.h"
+extern void diskindex_handler(void);
+extern void cia_parallelack(void);
+extern void cia_diskindex(void);
-extern void CIA_reset (void);
-extern void CIA_vsync_prehandler (void);
-extern void CIA_hsync_posthandler (bool);
-extern void CIA_handler (void);
-extern void CIAA_tod_handler (uae_u32);
-extern void CIAB_tod_inc_event (uae_u32);
-extern void CIAA_tod_inc (int);
-extern void CIAB_tod_handler (int);
+extern void dumpcia(void);
+extern void rethink_cias(void);
+extern int resetwarning_do(int);
+extern void cia_set_overlay(bool);
+void cia_heartbeat(void);
-extern void cia_diskindex (void);
-
-extern void rethink_cias (void);
-extern void cia_set_overlay (bool);
+extern int parallel_direct_write_data(uae_u8, uae_u8);
+extern int parallel_direct_read_data(uae_u8*);
+extern int parallel_direct_write_status(uae_u8, uae_u8);
+extern int parallel_direct_read_status(uae_u8*);
extern void rtc_hardreset(void);
-#endif /* UAE_CIA_H */
+extern void keyboard_connected(bool);
diff --git a/src/include/custom.h b/src/include/custom.h
index 183a7824..3048717d 100644
--- a/src/include/custom.h
+++ b/src/include/custom.h
@@ -1,19 +1,18 @@
- /*
- * UAE - The Un*x Amiga Emulator
- *
- * custom chip support
- *
- * (c) 1995 Bernd Schmidt
- */
+/*
+* UAE - The Un*x Amiga Emulator
+*
+* custom chip support
+*
+* (c) 1995 Bernd Schmidt
+*/
#ifndef UAE_CUSTOM_H
#define UAE_CUSTOM_H
-#include "uae/types.h"
#include "machdep/rpt.h"
/* These are the masks that are ORed together in the chipset_mask option.
- * If CSMASK_AGA is set, the ECS bits are guaranteed to be set as well. */
+* If CSMASK_AGA is set, the ECS bits are guaranteed to be set as well. */
#define CSMASK_ECS_AGNUS 1
#define CSMASK_ECS_DENISE 2
#define CSMASK_AGA 4
@@ -27,29 +26,41 @@
#define MAXVPOS_LINES_OCS 512
#define HPOS_SHIFT 3
-extern void set_speedup_values(void);
-extern int custom_init (void);
-extern void custom_prepare (void);
-extern void custom_reset (bool hardreset, bool keyboardreset);
-extern int intlev (void);
+uae_u32 get_copper_address(int copno);
-extern void do_copper (void);
+extern int custom_init(void);
+extern void custom_prepare(void);
+extern void custom_reset(bool hardreset, bool keyboardreset);
+extern int intlev(void);
+extern void dumpcustom(void);
-extern void notice_new_xcolors (void);
-extern void init_row_map (void);
-extern void init_hz_normal (void);
-extern void init_custom (void);
+extern void do_disk(void);
+extern void do_copper(void);
+
+extern void notice_new_xcolors(void);
+extern void notice_screen_contents_lost(void);
+extern void init_row_map(void);
+extern void init_hz_normal(void);
+extern void init_custom(void);
extern bool picasso_requested_on, picasso_requested_forced_on, picasso_on;
+extern void set_picasso_hack_rate(int hz);
-extern unsigned long int hsync_counter;
+/* Set to 1 to leave out the current frame in average frame time calculation.
+* Useful if the debugger was active. */
+extern int bogusframe;
+extern unsigned long int hsync_counter, vsync_counter;
extern uae_u16 dmacon;
-extern uae_u16 intreq;
+extern uae_u16 intena, intreq, intreqr;
-extern int vpos;
+extern int vpos, lof_store;
-STATIC_INLINE int dmaen (unsigned int dmamask)
+extern int find_copper_record(uaecptr, int *, int *);
+
+extern int n_frames;
+
+STATIC_INLINE int dmaen(unsigned int dmamask)
{
return (dmamask & dmacon) && (dmacon & 0x200);
}
@@ -74,22 +85,25 @@ STATIC_INLINE int dmaen (unsigned int dmamask)
extern uae_u16 adkcon;
-extern void INTREQ (uae_u16);
-extern bool INTREQ_0 (uae_u16);
-extern void INTREQ_f (uae_u16);
-STATIC_INLINE void send_interrupt (int num)
-{
- INTREQ_0 (0x8000 | (1 << num));
-}
+extern unsigned int joy0dir, joy1dir;
+extern int joy0button, joy1button;
+
+extern void INTREQ(uae_u16);
+extern bool INTREQ_0(uae_u16);
+extern void INTREQ_f(uae_u16);
+extern void send_interrupt(int num, int delay);
extern void rethink_uae_int(void);
-STATIC_INLINE uae_u16 INTREQR (void)
-{
- return intreq;
-}
+extern uae_u16 INTREQR(void);
/* maximums for statically allocated tables */
+#ifdef UAE_MINI
+/* absolute minimums for basic A500/A1200-emulation */
#define MAXHPOS 227
-#define MAXVPOS 314
+#define MAXVPOS 312
+#else
+#define MAXHPOS 256
+#define MAXVPOS 592
+#endif
/* PAL/NTSC values */
@@ -111,11 +125,14 @@ STATIC_INLINE uae_u16 INTREQR (void)
#define EQU_ENDLINE_PAL 8
#define EQU_ENDLINE_NTSC 10
-extern int maxhpos;
+extern int maxhpos, maxhpos_short;
extern int maxvpos, maxvpos_nom, maxvpos_display;
-extern int minfirstline;
-extern float vblank_hz, fake_vblank_hz;
-extern float hblank_hz;
+extern int hsyncstartpos, hsyncendpos;
+extern int minfirstline, vblank_endline, numscrlines;
+extern double vblank_hz, fake_vblank_hz;
+extern double hblank_hz;
+extern int vblank_skip, doublescan;
+extern bool programmedmode;
#define DMA_AUD0 0x0001
#define DMA_AUD1 0x0002
@@ -129,52 +146,99 @@ extern float hblank_hz;
#define DMA_MASTER 0x0200
#define DMA_BLITPRI 0x0400
-extern unsigned long timeframes;
+#define CYCLE_REFRESH 1
+#define CYCLE_STROBE 2
+#define CYCLE_MISC 3
+#define CYCLE_SPRITE 4
+#define CYCLE_COPPER 5
+#define CYCLE_BLITTER 6
+#define CYCLE_CPU 7
+#define CYCLE_CPUNASTY 8
+#define CYCLE_COPPER_SPECIAL 0x10
+
+#define CYCLE_MASK 0x0f
+
+extern unsigned long frametime, timeframes;
+extern uae_u16 htotal, vtotal, beamcon0;
/* 100 words give you 1600 horizontal pixels. Should be more than enough for
- * superhires. Don't forget to update the definition in genp2c.c as well.
- * needs to be larger for superhires support */
+* superhires. Don't forget to update the definition in genp2c.c as well.
+* needs to be larger for superhires support */
+#ifdef CUSTOM_SIMPLE
+#define MAX_WORDS_PER_LINE 50
+#else
#define MAX_WORDS_PER_LINE 100
+#endif
-#ifndef ARMV6_ASSEMBLY
+extern uae_u32 hirestab_h[256][2];
+extern uae_u32 lorestab_h[256][4];
+
+extern uae_u32 hirestab_l[256][1];
+extern uae_u32 lorestab_l[256][2];
+
+#ifdef AGA
/* AGA mode color lookup tables */
extern unsigned int xredcolors[256], xgreencolors[256], xbluecolors[256];
#endif
+extern int xredcolor_s, xredcolor_b, xredcolor_m;
+extern int xgreencolor_s, xgreencolor_b, xgreencolor_m;
+extern int xbluecolor_s, xbluecolor_b, xbluecolor_m;
#define RES_LORES 0
#define RES_HIRES 1
#define RES_SUPERHIRES 2
#define RES_MAX 2
+#define VRES_NONDOUBLE 0
+#define VRES_DOUBLE 1
+#define VRES_QUAD 2
+#define VRES_MAX 1
+
+/* calculate shift depending on resolution (replaced "decided_hires ? 4 : 8") */
+#define RES_SHIFT(res) ((res) == RES_LORES ? 8 : (res) == RES_HIRES ? 4 : 2)
/* get resolution from bplcon0 */
-STATIC_INLINE int GET_RES_DENISE (uae_u16 con0)
+STATIC_INLINE int GET_RES_DENISE(uae_u16 con0)
{
- if ((currprefs.chipset_mask & CSMASK_ECS_DENISE) && ((con0) & 0x40))
- return RES_SUPERHIRES; // SUPERHIRES
- return ((con0) & 0x8000) ? RES_HIRES : RES_LORES;
+ if (!(currprefs.chipset_mask & CSMASK_ECS_DENISE))
+ con0 &= ~0x40; // SUPERHIRES
+ return ((con0) & 0x40) ? RES_SUPERHIRES : ((con0) & 0x8000) ? RES_HIRES : RES_LORES;
}
-STATIC_INLINE int GET_RES_AGNUS (uae_u16 con0)
+STATIC_INLINE int GET_RES_AGNUS(uae_u16 con0)
{
- if ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) && ((con0) & 0x40))
- return RES_SUPERHIRES; // SUPERHIRES
- return ((con0) & 0x8000) ? RES_HIRES : RES_LORES;
+ if (!(currprefs.chipset_mask & CSMASK_ECS_AGNUS))
+ con0 &= ~0x40; // SUPERHIRES
+ return ((con0) & 0x40) ? RES_SUPERHIRES : ((con0) & 0x8000) ? RES_HIRES : RES_LORES;
}
/* get sprite width from FMODE */
#define GET_SPRITEWIDTH(FMODE) ((((FMODE) >> 2) & 3) == 3 ? 64 : (((FMODE) >> 2) & 3) == 0 ? 16 : 32)
/* Compute the number of bitplanes from a value written to BPLCON0 */
STATIC_INLINE int GET_PLANES(uae_u16 bplcon0)
{
- if ((bplcon0 & 0x0010) && (bplcon0 & 0x7000))
- return 0; // >8 planes = 0 planes
- if (bplcon0 & 0x0010)
- return 8; // AGA 8-planes bit
- return (bplcon0 >> 12) & 7; // normal planes bits
+ if ((bplcon0 & 0x0010) && (bplcon0 & 0x7000))
+ return 0; // >8 planes = 0 planes
+ if (bplcon0 & 0x0010)
+ return 8; // AGA 8-planes bit
+ return (bplcon0 >> 12) & 7; // normal planes bits
}
-extern void fpscounter_reset (void);
+extern void fpscounter_reset(void);
extern unsigned long idletime;
+extern int lightpen_x, lightpen_y, lightpen_cx, lightpen_cy, lightpen_active, lightpen_enabled;
-extern int current_maxvpos (void);
-extern struct chipset_refresh *get_chipset_refresh (void);
+struct customhack {
+ uae_u16 v;
+ int vpos, hpos;
+};
+void customhack_put(struct customhack *ch, uae_u16 v, int hpos);
+uae_u16 customhack_get(struct customhack *ch, int hpos);
+extern void alloc_cycle_ext(int, int);
+extern void alloc_cycle_blitter(int hpos, uaecptr *ptr, int);
+extern bool ispal(void);
+extern bool isvga(void);
+extern int current_maxvpos(void);
+extern struct chipset_refresh *get_chipset_refresh(void);
+extern void compute_framesync(void);
+extern void getsyncregisters(uae_u16 *phsstrt, uae_u16 *phsstop, uae_u16 *pvsstrt, uae_u16 *pvsstop);
+int is_bitplane_dma(int hpos);
#endif /* UAE_CUSTOM_H */
diff --git a/src/include/drawing.h b/src/include/drawing.h
index 7ab643bf..52311933 100644
--- a/src/include/drawing.h
+++ b/src/include/drawing.h
@@ -4,62 +4,81 @@
* Copyright 1996-1998 Bernd Schmidt
*/
-#ifndef UAE_DRAWING_H
-#define UAE_DRAWING_H
+#pragma once
+#define SMART_UPDATE 1
-#include "uae/types.h"
+#ifdef SUPPORT_PENGUINS
+#undef SMART_UPDATE
+#define SMART_UPDATE 1
+#endif
+#ifdef AGA
#define MAX_PLANES 8
+#else
+#define MAX_PLANES 6
+#endif
-/* According to the HRM, pixel data spends a couple of cycles somewhere in the chips
-before it appears on-screen. (TW: display emulation now does this automatically) */
+#ifdef AMIBERRY
+#define AMIGA_WIDTH_MAX (640 / 2)
+#define AMIGA_HEIGHT_MAX (512 / 2)
+#else
+#define AMIGA_WIDTH_MAX (752 / 2)
+#define AMIGA_HEIGHT_MAX (576 / 2)
+#endif
+
+ //#define NEWHSYNC
+
+#ifdef NEWHSYNC
+#define DIW_DDF_OFFSET 9
+ /* this many cycles starting from hpos=0 are visible on right border */
+#define HBLANK_OFFSET 13
+#define DISPLAY_LEFT_SHIFT 0x40
+#else
+ /* According to the HRM, pixel data spends a couple of cycles somewhere in the chips
+ before it appears on-screen. (TW: display emulation now does this automatically) */
#define DIW_DDF_OFFSET 1
-/* this many cycles starting from hpos=0 are visible on right border */
+ /* this many cycles starting from hpos=0 are visible on right border */
#define HBLANK_OFFSET 9
-/* We ignore that many lores pixels at the start of the display. These are
+ /* We ignore that many lores pixels at the start of the display. These are
* invisible anyway due to hardware DDF limits. */
#define DISPLAY_LEFT_SHIFT 0x38
+#endif
#define PIXEL_XPOS(HPOS) (((HPOS)*2 - DISPLAY_LEFT_SHIFT + DIW_DDF_OFFSET - 1) << lores_shift)
#define min_diwlastword (0)
-#define max_diwlastword (PIXEL_XPOS(0x1d4>> 1))
+#define max_diwlastword (PIXEL_XPOS(0x1d4 >> 1))
extern int lores_shift, interlace_seen;
-extern bool aga_mode;
+extern bool aga_mode, direct_rgb;
+extern int visible_left_border, visible_right_border;
+extern int detected_screen_resolution;
-STATIC_INLINE int shres_coord_hw_to_window_x (int x)
+STATIC_INLINE int coord_hw_to_window_x(int x)
{
- x -= DISPLAY_LEFT_SHIFT << 2;
- x <<= lores_shift;
- x >>= 2;
- return x;
-}
-
-STATIC_INLINE int coord_hw_to_window_x (int x)
-{
- x -= DISPLAY_LEFT_SHIFT;
+ x -= DISPLAY_LEFT_SHIFT;
return x << lores_shift;
}
-STATIC_INLINE int coord_window_to_hw_x (int x)
+STATIC_INLINE int coord_window_to_hw_x(int x)
{
x >>= lores_shift;
- return x + DISPLAY_LEFT_SHIFT;
+ return x + DISPLAY_LEFT_SHIFT;
}
-STATIC_INLINE int coord_diw_to_window_x (int x)
+STATIC_INLINE int coord_diw_to_window_x(int x)
{
return (x - DISPLAY_LEFT_SHIFT + DIW_DDF_OFFSET - 1) << lores_shift;
}
-STATIC_INLINE int coord_window_to_diw_x (int x)
+STATIC_INLINE int coord_window_to_diw_x(int x)
{
- x = coord_window_to_hw_x (x);
- return x - DIW_DDF_OFFSET;
+ x = coord_window_to_hw_x(x);
+ return x - DIW_DDF_OFFSET;
}
extern int framecnt;
+extern int custom_frame_redraw_necessary;
/* color values in two formats: 12 (OCS/ECS) or 24 (AGA) bit Amiga RGB (color_regs),
* and the native color value; both for each Amiga hardware color register.
@@ -67,6 +86,7 @@ extern int framecnt;
* !!! See color_reg_xxx functions below before touching !!!
*/
#define CE_BORDERBLANK 0
+#define CE_BORDERNTRANS 1
#define CE_BORDERSPRITE 2
#define CE_SHRES_DELAY 4
@@ -78,83 +98,83 @@ STATIC_INLINE bool ce_is_bordersprite(uae_u8 data)
{
return (data & (1 << CE_BORDERSPRITE)) != 0;
}
+STATIC_INLINE bool ce_is_borderntrans(uae_u8 data)
+{
+ return (data & (1 << CE_BORDERNTRANS)) != 0;
+}
struct color_entry {
- uae_u16 color_regs_ecs[32];
- xcolnr acolors[256];
- uae_u32 color_regs_aga[256];
+ uae_u16 color_regs_ecs[32];
+#ifndef AGA
+ xcolnr acolors[32];
+#else
+ xcolnr acolors[256];
+ uae_u32 color_regs_aga[256];
+#endif
uae_u8 extra;
};
+#ifdef AGA
/* convert 24 bit AGA Amiga RGB to native color */
-#ifdef ARMV6_ASSEMBLY
-STATIC_INLINE uae_u32 CONVERT_RGB(uae_u32 c)
-{
- uae_u32 ret;
- __asm__ (
- "ubfx r1, %[c], #19, #5 \n\t"
- "ubfx r2, %[c], #10, #6 \n\t"
- "ubfx %[v], %[c], #3, #5 \n\t"
- "orr %[v], %[v], r1, lsl #11 \n\t"
- "orr %[v], %[v], r2, lsl #5 \n\t"
- "pkhbt %[v], %[v], %[v], lsl #16 \n\t"
- : [v] "=r" (ret) : [c] "r" (c) : "r1", "r2" );
- return ret;
-}
-STATIC_INLINE uae_u16 CONVERT_RGB_16(uae_u32 c)
-{
- uae_u16 ret;
- __asm__ (
- "ubfx r1, %[c], #19, #5 \n\t"
- "ubfx r2, %[c], #10, #6 \n\t"
- "ubfx %[v], %[c], #3, #5 \n\t"
- "orr %[v], %[v], r1, lsl #11 \n\t"
- "orr %[v], %[v], r2, lsl #5 \n\t"
- : [v] "=r" (ret) : [c] "r" (c) : "r1", "r2" );
- return ret;
-}
-#else
-#define CONVERT_RGB(c) \
- ( xbluecolors[((uae_u8*)(&c))[0]] | xgreencolors[((uae_u8*)(&c))[1]] | xredcolors[((uae_u8*)(&c))[2]] )
-#define CONVERT_RGB_16(c) \
- ( xbluecolors[((uae_u8*)(&c))[0]] | xgreencolors[((uae_u8*)(&c))[1]] | xredcolors[((uae_u8*)(&c))[2]] )
+/* warning: this is still ugly, but now works with either byte order */
+# define CONVERT_RGB(c) \
+ ( xbluecolors[((uae_u8*)(&c))[0]] | xgreencolors[((uae_u8*)(&c))[1]] | xredcolors[((uae_u8*)(&c))[2]] )
#endif
-STATIC_INLINE xcolnr getxcolor (int c)
+STATIC_INLINE xcolnr getxcolor(int c)
{
- if (aga_mode)
+#ifdef AGA
+ if (direct_rgb)
return CONVERT_RGB(c);
else
+#endif
return xcolors[c];
}
/* functions for reading, writing, copying and comparing struct color_entry */
-STATIC_INLINE int color_reg_get (struct color_entry *ce, int c)
+STATIC_INLINE int color_reg_get(struct color_entry *ce, int c)
{
+#ifdef AGA
if (aga_mode)
return ce->color_regs_aga[c];
else
+#endif
return ce->color_regs_ecs[c];
}
-
-STATIC_INLINE void color_reg_set (struct color_entry *ce, int c, int v)
+STATIC_INLINE void color_reg_set(struct color_entry *ce, int c, int v)
{
+#ifdef AGA
if (aga_mode)
ce->color_regs_aga[c] = v;
else
+#endif
ce->color_regs_ecs[c] = v;
}
-
+STATIC_INLINE int color_reg_cmp(struct color_entry *ce1, struct color_entry *ce2)
+{
+ int v;
+#ifdef AGA
+ if (aga_mode)
+ v = memcmp(ce1->color_regs_aga, ce2->color_regs_aga, sizeof(uae_u32) * 256);
+ else
+#endif
+ v = memcmp(ce1->color_regs_ecs, ce2->color_regs_ecs, sizeof(uae_u16) * 32);
+ if (!v && ce1->extra == ce2->extra)
+ return 0;
+ return 1;
+}
/* ugly copy hack, is there better solution? */
-STATIC_INLINE void color_reg_cpy (struct color_entry *dst, struct color_entry *src)
+STATIC_INLINE void color_reg_cpy(struct color_entry *dst, struct color_entry *src)
{
dst->extra = src->extra;
- if (aga_mode)
- /* copy acolors and color_regs_aga */
- memcpy (dst->acolors, src->acolors, sizeof(struct color_entry) - sizeof(uae_u16) * 32);
- else
- /* copy first 32 acolors and color_regs_ecs */
- memcpy(dst->color_regs_ecs, src->color_regs_ecs, sizeof(uae_u16) * 32 + sizeof(xcolnr) * 32);
+#ifdef AGA
+ if (aga_mode)
+ /* copy acolors and color_regs_aga */
+ memcpy(dst->acolors, src->acolors, sizeof(struct color_entry) - sizeof(uae_u16) * 32);
+ else
+#endif
+ /* copy first 32 acolors and color_regs_ecs */
+ memcpy(dst->color_regs_ecs, src->color_regs_ecs, sizeof(struct color_entry));
}
/*
@@ -168,25 +188,30 @@ STATIC_INLINE void color_reg_cpy (struct color_entry *dst, struct color_entry *s
#define COLOR_CHANGE_BRDBLANK 0x80000000
#define COLOR_CHANGE_SHRES_DELAY 0x40000000
+#define COLOR_CHANGE_HSYNC_HACK 0x20000000
#define COLOR_CHANGE_MASK 0xf0000000
struct color_change {
- int linepos;
- int regno;
- unsigned int value;
+ int linepos;
+ int regno;
+ unsigned int value;
};
/* 440 rather than 880, since sprites are always lores. */
+#ifdef UAE_MINI
+#define MAX_PIXELS_PER_LINE 880
+#else
#define MAX_PIXELS_PER_LINE 1760
+#endif
-/* No divisors for MAX_PIXELS_PER_LINE; we support AGA and SHRES sprites */
-#define MAX_SPR_PIXELS (((MAXVPOS + 1)*2 + 1) * MAX_PIXELS_PER_LINE)
+/* No divisors for MAX_PIXELS_PER_LINE; we support AGA and SHRES sprites */
+#define MAX_SPR_PIXELS (((MAXVPOS + 1) * 2 + 1) * MAX_PIXELS_PER_LINE)
struct sprite_entry
{
- unsigned short pos;
- unsigned short max;
- unsigned int first_pixel;
- bool has_attached;
+ unsigned short pos;
+ unsigned short max;
+ unsigned int first_pixel;
+ bool has_attached;
};
union sps_union {
@@ -194,43 +219,44 @@ union sps_union {
uae_u32 words[2 * MAX_SPR_PIXELS / 4];
};
extern union sps_union spixstate;
-
extern uae_u16 spixels[MAX_SPR_PIXELS * 2];
/* Way too much... */
-#define MAX_REG_CHANGE ((MAXVPOS + 1) * MAXHPOS)
+#define MAX_REG_CHANGE ((MAXVPOS + 1) * 2 * MAXHPOS)
-extern struct color_entry curr_color_tables[(MAXVPOS + 2) * 2];
+extern struct color_entry *curr_color_tables, *prev_color_tables;
-extern struct sprite_entry *curr_sprite_entries;
-extern struct color_change *curr_color_changes;
-extern struct draw_info curr_drawinfo[2 * (MAXVPOS + 2) + 1];
+extern struct sprite_entry *curr_sprite_entries, *prev_sprite_entries;
+extern struct color_change *curr_color_changes, *prev_color_changes;
+extern struct draw_info *curr_drawinfo, *prev_drawinfo;
/* struct decision contains things we save across drawing frames for
* comparison (smart update stuff). */
struct decision {
- /* Records the leftmost access of BPL1DAT. */
- int plfleft, plfright, plflinelen;
- /* Display window: native coordinates, depend on lores state. */
- int diwfirstword, diwlastword;
- int ctable;
+ /* Records the leftmost access of BPL1DAT. */
+ int plfleft, plfright, plflinelen;
+ /* Display window: native coordinates, depend on lores state. */
+ int diwfirstword, diwlastword;
+ int ctable;
- uae_u16 bplcon0, bplcon2;
- uae_u16 bplcon3, bplcon4;
- uae_u8 nr_planes;
- uae_u8 bplres;
- bool ham_seen;
- bool ham_at_start;
+ uae_u16 bplcon0, bplcon2;
+#ifdef AGA
+ uae_u16 bplcon3, bplcon4;
+#endif
+ uae_u8 nr_planes;
+ uae_u8 bplres;
+ bool ehb_seen;
+ bool ham_seen;
+ bool ham_at_start;
bool bordersprite_seen;
- bool xor_seen;
};
/* Anything related to changes in hw registers during the DDF for one
* line. */
struct draw_info {
- int first_sprite_entry, last_sprite_entry;
- int first_color_change, last_color_change;
- int nr_color_changes, nr_sprites;
+ int first_sprite_entry, last_sprite_entry;
+ int first_color_change, last_color_change;
+ int nr_color_changes, nr_sprites;
};
extern struct decision line_decisions[2 * (MAXVPOS + 2) + 1];
@@ -238,34 +264,70 @@ extern struct decision line_decisions[2 * (MAXVPOS + 2) + 1];
extern uae_u8 line_data[(MAXVPOS + 2) * 2][MAX_PLANES * MAX_WORDS_PER_LINE * 2];
/* Functions in drawing.c. */
-extern int coord_native_to_amiga_y (int);
-extern int coord_native_to_amiga_x (int);
+extern int coord_native_to_amiga_y(int);
+extern int coord_native_to_amiga_x(int);
-extern void hsync_record_line_state (int lineno);
-extern void halt_draw_frame(void);
-extern void vsync_handle_redraw (void);
-extern bool vsync_handle_check (void);
-extern void init_hardware_for_drawing_frame (void);
-extern void reset_drawing (void);
-extern void drawing_init (void);
-extern bool notice_interlace_seen (bool);
-extern void check_prefs_picasso(void);
+extern void record_diw_line(int plfstrt, int first, int last);
+extern void hardware_line_completed(int lineno);
+
+/* Determine how to draw a scan line. */
+enum nln_how {
+ /* All lines on a non-doubled display. */
+ nln_normal,
+ /* Non-interlace, doubled display. */
+ nln_doubled,
+ /* Interlace, doubled display, upper line. */
+ nln_upper,
+ /* Interlace, doubled display, lower line. */
+ nln_lower,
+ /* This line normal, next one black. */
+ nln_nblack,
+ nln_upper_black,
+ nln_lower_black,
+ nln_upper_black_always,
+ nln_lower_black_always
+};
+
+extern void hsync_record_line_state(int lineno, enum nln_how, int changed);
+extern void vsync_handle_redraw(int long_field, int lof_changed, uae_u16, uae_u16);
+extern bool vsync_handle_check();
+extern void init_hardware_for_drawing_frame();
+extern void reset_drawing();
+extern void drawing_init();
+extern bool notice_interlace_seen(bool);
+extern void notice_resolution_seen(int, bool);
+extern void frame_drawn(void);
+extern void redraw_frame(void);
+extern bool draw_frame();
+extern int get_custom_limits(int *pw, int *ph, int *pdx, int *pdy, int *prealh);
+extern void store_custom_limits(int w, int h, int dx, int dy);
+extern void set_custom_limits(int w, int h, int dx, int dy);
+extern void get_custom_topedge(int *x, int *y, bool max);
+extern void get_custom_raw_limits(int *pw, int *ph, int *pdx, int *pdy);
+
+extern long time_per_frame;
/* Finally, stuff that shouldn't really be shared. */
+extern int thisframe_first_drawn_line, thisframe_last_drawn_line;
+
#define IHF_SCROLLLOCK 0
#define IHF_QUIT_PROGRAM 1
#define IHF_PICASSO 2
extern int inhibit_frame;
-STATIC_INLINE void set_inhibit_frame (int bit)
+STATIC_INLINE void set_inhibit_frame(int bit)
{
- inhibit_frame |= 1 << bit;
-}
-STATIC_INLINE void clear_inhibit_frame (int bit)
-{
- inhibit_frame &= ~(1 << bit);
+ inhibit_frame |= 1 << bit;
}
-#endif /* UAE_DRAWING_H */
+STATIC_INLINE void clear_inhibit_frame(int bit)
+{
+ inhibit_frame &= ~(1 << bit);
+}
+
+STATIC_INLINE void toggle_inhibit_frame(int bit)
+{
+ inhibit_frame ^= 1 << bit;
+}
diff --git a/src/include/events.h b/src/include/events.h
index 5a69b800..8e5f105b 100644
--- a/src/include/events.h
+++ b/src/include/events.h
@@ -1,3 +1,6 @@
+#ifndef EVENTS_H
+#define EVENTS_H
+
/*
* UAE - The Un*x Amiga Emulator
*
@@ -9,25 +12,27 @@
* Copyright 1995-1998 Bernd Schmidt
*/
-#ifndef UAE_EVENTS_H
-#define UAE_EVENTS_H
-
-#include "uae/types.h"
+#undef EVENT_DEBUG
#include "machdep/rpt.h"
extern frame_time_t vsyncmintime, vsyncmaxtime, vsyncwaittime;
extern int vsynctimebase, syncbase;
-extern void reset_frame_rate_hack (void);
+extern void reset_frame_rate_hack ();
+extern unsigned long int vsync_cycles;
+extern unsigned long start_cycles;
+extern int event2_count;
+extern bool event_wait;
extern int speedup_timelimit;
-extern void compute_vsynctime (void);
-extern void init_eventtab (void);
-extern void events_schedule (void);
+extern void compute_vsynctime ();
+extern void init_eventtab ();
+extern void events_schedule ();
extern unsigned long currcycle, nextevent;
-extern int is_syncline;
-typedef void (*evfunc)(void);
+extern int is_syncline, is_syncline_end;
+extern long last_synctime;
+typedef void (*evfunc)();
typedef void (*evfunc2)(uae_u32);
typedef void (*do_cycles_func)(unsigned long);
@@ -53,89 +58,98 @@ struct ev2
};
enum {
- ev_copper,
- ev_cia, ev_audio, ev_blitter, ev_dmal, ev_misc, ev_hsync,
- ev_max
+ ev_cia, ev_audio, ev_misc, ev_hsync,
+ ev_max
};
enum {
- ev2_disk, ev2_ciaa_tod, ev2_ciab_tod, ev2_disk_motor0, ev2_disk_motor1, ev2_disk_motor2, ev2_disk_motor3,
- ev2_max
+ ev2_blitter, ev2_disk, ev2_misc,
+ ev2_max = 12
};
extern int pissoff_value;
-#define countdown (regs.pissoff)
+extern uae_s32 pissoff;
+
+#define countdown (pissoff)
+//TODO: check and implement this
+//#define do_cycles do_cycles_slow
extern struct ev eventtab[ev_max];
extern struct ev2 eventtab2[ev2_max];
-STATIC_INLINE void cycles_do_special (void)
+extern volatile bool vblank_found_chipset;
+extern volatile bool vblank_found_rtg;
+extern int hpos_offset;
+extern int maxhpos;
+
+STATIC_INLINE void cycles_do_special ()
{
#ifdef JIT
if (currprefs.cachesize) {
- if (regs.pissoff >= 0)
- regs.pissoff = -1;
+ if (pissoff >= 0)
+ pissoff = -1;
} else
#endif
{
- regs.pissoff = 0;
+ pissoff = 0;
}
}
-STATIC_INLINE void do_extra_cycles (unsigned long cycles_to_add)
+STATIC_INLINE void do_extra_cycles(unsigned long cycles_to_add)
{
- regs.pissoff -= cycles_to_add;
+ pissoff -= cycles_to_add;
}
-STATIC_INLINE unsigned long int get_cycles (void)
+STATIC_INLINE unsigned long int get_cycles ()
{
return currcycle;
}
-STATIC_INLINE void set_cycles (unsigned long int x)
+STATIC_INLINE void set_cycles(unsigned long int x)
{
- currcycle = x;
+ currcycle = x;
eventtab[ev_hsync].oldcycles = x;
}
-STATIC_INLINE int current_hpos (void)
+STATIC_INLINE int current_hpos_safe(void)
{
- int hp = (get_cycles () - eventtab[ev_hsync].oldcycles) / CYCLE_UNIT;
+ int hp = (get_cycles() - eventtab[ev_hsync].oldcycles) / CYCLE_UNIT;
return hp;
}
-STATIC_INLINE bool cycles_in_range (unsigned long endcycles)
+extern int current_hpos(void);
+
+STATIC_INLINE bool cycles_in_range(unsigned long endcycles)
{
- signed long c = get_cycles ();
- return (signed long)endcycles - c > 0;
+ signed long c = get_cycles();
+ return static_cast(endcycles) - c > 0;
}
-extern void MISC_handler(void);
+extern void MISC_handler();
+extern void event2_newevent_xx(int no, evt t, uae_u32 data, evfunc2 func);
+extern void event2_newevent_x_replace(evt t, uae_u32 data, evfunc2 func);
-STATIC_INLINE void event2_newevent (int no, evt t, uae_u32 data)
+STATIC_INLINE void event2_newevent_x(int no, evt t, uae_u32 data, evfunc2 func)
{
- eventtab2[no].active = true;
- eventtab2[no].evtime = (t * CYCLE_UNIT) + get_cycles();
- eventtab2[no].data = data;
- MISC_handler();
+ if (int(t) <= 0) {
+ func(data);
+ return;
+ }
+ event2_newevent_xx(no, t * CYCLE_UNIT, data, func);
}
-STATIC_INLINE void event2_remevent (int no)
+STATIC_INLINE void event2_newevent(int no, evt t, uae_u32 data)
+{
+ event2_newevent_x(no, t, data, eventtab2[no].handler);
+}
+STATIC_INLINE void event2_newevent2(evt t, uae_u32 data, evfunc2 func)
+{
+ event2_newevent_x(-1, t, data, func);
+}
+
+STATIC_INLINE void event2_remevent(int no)
{
eventtab2[no].active = 0;
}
-STATIC_INLINE void event_newevent (int no, evt t)
-{
- evt ct = get_cycles();
- eventtab[no].active = true;
- eventtab[no].evtime = ct + t * CYCLE_UNIT;
- events_schedule();
-}
-
-STATIC_INLINE void event_remevent (int no)
-{
- eventtab[no].active = 0;
-}
-
-#endif /* UAE_EVENTS_H */
+#endif
diff --git a/src/include/filesys.h b/src/include/filesys.h
index f580e578..b7a5d825 100644
--- a/src/include/filesys.h
+++ b/src/include/filesys.h
@@ -1,4 +1,4 @@
- /*
+/*
* UAE - The Un*x Amiga Emulator
*
* Unix file system handler for AmigaDOS
@@ -6,43 +6,65 @@
* Copyright 1997 Bernd Schmidt
*/
-#ifndef UAE_FILESYS_H
-#define UAE_FILESYS_H
+#ifndef FILESYS_H
+#define FILESYS_H
-#include "uae/types.h"
-#include "traps.h"
+struct hardfilehandle;
+#define MAX_HDF_CACHE_BLOCKS 128
#define MAX_SCSI_SENSE 36
+struct hdf_cache
+{
+ bool valid;
+ uae_u8 *data;
+ uae_u64 block;
+ bool dirty;
+ int readcount;
+ int writecount;
+ time_t lastaccess;
+};
struct hardfiledata {
- uae_u64 virtsize; // virtual size
- uae_u64 physsize; // physical size (dynamic disk)
- uae_u64 offset;
+ uae_u64 virtsize; // virtual size
+ uae_u64 physsize; // physical size (dynamic disk)
+ uae_u64 offset;
struct uaedev_config_info ci;
- struct hardfilehandle *handle;
- int handle_valid;
- int dangerous;
- int flags;
- uae_u8 *cache;
- int cache_valid;
- uae_u64 cache_offset;
- TCHAR vendor_id[8 + 1];
- TCHAR product_id[16 + 1];
- TCHAR product_rev[4 + 1];
- /* geometry from possible RDSK block */
- int rdbcylinders;
- int rdbsectors;
- int rdbheads;
- uae_u8 *virtual_rdb;
- uae_u64 virtual_size;
- int unitnum;
- int byteswap;
- int adide;
- int hfd_type;
+ struct hardfilehandle *handle;
+ int handle_valid;
+ int dangerous;
+ int flags;
+ uae_u8 *cache;
+ int cache_valid;
+ uae_u64 cache_offset;
+ TCHAR vendor_id[8 + 1];
+ TCHAR product_id[16 + 1];
+ TCHAR product_rev[4 + 1];
+ /* geometry from possible RDSK block */
+ int rdbcylinders;
+ int rdbsectors;
+ int rdbheads;
+ uae_u8 *virtual_rdb;
+ uae_u64 virtual_size;
+ int unitnum;
+ int byteswap;
+ int adide;
+ int hfd_type;
- int drive_empty;
- TCHAR *emptyname;
+ uae_u8 *vhd_header;
+ uae_u32 vhd_bamoffset;
+ uae_u32 vhd_bamsize;
+ uae_u32 vhd_blocksize;
+ uae_u8 *vhd_sectormap;
+ uae_u64 vhd_sectormapblock;
+ uae_u32 vhd_bitmapsize;
+ uae_u64 vhd_footerblock;
+ void *chd_handle;
+
+ int drive_empty;
+ TCHAR *emptyname;
+
+ struct hdf_cache bcache[MAX_HDF_CACHE_BLOCKS];
uae_u8 scsi_sense[MAX_SCSI_SENSE];
struct uaedev_config_info delayedci;
@@ -51,20 +73,23 @@ struct hardfiledata {
bool unit_stopped;
};
+#define HFD_FLAGS_REALDRIVE 1
+#define HFD_FLAGS_REALDRIVEPARTITION 2
+
struct hd_hardfiledata {
- struct hardfiledata hfd;
- uae_u64 size;
- int cyls;
- int heads;
- int secspertrack;
- int cyls_def;
- int secspertrack_def;
- int heads_def;
- int ansi_version;
+ struct hardfiledata hfd;
+ uae_u64 size;
+ int cyls;
+ int heads;
+ int secspertrack;
+ int cyls_def;
+ int secspertrack_def;
+ int heads_def;
+ int ansi_version;
};
-#define HD_CONTROLLER_EXPANSION_MAX 50
-#define HD_CONTROLLER_NEXT_UNIT 200
+#define HD_CONTROLLER_EXPANSION_MAX 120
+#define HD_CONTROLLER_NEXT_UNIT 300
#define HD_CONTROLLER_TYPE_UAE 0
#define HD_CONTROLLER_TYPE_IDE_AUTO (HD_CONTROLLER_TYPE_UAE + 1)
@@ -83,35 +108,41 @@ struct hd_hardfiledata {
#define FILESYS_HARDFILE 1
#define FILESYS_HARDFILE_RDB 2
#define FILESYS_HARDDRIVE 3
+#define FILESYS_CD 4
+#define FILESYS_TAPE 5
#define MAX_FILESYSTEM_UNITS 30
struct uaedev_mount_info;
extern struct uaedev_mount_info options_mountinfo;
-extern struct hardfiledata *get_hardfile_data (int nr);
+extern struct hardfiledata* get_hardfile_data(int nr);
#define FILESYS_MAX_BLOCKSIZE 2048
-extern int hdf_open (struct hardfiledata *hfd);
-extern int hdf_open (struct hardfiledata *hfd, const TCHAR *altname);
-extern void hdf_close (struct hardfiledata *hfd);
-extern int hdf_read_rdb (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
-extern int hdf_read (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
-extern int hdf_write (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
-extern int get_native_path(TrapContext *ctx, uae_u32 lock, TCHAR *out);
-extern void hardfile_do_disk_change (struct uaedev_config_data *uci, bool insert);
-extern void hardfile_send_disk_change (struct hardfiledata *hfd, bool insert);
-extern int hardfile_media_change (struct hardfiledata *hfd, struct uaedev_config_info *ci, bool inserted, bool timer);
-extern int hardfile_added (struct uaedev_config_info *ci);
+extern int hdf_open(struct hardfiledata* hfd);
+extern int hdf_open(struct hardfiledata* hfd, const TCHAR* altname);
+extern void hdf_close(struct hardfiledata* hfd);
+extern int hdf_read_rdb(struct hardfiledata* hfd, void* buffer, uae_u64 offset, int len);
+extern int hdf_read(struct hardfiledata* hfd, void* buffer, uae_u64 offset, int len);
+extern int hdf_write(struct hardfiledata* hfd, void* buffer, uae_u64 offset, int len);
+extern int get_native_path(uae_u32 lock, TCHAR* out);
+extern void hardfile_do_disk_change(struct uaedev_config_data* uci, bool insert);
+extern void hardfile_send_disk_change(struct hardfiledata* hfd, bool insert);
+extern int hardfile_media_change(struct hardfiledata* hfd, struct uaedev_config_info* ci, bool inserted, bool timer);
-void hdf_hd_close(struct hd_hardfiledata *hfd);
-int hdf_hd_open(struct hd_hardfiledata *hfd);
+void hdf_hd_close(struct hd_hardfiledata* hfd);
+int hdf_hd_open(struct hd_hardfiledata* hfd);
-extern int hdf_open_target (struct hardfiledata *hfd, const TCHAR *name);
-extern void hdf_close_target (struct hardfiledata *hfd);
-extern int hdf_read_target (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
-extern int hdf_write_target (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
-extern void getchsgeometry (uae_u64 size, int *pcyl, int *phead, int *psectorspertrack);
-extern void getchsgeometry_hdf (struct hardfiledata *hfd, uae_u64 size, int *pcyl, int *phead, int *psectorspertrack);
-extern void getchspgeometry (uae_u64 total, int *pcyl, int *phead, int *psectorspertrack, bool idegeometry);
+extern int vhd_create(const TCHAR *name, uae_u64 size, uae_u32);
-#endif /* UAE_FILESYS_H */
+extern int hdf_init_target();
+extern int hdf_open_target(struct hardfiledata *hfd, const TCHAR *name);
+extern int hdf_dup_target(struct hardfiledata *dhfd, const struct hardfiledata *shfd);
+extern void hdf_close_target(struct hardfiledata *hfd);
+extern int hdf_read_target(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
+extern int hdf_write_target(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
+extern int hdf_resize_target(struct hardfiledata *hfd, uae_u64 newsize);
+extern void getchsgeometry(uae_u64 size, int *pcyl, int *phead, int *psectorspertrack);
+extern void getchsgeometry_hdf(struct hardfiledata *hfd, uae_u64 size, int *pcyl, int *phead, int *psectorspertrack);
+extern void getchspgeometry(uae_u64 total, int *pcyl, int *phead, int *psectorspertrack, bool idegeometry);
+
+#endif /* MEMORY_H */
diff --git a/src/include/gfxboard.h b/src/include/gfxboard.h
index 6d0ef890..f9e850b2 100644
--- a/src/include/gfxboard.h
+++ b/src/include/gfxboard.h
@@ -1,12 +1,89 @@
-#ifndef UAE_GFXBOARD_H
-#define UAE_GFXBOARD_H
-extern int gfxboard_get_configtype (struct rtgboardconfig*);
+#pragma once
+#include "picasso96.h"
+
+extern bool gfxboard_init_memory(struct autoconfig_info*);
+extern bool gfxboard_init_memory_p4_z2(struct autoconfig_info*);
+extern bool gfxboard_init_registers(struct autoconfig_info*);
+extern void gfxboard_free(void);
+extern void gfxboard_reset(void);
+extern bool gfxboard_vsync_handler(bool);
+extern void gfxboard_hsync_handler(void);
+extern int gfxboard_get_configtype(struct rtgboardconfig*);
+extern bool gfxboard_is_registers(struct rtgboardconfig*);
+extern int gfxboard_get_vram_min(struct rtgboardconfig*);
+extern int gfxboard_get_vram_max(struct rtgboardconfig*);
+extern bool gfxboard_need_byteswap(struct rtgboardconfig*);
+extern int gfxboard_get_autoconfig_size(struct rtgboardconfig*);
+extern double gfxboard_get_vsync(void);
+extern void gfxboard_refresh(void);
+extern int gfxboard_toggle(int mode, int msg);
+extern int gfxboard_num_boards(struct rtgboardconfig*);
+extern uae_u32 gfxboard_get_romtype(struct rtgboardconfig*);
extern const TCHAR *gfxboard_get_name(int);
+extern const TCHAR *gfxboard_get_manufacturername(int);
extern const TCHAR *gfxboard_get_configname(int);
+extern struct gfxboard_func *gfxboard_get_func(struct rtgboardconfig *rbc);
+
+extern bool gfxboard_allocate_slot(int, int);
+extern void gfxboard_free_slot(int);
+extern bool gfxboard_rtg_enable_initial(int);
+extern void gfxboard_rtg_disable(int);
+extern bool gfxboard_init_board(struct autoconfig_info*);
+
+extern struct gfxboard_func a2410_func;
+extern struct gfxboard_func harlequin_func;
+
+extern void vga_io_put(int board, int portnum, uae_u8 v);
+extern uae_u8 vga_io_get(int board, int portnum);
+extern void vga_ram_put(int board, int offset, uae_u8 v);
+extern uae_u8 vga_ram_get(int board, int offset);
+
+void gfxboard_get_a8_vram(int index);
+void gfxboard_free_vram(int index);
+
+int gfxboard_get_devnum(struct uae_prefs *p, int index);
#define GFXBOARD_UAE_Z2 0
#define GFXBOARD_UAE_Z3 1
#define GFXBOARD_HARDWARE 2
-#endif /* UAE_GFXBOARD_H */
+#define GFXBOARD_PICASSO2 2
+#define GFXBOARD_PICASSO2PLUS 3
+#define GFXBOARD_PICCOLO_Z2 4
+#define GFXBOARD_PICCOLO_Z3 5
+#define GFXBOARD_SD64_Z2 6
+#define GFXBOARD_SD64_Z3 7
+#define GFXBOARD_SPECTRUM_Z2 8
+#define GFXBOARD_SPECTRUM_Z3 9
+#define GFXBOARD_PICASSO4_Z2 10
+#define GFXBOARD_PICASSO4_Z3 11
+#define GFXBOARD_A2410 12
+#define GFXBOARD_VGA 13
+
+struct gfxboard_mode
+{
+ int width;
+ int height;
+ RGBFTYPE mode;
+ bool redraw_required;
+};
+
+typedef bool(*GFXBOARD_INIT)(struct autoconfig_info*);
+typedef void(*GFXBOARD_FREE)(void*);
+typedef void(*GFXBOARD_RESET)(void*);
+typedef void(*GFXBOARD_HSYNC)(void*);
+typedef bool(*GFXBOARD_VSYNC)(void*, struct gfxboard_mode*);
+typedef bool(*GFXBOARD_TOGGLE)(void*, int);
+typedef void(*GFXBOARD_CONFIGURED)(void*, uae_u32);
+
+struct gfxboard_func
+{
+ GFXBOARD_INIT init;
+ GFXBOARD_FREE free;
+ GFXBOARD_RESET reset;
+ GFXBOARD_HSYNC hsync;
+ GFXBOARD_VSYNC vsync;
+ GFXBOARD_TOGGLE toggle;
+ GFXBOARD_CONFIGURED configured;
+};
\ No newline at end of file
diff --git a/src/include/inputdevice.h b/src/include/inputdevice.h
index 3ee7dc95..b3f03e0b 100644
--- a/src/include/inputdevice.h
+++ b/src/include/inputdevice.h
@@ -7,11 +7,7 @@
* Copyright 2001-2002 Toni Wilen
*/
-#ifndef UAE_INPUTDEVICE_H
-#define UAE_INPUTDEVICE_H
-
-#include "uae/types.h"
-
+#pragma once
#define DIR_LEFT_BIT 0
#define DIR_RIGHT_BIT 1
#define DIR_UP_BIT 2
@@ -35,7 +31,8 @@
#define IDTYPE_JOYSTICK 0
#define IDTYPE_MOUSE 1
#define IDTYPE_KEYBOARD 2
-#define IDTYPE_MAX 3
+#define IDTYPE_INTERNALEVENT 3
+#define IDTYPE_MAX 4
struct inputdevice_functions {
int (*init)(void);
@@ -44,8 +41,8 @@ struct inputdevice_functions {
void (*unacquire)(int);
void (*read)(void);
int (*get_num)(void);
- const TCHAR* (*get_friendlyname)(int);
- const TCHAR* (*get_uniquename)(int);
+ const char* (*get_friendlyname)(int);
+ const char* (*get_uniquename)(int);
int (*get_widget_num)(int);
int (*get_widget_type)(int,int,TCHAR*,uae_u32*);
int (*get_widget_first)(int,int);
@@ -54,6 +51,7 @@ struct inputdevice_functions {
extern struct inputdevice_functions inputdevicefunc_joystick;
extern struct inputdevice_functions inputdevicefunc_mouse;
extern struct inputdevice_functions inputdevicefunc_keyboard;
+extern int pause_emulation;
struct uae_input_device_default_node
{
@@ -69,12 +67,10 @@ struct uae_input_device_kbr_default {
struct inputevent {
const TCHAR *confname;
const TCHAR *name;
- const TCHAR *shortname;
int allow_mask;
int type;
int unit;
int data;
- int portid;
};
#define MAX_INPUT_QUALIFIERS (8 + 5)
@@ -93,23 +89,23 @@ struct inputevent {
#define ID_FLAG_GAMEPORTSCUSTOM_MASK (ID_FLAG_GAMEPORTSCUSTOM1 | ID_FLAG_GAMEPORTSCUSTOM2)
#define ID_FLAG_AUTOFIRE_MASK (ID_FLAG_TOGGLE | ID_FLAG_INVERTTOGGLE | ID_FLAG_AUTOFIRE)
-#define ID_FLAG_QUALIFIER1 0x000000100000000ULL
-#define ID_FLAG_QUALIFIER1_R 0x000000200000000ULL
-#define ID_FLAG_QUALIFIER2 0x000000400000000ULL
-#define ID_FLAG_QUALIFIER3 0x000001000000000ULL
-#define ID_FLAG_QUALIFIER4 0x000004000000000ULL
-#define ID_FLAG_QUALIFIER5 0x000010000000000ULL
-#define ID_FLAG_QUALIFIER6 0x000040000000000ULL
-#define ID_FLAG_QUALIFIER7 0x000100000000000ULL
-#define ID_FLAG_QUALIFIER8 0x000400000000000ULL
-#define ID_FLAG_QUALIFIER_SPECIAL 0x001000000000000ULL
-#define ID_FLAG_QUALIFIER_SPECIAL_R 0x002000000000000ULL
-#define ID_FLAG_QUALIFIER_SHIFT 0x004000000000000ULL
-#define ID_FLAG_QUALIFIER_CONTROL 0x010000000000000ULL
-#define ID_FLAG_QUALIFIER_ALT 0x040000000000000ULL
-#define ID_FLAG_QUALIFIER_WIN 0x100000000000000ULL
-#define ID_FLAG_QUALIFIER_MASK 0xfffffff00000000ULL
-#define ID_FLAG_QUALIFIER_MASK_R 0xaaaaaaa00000000ULL
+#define ID_FLAG_QUALIFIER1 0x000000100000000
+#define ID_FLAG_QUALIFIER1_R 0x000000200000000
+#define ID_FLAG_QUALIFIER2 0x000000400000000
+#define ID_FLAG_QUALIFIER3 0x000001000000000
+#define ID_FLAG_QUALIFIER4 0x000004000000000
+#define ID_FLAG_QUALIFIER5 0x000010000000000
+#define ID_FLAG_QUALIFIER6 0x000040000000000
+#define ID_FLAG_QUALIFIER7 0x000100000000000
+#define ID_FLAG_QUALIFIER8 0x000400000000000
+#define ID_FLAG_QUALIFIER_SPECIAL 0x001000000000000
+#define ID_FLAG_QUALIFIER_SPECIAL_R 0x002000000000000
+#define ID_FLAG_QUALIFIER_SHIFT 0x004000000000000
+#define ID_FLAG_QUALIFIER_CONTROL 0x010000000000000
+#define ID_FLAG_QUALIFIER_ALT 0x040000000000000
+#define ID_FLAG_QUALIFIER_WIN 0x100000000000000
+#define ID_FLAG_QUALIFIER_MASK 0xfffffff00000000
+#define ID_FLAG_QUALIFIER_MASK_R 0xaaaaaaa00000000
#define ID_FLAG_SAVE_MASK_CONFIG 0x000001ff
#define ID_FLAG_SAVE_MASK_QUALIFIERS ID_FLAG_QUALIFIER_MASK
@@ -131,33 +127,28 @@ struct inputevent {
#define IDEV_MAPPED_SET_ONOFF 128
#define IDEV_MAPPED_SET_ONOFF_VAL 256
-#define IDEV_MAPPED_QUALIFIER1 0x000000100000000ULL
-#define IDEV_MAPPED_QUALIFIER2 0x000000400000000ULL
-#define IDEV_MAPPED_QUALIFIER3 0x000001000000000ULL
-#define IDEV_MAPPED_QUALIFIER4 0x000004000000000ULL
-#define IDEV_MAPPED_QUALIFIER5 0x000010000000000ULL
-#define IDEV_MAPPED_QUALIFIER6 0x000040000000000ULL
-#define IDEV_MAPPED_QUALIFIER7 0x000100000000000ULL
-#define IDEV_MAPPED_QUALIFIER8 0x000400000000000ULL
-#define IDEV_MAPPED_QUALIFIER_SPECIAL 0x001000000000000ULL
-#define IDEV_MAPPED_QUALIFIER_SHIFT 0x004000000000000ULL
-#define IDEV_MAPPED_QUALIFIER_CONTROL 0x010000000000000ULL
-#define IDEV_MAPPED_QUALIFIER_ALT 0x040000000000000ULL
-#define IDEV_MAPPED_QUALIFIER_WIN 0x100000000000000ULL
-#define IDEV_MAPPED_QUALIFIER_MASK 0xfffffff00000000ULL
+#define IDEV_MAPPED_QUALIFIER1 0x000000100000000
+#define IDEV_MAPPED_QUALIFIER2 0x000000400000000
+#define IDEV_MAPPED_QUALIFIER3 0x000001000000000
+#define IDEV_MAPPED_QUALIFIER4 0x000004000000000
+#define IDEV_MAPPED_QUALIFIER5 0x000010000000000
+#define IDEV_MAPPED_QUALIFIER6 0x000040000000000
+#define IDEV_MAPPED_QUALIFIER7 0x000100000000000
+#define IDEV_MAPPED_QUALIFIER8 0x000400000000000
+#define IDEV_MAPPED_QUALIFIER_SPECIAL 0x001000000000000
+#define IDEV_MAPPED_QUALIFIER_SHIFT 0x004000000000000
+#define IDEV_MAPPED_QUALIFIER_CONTROL 0x010000000000000
+#define IDEV_MAPPED_QUALIFIER_ALT 0x040000000000000
+#define IDEV_MAPPED_QUALIFIER_WIN 0x100000000000000
+#define IDEV_MAPPED_QUALIFIER_MASK 0xfffffff00000000
#define SET_ONOFF_ON_VALUE 0x7fffff01
#define SET_ONOFF_OFF_VALUE 0x7fffff00
#define ID_BUTTON_OFFSET 0
-#define ID_BUTTON_TOTAL 128
-#define ID_AXIS_OFFSET 128
-#define ID_AXIS_TOTAL 64
-
-//#define ID_BUTTON_OFFSET 0
-//#define ID_BUTTON_TOTAL 32
-//#define ID_AXIS_OFFSET 32
-//#define ID_AXIS_TOTAL 32
+#define ID_BUTTON_TOTAL 32
+#define ID_AXIS_OFFSET 32
+#define ID_AXIS_TOTAL 32
#define MAX_COMPA_INPUTLIST 30
@@ -176,74 +167,88 @@ struct inputevent {
#define AM_KK (AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT)
#define AM_KT (AM_K|AM_SETTOGGLE)
-extern int inputdevice_iterate (int devnum, int num, TCHAR *name, int *af);
-extern bool inputdevice_set_gameports_mapping (struct uae_prefs *prefs, int devnum, int num, int evtnum, uae_u64 flags, int port, int input_selected_setting);
-extern int inputdevice_set_mapping (int devnum, int num, const TCHAR *name, TCHAR *custom, uae_u64 flags, int port, int sub);
-extern int inputdevice_get_mapping (int devnum, int num, uae_u64 *pflags, int *port, TCHAR *name, TCHAR *custom, int sub);
-extern void inputdevice_copyconfig (struct uae_prefs *src, struct uae_prefs *dst);
-extern void inputdevice_copy_single_config (struct uae_prefs *p, int src, int dst, int devnum, int selectedwidget);
-extern void inputdevice_copyjports(struct uae_prefs *srcprefs, struct uae_prefs *dstprefs);
-extern void inputdevice_swap_ports (struct uae_prefs *p, int devnum);
-extern void inputdevice_swap_compa_ports (struct uae_prefs *p, int portswap);
-extern void inputdevice_config_change (void);
-extern int inputdevice_config_change_test (void);
-extern int inputdevice_get_device_index (int devnum);
-extern const TCHAR *inputdevice_get_device_name (int type, int devnum);
-extern const TCHAR *inputdevice_get_device_name2 (int devnum);
-extern const TCHAR *inputdevice_get_device_unique_name (int type, int devnum);
-extern int inputdevice_get_device_status (int devnum);
-extern void inputdevice_set_device_status (int devnum, int enabled);
-extern int inputdevice_get_device_total (int type);
-extern int inputdevice_get_widget_num (int devnum);
-extern int inputdevice_get_widget_type (int devnum, int num, TCHAR *name, bool inccode);
+extern int inputdevice_iterate(int devnum, int num, TCHAR *name, int *af);
+extern bool inputdevice_set_gameports_mapping(struct uae_prefs *prefs, int devnum, int num, int evtnum, uae_u64 flags, int port, int input_selected_setting);
+extern int inputdevice_set_mapping(int devnum, int num, const TCHAR *name, TCHAR *custom, uae_u64 flags, int port, int sub);
+extern int inputdevice_get_mapping(int devnum, int num, uae_u64 *pflags, int *port, TCHAR *name, TCHAR *custom, int sub);
+extern void inputdevice_copyconfig(const struct uae_prefs *src, struct uae_prefs *dst);
+extern void inputdevice_copy_single_config(struct uae_prefs *p, int src, int dst, int devnum, int selectedwidget);
+extern void inputdevice_swap_ports(struct uae_prefs *p, int devnum);
+extern void inputdevice_swap_compa_ports(struct uae_prefs *p, int portswap);
+extern void inputdevice_config_change(void);
+extern int inputdevice_config_change_test(void);
+extern int inputdevice_get_device_index(int devnum);
+extern const char* inputdevice_get_device_name(int type, int devnum);
+extern const char* inputdevice_get_device_name2(int devnum);
+extern const char* inputdevice_get_device_unique_name(int type, int devnum);
+extern int inputdevice_get_device_status(int devnum);
+extern void inputdevice_set_device_status(int devnum, int enabled);
+extern int inputdevice_get_device_total(int type);
+extern int inputdevice_get_widget_num(int devnum);
+extern int inputdevice_get_widget_type(int devnum, int num, TCHAR *name);
-extern int input_get_default_mouse (struct uae_input_device *uid, int num, int port, int af, bool gp, bool wheel, bool joymouseswap);
-extern int input_get_default_joystick (struct uae_input_device *uid, int num, int port, int af, int mode, bool gp, bool joymouseswap);
-extern int input_get_default_joystick_analog (struct uae_input_device *uid, int num, int port, int af, bool gp, bool joymouseswap);
-extern int input_get_default_keyboard (int num);
+extern int input_get_default_mouse(struct uae_input_device *uid, int num, int port, int af, bool gp, bool wheel, bool joymouseswap);
+extern int input_get_default_lightpen(struct uae_input_device *uid, int num, int port, int af, bool gp, bool joymouseswap);
+extern int input_get_default_joystick(struct uae_input_device *uid, int num, int port, int af, int mode, bool gp, bool joymouseswap);
+extern int input_get_default_joystick_analog(struct uae_input_device *uid, int num, int port, int af, bool gp, bool joymouseswap);
+extern int input_get_default_keyboard(int num);
#define DEFEVENT(A, B, C, D, E, F) INPUTEVENT_ ## A,
-#define DEFEVENT2(A, B, B2, C, D, E, F, G) INPUTEVENT_ ## A,
enum inputevents {
INPUTEVENT_ZERO,
-#include "../inputevents.def"
+#include "inputevents.def"
INPUTEVENT_END
};
#undef DEFEVENT
-#undef DEFEVENT2
extern void handle_cd32_joystick_cia (uae_u8, uae_u8);
extern uae_u8 handle_parport_joystick (int port, uae_u8 pra, uae_u8 dra);
extern uae_u8 handle_joystick_buttons (uae_u8, uae_u8);
-extern int inputdevice_is_tablet (void);
-extern int input_mousehack_status(TrapContext *ctx, int mode, uaecptr diminfo, uaecptr dispinfo, uaecptr vp, uae_u32 moffset);
-extern void input_mousehack_mouseoffset (uaecptr pointerprefs);
-extern void mousehack_wakeup(void);
+#define MAGICMOUSE_BOTH 0
+#define MAGICMOUSE_NATIVE_ONLY 1
+#define MAGICMOUSE_HOST_ONLY 2
-extern void setjoybuttonstate (int joy, int button, int state);
-extern void setmousebuttonstate (int mouse, int button, int state);
-extern void setjoystickstate (int joy, int axle, int state, int max);
-extern int getjoystickstate (int mouse);
-void setmousestate (int mouse, int axis, int data, int isabs);
-extern int getmousestate (int mouse);
-extern void inputdevice_updateconfig (struct uae_prefs *srcprefs, struct uae_prefs *dstprefs);
-extern void inputdevice_updateconfig_internal (struct uae_prefs *srcprefs, struct uae_prefs *dstprefs);
+extern int magicmouse_alive(void);
+extern int is_tablet(void);
+extern int inputdevice_is_tablet(void);
+extern int inputdevice_is_tablet (void);
+extern int input_mousehack_status (int mode, uaecptr diminfo, uaecptr dispinfo, uaecptr vp, uae_u32 moffset);
+extern void input_mousehack_mouseoffset (uaecptr pointerprefs);
+extern int mousehack_alive(void);
+extern void setmouseactive(int);
+extern bool ismouseactive(void);
+
+extern void setmousebuttonstateall(int mouse, uae_u32 buttonbits, uae_u32 buttonmask);
+extern void setjoybuttonstateall(int joy, uae_u32 buttonbits, uae_u32 buttonmask);
+extern void setjoybuttonstate(int joy, int button, int state);
+extern void setmousebuttonstate(int mouse, int button, int state);
+extern void setjoystickstate(int joy, int axle, int state, int max);
+extern int getjoystickstate(int mouse);
+void setmousestate(int mouse, int axis, int data, int isabs);
+extern int getmousestate(int mouse);
+extern void inputdevice_updateconfig(const struct uae_prefs *srcprefs, struct uae_prefs *dstprefs);
+extern void inputdevice_updateconfig_internal(const struct uae_prefs *srcprefs, struct uae_prefs *dstprefs);
extern void inputdevice_devicechange (struct uae_prefs *prefs);
+#define INTERNALEVENT_CPURESET 0
+#define INTERNALEVENT_KBRESET 1
+
+extern void send_internalevent (int eventid);
+
extern int inputdevice_translatekeycode (int keyboard, int scancode, int state);
extern void inputdevice_checkqualifierkeycode (int keyboard, int scancode, int state);
extern void inputdevice_setkeytranslation (struct uae_input_device_kbr_default **trans, int **kbmaps);
extern void inputdevice_do_keyboard (int code, int state);
extern int inputdevice_iskeymapped (int keyboard, int scancode);
+extern int inputdevice_synccapslock(int, int*);
extern int inputdevice_get_compatibility_input (struct uae_prefs*, int index, int *typelist, int *inputlist, const int **at);
-extern const struct inputevent *inputdevice_get_eventinfo (int evt);
+extern struct inputevent *inputdevice_get_eventinfo (int evt);
extern bool inputdevice_get_eventname (const struct inputevent *ie, TCHAR *out);
extern void inputdevice_compa_prepare_custom (struct uae_prefs *prefs, int index, int mode, bool removeold);
extern void inputdevice_compa_clear (struct uae_prefs *prefs, int index);
extern int intputdevice_compa_get_eventtype (int evt, const int **axistable);
extern void inputdevice_sparecopy (struct uae_input_device *uid, int num, int sub);
-extern void inputdevice_forget_unplugged_device(int portnum);
extern uae_u16 potgo_value;
extern uae_u16 POTGOR (void);
@@ -262,12 +267,12 @@ extern void inputdevice_reset (void);
extern void write_inputdevice_config (struct uae_prefs *p, struct zfile *f);
extern void read_inputdevice_config (struct uae_prefs *p, const TCHAR *option, TCHAR *value);
-extern void reset_inputdevice_config (struct uae_prefs *pr, bool reset);
-extern int inputdevice_joyport_config(struct uae_prefs *p, const TCHAR *value1, const TCHAR *value2, int portnum, int mode, int type, bool candefault);
-extern void inputdevice_joyport_config_store(struct uae_prefs *p, const TCHAR *value, int portnum, int mode, int type);
+extern void reset_inputdevice_config (struct uae_prefs *pr);
+extern void store_inputdevice_config (struct uae_prefs *pr);
+extern void restore_inputdevice_config (struct uae_prefs *p, int portnum);
+extern int inputdevice_joyport_config (struct uae_prefs *p, const TCHAR *value, int portnum, int mode, int type, bool validate);
extern int inputdevice_getjoyportdevice (int port, int val);
-extern void inputdevice_validate_jports (struct uae_prefs *p, int changedport, bool *fixedports);
-extern void inputdevice_fix_prefs(struct uae_prefs *p, bool userconfig);
+extern void inputdevice_validate_jports (struct uae_prefs *p, int changedport);
extern void inputdevice_init (void);
extern void inputdevice_close (void);
@@ -275,15 +280,25 @@ extern void inputdevice_default_prefs (struct uae_prefs *p);
extern void inputdevice_acquire (int allmode);
extern void inputdevice_unacquire (void);
-extern void inputdevice_unacquire(bool emulationactive, int inputmask);
+
+extern void indicator_leds(int num, int state);
+
+extern void warpmode(int mode);
+extern void pausemode(int mode);
extern void inputdevice_add_inputcode (int code, int state);
extern void inputdevice_handle_inputcode (void);
-extern void inputdevice_tablet_strobe (void);
+extern void inputdevice_tablet(int x, int y, int z,
+ int pressure, uae_u32 buttonbits, int inproximity,
+ int ax, int ay, int az);
+extern void inputdevice_tablet_info(int maxx, int maxy, int maxz, int maxax, int maxay, int maxaz, int xres, int yres);
+extern void inputdevice_tablet_strobe(void);
extern uae_u64 input_getqualifiers (void);
+extern void setsystime (void);
+
#define JSEM_MODE_DEFAULT 0
#define JSEM_MODE_WHEELMOUSE 1
#define JSEM_MODE_MOUSE 2
@@ -303,6 +318,7 @@ extern uae_u64 input_getqualifiers (void);
#define JSEM_ISNUMPAD(port,p) (jsem_iskbdjoy(port,p) == JSEM_KBDLAYOUT)
#define JSEM_ISCURSOR(port,p) (jsem_iskbdjoy(port,p) == JSEM_KBDLAYOUT + 1)
#define JSEM_ISSOMEWHEREELSE(port,p) (jsem_iskbdjoy(port,p) == JSEM_KBDLAYOUT + 2)
+#define JSEM_ISCUSTOM(port,p) ((p)->jports[port].id >= JSEM_CUSTOM && (p)->jports[port].id < JSEM_CUSTOM + MAX_JPORTS_CUSTOM)
#define JSEM_GETCUSTOMIDX(port,p) ((p)->jports[port].id - JSEM_CUSTOM)
#define JSEM_LASTKBD 3
#define JSEM_ISANYKBD(port,p) (jsem_iskbdjoy(port,p) >= JSEM_KBDLAYOUT && jsem_iskbdjoy(port,p) < JSEM_KBDLAYOUT + JSEM_LASTKBD)
@@ -312,85 +328,3 @@ extern int jsem_ismouse (int port, const struct uae_prefs *p);
extern int jsem_iskbdjoy (int port, const struct uae_prefs *p);
extern int inputdevice_uaelib (const TCHAR *, const TCHAR *);
-extern int inputdevice_uaelib(const TCHAR *s, int parm, int max, bool autofire);
-
-extern bool target_can_autoswitchdevice(void);
-
-
-struct host_input_button {
- int north_button;
- int east_button;
- int south_button;
- int west_button;
- int dpad_left;
- int dpad_right;
- int dpad_up;
- int dpad_down;
- int select_button;
- int start_button;
-
- int left_shoulder;
- int right_shoulder;
- int left_trigger;
- int right_trigger;
-
- int lstick_button;
- int lstick_axis_y;
- int lstick_axis_x;
- int lstick_left;
- int lstick_right;
- int lstick_up;
- int lstick_down;
-
- int rstick_button;
- int rstick_axis_y;
- int rstick_axis_x;
- int rstick_left;
- int rstick_right;
- int rstick_up;
- int rstick_down;
-
- int hotkey_button;
- int quit_button;
- int menu_button;
- int reset_button;
- int load_state_button;
- int save_state_button;
-
- int number_of_hats;
- int number_of_axis;
-
- bool is_retroarch;
-};
-
-struct host_keyboard_button {
-
- int north_button;
- int east_button;
- int south_button;
- int west_button;
- int dpad_left;
- int dpad_right;
- int dpad_up;
- int dpad_down;
- int left_shoulder;
- int right_shoulder;
- int select_button;
- int start_button;
- int lstick_button;
- int rstick_button;
-
- bool is_retroarch;
-
-};
-
-
-extern struct host_input_button host_input_buttons[MAX_INPUT_DEVICES];
-
-extern int multipler_maps[MAX_JPORTS];
-
-
-extern int find_in_array(const int arr[], int n, int key);
-
-
-#endif /* UAE_INPUTDEVICE_H */
diff --git a/src/include/keybuf.h b/src/include/keybuf.h
index 1924b3ce..28041c8e 100644
--- a/src/include/keybuf.h
+++ b/src/include/keybuf.h
@@ -7,12 +7,12 @@
* (c) 1996 Bernd Schmidt
*/
-#ifndef UAE_KEYBUF_H
-#define UAE_KEYBUF_H
-
-extern int get_next_key (void);
-extern int keys_available (void);
-extern int record_key (int);
-extern void keybuf_init (void);
-
-#endif /* UAE_KEYBUF_H */
+#pragma once
+extern int get_next_key(void);
+extern int keys_available(void);
+extern int record_key(int);
+extern int record_key_direct(int);
+extern void keybuf_init(void);
+extern int getcapslockstate(void);
+extern void setcapslockstate(int);
+extern void keybuf_inject(const uae_char*);
diff --git a/src/include/memory.h b/src/include/memory.h
index dc65071b..1f37c79e 100644
--- a/src/include/memory.h
+++ b/src/include/memory.h
@@ -6,19 +6,34 @@
* Copyright 1995 Bernd Schmidt
*/
-#ifndef UAE_MEMORY_H
-#define UAE_MEMORY_H
+#ifndef MEMORY_H
+#define MEMORY_H
-extern void memory_reset (void);
+#include "options.h"
+
+extern void memory_reset(void);
+extern void memory_restore(void);
+extern void a1000_reset(void);
#ifdef JIT
extern int special_mem;
+
+extern uae_u8 *cache_alloc (int);
+extern void cache_free (uae_u8*, int);
#endif
#define S_READ 1
#define S_WRITE 2
-bool init_shm (void);
+#ifdef AMIBERRY
+extern uae_u8* natmem_offset;
+#endif
+
+bool init_shm(void);
+void free_shm(void);
+bool preinit_shm(void);
+extern bool canbang;
+extern bool jit_direct_compatible_memory;
#define Z3BASE_UAE 0x10000000
#define Z3BASE_REAL 0x40000000
@@ -31,26 +46,34 @@ bool init_shm (void);
#define MEMORY_BANKS 256
#else
#define MEMORY_BANKS 65536
+#define MEMORY_RANGE_MASK (~0)
#endif
-typedef uae_u32 (REGPARAM3 *mem_get_func)(uaecptr) REGPARAM;
+typedef uae_u32(REGPARAM3 *mem_get_func)(uaecptr) REGPARAM;
typedef void (REGPARAM3 *mem_put_func)(uaecptr, uae_u32) REGPARAM;
typedef uae_u8 *(REGPARAM3 *xlate_func)(uaecptr) REGPARAM;
typedef int (REGPARAM3 *check_func)(uaecptr, uae_u32) REGPARAM;
extern uae_u32 max_z3fastmem;
+extern uae_u32 wait_cpu_cycle_read(uaecptr addr, int mode);
+extern void wait_cpu_cycle_write(uaecptr addr, int mode, uae_u32 v);
+extern uae_u32 wait_cpu_cycle_read_ce020(uaecptr addr, int mode);
+extern void wait_cpu_cycle_write_ce020(uaecptr addr, int mode, uae_u32 v);
+
#undef DIRECT_MEMFUNCS_SUCCESSFUL
#include "machdep/maccess.h"
#define chipmem_start_addr 0x00000000
#define bogomem_start_addr 0x00C00000
+#define cardmem_start_addr 0x00E00000
#define kickmem_start_addr 0x00F80000
#define ROM_SIZE_512 524288
#define ROM_SIZE_256 262144
#define ROM_SIZE_128 131072
+extern bool ersatzkickfile;
extern bool cloanto_rom, kickstart_rom;
extern uae_u16 kickstart_version;
extern int uae_boot_rom_type;
@@ -58,6 +81,8 @@ extern int uae_boot_rom_size;
extern uaecptr rtarea_base;
extern uaecptr uaeboard_base;
+extern uae_u8* baseaddr[];
+
enum
{
ABFLAG_UNK = 0, ABFLAG_RAM = 1, ABFLAG_ROM = 2, ABFLAG_ROMIN = 4, ABFLAG_IO = 8,
@@ -66,32 +91,33 @@ enum
ABFLAG_CHIPRAM = 4096, ABFLAG_CIA = 8192, ABFLAG_PPCIOSPACE = 16384,
};
typedef struct {
- /* These ones should be self-explanatory... */
- mem_get_func lget, wget, bget;
- mem_put_func lput, wput, bput;
- /* Use xlateaddr to translate an Amiga address to a uae_u8 * that can
- * be used to address memory without calling the wget/wput functions.
- * This doesn't work for all memory banks, so this function may call
- * abort(). */
- xlate_func xlateaddr;
- /* To prevent calls to abort(), use check before calling xlateaddr.
- * It checks not only that the memory bank can do xlateaddr, but also
- * that the pointer points to an area of at least the specified size.
- * This is used for example to translate bitplane pointers in custom.c */
- check_func check;
- /* For those banks that refer to real memory, we can save the whole trouble
- of going through function calls, and instead simply grab the memory
- ourselves. This holds the memory address where the start of memory is
- for this particular bank. */
- uae_u8 *baseaddr;
+ /* These ones should be self-explanatory... */
+ mem_get_func lget, wget, bget;
+ mem_put_func lput, wput, bput;
+ /* Use xlateaddr to translate an Amiga address to a uae_u8 * that can
+ * be used to address memory without calling the wget/wput functions.
+ * This doesn't work for all memory banks, so this function may call
+ * abort(). */
+ xlate_func xlateaddr;
+ /* To prevent calls to abort(), use check before calling xlateaddr.
+ * It checks not only that the memory bank can do xlateaddr, but also
+ * that the pointer points to an area of at least the specified size.
+ * This is used for example to translate bitplane pointers in custom.c */
+ check_func check;
+ /* For those banks that refer to real memory, we can save the whole trouble
+ of going through function calls, and instead simply grab the memory
+ ourselves. This holds the memory address where the start of memory is
+ for this particular bank. */
+ uae_u8 *baseaddr;
const TCHAR *label;
- const TCHAR *name;
- /* for instruction opcode/operand fetches */
- mem_get_func lgeti, wgeti;
- int flags;
+ const TCHAR *name;
+ /* for instruction opcode/operand fetches */
+ mem_get_func lgeti, wgeti;
+ int flags;
int jit_read_flag, jit_write_flag;
struct addrbank_sub *sub_banks;
uae_u32 mask;
+ uae_u32 startmask;
uae_u32 start;
// if RAM: size of allocated RAM. Zero if failed.
uae_u32 allocated_size;
@@ -113,6 +139,7 @@ struct autoconfig_info
{
struct uae_prefs *prefs;
bool doinit;
+ bool postinit;
int devnum;
uae_u8 autoconfig_raw[128];
uae_u8 autoconfig_bytes[16];
@@ -123,22 +150,38 @@ struct autoconfig_info
uae_u32 size;
int zorro;
const TCHAR *label;
- addrbank *addrbankp;
+ addrbank *Addrbank;
+ uaecptr write_bank_address;
struct romconfig *rc;
uae_u32 last_high_ram;
+ const struct cpuboardsubtype *cst;
const struct expansionromtype *ert;
+ struct autoconfig_info *parent;
+ const int *parent_romtype;
+ bool parent_of_previous;
+ bool parent_address_space;
bool direct_vram;
+ const TCHAR *parent_name;
bool can_sort;
- bool (*get_params)(struct uae_prefs*, struct expansion_params*);
- bool (*set_params)(struct uae_prefs*, struct expansion_params*);
+ bool hardwired;
+ bool(*get_params)(struct uae_prefs*, struct expansion_params*);
+ bool(*set_params)(struct uae_prefs*, struct expansion_params*);
+ void *userdata;
};
+#define CE_MEMBANK_FAST32 0
+#define CE_MEMBANK_CHIP16 1
+#define CE_MEMBANK_CHIP32 2
+#define CE_MEMBANK_CIA 3
+#define CE_MEMBANK_FAST16 4
+extern uae_u8 ce_banktype[65536], ce_cachable[65536];
+
#define MEMORY_LGET(name) \
static uae_u32 REGPARAM3 name ## _lget (uaecptr) REGPARAM; \
static uae_u32 REGPARAM2 name ## _lget (uaecptr addr) \
{ \
uae_u8 *m; \
- addr -= name ## _bank.start; \
+ addr -= name ## _bank.start & name ## _bank.mask; \
addr &= name ## _bank.mask; \
m = name ## _bank.baseaddr + addr; \
return do_get_mem_long ((uae_u32 *)m); \
@@ -148,7 +191,7 @@ static uae_u32 REGPARAM3 name ## _wget (uaecptr) REGPARAM; \
static uae_u32 REGPARAM2 name ## _wget (uaecptr addr) \
{ \
uae_u8 *m; \
- addr -= name ## _bank.start; \
+ addr -= name ## _bank.start & name ## _bank.mask; \
addr &= name ## _bank.mask; \
m = name ## _bank.baseaddr + addr; \
return do_get_mem_word ((uae_u16 *)m); \
@@ -157,7 +200,7 @@ static uae_u32 REGPARAM2 name ## _wget (uaecptr addr) \
static uae_u32 REGPARAM3 name ## _bget (uaecptr) REGPARAM; \
static uae_u32 REGPARAM2 name ## _bget (uaecptr addr) \
{ \
- addr -= name ## _bank.start; \
+ addr -= name ## _bank.start & name ## _bank.mask; \
addr &= name ## _bank.mask; \
return name ## _bank.baseaddr[addr]; \
}
@@ -166,7 +209,7 @@ static void REGPARAM3 name ## _lput (uaecptr, uae_u32) REGPARAM; \
static void REGPARAM2 name ## _lput (uaecptr addr, uae_u32 l) \
{ \
uae_u8 *m; \
- addr -= name ## _bank.start; \
+ addr -= name ## _bank.start & name ## _bank.mask; \
addr &= name ## _bank.mask; \
m = name ## _bank.baseaddr + addr; \
do_put_mem_long ((uae_u32 *)m, l); \
@@ -176,7 +219,7 @@ static void REGPARAM3 name ## _wput (uaecptr, uae_u32) REGPARAM; \
static void REGPARAM2 name ## _wput (uaecptr addr, uae_u32 w) \
{ \
uae_u8 *m; \
- addr -= name ## _bank.start; \
+ addr -= name ## _bank.start & name ## _bank.mask; \
addr &= name ## _bank.mask; \
m = name ## _bank.baseaddr + addr; \
do_put_mem_word ((uae_u16 *)m, w); \
@@ -185,7 +228,7 @@ static void REGPARAM2 name ## _wput (uaecptr addr, uae_u32 w) \
static void REGPARAM3 name ## _bput (uaecptr, uae_u32) REGPARAM; \
static void REGPARAM2 name ## _bput (uaecptr addr, uae_u32 b) \
{ \
- addr -= name ## _bank.start; \
+ addr -= name ## _bank.start & name ## _bank.mask; \
addr &= name ## _bank.mask; \
name ## _bank.baseaddr[addr] = b; \
}
@@ -193,7 +236,7 @@ static void REGPARAM2 name ## _bput (uaecptr addr, uae_u32 b) \
static int REGPARAM3 name ## _check (uaecptr addr, uae_u32 size) REGPARAM; \
static int REGPARAM2 name ## _check (uaecptr addr, uae_u32 size) \
{ \
- addr -= name ## _bank.start; \
+ addr -= name ## _bank.start & name ## _bank.mask; \
addr &= name ## _bank.mask; \
return (addr + size) <= name ## _bank.allocated_size; \
}
@@ -201,7 +244,7 @@ static int REGPARAM2 name ## _check (uaecptr addr, uae_u32 size) \
static uae_u8 *REGPARAM3 name ## _xlate (uaecptr addr) REGPARAM; \
static uae_u8 *REGPARAM2 name ## _xlate (uaecptr addr) \
{ \
- addr -= name ## _bank.start; \
+ addr -= name ## _bank.start & name ## _bank.mask; \
addr &= name ## _bank.mask; \
return name ## _bank.baseaddr + addr; \
}
@@ -218,6 +261,18 @@ static void REGPARAM3 NOWARN_UNUSED(name ## _bput) (uaecptr, uae_u32) REGPARAM;
static int REGPARAM3 NOWARN_UNUSED(name ## _check) (uaecptr addr, uae_u32 size) REGPARAM; \
static uae_u8 *REGPARAM3 NOWARN_UNUSED(name ## _xlate) (uaecptr addr) REGPARAM;
+#define DECLARE_MEMORY_FUNCTIONS_WITH_SUFFIX(name, suffix) \
+static uae_u32 REGPARAM3 NOWARN_UNUSED(name ## _lget_ ## suffix) (uaecptr) REGPARAM; \
+static uae_u32 REGPARAM3 NOWARN_UNUSED(name ## _lgeti_ ## suffix) (uaecptr) REGPARAM; \
+static uae_u32 REGPARAM3 NOWARN_UNUSED(name ## _wget_ ## suffix) (uaecptr) REGPARAM; \
+static uae_u32 REGPARAM3 NOWARN_UNUSED(name ## _wgeti_ ## suffix) (uaecptr) REGPARAM; \
+static uae_u32 REGPARAM3 NOWARN_UNUSED(name ## _bget_ ## suffix) (uaecptr) REGPARAM; \
+static void REGPARAM3 NOWARN_UNUSED(name ## _lput_ ## suffix) (uaecptr, uae_u32) REGPARAM; \
+static void REGPARAM3 NOWARN_UNUSED(name ## _wput_ ## suffix) (uaecptr, uae_u32) REGPARAM; \
+static void REGPARAM3 NOWARN_UNUSED(name ## _bput_ ## suffix) (uaecptr, uae_u32) REGPARAM; \
+static int REGPARAM3 NOWARN_UNUSED(name ## _check_ ## suffix) (uaecptr addr, uae_u32 size) REGPARAM; \
+static uae_u8 *REGPARAM3 NOWARN_UNUSED(name ## _xlate_ ## suffix) (uaecptr addr) REGPARAM;
+
#define MEMORY_FUNCTIONS(name) \
MEMORY_LGET(name); \
MEMORY_WGET(name); \
@@ -228,12 +283,13 @@ MEMORY_BPUT(name); \
MEMORY_CHECK(name); \
MEMORY_XLATE(name);
+
#define MEMORY_ARRAY_LGET(name, index) \
static uae_u32 REGPARAM3 name ## index ## _lget (uaecptr) REGPARAM; \
static uae_u32 REGPARAM2 name ## index ## _lget (uaecptr addr) \
{ \
uae_u8 *m; \
- addr -= name ## _bank[index].start; \
+ addr -= name ## _bank[index].start & name ## _bank[index].mask; \
addr &= name ## _bank[index].mask; \
m = name ## _bank[index].baseaddr + addr; \
return do_get_mem_long ((uae_u32 *)m); \
@@ -243,7 +299,7 @@ static uae_u32 REGPARAM3 name ## index ## _wget (uaecptr) REGPARAM; \
static uae_u32 REGPARAM2 name ## index ## _wget (uaecptr addr) \
{ \
uae_u8 *m; \
- addr -= name ## _bank[index].start; \
+ addr -= name ## _bank[index].start & name ## _bank[index].mask; \
addr &= name ## _bank[index].mask; \
m = name ## _bank[index].baseaddr + addr; \
return do_get_mem_word ((uae_u16 *)m); \
@@ -252,7 +308,7 @@ static uae_u32 REGPARAM2 name ## index ## _wget (uaecptr addr) \
static uae_u32 REGPARAM3 name ## index ## _bget (uaecptr) REGPARAM; \
static uae_u32 REGPARAM2 name ## index ## _bget (uaecptr addr) \
{ \
- addr -= name ## _bank[index].start; \
+ addr -= name ## _bank[index].start & name ## _bank[index].mask; \
addr &= name ## _bank[index].mask; \
return name ## _bank[index].baseaddr[addr]; \
}
@@ -261,7 +317,7 @@ static void REGPARAM3 name ## index ## _lput (uaecptr, uae_u32) REGPARAM; \
static void REGPARAM2 name ## index ## _lput (uaecptr addr, uae_u32 l) \
{ \
uae_u8 *m; \
- addr -= name ## _bank[index].start; \
+ addr -= name ## _bank[index].start & name ## _bank[index].mask; \
addr &= name ## _bank[index].mask; \
m = name ## _bank[index].baseaddr + addr; \
do_put_mem_long ((uae_u32 *)m, l); \
@@ -271,7 +327,7 @@ static void REGPARAM3 name ## index ## _wput (uaecptr, uae_u32) REGPARAM; \
static void REGPARAM2 name ## index ## _wput (uaecptr addr, uae_u32 w) \
{ \
uae_u8 *m; \
- addr -= name ## _bank[index].start; \
+ addr -= name ## _bank[index].start & name ## _bank[index].mask; \
addr &= name ## _bank[index].mask; \
m = name ## _bank[index].baseaddr + addr; \
do_put_mem_word ((uae_u16 *)m, w); \
@@ -280,7 +336,7 @@ static void REGPARAM2 name ## index ## _wput (uaecptr addr, uae_u32 w) \
static void REGPARAM3 name ## index ## _bput (uaecptr, uae_u32) REGPARAM; \
static void REGPARAM2 name ## index ## _bput (uaecptr addr, uae_u32 b) \
{ \
- addr -= name ## _bank[index].start; \
+ addr -= name ## _bank[index].start & name ## _bank[index].mask; \
addr &= name ## _bank[index].mask; \
name ## _bank[index].baseaddr[addr] = b; \
}
@@ -288,7 +344,7 @@ static void REGPARAM2 name ## index ## _bput (uaecptr addr, uae_u32 b) \
static int REGPARAM3 name ## index ## _check (uaecptr addr, uae_u32 size) REGPARAM; \
static int REGPARAM2 name ## index ## _check (uaecptr addr, uae_u32 size) \
{ \
- addr -= name ## _bank[index].start; \
+ addr -= name ## _bank[index].start & name ## _bank[index].mask; \
addr &= name ## _bank[index].mask; \
return (addr + size) <= name ## _bank[index].allocated_size; \
}
@@ -296,7 +352,7 @@ static int REGPARAM2 name ## index ## _check (uaecptr addr, uae_u32 size) \
static uae_u8 *REGPARAM3 name ## index ## _xlate (uaecptr addr) REGPARAM; \
static uae_u8 *REGPARAM2 name ## index ## _xlate (uaecptr addr) \
{ \
- addr -= name ## _bank[index].start; \
+ addr -= name ## _bank[index].start & name ## _bank[index].mask; \
addr &= name ## _bank[index].mask; \
return name ## _bank[index].baseaddr + addr; \
}
@@ -312,6 +368,8 @@ MEMORY_ARRAY_CHECK(name, index); \
MEMORY_ARRAY_XLATE(name, index);
extern addrbank chipmem_bank;
+extern addrbank chipmem_agnus_bank;
+extern addrbank chipmem_bank_ce2;
extern addrbank kickmem_bank;
extern addrbank custom_bank;
extern addrbank clock_bank;
@@ -320,15 +378,19 @@ extern addrbank rtarea_bank;
extern addrbank filesys_bank;
extern addrbank uaeboard_bank;
extern addrbank expamem_bank;
-extern addrbank expamem_null;
+extern addrbank expamem_null, expamem_none;
extern addrbank fastmem_bank[MAX_RAM_BOARDS];
+extern addrbank fastmem_nojit_bank[MAX_RAM_BOARDS];
extern addrbank *gfxmem_banks[MAX_RTG_BOARDS];
extern addrbank gayle_bank;
extern addrbank gayle2_bank;
extern addrbank mbres_bank;
extern addrbank akiko_bank;
+extern addrbank cardmem_bank;
extern addrbank bogomem_bank;
extern addrbank z3fastmem_bank[MAX_RAM_BOARDS];
+extern addrbank z3chipmem_bank;
+extern addrbank mem25bit_bank;
extern addrbank a3000lmem_bank;
extern addrbank a3000hmem_bank;
extern addrbank extendedkickmem_bank;
@@ -336,14 +398,15 @@ extern addrbank extendedkickmem2_bank;
extern addrbank custmem1_bank;
extern addrbank custmem2_bank;
-extern void rtarea_init (void);
+extern void rtarea_init(void);
extern void rtarea_free(void);
-extern void rtarea_init_mem (void);
-extern void rtarea_setup (void);
-extern void expamem_reset (void);
-extern void expamem_next (addrbank *mapped, addrbank *next);
-extern void expamem_shutup (addrbank *mapped);
+extern void rtarea_init_mem(void);
+extern void rtarea_setup(void);
+extern void expamem_reset(void);
+extern void expamem_next(addrbank *mapped, addrbank *next);
+extern void expamem_shutup(addrbank *mapped);
extern bool expamem_z3hack(struct uae_prefs*);
+extern void expansion_cpu_fallback(void);
extern void set_expamem_z3_hack_mode(int);
extern uaecptr expamem_board_pointer, expamem_highmem_pointer;
extern uaecptr expamem_z3_pointer_real, expamem_z3_pointer_uae;
@@ -354,17 +417,18 @@ extern uae_u32 last_custom_value1;
/* Default memory access functions */
-extern uae_u32 dummy_get (uaecptr addr, int size, bool inst, uae_u32 defvalue);
+extern void dummy_put(uaecptr addr, int size, uae_u32 val);
+extern uae_u32 dummy_get(uaecptr addr, int size, bool inst, uae_u32 defvalue);
extern uae_u32 dummy_get_safe(uaecptr addr, int size, bool inst, uae_u32 defvalue);
extern int REGPARAM3 default_check(uaecptr addr, uae_u32 size) REGPARAM;
extern uae_u8 *REGPARAM3 default_xlate(uaecptr addr) REGPARAM;
/* 680x0 opcode fetches */
-extern uae_u32 REGPARAM3 dummy_lgeti (uaecptr addr) REGPARAM;
-extern uae_u32 REGPARAM3 dummy_wgeti (uaecptr addr) REGPARAM;
+extern uae_u32 REGPARAM3 dummy_lgeti(uaecptr addr) REGPARAM;
+extern uae_u32 REGPARAM3 dummy_wgeti(uaecptr addr) REGPARAM;
/* sub bank support */
-extern uae_u32 REGPARAM3 sub_bank_lget (uaecptr) REGPARAM;
+extern uae_u32 REGPARAM3 sub_bank_lget(uaecptr) REGPARAM;
extern uae_u32 REGPARAM3 sub_bank_wget(uaecptr) REGPARAM;
extern uae_u32 REGPARAM3 sub_bank_bget(uaecptr) REGPARAM;
extern void REGPARAM3 sub_bank_lput(uaecptr, uae_u32) REGPARAM;
@@ -380,26 +444,50 @@ extern addrbank *get_sub_bank(uaecptr *addr);
extern addrbank *mem_banks[MEMORY_BANKS];
-#define get_mem_bank(addr) (*mem_banks[bankindex(addr)])
+#ifdef JIT
+extern uae_u8 *baseaddr[MEMORY_BANKS];
+#endif
-extern void memory_init (void);
-extern void memory_cleanup (void);
-extern void map_banks (addrbank *bank, int first, int count, int realsize);
-extern void map_banks_z2 (addrbank *bank, int first, int count);
+#define get_mem_bank(addr) (*mem_banks[bankindex(addr)])
+extern addrbank *get_mem_bank_real(uaecptr);
+
+#ifdef JIT
+#define put_mem_bank(addr, b, realstart) do { \
+ (mem_banks[bankindex(addr)] = (b)); \
+ if ((b)->baseaddr) \
+ baseaddr[bankindex(addr)] = (b)->baseaddr - (realstart); \
+ else \
+ baseaddr[bankindex(addr)] = (uae_u8*)(((uae_u8*)b)+1); \
+} while (0)
+#else
+#define put_mem_bank(addr, b, realstart) \
+ (mem_banks[bankindex(addr)] = (b));
+#endif
+
+extern void memory_init(void);
+extern void memory_cleanup(void);
+extern void restore_banks(void);
+extern void map_banks(addrbank *bank, int first, int count, int realsize);
+extern void map_banks_z2(addrbank *bank, int first, int count);
+extern uae_u32 map_banks_z2_autosize(addrbank *bank, int first);
extern void map_banks_z3(addrbank *bank, int first, int count);
extern bool validate_banks_z2(addrbank *bank, int start, int size);
extern bool validate_banks_z3(addrbank *bank, int start, int size);
-extern void map_banks_quick (addrbank *bank, int first, int count, int realsize);
-extern void map_banks_cond (addrbank *bank, int first, int count, int realsize);
-extern void map_overlay (int chip);
-extern void memory_hardreset (int);
-extern void memory_clear (void);
-extern void free_fastmemory (int);
+extern void map_banks_quick(addrbank *bank, int first, int count, int realsize);
+extern void map_banks_nojitdirect(addrbank *bank, int first, int count, int realsize);
+extern void map_banks_cond(addrbank *bank, int first, int count, int realsize);
+extern void map_overlay(int chip);
+extern void memory_hardreset(int);
+extern void memory_clear(void);
+extern void free_fastmemory(int);
+extern void set_roms_modified(void);
+extern void reload_roms(void);
extern bool read_kickstart_version(struct uae_prefs *p);
#define longget(addr) (call_mem_get_func(get_mem_bank(addr).lget, addr))
#define wordget(addr) (call_mem_get_func(get_mem_bank(addr).wget, addr))
#define byteget(addr) (call_mem_get_func(get_mem_bank(addr).bget, addr))
+#define longgeti(addr) (call_mem_get_func(get_mem_bank(addr).lgeti, addr))
#define wordgeti(addr) (call_mem_get_func(get_mem_bank(addr).wgeti, addr))
#define longput(addr,l) (call_mem_put_func(get_mem_bank(addr).lput, addr, l))
#define wordput(addr,w) (call_mem_put_func(get_mem_bank(addr).wput, addr, w))
@@ -407,19 +495,23 @@ extern bool read_kickstart_version(struct uae_prefs *p);
STATIC_INLINE uae_u32 get_long(uaecptr addr)
{
- return longget(addr);
+ return longget(addr);
}
STATIC_INLINE uae_u32 get_word(uaecptr addr)
{
- return wordget(addr);
+ return wordget(addr);
}
STATIC_INLINE uae_u32 get_byte(uaecptr addr)
{
- return byteget(addr);
+ return byteget(addr);
+}
+STATIC_INLINE uae_u32 get_longi(uaecptr addr)
+{
+ return longgeti(addr);
}
STATIC_INLINE uae_u32 get_wordi(uaecptr addr)
{
- return wordgeti(addr);
+ return wordgeti(addr);
}
STATIC_INLINE uae_u32 get_long_jit(uaecptr addr)
@@ -446,31 +538,47 @@ STATIC_INLINE uae_u32 get_byte_jit(uaecptr addr)
#endif
return bank->bget(addr);
}
+STATIC_INLINE uae_u32 get_longi_jit(uaecptr addr)
+{
+ addrbank *bank = &get_mem_bank(addr);
+#ifdef JIT
+ special_mem |= bank->jit_read_flag;
+#endif
+ return bank->lgeti(addr);
+}
+STATIC_INLINE uae_u32 get_wordi_jit(uaecptr addr)
+{
+ addrbank *bank = &get_mem_bank(addr);
+#ifdef JIT
+ special_mem |= bank->jit_read_flag;
+#endif
+ return bank->wgeti(addr);
+}
/*
- * Read a host pointer from addr
- */
+* Read a host pointer from addr
+*/
#if SIZEOF_VOID_P == 4
-# define get_pointer(addr) ((void *)get_long(addr))
+# define get_pointer(addr) ((void *)get_long (addr))
#else
# if SIZEOF_VOID_P == 8
-STATIC_INLINE void *get_pointer (uaecptr addr)
+STATIC_INLINE void *get_pointer(uaecptr addr)
{
- const unsigned int n = SIZEOF_VOID_P / 4;
- union {
- void *ptr;
- uae_u32 longs[SIZEOF_VOID_P / 4];
- } p;
- unsigned int i;
+ const unsigned int n = SIZEOF_VOID_P / 4;
+ union {
+ void *ptr;
+ uae_u32 longs[SIZEOF_VOID_P / 4];
+ } p;
+ unsigned int i;
- for (i = 0; i < n; i++) {
+ for (i = 0; i < n; i++) {
#ifdef WORDS_BIGENDIAN
- p.longs[i] = get_long (addr + i * 4);
+ p.longs[i] = get_long(addr + i * 4);
#else
- p.longs[n - 1 - i] = get_long (addr + i * 4);
+ p.longs[n - 1 - i] = get_long(addr + i * 4);
#endif
- }
- return p.ptr;
+ }
+ return p.ptr;
}
# else
# error "Unknown or unsupported pointer size."
@@ -479,15 +587,15 @@ STATIC_INLINE void *get_pointer (uaecptr addr)
STATIC_INLINE void put_long(uaecptr addr, uae_u32 l)
{
- longput(addr, l);
+ longput(addr, l);
}
STATIC_INLINE void put_word(uaecptr addr, uae_u32 w)
{
- wordput(addr, w);
+ wordput(addr, w);
}
STATIC_INLINE void put_byte(uaecptr addr, uae_u32 b)
{
- byteput(addr, b);
+ byteput(addr, b);
}
STATIC_INLINE void put_long_jit(uaecptr addr, uae_u32 l)
@@ -516,42 +624,42 @@ STATIC_INLINE void put_byte_jit(uaecptr addr, uae_u32 l)
}
/*
- * Store host pointer v at addr
- */
+* Store host pointer v at addr
+*/
#if SIZEOF_VOID_P == 4
-# define put_pointer(addr, p) (put_long((addr), (uae_u32)(p)))
+# define put_pointer(addr, p) (put_long ((addr), (uae_u32)(p)))
#else
# if SIZEOF_VOID_P == 8
-STATIC_INLINE void put_pointer (uaecptr addr, void *v)
+STATIC_INLINE void put_pointer(uaecptr addr, void *v)
{
- const unsigned int n = SIZEOF_VOID_P / 4;
- union {
- void *ptr;
- uae_u32 longs[SIZEOF_VOID_P / 4];
- } p;
- unsigned int i;
+ const unsigned int n = SIZEOF_VOID_P / 4;
+ union {
+ void *ptr;
+ uae_u32 longs[SIZEOF_VOID_P / 4];
+ } p;
+ unsigned int i;
- p.ptr = v;
+ p.ptr = v;
- for (i = 0; i < n; i++) {
+ for (i = 0; i < n; i++) {
#ifdef WORDS_BIGENDIAN
- put_long (addr + i * 4, p.longs[i]);
+ put_long(addr + i * 4, p.longs[i]);
#else
- put_long (addr + i * 4, p.longs[n - 1 - i]);
+ put_long(addr + i * 4, p.longs[n - 1 - i]);
#endif
- }
+ }
}
# endif
#endif
STATIC_INLINE uae_u8 *get_real_address(uaecptr addr)
{
- return get_mem_bank(addr).xlateaddr(addr);
+ return get_mem_bank(addr).xlateaddr(addr);
}
STATIC_INLINE int valid_address(uaecptr addr, uae_u32 size)
{
- return get_mem_bank(addr).check(addr, size);
+ return get_mem_bank(addr).check(addr, size);
}
STATIC_INLINE void put_quad_host(void *addr, uae_u64 v)
@@ -590,35 +698,84 @@ STATIC_INLINE uae_u32 get_byte_host(void *addr)
return *((uae_u8*)addr);
}
-extern int addr_valid (const TCHAR*,uaecptr,uae_u32);
+extern int addr_valid(const TCHAR*, uaecptr, uae_u32);
/* For faster access in custom chip emulation. */
-extern void REGPARAM3 chipmem_lput (uaecptr, uae_u32) REGPARAM;
-extern void REGPARAM3 chipmem_wput (uaecptr, uae_u32) REGPARAM;
-extern void REGPARAM3 chipmem_bput (uaecptr, uae_u32) REGPARAM;
+extern void REGPARAM3 chipmem_lput(uaecptr, uae_u32) REGPARAM;
+extern void REGPARAM3 chipmem_wput(uaecptr, uae_u32) REGPARAM;
+extern void REGPARAM3 chipmem_bput(uaecptr, uae_u32) REGPARAM;
-extern void REGPARAM3 chipmem_agnus_wput (uaecptr, uae_u32) REGPARAM;
+extern uae_u32 REGPARAM3 chipmem_agnus_wget(uaecptr) REGPARAM;
+extern void REGPARAM3 chipmem_agnus_wput(uaecptr, uae_u32) REGPARAM;
-extern uae_u32 chipmem_full_mask;
extern addrbank dummy_bank;
-STATIC_INLINE uae_u32 chipmem_lget_indirect(uae_u32 PT) {
- return do_get_mem_long((uae_u32 *)&chipmem_bank.baseaddr[PT & chipmem_full_mask]);
-}
-STATIC_INLINE uae_u32 chipmem_wget_indirect (uae_u32 PT) {
- return do_get_mem_word((uae_u16 *)&chipmem_bank.baseaddr[PT & chipmem_full_mask]);
-}
+/* 68020+ Chip RAM DMA contention emulation */
+extern void REGPARAM3 chipmem_bput_c2(uaecptr, uae_u32) REGPARAM;
-#define chipmem_wput_indirect chipmem_agnus_wput
+extern uae_u32(REGPARAM3 *chipmem_lget_indirect)(uaecptr) REGPARAM;
+extern uae_u32(REGPARAM3 *chipmem_wget_indirect)(uaecptr) REGPARAM;
+extern uae_u32(REGPARAM3 *chipmem_bget_indirect)(uaecptr) REGPARAM;
+extern void (REGPARAM3 *chipmem_lput_indirect)(uaecptr, uae_u32) REGPARAM;
+extern void (REGPARAM3 *chipmem_wput_indirect)(uaecptr, uae_u32) REGPARAM;
+extern void (REGPARAM3 *chipmem_bput_indirect)(uaecptr, uae_u32) REGPARAM;
+extern int (REGPARAM3 *chipmem_check_indirect)(uaecptr, uae_u32) REGPARAM;
+extern uae_u8 *(REGPARAM3 *chipmem_xlate_indirect)(uaecptr) REGPARAM;
-extern bool mapped_malloc (addrbank*);
-extern void mapped_free (addrbank*);
+#ifdef NATMEM_OFFSET
-extern uaecptr strcpyha_safe (uaecptr dst, const uae_char *src);
-extern uae_char *strcpyah_safe (uae_char *dst, uaecptr src, int maxsize);
-extern void memcpyha_safe (uaecptr dst, const uae_u8 *src, int size);
-extern void memcpyha (uaecptr dst, const uae_u8 *src, int size);
-extern void memcpyah_safe (uae_u8 *dst, uaecptr src, int size);
-extern void memcpyah (uae_u8 *dst, uaecptr src, int size);
+typedef struct shmpiece_reg {
+ uae_u8 *native_address;
+ int id;
+ uae_u32 size;
+ const TCHAR *name;
+ struct shmpiece_reg *next;
+ struct shmpiece_reg *prev;
+} shmpiece;
-#endif /* UAE_MEMORY_H */
+extern shmpiece *shm_start;
+
+extern uae_u8* natmem_offset;
+extern uae_u8 *natmem_reserved;
+extern uae_u32 natmem_reserved_size;
+
+#endif
+
+extern bool mapped_malloc(addrbank*);
+extern void mapped_free(addrbank*);
+extern void a3000_fakekick(int);
+
+extern uaecptr strcpyha_safe(uaecptr dst, const uae_char *src);
+extern uae_char *strcpyah_safe(uae_char *dst, uaecptr src, int maxsize);
+extern void memcpyha_safe(uaecptr dst, const uae_u8 *src, int size);
+extern void memcpyha(uaecptr dst, const uae_u8 *src, int size);
+extern void memcpyah_safe(uae_u8 *dst, uaecptr src, int size);
+extern void memcpyah(uae_u8 *dst, uaecptr src, int size);
+
+#define UAE_MEMORY_REGIONS_MAX 64
+#define UAE_MEMORY_REGION_NAME_LENGTH 64
+
+#define UAE_MEMORY_REGION_RAM (1 << 0)
+#define UAE_MEMORY_REGION_ALIAS (1 << 1)
+#define UAE_MEMORY_REGION_MIRROR (1 << 2)
+
+/* Get a list of memory regions in the Amiga address space */
+
+typedef struct UaeMemoryRegion {
+ uaecptr start;
+ uae_u32 size;
+ TCHAR name[UAE_MEMORY_REGION_NAME_LENGTH];
+ TCHAR rom_name[UAE_MEMORY_REGION_NAME_LENGTH];
+ uaecptr alias;
+ int flags;
+ uae_u8 *memory;
+} UaeMemoryRegion;
+
+typedef struct UaeMemoryMap {
+ UaeMemoryRegion regions[UAE_MEMORY_REGIONS_MAX];
+ int num_regions;
+} UaeMemoryMap;
+
+void uae_memory_map(UaeMemoryMap *map);
+
+#endif /* MEMORY_H */
diff --git a/src/include/native2amiga.h b/src/include/native2amiga.h
index a29f3f42..7a2493d4 100644
--- a/src/include/native2amiga.h
+++ b/src/include/native2amiga.h
@@ -1,19 +1,17 @@
- /*
- * UAE - The Un*x Amiga Emulator
- *
- * Call (some) Amiga Exec functions outside the main UAE thread
- * and without stack magic.
- *
- * Copyright 1999 Patrick Ohly
- *
- * Uses the EXTER interrupt that is setup in filesys.c
- * and some of it needs thread support.
- */
+/*
+ * UAE - The Un*x Amiga Emulator
+ *
+ * Call (some) Amiga Exec functions outside the main UAE thread
+ * and without stack magic.
+ *
+ * Copyright 1999 Patrick Ohly
+ *
+ * Uses the EXTER interrupt that is setup in filesys.c
+ * and some of it needs thread support.
+ */
-#ifndef UAE_NATIVE2AMIGA_H
-#define UAE_NATIVE2AMIGA_H
-
-#include "uae/types.h"
+#pragma once
+#include "sysconfig.h"
#include "native2amiga_api.h"
#include "traps.h"
@@ -52,7 +50,5 @@ extern smp_comm_pipe native2amiga_pending;
STATIC_INLINE void do_uae_int_requested (void)
{
- atomic_or(&uae_int_requested, 1);
+ uae_int_requested |= 1;
}
-
-#endif /* UAE_NATIVE2AMIGA_H */
diff --git a/src/include/newcpu.h b/src/include/newcpu.h
index fbc1f551..fd933f84 100644
--- a/src/include/newcpu.h
+++ b/src/include/newcpu.h
@@ -1,3 +1,27 @@
+/*
+ * newcpu.h - CPU emulation
+ *
+ * Copyright (c) 2009 ARAnyM dev team (see AUTHORS)
+ *
+ * Inspired by Christian Bauer's Basilisk II
+ *
+ * This file is part of the ARAnyM project which builds a new and powerful
+ * TOS/FreeMiNT compatible virtual machine running on almost any hardware.
+ *
+ * ARAnyM 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.
+ *
+ * ARAnyM 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 ARAnyM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
/*
* UAE - The Un*x Amiga Emulator
*
@@ -6,13 +30,13 @@
* Copyright 1995 Bernd Schmidt
*/
-#ifndef UAE_NEWCPU_H
-#define UAE_NEWCPU_H
+#ifndef _NEWCPU_H
+#define _NEWCPU_H
-#include "uae/types.h"
#include "readcpu.h"
#include "machdep/m68k.h"
-#include
+#include "include/memory.h"
+#include "events.h"
extern const int areg_byteinc[];
extern const int imm8_table[];
@@ -31,11 +55,8 @@ typedef uae_u32 REGPARAM3 cpuop_func (uae_u32) REGPARAM;
typedef void REGPARAM3 cpuop_func_ce (uae_u32) REGPARAM;
struct cputbl {
- cpuop_func *handler;
- uae_u16 opcode;
- uae_s8 length;
- uae_s8 disp020[2];
- uae_u8 branch;
+ cpuop_func *handler;
+ uae_u16 opcode;
};
#ifdef JIT
@@ -50,19 +71,20 @@ typedef uae_u32 REGPARAM3 compop_func (uae_u32) REGPARAM;
#define COMP_OPCODE_USES_FPU 0x0020
struct comptbl {
- compop_func *handler;
+ compop_func *handler;
uae_u32 specific;
- uae_u32 opcode;
+ uae_u32 opcode;
};
#endif
extern uae_u32 REGPARAM3 op_illg (uae_u32) REGPARAM;
+extern void REGPARAM3 op_unimpl (uae_u16) REGPARAM;
typedef uae_u8 flagtype;
#ifdef FPUEMU
-#ifdef USE_LONG_DOUBLE
+#if USE_LONG_DOUBLE
typedef long double fptype;
#define LDPTR tbyte ptr
#else
@@ -73,8 +95,12 @@ typedef double fptype;
typedef struct
{
- floatx80 fpx;
fptype fp;
+#ifdef USE_SOFT_LONG_DOUBLE
+ bool fpx;
+ uae_u32 fpm;
+ uae_u64 fpe;
+#endif
} fpdata;
struct regstruct
@@ -85,12 +111,15 @@ struct regstruct
uae_u32 pc;
uae_u8 *pc_p;
uae_u8 *pc_oldp;
- uae_u16 opcode;
uae_u32 instruction_pc;
- uae_u16 irc, ir, db;
+ uae_u16 irc, ir, db;
volatile uae_atomic spcflags;
-
+ uae_u32 last_prefetch;
+ uae_u32 chipset_latch_rw;
+ uae_u32 chipset_latch_read;
+ uae_u32 chipset_latch_write;
+
uaecptr usp, isp, msp;
uae_u16 sr;
flagtype t1;
@@ -99,38 +128,40 @@ struct regstruct
flagtype m;
flagtype x;
flagtype stopped;
- int halted;
+ int halted;
+ int exception;
int intmask;
+ int ipl, ipl_pin;
uae_u32 vbr,sfc,dfc;
#ifdef FPUEMU
fpdata fp[8];
+ fpdata fp_result;
+ uae_u32 fp_result_status;
uae_u32 fpcr,fpsr, fpiar;
uae_u32 fpu_state;
uae_u32 fpu_exp_state;
- uae_u16 fp_opword;
- uaecptr fp_ea;
- uae_u32 fp_exp_pend, fp_unimp_pend;
- bool fpu_exp_pre;
- bool fp_unimp_ins;
+ fpdata exp_src1, exp_src2;
+ uae_u32 exp_pack[3];
+ uae_u16 exp_opcode, exp_extra, exp_type;
bool fp_exception;
- bool fp_branch;
#endif
+#ifndef CPUEMU_68000_ONLY
uae_u32 cacr, caar;
uae_u32 itt0, itt1, dtt0, dtt1;
uae_u32 tcr, mmusr, urp, srp, buscr;
+#endif
uae_u32 pcr;
uae_u32 address_space_mask;
- uae_s32 pissoff;
+ uae_u8 panic;
+ uae_u32 panic_pc, panic_addr;
};
extern struct regstruct regs;
-#define REGS_DEFINED
-#include "machdep/m68k.h"
#include "events.h"
STATIC_INLINE uae_u32 munge24(uae_u32 x)
@@ -139,40 +170,26 @@ STATIC_INLINE uae_u32 munge24(uae_u32 x)
}
extern int cpu_cycles;
-extern int m68k_pc_indirect;
+extern bool m68k_pc_indirect;
-STATIC_INLINE void set_special (uae_u32 x)
+STATIC_INLINE void set_special_exter(uae_u32 x)
{
- atomic_or(®s.spcflags, x);
- cycles_do_special();
+ regs.spcflags |= x;
+}
+STATIC_INLINE void set_special(uae_u32 x)
+{
+ regs.spcflags |= x;
+ cycles_do_special();
}
STATIC_INLINE void unset_special (uae_u32 x)
{
- atomic_and(®s.spcflags, ~x);
+ regs.spcflags &= ~x;
}
#define m68k_dreg(r,num) ((r).regs[(num)])
#define m68k_areg(r,num) (((r).regs + 8)[(num)])
-extern uae_u32(*x_get_byte)(uaecptr addr);
-extern uae_u32(*x_get_word)(uaecptr addr);
-extern uae_u32(*x_get_long)(uaecptr addr);
-extern void(*x_put_byte)(uaecptr addr, uae_u32 v);
-extern void(*x_put_word)(uaecptr addr, uae_u32 v);
-extern void(*x_put_long)(uaecptr addr, uae_u32 v);
-extern uae_u32(*x_get_iword)(int);
-
-#define x_cp_get_byte x_get_byte
-#define x_cp_get_word x_get_word
-#define x_cp_get_long x_get_long
-#define x_cp_put_byte x_put_byte
-#define x_cp_put_word x_put_word
-#define x_cp_put_long x_put_long
-#define x_cp_next_iword() next_diword()
-#define x_cp_next_ilong() next_dilong()
-
-#define x_cp_get_disp_ea_020(base,idx) _get_disp_ea_020(base)
/* direct (regs.pc_p) access */
@@ -181,6 +198,7 @@ STATIC_INLINE void m68k_setpc (uaecptr newpc)
regs.pc_p = regs.pc_oldp = get_real_address (newpc);
regs.instruction_pc = regs.pc = newpc;
}
+
STATIC_INLINE uaecptr m68k_getpc (void)
{
return (uaecptr)(regs.pc + ((uae_u8*)regs.pc_p - (uae_u8*)regs.pc_oldp));
@@ -190,10 +208,7 @@ STATIC_INLINE uaecptr m68k_getpc (void)
#define m68k_incpc(o) ((regs).pc_p += (o))
#define get_dibyte(o) do_get_mem_byte((uae_u8 *)((regs).pc_p + (o) + 1))
-STATIC_INLINE uae_u32 get_diword(int o)
-{
- return do_get_mem_word((uae_u16 *)((regs).pc_p + (o)));
-}
+#define get_diword(o) do_get_mem_word((uae_u16 *)((regs).pc_p + (o)))
#define get_dilong(o) do_get_mem_long((uae_u32 *)((regs).pc_p + (o)))
STATIC_INLINE uae_u32 next_diword (void)
@@ -215,6 +230,8 @@ STATIC_INLINE void m68k_do_bsr (uaecptr oldpc, uae_s32 offset)
put_long(m68k_areg(regs, 7), oldpc);
m68k_incpc (offset);
}
+
+
STATIC_INLINE void m68k_do_rts (void)
{
uae_u32 newpc = get_long (m68k_areg (regs, 7));
@@ -231,11 +248,6 @@ STATIC_INLINE uaecptr m68k_getpci(void)
}
#define m68k_incpci(o) (regs.pc += (o))
-STATIC_INLINE uae_u32 get_iiword(int o)
-{
- return get_wordi(m68k_getpci() + (o));
-}
-
STATIC_INLINE void m68k_do_bsri(uaecptr oldpc, uae_s32 offset)
{
m68k_areg(regs, 7) -= 4;
@@ -253,7 +265,7 @@ STATIC_INLINE void m68k_do_rtsi(void)
STATIC_INLINE void m68k_incpc_normal(int o)
{
- if (m68k_pc_indirect > 0)
+ if (m68k_pc_indirect)
m68k_incpci(o);
else
m68k_incpc(o);
@@ -261,15 +273,29 @@ STATIC_INLINE void m68k_incpc_normal(int o)
STATIC_INLINE void m68k_setpc_normal(uaecptr pc)
{
- if (m68k_pc_indirect > 0) {
+ if (m68k_pc_indirect) {
regs.pc_p = regs.pc_oldp = 0;
m68k_setpci(pc);
- } else {
+ }
+ else {
m68k_setpc(pc);
}
}
-extern void check_t0_trace(void);
+#define x_get_word get_word
+#define x_get_long get_long
+#define x_put_word put_word
+#define x_put_long put_long
+
+#define x_cp_put_long put_long
+#define x_cp_put_word put_word
+#define x_cp_put_byte put_byte
+#define x_cp_get_long get_long
+#define x_cp_get_word get_word
+#define x_cp_get_byte get_byte
+#define x_cp_next_iword() next_diword()
+#define x_cp_next_ilong() next_dilong()
+#define x_cp_get_disp_ea_020(base,idx) _get_disp_ea_020(base)
#define x_do_cycles(c) do_cycles(c)
@@ -287,10 +313,7 @@ extern int get_cpu_model(void);
extern void set_cpu_caches (bool flush);
extern void REGPARAM3 MakeSR (void) REGPARAM;
extern void REGPARAM3 MakeFromSR (void) REGPARAM;
-extern void REGPARAM3 MakeFromSR_T0(void) REGPARAM;
extern void REGPARAM3 Exception (int) REGPARAM;
-extern void REGPARAM3 Exception_cpu(int) REGPARAM;
-extern void NMI (void);
extern void doint (void);
extern void dump_counts (void);
extern int m68k_move2c (int, uae_u32 *);
@@ -301,9 +324,7 @@ extern void init_m68k (void);
extern void m68k_go (int);
extern int getDivu68kCycles(uae_u32 dividend, uae_u16 divisor);
extern int getDivs68kCycles(uae_s32 dividend, uae_s16 divisor);
-extern void divbyzero_special (bool issigned, uae_s32 dst);
extern void protect_roms (bool);
-extern bool is_hardreset(void);
STATIC_INLINE int bitset_count16(uae_u16 data)
{
@@ -321,7 +342,7 @@ STATIC_INLINE int bitset_count16(uae_u16 data)
}
extern void mmu_op (uae_u32, uae_u32);
-extern bool mmu_op30 (uaecptr, uae_u32, uae_u16, uaecptr);
+extern void mmu_op30 (uaecptr, uae_u32, uae_u16, uaecptr);
extern void fpuop_arithmetic(uae_u32, uae_u16);
extern void fpuop_dbcc(uae_u32, uae_u16);
@@ -330,17 +351,15 @@ extern void fpuop_trapcc(uae_u32, uaecptr, uae_u16);
extern void fpuop_bcc(uae_u32, uaecptr, uae_u32);
extern void fpuop_save(uae_u32);
extern void fpuop_restore(uae_u32);
-extern uae_u32 fpp_get_fpsr (void);
extern void fpu_reset (void);
extern bool fpu_get_constant(fpdata *fp, int cr);
extern int fpp_cond(int condition);
-extern void exception3_read(uae_u32 opcode, uaecptr addr);
-extern void exception3_write(uae_u32 opcode, uaecptr addr);
-extern void exception3_notinstruction(uae_u32 opcode, uaecptr addr);
+extern void exception3 (uae_u32 opcode, uaecptr addr);
extern void exception3i (uae_u32 opcode, uaecptr addr);
extern void exception3b (uae_u32 opcode, uaecptr addr, bool w, bool i, uaecptr pc);
-extern void exception2 (uaecptr addr, bool read, int size, uae_u32 fc);
+extern void exception2 (uaecptr addr);
+extern void exception2_fake (uaecptr addr);
extern void cpureset (void);
extern void cpu_halt (int id);
@@ -350,45 +369,27 @@ extern void fill_prefetch (void);
/* 68040 */
extern const struct cputbl op_smalltbl_1_ff[];
-extern const struct cputbl op_smalltbl_41_ff[];
/* 68030 */
extern const struct cputbl op_smalltbl_2_ff[];
-extern const struct cputbl op_smalltbl_42_ff[];
/* 68020 */
extern const struct cputbl op_smalltbl_3_ff[];
-extern const struct cputbl op_smalltbl_43_ff[];
/* 68010 */
extern const struct cputbl op_smalltbl_4_ff[];
-extern const struct cputbl op_smalltbl_44_ff[];
extern const struct cputbl op_smalltbl_11_ff[]; // prefetch
/* 68000 */
extern const struct cputbl op_smalltbl_5_ff[];
-extern const struct cputbl op_smalltbl_45_ff[];
extern const struct cputbl op_smalltbl_12_ff[]; // prefetch
extern cpuop_func *cpufunctbl[65536] ASM_SYM_FOR_FUNC ("cpufunctbl");
#ifdef JIT
-extern void flush_icache(int);
-extern void flush_icache_hard(int);
+extern void (*flush_icache)(uaecptr, int);
extern void compemu_reset(void);
+extern bool check_prefs_changed_comp (void);
#else
-#define flush_icache(int) do {} while (0)
-#define flush_icache_hard(int) do {} while (0)
+#define flush_icache(uaecptr, int) do {} while (0)
#endif
-bool check_prefs_changed_comp (bool);
extern int movec_illg (int regno);
-#define CPU_HALT_BUS_ERROR_DOUBLE_FAULT 1
-#define CPU_HALT_DOUBLE_FAULT 2
-#define CPU_HALT_OPCODE_FETCH_FROM_NON_EXISTING_ADDRESS 3
-#define CPU_HALT_ALL_CPUS_STOPPED 5
-#define CPU_HALT_FAKE_DMA 6
-#define CPU_HALT_AUTOCONFIG_CONFLICT 7
-#define CPU_HALT_PCI_CONFLICT 8
-#define CPU_HALT_CPU_STUCK 9
-#define CPU_HALT_SSP_IN_NON_EXISTING_ADDRESS 10
-#define CPU_HALT_INVALID_START_ADDRESS 11
-
-#endif /* UAE_NEWCPU_H */
+#endif /* _NEWCPU_H */
diff --git a/src/include/options.h b/src/include/options.h
index f9ccabfd..1af20c1d 100644
--- a/src/include/options.h
+++ b/src/include/options.h
@@ -1,4 +1,4 @@
- /*
+/*
* UAE - The Un*x Amiga Emulator
*
* Stuff
@@ -7,28 +7,32 @@
* Copyright 1995-2001 Bernd Schmidt
*/
-#ifndef UAE_OPTIONS_H
-#define UAE_OPTIONS_H
-
-#include "uae/types.h"
-
-#include "traps.h"
+#ifndef OPTIONS_H
+#define OPTIONS_H
#define UAEMAJOR 3
-#define UAEMINOR 5
-#define UAESUBREV 0
-
-typedef enum { KBD_LANG_US, KBD_LANG_DK, KBD_LANG_DE, KBD_LANG_SE, KBD_LANG_FR, KBD_LANG_IT, KBD_LANG_ES } KbdLang;
+#define UAEMINOR 4
+#define UAESUBREV 1
+#include "traps.h"
extern long int version;
-struct strlist {
- struct strlist *next;
- TCHAR *option, *value;
- int unknown;
+#define MAX_PATHS 8
+
+struct multipath {
+ TCHAR path[MAX_PATHS][PATH_MAX];
};
-#define MAX_TOTAL_SCSI_DEVICES 1
+struct strlist
+{
+ struct strlist* next;
+ TCHAR *option, *value;
+ int unknown;
+};
+
+#define DEFAULT_JIT_CACHE_SIZE 8192
+
+#define MAX_TOTAL_SCSI_DEVICES 8
/* maximum number native input devices supported (single type) */
#define MAX_INPUT_DEVICES 8
@@ -42,37 +46,27 @@ struct strlist {
#define MAX_INPUT_SUB_EVENT_ALL 9
#define SPARE_SUB_EVENT 8
-struct uae_input_device {
- TCHAR *name;
- TCHAR *configname;
+#define INTERNALEVENT_COUNT 1
+
+struct uae_input_device
+{
+ TCHAR* name;
+ TCHAR* configname;
uae_s16 eventid[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT_ALL];
- TCHAR *custom[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT_ALL];
+ TCHAR* custom[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT_ALL];
uae_u64 flags[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT_ALL];
uae_s8 port[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT_ALL];
uae_s16 extra[MAX_INPUT_DEVICE_EVENTS];
uae_s8 enabled;
};
-struct joypad_map_layout {
- int south_action = 0;
- int east_action = 0;
- int west_action = 0;
- int north_action = 0;
- int left_shoulder_action = 0;
- int right_shoulder_action = 0;
- int start_action = 0;
- int select_action = 0;
- int dpad_left_action = 0;
- int dpad_right_action = 0;
- int dpad_up_action = 0;
- int dpad_down_action = 0;
- int lstick_select_action = 0;
- int rstick_select_action = 0;
-};
-
+#define MAX_JPORTS_CUSTOM 6
#define MAX_JPORTS 4
#define NORMAL_JPORTS 2
#define MAX_JPORTNAME 128
+struct jport_custom {
+ TCHAR custom[MAX_DPATH];
+};
struct inputdevconfig {
TCHAR name[MAX_JPORTNAME];
TCHAR configname[MAX_JPORTNAME];
@@ -82,13 +76,8 @@ struct jport {
int id;
int mode; // 0=def,1=mouse,2=joy,3=anajoy,4=lightpen
int autofire;
- int mousemap;
struct inputdevconfig idc;
bool nokeyboardoverride;
- struct joypad_map_layout amiberry_custom_none;
- struct joypad_map_layout amiberry_custom_hotkey;
- struct joypad_map_layout amiberry_custom_left_trigger;
- struct joypad_map_layout amiberry_custom_right_trigger;
};
#define JPORT_UNPLUGGED -2
@@ -98,6 +87,11 @@ struct jport {
#define JPORT_AF_TOGGLE 2
#define JPORT_AF_ALWAYS 3
+#define KBTYPE_AMIGA 0
+#define KBTYPE_PC1 1
+#define KBTYPE_PC2 2
+
+#define MAX_SPARE_DRIVES 20
#define MAX_CUSTOM_MEMORY_ADDRS 2
#define CONFIG_TYPE_ALL -1
@@ -107,10 +101,26 @@ struct jport {
#define CONFIG_TYPE_NORESET 4
#define CONFIG_BLEN 2560
+#define MOUSEUNTRAP_NONE 0
+#define MOUSEUNTRAP_MIDDLEBUTTON 1
+#define MOUSEUNTRAP_MAGIC 2
+#define MOUSEUNTRAP_BOTH 3
+
#define TABLET_OFF 0
#define TABLET_MOUSEHACK 1
#define TABLET_REAL 2
+#ifdef WITH_SLIRP
+#define MAX_SLIRP_REDIRS 32
+struct slirp_redir
+{
+ int proto;
+ int srcport;
+ int dstport;
+ unsigned long addr;
+};
+#endif
+
struct cdslot
{
TCHAR name[MAX_DPATH];
@@ -123,17 +133,24 @@ struct floppyslot
{
TCHAR df[MAX_DPATH];
int dfxtype;
+ int dfxclick;
+ TCHAR dfxclickexternal[256];
bool forcedwriteprotect;
};
+#define ASPECTMULT 1024
+#define WH_NATIVE 1
struct wh {
- int width, height;
+ int x, y;
+ int width, height;
+ int special;
};
#define MOUNT_CONFIG_SIZE 30
#define UAEDEV_DIR 0
#define UAEDEV_HDF 1
#define UAEDEV_CD 2
+#define UAEDEV_TAPE 3
#define HD_LEVEL_SCSI_1 0
#define HD_LEVEL_SCSI_2 1
@@ -149,6 +166,12 @@ struct wh {
#define BOOTPRI_NOAUTOMOUNT -129
#define ISAUTOBOOT(ci) ((ci)->bootpri > BOOTPRI_NOAUTOBOOT)
#define ISAUTOMOUNT(ci) ((ci)->bootpri > BOOTPRI_NOAUTOMOUNT)
+#define MAX_UAEDEV_BADBLOCKS 8
+struct uaedev_badblock
+{
+ uae_u32 first;
+ uae_u32 last;
+};
struct uaedev_config_info {
int type;
TCHAR devname[MAX_DPATH];
@@ -187,6 +210,8 @@ struct uaedev_config_info {
int forceload;
int device_emu_unit;
bool inject_icons;
+ int badblock_num;
+ struct uaedev_badblock badblocks[MAX_UAEDEV_BADBLOCKS];
};
struct uaedev_config_data
@@ -196,31 +221,72 @@ struct uaedev_config_data
int unitnum; // scsi unit number (if tape currently)
};
-enum { CP_GENERIC = 1, CP_CD32, CP_A500, CP_A500P, CP_A600,
- CP_A1200, CP_A2000, CP_A4000 };
+enum {
+ CP_GENERIC = 1, CP_CDTV, CP_CDTVCR, CP_CD32, CP_A500, CP_A500P, CP_A600, CP_A1000,
+ CP_A1200, CP_A2000, CP_A3000, CP_A3000T, CP_A4000, CP_A4000T, CP_VELVET
+};
#define IDE_A600A1200 1
#define IDE_A4000 2
-#define MAX_CHIPSET_REFRESH 1
+#define GFX_WINDOW 0
+#define GFX_FULLSCREEN 1
+#define GFX_FULLWINDOW 2
+
+#define AUTOSCALE_NONE 0
+#define AUTOSCALE_STATIC_AUTO 1
+#define AUTOSCALE_STATIC_NOMINAL 2
+#define AUTOSCALE_STATIC_MAX 3
+#define AUTOSCALE_NORMAL 4
+#define AUTOSCALE_RESIZE 5
+#define AUTOSCALE_CENTER 6
+#define AUTOSCALE_MANUAL 7 // use gfx_xcenter_pos and gfx_ycenter_pos
+#define AUTOSCALE_INTEGER 8
+#define AUTOSCALE_INTEGER_AUTOSCALE 9
+#define AUTOSCALE_SEPARATOR 10
+#define AUTOSCALE_OVERSCAN_BLANK 11
+
+#define MONITOREMU_NONE 0
+#define MONITOREMU_AUTO 1
+#define MONITOREMU_A2024 2
+#define MONITOREMU_GRAFFITI 3
+#define MONITOREMU_HAM_E 4
+#define MONITOREMU_HAM_E_PLUS 5
+#define MONITOREMU_VIDEODAC18 6
+#define MONITOREMU_AVIDEO12 7
+#define MONITOREMU_AVIDEO24 8
+#define MONITOREMU_FIRECRACKER24 9
+#define MONITOREMU_DCTV 10
+#define MONITOREMU_OPALVISION 11
+#define MONITOREMU_COLORBURST 12
+
+#define MAX_FILTERSHADERS 4
+
+#define MAX_CHIPSET_REFRESH 10
#define MAX_CHIPSET_REFRESH_TOTAL (MAX_CHIPSET_REFRESH + 2)
#define CHIPSET_REFRESH_PAL (MAX_CHIPSET_REFRESH + 0)
#define CHIPSET_REFRESH_NTSC (MAX_CHIPSET_REFRESH + 1)
+
struct chipset_refresh
{
bool inuse;
int index;
bool locked;
bool rtg;
+ bool exit;
bool defaultdata;
int horiz;
int vert;
int lace;
int resolution;
+ int resolution_pct;
int ntsc;
int vsync;
- float rate;
+ int framelength;
+ double rate;
TCHAR label[16];
+ TCHAR commands[256];
+ TCHAR filterprofile[64];
};
#define APMODE_NATIVE 0
@@ -228,15 +294,48 @@ struct chipset_refresh
struct apmode
{
+ int gfx_fullscreen;
+ int gfx_display;
int gfx_vsync;
// 0 = immediate flip
// -1 = wait for flip, before frame ends
// 1 = wait for flip, after new frame has started
int gfx_vflip;
+ // doubleframemode strobo
+ bool gfx_strobo;
+ int gfx_vsyncmode;
+ int gfx_backbuffers;
+ bool gfx_interlaced;
int gfx_refreshrate;
};
-#define MAX_DUPLICATE_EXPANSION_BOARDS 1
+#define MAX_LUA_STATES 16
+
+
+struct gfx_filterdata
+{
+ int gfx_filter;
+ TCHAR gfx_filtershader[2 * MAX_FILTERSHADERS + 1][MAX_DPATH];
+ TCHAR gfx_filtermask[2 * MAX_FILTERSHADERS + 1][MAX_DPATH];
+ TCHAR gfx_filteroverlay[MAX_DPATH];
+ struct wh gfx_filteroverlay_pos;
+ int gfx_filteroverlay_overscan;
+ int gfx_filter_scanlines;
+ int gfx_filter_scanlineratio;
+ int gfx_filter_scanlinelevel;
+ float gfx_filter_horiz_zoom, gfx_filter_vert_zoom;
+ float gfx_filter_horiz_zoom_mult, gfx_filter_vert_zoom_mult;
+ float gfx_filter_horiz_offset, gfx_filter_vert_offset;
+ int gfx_filter_filtermode;
+ int gfx_filter_bilinear;
+ int gfx_filter_noise, gfx_filter_blur;
+ int gfx_filter_saturation, gfx_filter_luminance, gfx_filter_contrast, gfx_filter_gamma;
+ int gfx_filter_keep_aspect, gfx_filter_aspect;
+ int gfx_filter_autoscale;
+ int gfx_filter_keep_autoscale_aspect;
+};
+
+#define MAX_DUPLICATE_EXPANSION_BOARDS 4
#define MAX_EXPANSION_BOARDS 20
struct boardromconfig;
struct romconfig
@@ -260,21 +359,28 @@ struct boardromconfig
int device_order;
struct romconfig roms[MAX_BOARD_ROMS];
};
-#define MAX_RTG_BOARDS 1
+#define MAX_RTG_BOARDS 4
struct rtgboardconfig
{
+ int rtg_index;
int rtgmem_type;
uae_u32 rtgmem_size;
int device_order;
};
-#define MAX_RAM_BOARDS 1
+#define MAX_RAM_BOARDS 4
struct ramboard
{
uae_u32 size;
uae_u16 manufacturer;
uae_u8 product;
uae_u8 autoconfig[16];
+ bool autoconfig_inuse;
+ bool manual_config;
+ bool no_reset_unmap;
int device_order;
+ uae_u32 start_address;
+ uae_u32 end_address;
+ uae_u32 write_address;
};
struct expansion_params
{
@@ -285,61 +391,171 @@ struct expansion_params
#define Z3MAPPING_UAE 1
#define Z3MAPPING_REAL 2
-struct uae_prefs {
- struct strlist *all_lines;
+struct uae_prefs
+{
+ struct strlist* all_lines;
TCHAR description[256];
TCHAR info[256];
int config_version;
- bool socket_emu;
- bool start_gui;
+ TCHAR config_hardware_path[MAX_DPATH];
+ TCHAR config_host_path[MAX_DPATH];
+ TCHAR config_all_path[MAX_DPATH];
+ TCHAR config_window_title[256];
- KbdLang keyboard_lang;
+ bool illegal_mem;
+ bool use_serial;
+ bool serial_demand;
+ bool serial_hwctsrts;
+ bool serial_direct;
+ int serial_stopbits;
+ int serial_crlf;
+ bool parallel_demand;
+ int parallel_matrix_emulation;
+ bool parallel_postscript_emulation;
+ bool parallel_postscript_detection;
+ int parallel_autoflush_time;
+ TCHAR ghostscript_parameters[256];
+ bool use_gfxlib;
+ bool socket_emu;
+
+ bool start_debugger;
+ bool start_gui;
int produce_sound;
int sound_stereo;
int sound_stereo_separation;
int sound_mixed_stereo_delay;
int sound_freq;
+ int sound_maxbsiz;
int sound_interpol;
int sound_filter;
int sound_filter_type;
+ int sound_volume_master;
+ int sound_volume_paula;
int sound_volume_cd;
+ int sound_volume_board;
+ int sound_volume_midi;
+ int sound_volume_genlock;
+ bool sound_stereo_swap_paula;
+ bool sound_stereo_swap_ahi;
+ bool sound_auto;
+ bool sound_cdaudio;
+ int sampler_freq;
+ int sampler_buffer;
+ bool sampler_stereo;
+
+ int comptrustbyte;
+ int comptrustword;
+ int comptrustlong;
+ int comptrustnaddr;
+ bool compnf;
+ bool compfpu;
+ bool comp_hardflush;
+ bool comp_constjump;
int cachesize;
bool fpu_strict;
+
bool fpu_softfloat;
- int gfx_framerate;
+ int gfx_framerate, gfx_autoframerate;
+ struct wh gfx_size_win;
+ struct wh gfx_size_fs;
struct wh gfx_size;
+ struct wh gfx_size_win_xtra[6];
+ struct wh gfx_size_fs_xtra[6];
+ bool gfx_autoresolution_vga;
+ int gfx_autoresolution;
+ int gfx_autoresolution_delay;
+ int gfx_autoresolution_minv, gfx_autoresolution_minh;
+ bool gfx_scandoubler;
struct apmode gfx_apmode[2];
int gfx_resolution;
+ int gfx_vresolution;
+ int gfx_lores_mode;
+ int gfx_pscanlines, gfx_iscanlines;
+ int gfx_xcenter, gfx_ycenter;
+ int gfx_xcenter_pos, gfx_ycenter_pos;
+ int gfx_xcenter_size, gfx_ycenter_size;
+ int gfx_max_horizontal, gfx_max_vertical;
+ int gfx_saturation, gfx_luminance, gfx_contrast, gfx_gamma, gfx_gamma_ch[3];
+ bool gfx_blackerthanblack;
+ int gfx_threebitcolors;
+ int gfx_api;
+ int color_mode;
+ int gfx_extrawidth;
+ bool lightboost_strobo;
+ int lightboost_strobo_ratio;
+ bool gfx_grayscale;
+
+ struct gfx_filterdata gf[2];
+
+ float rtg_horiz_zoom_mult;
+ float rtg_vert_zoom_mult;
bool immediate_blits;
int waiting_blits;
unsigned int chipset_mask;
+ bool keyboard_connected;
bool ntscmode;
- float chipset_refreshrate;
+ bool genlock;
+ int genlock_image;
+ int genlock_mix;
+ int genlock_scale;
+ int genlock_aspect;
+ bool genlock_alpha;
+ TCHAR genlock_image_file[MAX_DPATH];
+ TCHAR genlock_video_file[MAX_DPATH];
+ int monitoremu;
+ double chipset_refreshrate;
struct chipset_refresh cr[MAX_CHIPSET_REFRESH + 2];
int cr_selected;
int collision_level;
int leds_on_screen;
- int fast_copper;
+ int leds_on_screen_mask[2];
+ struct wh osd_pos;
+ int keyboard_leds[3];
+ bool keyboard_leds_in_use;
+ int scsi;
+ bool sana2;
+ bool uaeserial;
+ int catweasel;
+ int cpu_idle;
+ int ppc_cpu_idle;
+ bool cpu_cycle_exact;
+ int cpu_clock_multiplier;
+ int cpu_frequency;
+ bool blitter_cycle_exact;
+ bool cpu_memory_cycle_exact;
int floppy_speed;
int floppy_write_length;
+ int floppy_random_bits_min;
+ int floppy_random_bits_max;
int floppy_auto_ext2;
int cd_speed;
+ bool tod_hack;
+ uae_u32 maprom;
int boot_rom;
+ bool rom_readwrite;
+ int turbo_emulation;
+ int turbo_emulation_limit;
+ bool headless;
int filesys_limit;
int filesys_max_name;
+ int filesys_max_file_size;
bool filesys_inject_icons;
TCHAR filesys_inject_icons_tool[MAX_DPATH];
TCHAR filesys_inject_icons_project[MAX_DPATH];
TCHAR filesys_inject_icons_drawer[MAX_DPATH];
+ int uaescsidevmode;
+ bool reset_delay;
int cs_compatible;
int cs_ciaatod;
int cs_rtc;
+ int cs_rtc_adjust;
+ int cs_rtc_adjust_mode;
bool cs_ksmirror_e0;
bool cs_ksmirror_a8;
bool cs_ciaoverlay;
@@ -348,44 +564,103 @@ struct uae_prefs {
bool cs_cd32nvram;
bool cs_cd32fmv;
int cs_cd32nvram_size;
+ bool cs_cdtvcd;
+ bool cs_cdtvram;
+ int cs_cdtvcard;
int cs_ide;
bool cs_pcmcia;
+ bool cs_a1000ram;
int cs_fatgaryrev;
int cs_ramseyrev;
+ int cs_agnusrev;
+ int cs_deniserev;
+ int cs_mbdmac;
+ bool cs_cdtvscsi;
+ bool cs_cdtvcr;
bool cs_df0idhw;
+ bool cs_slowmemisfast;
+ bool cs_resetwarning;
+ bool cs_denisenoehb;
+ bool cs_dipagnus;
+ bool cs_agnusbltbusybug;
bool cs_ciatodbug;
bool cs_z3autoconfig;
+ bool cs_1mchipjumper;
+ bool cs_cia6526;
bool cs_bytecustomwritebug;
+ bool cs_color_burst;
+ int cs_hacks;
struct boardromconfig expansionboard[MAX_EXPANSION_BOARDS];
TCHAR romfile[MAX_DPATH];
+ TCHAR romident[256];
TCHAR romextfile[MAX_DPATH];
+ uae_u32 romextfile2addr;
+ TCHAR romextfile2[MAX_DPATH];
+ TCHAR romextident[256];
TCHAR flashfile[MAX_DPATH];
+ TCHAR rtcfile[MAX_DPATH];
TCHAR cartfile[MAX_DPATH];
+ TCHAR cartident[256];
int cart_internal;
+ TCHAR pci_devices[256];
+ TCHAR prtname[256];
+ TCHAR sername[256];
+ TCHAR a2065name[MAX_DPATH];
+ TCHAR ne2000pciname[MAX_DPATH];
+ TCHAR ne2000pcmcianame[MAX_DPATH];
+ TCHAR picassoivromfile[MAX_DPATH];
struct cdslot cdslots[MAX_TOTAL_SCSI_DEVICES];
+ TCHAR quitstatefile[MAX_DPATH];
+ TCHAR statefile[MAX_DPATH];
+ TCHAR inprecfile[MAX_DPATH];
+ bool inprec_autoplay;
+ bool refresh_indicator;
- TCHAR path_floppy[MAX_DPATH];
- TCHAR path_hardfile[MAX_DPATH];
- TCHAR path_rom[MAX_DPATH];
- TCHAR path_cd[MAX_DPATH];
+ struct multipath path_floppy;
+ struct multipath path_hardfile;
+ struct multipath path_rom;
+ struct multipath path_cd;
int m68k_speed;
+ double m68k_speed_throttle;
+ double x86_speed_throttle;
int cpu_model;
+ int mmu_model;
+ int cpu060_revision;
int fpu_model;
+ int fpu_revision;
+ int ppc_mode;
+ TCHAR ppc_model[32];
bool cpu_compatible;
+ bool cpu_thread;
+ bool int_no_unimplemented;
bool fpu_no_unimplemented;
bool address_space_24;
+ bool picasso96_nocustom;
int picasso96_modeflags;
+ int cpu_model_fallback;
uae_u32 z3autoconfig_start;
struct ramboard z3fastmem[MAX_RAM_BOARDS];
struct ramboard fastmem[MAX_RAM_BOARDS];
+ uae_u32 z3chipmem_size;
+ uae_u32 z3chipmem_start;
uae_u32 chipmem_size;
uae_u32 bogomem_size;
uae_u32 mbresmem_low_size;
uae_u32 mbresmem_high_size;
+ uae_u32 mem25bit_size;
+ int cpuboard_type;
+ int cpuboard_subtype;
+ int cpuboard_settings;
+ uae_u32 cpuboardmem1_size;
+ uae_u32 cpuboardmem2_size;
+ int ppc_implementation;
+ bool rtg_hardwareinterrupt;
+ bool rtg_hardwaresprite;
+ bool rtg_more_compatible;
struct rtgboardconfig rtgboards[MAX_RTG_BOARDS];
uae_u32 custom_memory_addrs[MAX_CUSTOM_MEMORY_ADDRS];
uae_u32 custom_memory_sizes[MAX_CUSTOM_MEMORY_ADDRS];
@@ -393,7 +668,20 @@ struct uae_prefs {
int uaeboard;
int uaeboard_order;
+ bool kickshifter;
+ bool filesys_no_uaefsdb;
+ bool filesys_custom_uaefsdb;
+ bool mmkeyboard;
+ int uae_hide;
+ bool clipboard_sharing;
+ bool native_code;
+ bool uae_hide_autoconfig;
int z3_mapping_mode;
+ bool autoconfig_custom_sort;
+ bool obs_sound_toccata;
+ bool obs_sound_toccata_mixer;
+ bool obs_sound_es1370;
+ bool obs_sound_fm801;
int mountitems;
struct uaedev_config_data mountconfig[MOUNT_CONFIG_SIZE];
@@ -402,42 +690,40 @@ struct uae_prefs {
struct floppyslot floppyslots[4];
bool floppy_read_only;
bool harddrive_read_only;
+ TCHAR dfxlist[MAX_SPARE_DRIVES][MAX_DPATH];
+ int dfxclickvolume_disk[4];
+ int dfxclickvolume_empty[4];
+ int dfxclickchannelmask;
+
+ TCHAR luafiles[MAX_LUA_STATES][MAX_DPATH];
/* Target specific options */
#ifdef AMIBERRY
+ int gfx_correct_aspect;
+ int gfx_fullscreen_ratio;
int kbd_led_num;
int kbd_led_scr;
int kbd_led_cap;
int scaling_method;
- bool customControls;
- TCHAR custom_up[256];
- TCHAR custom_down[256];
- TCHAR custom_left[256];
- TCHAR custom_right[256];
- TCHAR custom_a[256];
- TCHAR custom_b[256];
- TCHAR custom_x[256];
- TCHAR custom_y[256];
- TCHAR custom_l[256];
- TCHAR custom_r[256];
- TCHAR custom_play[256];
- TCHAR open_gui[256];
- TCHAR quit_amiberry[256];
-#endif
-
-#ifdef PANDORA
-int pandora_vertical_offset;
- int pandora_cpu_speed;
- int pandora_hide_idle_led;
-
- int pandora_tapDelay;
- int pandora_customControls;
+ int amiberry_customControls;
+ int key_for_menu;
+ int key_for_quit;
+ int button_for_menu;
+ int button_for_quit;
#endif
+ int statecapturerate, statecapturebuffersize;
+ int aviout_width, aviout_height, aviout_xoffset, aviout_yoffset;
+ int screenshot_width, screenshot_height, screenshot_xoffset, screenshot_yoffset;
+ int screenshot_min_width, screenshot_min_height;
+ int screenshot_max_width, screenshot_max_height;
+ int screenshot_output_width, screenshot_output_height;
+ int screenshot_xmult, screenshot_ymult;
/* input */
struct jport jports[MAX_JPORTS];
+ struct jport_custom jports_custom[MAX_JPORTS_CUSTOM];
int input_selected_setting;
int input_joymouse_multiplier;
int input_joymouse_deadzone;
@@ -448,153 +734,105 @@ int pandora_vertical_offset;
int input_autofire_linecnt;
int input_mouse_speed;
int input_tablet;
+ bool tablet_library;
+ int input_mouse_untrap;
+ int input_magic_mouse_cursor;
int input_keyboard_type;
-
- bool amiberry_use_retroarch_quit;
- bool amiberry_use_retroarch_menu;
- bool amiberry_use_retroarch_reset;
- bool amiberry_use_retroarch_statebuttons;
-
- /* ANDROID */
-#ifdef ANDROIDSDL
-int onScreen;
-int onScreen_textinput;
-int onScreen_dpad;
-int onScreen_button1;
-int onScreen_button2;
-int onScreen_button3;
-int onScreen_button4;
-int onScreen_button5;
-int onScreen_button6;
-int custom_position;
-int pos_x_textinput;
-int pos_y_textinput;
-int pos_x_dpad;
-int pos_y_dpad;
-int pos_x_button1;
-int pos_y_button1;
-int pos_x_button2;
-int pos_y_button2;
-int pos_x_button3;
-int pos_y_button3;
-int pos_x_button4;
-int pos_y_button4;
-int pos_x_button5;
-int pos_y_button5;
-int pos_x_button6;
-int pos_y_button6;
-int extfilter;
-int quickSwitch;
-int floatingJoystick;
-int disableMenuVKeyb;
-#endif
-
+ int input_autoswitch;
struct uae_input_device joystick_settings[MAX_INPUT_SETTINGS][MAX_INPUT_DEVICES];
struct uae_input_device mouse_settings[MAX_INPUT_SETTINGS][MAX_INPUT_DEVICES];
struct uae_input_device keyboard_settings[MAX_INPUT_SETTINGS][MAX_INPUT_DEVICES];
+ struct uae_input_device internalevent_settings[MAX_INPUT_SETTINGS][INTERNALEVENT_COUNT];
TCHAR input_config_name[GAMEPORT_INPUT_SETTINGS][256];
+ int dongle;
+ int input_contact_bounce;
+ int input_device_match_mask;
};
extern int config_changed;
-extern void config_check_vsync (void);
-extern void set_config_changed (void);
+extern void config_check_vsync(void);
+extern void set_config_changed(void);
/* Contains the filename of .uaerc */
-extern void cfgfile_write (struct zfile *, const TCHAR *option, const TCHAR *format,...);
-extern void cfgfile_dwrite (struct zfile *, const TCHAR *option, const TCHAR *format,...);
-extern void cfgfile_target_write (struct zfile *, const TCHAR *option, const TCHAR *format,...);
-extern void cfgfile_target_dwrite (struct zfile *, const TCHAR *option, const TCHAR *format,...);
+extern TCHAR optionsfile[];
+extern void save_options(struct zfile *, struct uae_prefs *, int);
-extern void cfgfile_write_bool (struct zfile *f, const TCHAR *option, bool b);
-extern void cfgfile_dwrite_bool (struct zfile *f,const TCHAR *option, bool b);
-extern void cfgfile_target_write_bool (struct zfile *f, const TCHAR *option, bool b);
-extern void cfgfile_target_dwrite_bool (struct zfile *f, const TCHAR *option, bool b);
+extern void cfgfile_write(struct zfile *, const TCHAR *option, const TCHAR *format, ...);
+extern void cfgfile_dwrite(struct zfile *, const TCHAR *option, const TCHAR *format, ...);
+extern void cfgfile_target_write(struct zfile *, const TCHAR *option, const TCHAR *format, ...);
+extern void cfgfile_target_dwrite(struct zfile *, const TCHAR *option, const TCHAR *format, ...);
-extern void cfgfile_write_str (struct zfile *f, const TCHAR *option, const TCHAR *value);
-extern void cfgfile_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *value);
-extern void cfgfile_target_write_str (struct zfile *f, const TCHAR *option, const TCHAR *value);
-extern void cfgfile_target_dwrite_str (struct zfile *f, const TCHAR *option, const TCHAR *value);
+extern void cfgfile_write_bool(struct zfile *f, const TCHAR *option, bool b);
+extern void cfgfile_dwrite_bool(struct zfile *f, const TCHAR *option, bool b);
+extern void cfgfile_target_write_bool(struct zfile *f, const TCHAR *option, bool b);
+extern void cfgfile_target_dwrite_bool(struct zfile *f, const TCHAR *option, bool b);
-extern struct uaedev_config_data *add_filesys_config (struct uae_prefs *p, int index, struct uaedev_config_info*);
-extern bool get_hd_geometry (struct uaedev_config_info *);
-extern void uci_set_defaults (struct uaedev_config_info *uci, bool rdb);
+extern void cfgfile_write_str(struct zfile *f, const TCHAR *option, const TCHAR *value);
+extern void cfgfile_dwrite_str(struct zfile *f, const TCHAR *option, const TCHAR *value);
+extern void cfgfile_target_write_str(struct zfile *f, const TCHAR *option, const TCHAR *value);
+extern void cfgfile_target_dwrite_str(struct zfile *f, const TCHAR *option, const TCHAR *value);
-extern void error_log (const TCHAR*, ...);
-extern TCHAR *get_error_log (void);
-extern bool is_error_log (void);
+extern void cfgfile_backup(const TCHAR *path);
+extern struct uaedev_config_data *add_filesys_config(struct uae_prefs *p, int index, struct uaedev_config_info*);
+extern bool get_hd_geometry(struct uaedev_config_info *);
+extern void uci_set_defaults(struct uaedev_config_info *uci, bool rdb);
-extern void default_prefs (struct uae_prefs *, bool, int);
-extern void discard_prefs (struct uae_prefs *, int);
-extern int bip_a500 (struct uae_prefs *p, int rom);
-extern int bip_a500plus (struct uae_prefs *p, int rom);
-extern int bip_a1200 (struct uae_prefs *p, int rom);
-extern int bip_a2000 (struct uae_prefs *p, int rom);
-extern int bip_a4000 (struct uae_prefs *p, int rom);
-extern int bip_cd32 (struct uae_prefs *p, int rom);
+extern void error_log(const TCHAR*, ...);
+extern TCHAR *get_error_log(void);
+extern bool is_error_log(void);
-int parse_cmdline_option (struct uae_prefs *, TCHAR, const TCHAR *);
+extern void default_prefs(struct uae_prefs *, bool, int);
+extern void discard_prefs(struct uae_prefs *, int);
-extern int cfgfile_separate_linea (const TCHAR *filename, char *line, TCHAR *line1b, TCHAR *line2b);
-extern int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location);
-extern int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale);
-extern int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, const TCHAR *table[], int more);
-extern int cfgfile_string (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz);
-extern TCHAR *cfgfile_subst_path (const TCHAR *path, const TCHAR *subst, const TCHAR *file);
+int parse_cmdline_option(struct uae_prefs *, TCHAR, const TCHAR*);
-extern TCHAR *target_expand_environment (const TCHAR *path, TCHAR *out, int maxlen);
-extern int target_parse_option (struct uae_prefs *, const TCHAR *option, const TCHAR *value);
-extern void target_save_options (struct zfile*, struct uae_prefs *);
-extern void target_default_options (struct uae_prefs *, int type);
-extern void target_fixup_options (struct uae_prefs *);
-extern int target_cfgfile_load (struct uae_prefs *, const TCHAR *filename, int type, int isdefault);
-extern void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type);
+extern int cfgfile_yesno(const TCHAR *option, const TCHAR *value, const TCHAR *name, bool *location);
+extern int cfgfile_intval(const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale);
+extern int cfgfile_strval(const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, const TCHAR *table[], int more);
+extern int cfgfile_string(const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz);
+extern TCHAR *cfgfile_subst_path(const TCHAR *path, const TCHAR *subst, const TCHAR *file);
-extern int cfgfile_load (struct uae_prefs *p, const TCHAR *filename, int *type, int ignorelink, int userconfig);
-extern int cfgfile_save (struct uae_prefs *p, const TCHAR *filename, int);
-extern void cfgfile_parse_line (struct uae_prefs *p, TCHAR *, int);
-extern int cfgfile_parse_option (struct uae_prefs *p, const TCHAR *option, TCHAR *value, int);
-extern int cfgfile_get_description (const TCHAR *filename, TCHAR *description);
-extern uae_u32 cfgfile_uaelib (TrapContext *ctx, int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen);
-extern uae_u32 cfgfile_uaelib_modify (TrapContext *ctx, uae_u32 mode, uae_u32 parms, uae_u32 size, uae_u32 out, uae_u32 outsize);
-extern uae_u32 cfgfile_modify (uae_u32 index, const TCHAR *parms, uae_u32 size, TCHAR *out, uae_u32 outsize);
-extern void cfgfile_addcfgparam (TCHAR *);
-extern int built_in_prefs (struct uae_prefs *p, int model, int config, int compa, int romcheck);
-extern int built_in_chipset_prefs (struct uae_prefs *p);
+extern TCHAR *target_expand_environment(const TCHAR *path);
+extern int target_parse_option(struct uae_prefs *, const TCHAR *option, const TCHAR *value);
+extern void target_save_options(struct zfile*, struct uae_prefs *);
+extern void target_default_options(struct uae_prefs *, int type);
+extern void target_fixup_options(struct uae_prefs *);
+extern int target_cfgfile_load(struct uae_prefs *, const TCHAR *filename, int type, int isdefault);
+extern void cfgfile_save_options(struct zfile *f, struct uae_prefs *p, int type);
+extern int target_get_display(const TCHAR*);
+extern const TCHAR *target_get_display_name(int, bool);
+
+extern int cfgfile_load(struct uae_prefs *p, const TCHAR *filename, int *type, int ignorelink, int userconfig);
+extern int cfgfile_save(struct uae_prefs *p, const TCHAR *filename, int);
+extern void cfgfile_parse_line(struct uae_prefs *p, TCHAR *, int);
+extern void cfgfile_parse_lines(struct uae_prefs *p, const TCHAR *, int);
+extern int cfgfile_parse_option(struct uae_prefs *p, const TCHAR *option, TCHAR *value, int);
+extern int cfgfile_get_description(const TCHAR *filename, TCHAR *description, TCHAR *hostlink, TCHAR *hardwarelink, int *type);
+extern void cfgfile_show_usage(void);
+extern int cfgfile_searchconfig(const TCHAR *in, int index, TCHAR *out, int outsize);
+extern uae_u32 cfgfile_uaelib(TrapContext *ctx, int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen);
+extern uae_u32 cfgfile_uaelib_modify(TrapContext *ctx, uae_u32 mode, uae_u32 parms, uae_u32 size, uae_u32 out, uae_u32 outsize);
+extern uae_u32 cfgfile_modify(uae_u32 index, const TCHAR *parms, uae_u32 size, TCHAR *out, uae_u32 outsize);
+extern void cfgfile_addcfgparam(TCHAR *);
+extern int built_in_prefs(struct uae_prefs *p, int model, int config, int compa, int romcheck);
+extern int built_in_chipset_prefs(struct uae_prefs *p);
+extern int cmdlineparser(const TCHAR *s, TCHAR *outp[], int max);
extern int cfgfile_configuration_change(int);
-extern void fixup_prefs_dimensions (struct uae_prefs *prefs);
-extern void fixup_prefs (struct uae_prefs *prefs, bool userconfig);
-extern void fixup_cpu (struct uae_prefs *prefs);
+extern void fixup_prefs_dimensions(struct uae_prefs *prefs);
+extern void fixup_prefs(struct uae_prefs *prefs, bool userconfig);
+extern void fixup_cpu(struct uae_prefs *prefs);
extern void cfgfile_compatibility_romtype(struct uae_prefs *p);
extern void cfgfile_compatibility_rtg(struct uae_prefs *p);
-extern void check_prefs_changed_custom (void);
-extern void check_prefs_changed_cpu (void);
-extern void check_prefs_changed_audio (void);
-extern void check_prefs_changed_cd (void);
-extern int check_prefs_changed_gfx (void);
+extern void check_prefs_changed_custom(void);
+extern void check_prefs_changed_cpu(void);
+extern void check_prefs_changed_audio(void);
+extern void check_prefs_changed_cd(void);
+extern int check_prefs_changed_gfx(void);
extern struct uae_prefs currprefs, changed_prefs;
-extern int machdep_init (void);
-extern void machdep_free (void);
+extern int machdep_init(void);
+extern void machdep_free(void);
-
-
-
-struct amiberry_customised_layout {
-
- // create structures for each 'function' button
- struct joypad_map_layout none;
- struct joypad_map_layout select;
- struct joypad_map_layout left_trigger;
- struct joypad_map_layout right_trigger;
-
- };
-
-extern const int RemapEventList[];
-extern const int RemapEventListSize;
-
-extern void saveAdfDir(void);
-extern void import_joysticks(void);
-
-#endif /* UAE_OPTIONS_H */
+#endif /* OPTIONS_H */
diff --git a/src/include/rommgr.h b/src/include/rommgr.h
index c0f5e8e6..cf3dfa4c 100644
--- a/src/include/rommgr.h
+++ b/src/include/rommgr.h
@@ -1,7 +1,5 @@
-#ifndef UAE_ROMMGR_H
-#define UAE_ROMMGR_H
-
-extern int decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size);
+#pragma once
+extern int decode_cloanto_rom_do(uae_u8 *mem, int size, int real_size);
#define ROMTYPE_SUB_MASK 0x000000ff
#define ROMTYPE_GROUP_MASK 0x003fff00
@@ -148,9 +146,6 @@ extern int decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size);
#define ROMTYPE_HARDFRAME 0x0010005e
#define ROMTYPE_ATEAM 0x0010005f
#define ROMTYPE_PMX 0x00100060
-#define ROMTYPE_COMSPEC 0x00100061
-#define ROMTYPE_MALIBU 0x00100062
-#define ROMTYPE_RAPIDFIRE 0x00100063
#define ROMTYPE_NOT 0x00800000
#define ROMTYPE_QUAD 0x01000000
@@ -163,84 +158,91 @@ extern int decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size);
#define ROMTYPE_NONE 0x80000000
#define ROMTYPE_ALL_KICK (ROMTYPE_KICK | ROMTYPE_KICKCD32 | ROMTYPE_CD32)
-#define ROMTYPE_ALL_EXT (ROMTYPE_EXTCD32)
+#define ROMTYPE_ALL_EXT (ROMTYPE_EXTCD32 | ROMTYPE_EXTCDTV)
#define ROMTYPE_ALL_CART (ROMTYPE_AR | ROMTYPE_HRTMON | ROMTYPE_NORDIC | ROMTYPE_XPOWER | ROMTYPE_CD32CART)
struct romheader {
const TCHAR *name;
- int id;
+ int id;
};
struct romdata {
const TCHAR *name;
- int ver, rev;
- int subver, subrev;
+ int ver, rev;
+ int subver, subrev;
const TCHAR *model;
- uae_u32 size;
- int id;
- int cpu;
- int cloanto;
+ uae_u32 size;
+ int id;
+ int cpu;
+ int cloanto;
uae_u32 type;
- int group;
- int title;
+ int group;
+ int title;
const TCHAR *partnumber;
- uae_u32 crc32;
- uae_u32 sha1[5];
+ uae_u32 crc32;
+ uae_u32 sha1[5];
const TCHAR *configname;
const TCHAR *defaultfilename;
};
struct romlist {
- TCHAR *path;
- struct romdata *rd;
+ TCHAR *path;
+ struct romdata *rd;
};
-extern struct romdata *getromdatabypath (const TCHAR *path);
-extern struct romdata *getromdatabycrc (uae_u32 crc32);
-extern struct romdata *getromdatabycrc (uae_u32 crc32, bool);
-extern struct romdata *getromdatabydata (uae_u8 *rom, int size);
-extern struct romdata *getromdatabyid (int id);
-extern struct romdata *getromdatabyidgroup (int id, int group, int subitem);
-extern struct romdata *getromdatabyzfile (struct zfile *f);
+extern struct romdata *getromdatabypath(const TCHAR *path);
+extern struct romdata *getromdatabycrc(uae_u32 crc32);
+extern struct romdata *getromdatabycrc(uae_u32 crc32, bool);
+extern struct romdata *getromdatabydata(uae_u8 *rom, int size);
+extern struct romdata *getromdatabyid(int id);
+extern struct romdata *getromdatabyidgroup(int id, int group, int subitem);
+extern struct romdata *getromdatabyzfile(struct zfile *f);
extern struct romdata *getfrombydefaultname(const TCHAR *name, int size);
-extern void getromname (const struct romdata*, TCHAR*);
-extern struct romdata *getromdatabyname (const TCHAR*);
-extern struct romlist *getromlistbyids (const int *ids, const TCHAR *romname);
-extern struct romdata *getromdatabyids (const int *ids);
+extern struct romlist **getarcadiaroms(void);
+extern struct romdata *getarcadiarombyname(const TCHAR *name);
+extern struct romlist **getromlistbyident(int ver, int rev, int subver, int subrev, const TCHAR *model, int romflags, bool all);
+extern void getromname(const struct romdata*, TCHAR*);
+extern struct romdata *getromdatabyname(const TCHAR*);
+extern struct romlist *getromlistbyids(const int *ids, const TCHAR *romname);
+extern struct romdata *getromdatabyids(const int *ids);
extern struct romlist *getromlistbyromtype(uae_u32 romtype);
extern void romwarning(const int *ids);
extern struct romlist *getromlistbyromdata(const struct romdata *rd);
-extern void romlist_add (const TCHAR *path, struct romdata *rd);
-extern TCHAR *romlist_get (const struct romdata *rd);
-extern void romlist_clear (void);
-extern struct zfile *read_rom (struct romdata *rd);
-extern struct zfile *read_rom_name (const TCHAR *filename);
+extern void romlist_add(const TCHAR *path, struct romdata *rd);
+extern TCHAR *romlist_get(const struct romdata *rd);
+extern void romlist_clear(void);
+extern struct zfile *read_rom(struct romdata *rd);
+extern struct zfile *read_rom_name(const TCHAR *filename);
extern struct zfile *read_device_from_romconfig(struct romconfig *rc, uae_u32 romtype);
-extern int load_keyring (struct uae_prefs *p, const TCHAR *path);
-extern uae_u8 *target_load_keyfile (struct uae_prefs *p, const TCHAR *path, int *size, TCHAR *name);
-extern void free_keyring (void);
-extern int get_keyring (void);
-extern void kickstart_fix_checksum (uae_u8 *mem, int size);
-extern void descramble_nordicpro (uae_u8*, int, int);
-extern int kickstart_checksum (uae_u8 *mem, int size);
-extern int decode_rom (uae_u8 *mem, int size, int mode, int real_size);
-extern struct zfile *rom_fopen (const TCHAR *name, const TCHAR *mode, int mask);
-extern struct zfile *read_rom_name_guess (const TCHAR *filename);
-extern void addkeydir (const TCHAR *path);
-extern void addkeyfile (const TCHAR *path);
-extern int romlist_count (void);
-extern struct romlist *romlist_getit (void);
-extern int configure_rom (struct uae_prefs *p, const int *rom, int msg);
+extern int load_keyring(struct uae_prefs *p, const TCHAR *path);
+extern uae_u8 *target_load_keyfile(struct uae_prefs *p, const TCHAR *path, int *size, TCHAR *name);
+extern void free_keyring(void);
+extern int get_keyring(void);
+extern void kickstart_fix_checksum(uae_u8 *mem, int size);
+extern void descramble_nordicpro(uae_u8*, int, int);
+extern int kickstart_checksum(uae_u8 *mem, int size);
+extern int decode_rom(uae_u8 *mem, int size, int mode, int real_size);
+extern struct zfile *rom_fopen(const TCHAR *name, const TCHAR *mode, int mask);
+extern struct zfile *read_rom_name_guess(const TCHAR *filename);
+extern void addkeydir(const TCHAR *path);
+extern void addkeyfile(const TCHAR *path);
+extern int romlist_count(void);
+extern struct romlist *romlist_getit(void);
+extern int configure_rom(struct uae_prefs *p, const int *rom, int msg);
int is_device_rom(struct uae_prefs *p, int romtype, int devnum);
+struct zfile *read_device_rom(struct uae_prefs *p, int romtype, int devnum, int *roms);
struct romconfig *get_device_romconfig(struct uae_prefs *p, int romtype, int devnum);
struct boardromconfig *get_device_rom(struct uae_prefs *p, int romtype, int devnum, int *index);
+void set_device_rom(struct uae_prefs *p, const TCHAR *path, int romtype, int devnum);
const struct expansionromtype *get_device_expansion_rom(int romtype);
+const struct expansionromtype *get_unit_expansion_rom(int hdunit);
struct boardromconfig *get_device_rom_new(struct uae_prefs *p, int romtype, int devnum, int *index);
void clear_device_rom(struct uae_prefs *p, int romtype, int devnum, bool deleteDevice);
struct boardromconfig *get_boardromconfig(struct uae_prefs *p, int romtype, int *index);
bool is_board_enabled(struct uae_prefs *p, int romtype, int devnum);
+void board_prefs_changed(int romtype, int devnum);
#define LOADROM_FILL 1
#define LOADROM_EVENONLY 2
@@ -251,5 +253,3 @@ bool is_board_enabled(struct uae_prefs *p, int romtype, int devnum);
bool load_rom_rc(struct romconfig *rc, uae_u32 romtype, int maxfilesize, int fileoffset, uae_u8 *rom, int maxromsize, int flags);
#define EXPANSION_ORDER_MAX 10000
-
-#endif /* UAE_ROMMGR_H */
diff --git a/src/include/savestate.h b/src/include/savestate.h
index 2432a51a..8f24fc75 100644
--- a/src/include/savestate.h
+++ b/src/include/savestate.h
@@ -1,15 +1,14 @@
- /*
- * UAE - The Un*x Amiga Emulator
- *
- * Save/restore emulator state
- *
- * (c) 1999-2001 Toni Wilen
- */
+/*
+ * UAE - The Un*x Amiga Emulator
+ *
+ * Save/restore emulator state
+ *
+ * (c) 1999-2001 Toni Wilen
+ */
-#ifndef UAE_SAVESTATE_H
-#define UAE_SAVESTATE_H
-#include "uae/types.h"
+/* functions to save byte,word or long word
+ * independent of CPU's endianess */
extern void save_u64_func (uae_u8 **, uae_u64);
extern void save_u32_func (uae_u8 **, uae_u32);
@@ -117,53 +116,45 @@ extern uae_u8 *restore_filesys_common (uae_u8 *src);
extern uae_u8 *save_filesys_common (int *len);
extern int save_filesys_cando(void);
-extern uae_u8 *restore_gayle(uae_u8 *src);
-extern uae_u8 *save_gayle (int *len, uae_u8*);
-extern uae_u8 *restore_gayle_ide (uae_u8 *src);
-extern uae_u8 *save_gayle_ide (int num, int *len, uae_u8*);
-
extern uae_u8 *save_cd (int num, int *len);
extern uae_u8 *restore_cd (int, uae_u8 *src);
+extern void restore_cd_finish (void);
extern uae_u8 *restore_input (uae_u8 *src);
extern uae_u8 *save_input (int *len, uae_u8 *dstptr);
extern void restore_cram (int, size_t);
extern void restore_bram (int, size_t);
-extern void restore_fram (int, size_t, int);
+extern void restore_fram(int, size_t, int);
extern void restore_zram (int, size_t, int);
extern void restore_bootrom (int, size_t);
extern void restore_pram (int, size_t);
-extern void restore_a3000lram (int, size_t);
-extern void restore_a3000hram (int, size_t);
-
extern void restore_ram (size_t, uae_u8*);
-extern uae_u8 *save_cram (int *);
-extern uae_u8 *save_bram (int *);
-extern uae_u8 *save_fram (int *, int);
-extern uae_u8 *save_zram (int *, int);
-extern uae_u8 *save_bootrom (int *);
-extern uae_u8 *save_pram (int *);
-extern uae_u8 *save_a3000lram (int *);
-extern uae_u8 *save_a3000hram (int *);
+extern uae_u8 *save_cram(int *);
+extern uae_u8 *save_bram(int *);
+extern uae_u8 *save_fram(int *, int);
+extern uae_u8 *save_zram(int *, int);
+extern uae_u8 *save_bootrom(int *);
+extern uae_u8 *save_pram(int *);
+extern uae_u8 *save_a3000lram(int *);
+extern uae_u8 *save_a3000hram(int *);
+
+extern uae_u8 *restore_rom(uae_u8 *);
+extern uae_u8 *save_rom(int, int *, uae_u8 *);
+
+extern uae_u8 *restore_action_replay(uae_u8 *);
+extern uae_u8 *save_action_replay(int *, uae_u8 *);
+extern uae_u8 *restore_hrtmon(uae_u8 *);
+extern uae_u8 *save_hrtmon(int *, uae_u8 *);
-extern uae_u8 *restore_rom (uae_u8 *);
-extern uae_u8 *save_rom (int, int *, uae_u8 *);
-
-extern uae_u8 *save_expansion_info(int*, uae_u8*);
-extern uae_u8 *restore_expansion_info(uae_u8*);
-
-extern uae_u8 *restore_action_replay (uae_u8 *);
-extern uae_u8 *save_action_replay (int *, uae_u8 *);
-extern uae_u8 *restore_hrtmon (uae_u8 *);
-extern uae_u8 *save_hrtmon (int *, uae_u8 *);
-
-extern void savestate_initsave (const TCHAR *filename, int docompress, int nodialogs, bool save);
-extern int save_state (const TCHAR *filename, const TCHAR *description);
-extern void restore_state (const TCHAR *filename);
-extern void savestate_restore_finish (void);
+extern void savestate_initsave(const TCHAR *filename, int docompress, int nodialogs, bool save);
+extern int save_state(const TCHAR *filename, const TCHAR *description);
+extern void restore_state(const TCHAR *filename);
+extern void savestate_restore_finish(void);
+extern void savestate_memorysave(void);
+extern void custom_save_state (void);
extern void custom_prepare_savestate (void);
extern bool savestate_check (void);
@@ -179,9 +170,18 @@ extern int savestate_state;
extern TCHAR savestate_fname[MAX_DPATH];
extern struct zfile *savestate_file;
-STATIC_INLINE bool isrestore (void)
-{
- return savestate_state == STATE_RESTORE;
+STATIC_INLINE bool isrestore(void)
+{
+ return savestate_state == STATE_RESTORE || savestate_state == STATE_REWIND;
}
-#endif /* UAE_SAVESTATE_H */
+extern void savestate_quick(int slot, int save);
+
+extern void savestate_capture(int);
+extern void savestate_free(void);
+extern void savestate_init(void);
+extern void savestate_rewind(void);
+extern int savestate_dorewind(int);
+extern void savestate_listrewind(void);
+extern void statefile_save_recording(const TCHAR*);
+extern void savestate_capture_request(void);
\ No newline at end of file
diff --git a/src/include/sysdeps.h b/src/include/sysdeps.h
index 3222c77b..54aced6a 100644
--- a/src/include/sysdeps.h
+++ b/src/include/sysdeps.h
@@ -1,3 +1,6 @@
+#ifndef UAE_SYSDEPS_H
+#define UAE_SYSDEPS_H
+
/*
* UAE - The Un*x Amiga Emulator
*
@@ -11,25 +14,8 @@
*
* Copyright 1996, 1997 Bernd Schmidt
*/
-#ifndef UAE_SYSDEPS_H
-#define UAE_SYSDEPS_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "sysconfig.h"
-
-#ifndef UAE
-#define UAE
-#endif
-
-#ifdef __cplusplus
#include
using namespace std;
-#else
-#include
-#include
-#endif
#include
#include
#include
@@ -53,11 +39,29 @@ using namespace std;
#error unrecognized CPU type
#endif
+//#ifdef _WIN32
+/* Parameters are passed in ECX, EDX for both x86 and x86-64 (RCX, RDX).
+* For x86-64, __fastcall is the default, so it isn't really required. */
+//#define JITCALL __fastcall
+//#elif defined(CPU_x86_64)
+///* Parameters are passed in RDI, RSI by default (System V AMD64 ABI). */
+//#define JITCALL
+//#elif defined(HAVE_FUNC_ATTRIBUTE_REGPARM)
+///* Parameters are passed in EAX, EDX on x86 with regparm(2). */
+//#define JITCALL __attribute__((regparm(2)))
+///* This was originally regparm(3), but as far as I can see only two register
+//* params are supported by the JIT code. It probably just worked anyway
+//* if all functions used max two arguments. */
+//#elif !defined(JIT)
+//#define JITCALL
+//#endif
+#define REGPARAM
+#define REGPARAM2
+#define REGPARAM3
+
#ifndef __STDC__
-#ifndef _MSC_VER_
#error "Your compiler is not ANSI. Get a real one."
#endif
-#endif
#include
@@ -124,6 +128,10 @@ using namespace std;
#include
#include
+#if EEXIST == ENOTEMPTY
+#define BROKEN_OS_PROBABLY_AIX
+#endif
+
#ifdef __NeXT__
#define S_IRUSR S_IREAD
#define S_IWUSR S_IWRITE
@@ -131,11 +139,51 @@ using namespace std;
#define S_ISDIR(val) (S_IFDIR & val)
struct utimbuf
{
- time_t actime;
- time_t modtime;
+ time_t actime;
+ time_t modtime;
};
#endif
+/* sam: some definitions so that SAS/C can compile UAE */
+#if defined(__SASC) && defined(AMIGA)
+#define REGPARAM2
+#define REGPARAM
+#define S_IRUSR S_IREAD
+#define S_IWUSR S_IWRITE
+#define S_IXUSR S_IEXECUTE
+#define S_ISDIR(val) (S_IFDIR & val)
+#define mkdir(x,y) mkdir(x)
+#define truncate(x,y) 0
+#define creat(x,y) open("T:creat",O_CREAT|O_TEMP|O_RDWR) /* sam: for zfile.c */
+#define strcasecmp stricmp
+#define utime(file,time) 0
+struct utimbuf
+{
+ time_t actime;
+ time_t modtime;
+};
+#endif
+
+#ifdef __DOS__
+#include
+#include
+#endif
+
+/* Acorn specific stuff */
+#ifdef ACORN
+
+#define S_IRUSR S_IREAD
+#define S_IWUSR S_IWRITE
+#define S_IXUSR S_IEXEC
+
+#define strcasecmp stricmp
+
+#endif
+
+#ifndef L_tmpnam
+#define L_tmpnam 128 /* ought to be safe */
+#endif
+
/* If char has more then 8 bits, good night. */
typedef unsigned char uae_u8;
typedef signed char uae_s8;
@@ -185,27 +233,36 @@ typedef uae_u32 uaecptr;
#define UVAL64(a) (a ## ul)
#endif
+void atomic_and(volatile uae_atomic *p, uae_u32 v);
+void atomic_or(volatile uae_atomic *p, uae_u32 v);
+uae_atomic atomic_inc(volatile uae_atomic *p);
+uae_atomic atomic_dec(volatile uae_atomic *p);
+uae_u32 atomic_bit_test_and_reset(volatile uae_atomic *p, uae_u32 v);
+
#ifdef HAVE_STRDUP
-#define my_strdup _tcsdup
+#define my_strdup strdup
#else
-extern TCHAR *my_strdup (const TCHAR*s);
+extern TCHAR *my_strdup(const TCHAR*s);
#endif
-extern TCHAR *my_strdup_ansi (const char*);
-extern void my_trim (TCHAR*);
-extern TCHAR *my_strdup_trim (const TCHAR*);
-extern TCHAR *au (const char*);
-extern char *ua (const TCHAR*);
-extern TCHAR *au_fs (const char*);
-extern char *ua_fs (const TCHAR*, int);
-extern char *ua_copy (char *dst, int maxlen, const TCHAR *src);
-extern TCHAR *au_copy (TCHAR *dst, int maxlen, const char *src);
-extern char *ua_fs_copy (char *dst, int maxlen, const TCHAR *src, int defchar);
-extern TCHAR *au_fs_copy (TCHAR *dst, int maxlen, const char *src);
-extern char *uutf8 (const TCHAR *s);
-extern TCHAR *utf8u (const char *s);
-extern void to_lower (TCHAR *s, int len);
-extern void to_upper (TCHAR *s, int len);
+extern TCHAR *my_strdup_ansi(const char*);
+extern void my_trim(TCHAR*);
+extern TCHAR *my_strdup_trim(const TCHAR*);
+extern TCHAR *au(const char*);
+extern char *ua(const TCHAR*);
+extern TCHAR *aucp(const char *s, unsigned int cp);
+extern char *uacp(const TCHAR *s, unsigned int cp);
+extern TCHAR *au_fs(const char*);
+extern char *ua_fs(const TCHAR*, int);
+extern char *ua_copy(char *dst, int maxlen, const TCHAR *src);
+extern TCHAR *au_copy(TCHAR *dst, int maxlen, const char *src);
+extern char *ua_fs_copy(char *dst, int maxlen, const TCHAR *src, int defchar);
+extern TCHAR *au_fs_copy(TCHAR *dst, int maxlen, const char *src);
+extern char *uutf8(const TCHAR *s);
+extern TCHAR *utf8u(const char *s);
+extern void unicode_init(void);
+extern void to_lower(TCHAR *s, int len);
+extern void to_upper(TCHAR *s, int len);
/* We can only rely on GNU C getting enums right. Mickeysoft VSC++ is known
* to have problems, and it's likely that other compilers choke too. */
@@ -238,8 +295,8 @@ extern void to_upper (TCHAR *s, int len);
#undef DONT_HAVE_STDIO
#undef DONT_HAVE_MALLOC
-#if defined AMIBERRY
-
+#ifdef AMIBERRY
+#include
#include
#define FILEFLAG_DIR 0x1
@@ -250,17 +307,6 @@ extern void to_upper (TCHAR *s, int len);
#define FILEFLAG_SCRIPT 0x20
#define FILEFLAG_PURE 0x40
-#define REGPARAM2
-#define REGPARAM3
-#define REGPARAM
-
-#define abort() \
- do { \
- printf ("Internal error; file %s, line %d\n", __FILE__, __LINE__); \
- SDL_Quit(); \
- (abort) (); \
-} while (0)
-
#endif
#ifdef DONT_HAVE_POSIX
@@ -342,6 +388,8 @@ extern void mallocemu_free(void *ptr);
#define ASM_SYM_FOR_FUNC(a)
#endif
+#include "target.h"
+
#ifdef UAE_CONSOLE
#undef write_log
#define write_log write_log_standard
@@ -362,19 +410,11 @@ extern void gui_message(const TCHAR *, ...);
#endif
#ifndef STATIC_INLINE
-#ifdef DEBUG
-#define STATIC_INLINE static __attribute__ ((noinline))
-#define NOINLINE __attribute__ ((noinline))
-#define NORETURN
-#elif __GNUC__ - 1 > 1 && __GNUC_MINOR__ - 1 >= 0
-#ifdef AMIBERRY
-#define STATIC_INLINE static __inline__
-#else
+#if __GNUC__ - 1 > 1 && __GNUC_MINOR__ - 1 >= 0
#define STATIC_INLINE static __inline__ __attribute__ ((always_inline))
-#endif
#define NOINLINE __attribute__ ((noinline))
#define NORETURN __attribute__ ((noreturn))
-#elif _MSC_VER_
+#elif _MSC_VER
#define STATIC_INLINE static __forceinline
#define NOINLINE __declspec(noinline)
#define NORETURN __declspec(noreturn)
@@ -385,8 +425,6 @@ extern void gui_message(const TCHAR *, ...);
#endif
#endif
-#include "target.h"
-
/* Every Amiga hardware clock cycle takes this many "virtual" cycles. This
used to be hardcoded as 1, but using higher values allows us to time some
stuff more precisely.
@@ -413,29 +451,28 @@ extern void gui_message(const TCHAR *, ...);
* Byte-swapping functions
*/
-#ifdef ARMV6_ASSEMBLY
-STATIC_INLINE uae_u32 do_byteswap_32(uae_u32 v) {
- __asm__(
- "rev %0, %0"
- : "=r" (v) : "0" (v)); return v;
-}
-
-STATIC_INLINE uae_u32 do_byteswap_16(uae_u32 v) {
- __asm__(
- "revsh %0, %0\n\t"
- "uxth %0, %0"
- : "=r" (v) : "0" (v)); return v;
-}
-#define bswap_16(x) do_byteswap_16(x)
-#define bswap_32(x) do_byteswap_32(x)
-#else
-
/* Try to use system bswap_16/bswap_32 functions. */
#if defined HAVE_BSWAP_16 && defined HAVE_BSWAP_32
# include
# ifdef HAVE_BYTESWAP_H
# include
# endif
+#else
+# ifdef ARMV6_ASSEMBLY
+STATIC_INLINE uae_u32 do_byteswap_32(uae_u32 v) {
+ __asm__(
+ "rev %0, %0"
+ : "=r" (v) : "0" (v)); return v;
+}
+
+STATIC_INLINE uae_u32 do_byteswap_16(uae_u32 v) {
+ __asm__(
+ "revsh %0, %0\n\t"
+ "uxth %0, %0"
+ : "=r" (v) : "0" (v)); return v;
+}
+#define bswap_16(x) do_byteswap_16(x)
+#define bswap_32(x) do_byteswap_32(x)
# else
/* Else, if using SDL, try SDL's endian functions. */
# ifdef USE_SDL
@@ -450,6 +487,8 @@ STATIC_INLINE uae_u32 do_byteswap_16(uae_u32 v) {
#endif
#endif
+#endif
+
#ifndef __cplusplus
#define xmalloc(T, N) malloc(sizeof (T) * (N))
@@ -457,6 +496,12 @@ STATIC_INLINE uae_u32 do_byteswap_16(uae_u32 v) {
#define xfree(T) free(T)
#define xrealloc(T, TP, N) realloc(TP, sizeof (T) * (N))
+#if 0
+extern void *xmalloc(size_t);
+extern void *xcalloc(size_t, size_t);
+extern void xfree(const void*);
+#endif
+
#else
#define xmalloc(T, N) static_cast(malloc (sizeof (T) * (N)))
@@ -472,6 +517,4 @@ STATIC_INLINE uae_u32 do_byteswap_16(uae_u32 v) {
#define NOWARN_UNUSED(x) __attribute__((unused)) x
#else
#define NOWARN_UNUSED(x) x
-#endif
-
-#endif /* UAE_SYSDEPS_H */
+#endif
\ No newline at end of file
diff --git a/src/include/traps.h b/src/include/traps.h
index 102dd741..70cd93d1 100644
--- a/src/include/traps.h
+++ b/src/include/traps.h
@@ -1,19 +1,19 @@
- /*
- * E-UAE - The portable Amiga Emulator
- *
- * Support for traps
- *
- * Copyright Richard Drummond 2005
- *
- * Based on code:
- * Copyright 1995, 1996 Bernd Schmidt
- * Copyright 1996 Ed Hanway
- */
+/*
+ * E-UAE - The portable Amiga Emulator
+ *
+ * Support for traps
+ *
+ * Copyright Richard Drummond 2005
+ *
+ * Based on code:
+ * Copyright 1995, 1996 Bernd Schmidt
+ * Copyright 1996 Ed Hanway
+ */
-#ifndef UAE_TRAPS_H
-#define UAE_TRAPS_H
+#ifndef TRAPS_H
+#define TRAPS_H
-#include "uae/types.h"
+#include "sysconfig.h"
#define TRAPCMD_MULTI 0
#define TRAPCMD_PUT_LONG 1
@@ -58,30 +58,31 @@ typedef struct TrapContext TrapContext;
#define TRAPFLAG_UAERES 16
/*
- * A function which handles a 68k trap
- */
-typedef uae_u32 (REGPARAM3 *TrapHandler) (TrapContext *) REGPARAM;
+* A function which handles a 68k trap
+*/
+typedef uae_u32(REGPARAM3 *TrapHandler) (TrapContext *) REGPARAM;
/*
- * Interface with 68k interpreter
- */
-extern void REGPARAM3 m68k_handle_trap (unsigned int trap_num) REGPARAM;
+* Interface with 68k interpreter
+*/
+extern void REGPARAM3 m68k_handle_trap(unsigned int trap_num) REGPARAM;
-unsigned int define_trap (TrapHandler handler_func, int flags, const TCHAR *name);
-uaecptr find_trap (const TCHAR *name);
+unsigned int define_trap(TrapHandler handler_func, int flags, const TCHAR *name);
+uaecptr find_trap(const TCHAR *name);
/*
- * Call a 68k Library function from an extended trap
- */
-extern uae_u32 CallLib (TrapContext *context, uaecptr library_base, uae_s16 func_offset);
-extern uae_u32 CallFunc (TrapContext *context, uaecptr func);
+* Call a 68k Library function from an extended trap
+*/
+extern uae_u32 CallLib(TrapContext *context, uaecptr library_base, uae_s16 func_offset);
+extern uae_u32 CallFunc(TrapContext *context, uaecptr func);
/*
- * Initialization
- */
-void init_traps (void);
-void init_extended_traps (void);
+* Initialization
+*/
+void init_traps(void);
+void free_traps(void);
+void init_extended_traps(void);
#define deftrap(f) define_trap((f), 0, _T(#f))
#define deftrap2(f, mode, str) define_trap((f), (mode), (str))
@@ -89,11 +90,23 @@ void init_extended_traps (void);
/* New trap system */
+void call_hardware_trap(uae_u8*, uaecptr, int);
+void trap_set_background(TrapContext *ctx);
+void trap_background_set_complete(TrapContext *ctx);
bool trap_valid_address(TrapContext *ctx, uaecptr addr, uae_u32 size);
+bool trap_is_indirect(void);
+void trap_dos_active(void);
+void trap_reset(void);
+typedef uae_u32(*TRAP_CALLBACK)(TrapContext*, void*);
+void trap_callback(TRAP_CALLBACK, void*);
void trap_memcpyha_safe(TrapContext *ctx, uaecptr dst, const uae_u8 *src, int size);
void trap_memcpyah_safe(TrapContext *ctx, uae_u8 *dst, uaecptr src, int size);
+TrapContext *alloc_host_main_trap_context(void);
+TrapContext *alloc_host_thread_trap_context(void);
+void free_host_trap_context(TrapContext*);
+
uae_u32 trap_get_dreg(TrapContext *ctx, int reg);
uae_u32 trap_get_areg(TrapContext *ctx, int reg);
void trap_set_dreg(TrapContext *ctx, int reg, uae_u32 v);
@@ -131,4 +144,4 @@ void trap_call_add_areg(TrapContext *ctx, int reg, uae_u32 v);
uae_u32 trap_call_lib(TrapContext *ctx, uaecptr base, uae_s16 offset);
uae_u32 trap_call_func(TrapContext *ctx, uaecptr func);
-#endif /* UAE_TRAPS_H */
+#endif
diff --git a/src/include/xwin.h b/src/include/xwin.h
index 45ffcec4..969cd7d4 100644
--- a/src/include/xwin.h
+++ b/src/include/xwin.h
@@ -63,7 +63,9 @@ extern int bits_in_mask (unsigned long mask);
extern int mask_shift (unsigned long mask);
extern unsigned int doMask (int p, int bits, int shift);
extern unsigned int doMask256 (int p, int bits, int shift);
-extern void alloc_colors64k (int, int, int, int, int, int, int);
+extern void alloc_colors64k(int, int, int, int, int, int, int, int, int, int);
+extern void alloc_colors_rgb(int rw, int gw, int bw, int rs, int gs, int bs, int aw, int as, int alpha, int byte_swap,
+ uae_u32 *rc, uae_u32 *gc, uae_u32 *bc);
extern void alloc_colors_picasso (int rw, int gw, int bw, int rs, int gs, int bs, int rgbfmt);
struct vidbuffer
diff --git a/src/inputdevice.cpp b/src/inputdevice.cpp
index f05706e4..4d9f0117 100644
--- a/src/inputdevice.cpp
+++ b/src/inputdevice.cpp
@@ -1,9 +1,9 @@
- /*
+/*
* UAE - The Un*x Amiga Emulator
*
* joystick/mouse emulation
*
-* Copyright 2001-2016 Toni Wilen
+* Copyright 2001-2012 Toni Wilen
*
* new fetures:
* - very configurable (and very complex to configure :)
@@ -30,14 +30,10 @@
#include "newcpu.h"
#include "uae.h"
#include "picasso96.h"
-#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 "disk.h"
+#include "sounddep/sound.h"
// 01 = host events
// 02 = joystick
@@ -53,28 +49,30 @@
#define ID_FLAG_CUSTOMEVENT_TOGGLED2 0x8000
#define IE_INVERT 0x80
+#define IE_CDTV 0x100
#define INPUTEVENT_JOY1_CD32_FIRST INPUTEVENT_JOY1_CD32_PLAY
#define INPUTEVENT_JOY2_CD32_FIRST INPUTEVENT_JOY2_CD32_PLAY
#define INPUTEVENT_JOY1_CD32_LAST INPUTEVENT_JOY1_CD32_BLUE
#define INPUTEVENT_JOY2_CD32_LAST INPUTEVENT_JOY2_CD32_BLUE
-#define DEFEVENT(A, B, C, D, E, F) {_T(#A), B, NULL, C, D, E, F, 0 },
-#define DEFEVENT2(A, B, B2, C, D, E, F, G) {_T(#A), B, B2, C, D, E, F, G },
-static const struct inputevent events[] = {
- {0, 0, 0, AM_K, 0, 0, 0, 0},
+#define JOYMOUSE_CDTV 8
+
+#define DEFEVENT(A, B, C, D, E, F) {_T(#A), B, C, D, E, F },
+static struct inputevent events[] = {
+ {0, 0, AM_K,0,0,0},
#include "inputevents.def"
- {0, 0, 0, 0, 0, 0, 0, 0}
+ {0, 0, 0, 0, 0, 0}
};
#undef DEFEVENT
-#undef DEFEVENT2
static int sublevdir[2][MAX_INPUT_SUB_EVENT];
-static const int slotorder1[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
-static const int slotorder2[] = { 8, 1, 2, 3, 4, 5, 6, 7 };
+static const int slotorder1[] = {0, 1, 2, 3, 4, 5, 6, 7};
+static const int slotorder2[] = {8, 1, 2, 3, 4, 5, 6, 7};
-struct uae_input_device2 {
+struct uae_input_device2
+{
uae_u32 buttonmask;
int states[MAX_INPUT_DEVICE_EVENTS / 2][MAX_INPUT_SUB_EVENT + 1];
};
@@ -83,41 +81,31 @@ static struct uae_input_device2 joysticks2[MAX_INPUT_DEVICES];
static struct uae_input_device2 mice2[MAX_INPUT_DEVICES];
static uae_u8 scancodeused[MAX_INPUT_DEVICES][256];
static uae_u64 qualifiers, qualifiers_r;
-static uae_s16 *qualifiers_evt[MAX_INPUT_QUALIFIERS];
+static uae_s16* qualifiers_evt[MAX_INPUT_QUALIFIERS];
+
+// fire/left mouse button pullup resistors enabled?
+static bool mouse_pullup = true;
static int joymodes[MAX_JPORTS];
-static const int *joyinputs[MAX_JPORTS];
+static int* joyinputs[MAX_JPORTS];
static int input_acquired;
-static int handle_input_event (int nr, int state, int max, int autofire);
+#ifdef INPUTDEVICE_SIMPLE
+static int handle_input_event(int nr, int state, int max, int autofire);
+#else
+static int handle_input_event (int nr, int state, int max, int autofire, bool canstoprecord, bool playbackevent);
+#endif
static struct inputdevice_functions idev[IDTYPE_MAX];
-struct temp_uids {
- TCHAR *name;
- TCHAR *configname;
- uae_s8 disabled;
- uae_s8 empty;
- uae_s8 custom;
- int joystick;
- int devtype;
- int idnum;
- bool initialized;
- int kbreventcnt[MAX_INPUT_DEVICES];
- int lastdevtype;
- int matcheddevices[MAX_INPUT_DEVICES];
- int nonmatcheddevices[MAX_INPUT_DEVICES];
-};
-static struct temp_uids temp_uid;
-static int temp_uid_index[MAX_INPUT_DEVICES][IDTYPE_MAX];
-static int temp_uid_cnt[IDTYPE_MAX];
-
-static int isdevice (struct uae_input_device *id)
+static int isdevice(struct uae_input_device* id)
{
int i, j;
- for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
- for (j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
+ for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
+ {
+ for (j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
if (id->eventid[i][j] > 0)
return 1;
}
@@ -125,105 +113,31 @@ static int isdevice (struct uae_input_device *id)
return 0;
}
-static void check_enable(int ei);
-
-int inputdevice_uaelib (const TCHAR *s, const TCHAR *parm)
+int inputdevice_uaelib(const TCHAR* s, const TCHAR* parm)
{
int i;
- if (!_tcsncmp(s, _T("KEY_RAW_"), 8)) {
- // KEY_RAW_UP
- // KEY_RAW_DOWN
- int v;
- const TCHAR *value = parm;
- TCHAR *endptr;
- int base = 10;
- int state = _tcscmp(s, _T("KEY_RAW_UP")) ? 1 : 0;
- if (value[0] == '0' && _totupper(value[1]) == 'X')
- value += 2, base = 16;
- v = _tcstol(value, &endptr, base);
- for (i = 1; events[i].name; i++) {
- const struct inputevent *ie = &events[i];
- if (_tcsncmp(ie->confname, _T("KEY_"), 4))
- continue;
- if (ie->data == v) {
- handle_input_event(i, state, 1, 0);
- return 1;
- }
- }
- return 0;
- }
-
- for (i = 1; events[i].name; i++) {
- if (!_tcscmp (s, events[i].confname)) {
- check_enable(i);
- handle_input_event (i, parm ? _tstol (parm) : 0, 1, 0);
+ for (i = 1; events[i].name; i++)
+ {
+ if (!_tcscmp (s, events[i].confname))
+ {
+#ifdef INPUTDEVICE_SIMPLE
+ handle_input_event(i, parm ? _tstol (parm) : 0, 1, 0);
+#else
+ handle_input_event (i, parm ? _tstol (parm) : 0, 1, 0, false, false);
+#endif
return 1;
}
}
return 0;
}
-int inputdevice_uaelib(const TCHAR *s, int parm, int max, bool autofire)
-{
- for (int i = 1; events[i].name; i++) {
- if (!_tcscmp(s, events[i].confname)) {
- check_enable(i);
- handle_input_event(i, parm, max, autofire);
- return 1;
- }
- }
- return 0;
-}
-
-static int getdevnum(int type, int devnum)
-{
- int jcnt = idev[IDTYPE_JOYSTICK].get_num();
- int mcnt = idev[IDTYPE_MOUSE].get_num();
- int kcnt = idev[IDTYPE_KEYBOARD].get_num();
-
- if (type == IDTYPE_JOYSTICK)
- return devnum;
- else if (type == IDTYPE_MOUSE)
- return jcnt + devnum;
- else if (type == IDTYPE_KEYBOARD)
- return jcnt + mcnt + devnum;
- return -1;
-}
-
-static int gettype (int devnum)
-{
- int jcnt = idev[IDTYPE_JOYSTICK].get_num ();
- int mcnt = idev[IDTYPE_MOUSE].get_num ();
- int kcnt = idev[IDTYPE_KEYBOARD].get_num ();
-
- if (devnum < jcnt)
- return IDTYPE_JOYSTICK;
- else if (devnum < jcnt + mcnt)
- return IDTYPE_MOUSE;
- else if (devnum < jcnt + mcnt + kcnt)
- return IDTYPE_KEYBOARD;
- return -1;
-}
-
-static struct inputdevice_functions *getidf (int devnum)
-{
- int type = gettype (devnum);
- if (type < 0)
- return NULL;
- return &idev[type];
-}
-
-const struct inputevent *inputdevice_get_eventinfo(int evt)
-{
- if (evt > 0 && !events[evt].name)
- return NULL;
- return &events[evt];
-}
-
-static struct uae_input_device *joysticks;
-static struct uae_input_device *mice;
-static struct uae_input_device *keyboards;
+static struct uae_input_device* joysticks;
+static struct uae_input_device* mice;
+static struct uae_input_device* keyboards;
+#ifndef INPUTDEVICE_SIMPLE
+static struct uae_input_device *internalevents;
+#endif
static struct uae_input_device_kbr_default *keyboard_default, **keyboard_default_table;
static int default_keyboard_layout[MAX_JPORTS];
@@ -241,7 +155,12 @@ static int default_keyboard_layout[MAX_JPORTS];
#define KBR_DEFAULT_MAP_CD32_NP 6
#define KBR_DEFAULT_MAP_CD32_CK 7
#define KBR_DEFAULT_MAP_CD32_SE 8
-static int **keyboard_default_kbmaps;
+#define KBR_DEFAULT_MAP_XA1 9
+#define KBR_DEFAULT_MAP_XA2 10
+#define KBR_DEFAULT_MAP_ARCADIA 11
+#define KBR_DEFAULT_MAP_ARCADIA_XA 12
+#define KBR_DEFAULT_MAP_CDTV 13
+static int** keyboard_default_kbmaps;
static int mouse_axis[MAX_INPUT_DEVICES][MAX_INPUT_DEVICE_EVENTS];
static int oldm_axis[MAX_INPUT_DEVICES][MAX_INPUT_DEVICE_EVENTS];
@@ -251,33 +170,26 @@ static int oldm_axis[MAX_INPUT_DEVICES][MAX_INPUT_DEVICE_EVENTS];
static uae_s16 mouse_x[MAX_JPORTS], mouse_y[MAX_JPORTS];
static uae_s16 mouse_delta[MAX_JPORTS][MOUSE_AXIS_TOTAL];
static uae_s16 mouse_deltanoreset[MAX_JPORTS][MOUSE_AXIS_TOTAL];
+static uae_s16 lightpen_delta[2];
+static uae_s16 lightpen_deltanoreset[2];
static int joybutton[MAX_JPORTS];
static int joydir[MAX_JPORTS];
-#ifndef INPUTDEVICE_SIMPLE
static int joydirpot[MAX_JPORTS][2];
-#endif
static uae_s16 mouse_frame_x[MAX_JPORTS], mouse_frame_y[MAX_JPORTS];
static int mouse_port[NORMAL_JPORTS];
static int cd32_shifter[NORMAL_JPORTS];
static int cd32_pad_enabled[NORMAL_JPORTS];
-
-#if !defined(INPUTDEVICE_SIMPLE) || defined(AMIBERRY)
static int parport_joystick_enabled;
-#endif
-
static int oleft[MAX_JPORTS], oright[MAX_JPORTS], otop[MAX_JPORTS], obot[MAX_JPORTS];
+static int horizclear[MAX_JPORTS], vertclear[MAX_JPORTS];
static int relativecount[MAX_JPORTS][2];
uae_u16 potgo_value;
-#ifndef INPUTDEVICE_SIMPLE
static int pot_cap[NORMAL_JPORTS][2];
-#endif
static uae_u8 pot_dat[NORMAL_JPORTS][2];
static int pot_dat_act[NORMAL_JPORTS][2];
-#ifndef INPUTDEVICE_SIMPLE
static int analog_port[NORMAL_JPORTS][2];
-#endif
static int digital_port[NORMAL_JPORTS][2];
#define POTDAT_DELAY_PAL 8
#define POTDAT_DELAY_NTSC 7
@@ -286,31 +198,31 @@ static int use_joysticks[MAX_INPUT_DEVICES];
static int use_mice[MAX_INPUT_DEVICES];
static int use_keyboards[MAX_INPUT_DEVICES];
-#ifdef INPUTDEVICE_SIMPLE
-#define INPUT_QUEUE_SIZE 6
-#else
#define INPUT_QUEUE_SIZE 16
-#endif
struct input_queue_struct {
int evt, storedstate, state, max, linecnt, nextlinecnt;
+ TCHAR *custom;
};
static struct input_queue_struct input_queue[INPUT_QUEUE_SIZE];
-uae_u8 *restore_input (uae_u8 *src)
+uae_u8* restore_input(uae_u8* src)
{
restore_u32 ();
- for (int i = 0; i < 2; i++) {
- for (int j = 0; j < 2; j++) {
+ for (int i = 0; i < 2; i++)
+ {
+ for (int j = 0; j < 2; j++)
+ {
#ifndef INPUTDEVICE_SIMPLE
pot_cap[i][j] = restore_u16 ();
#else
- restore_u16();
+ restore_u16();
#endif
}
}
return src;
}
-uae_u8 *save_input (int *len, uae_u8 *dstptr)
+
+uae_u8* save_input(int* len, uae_u8* dstptr)
{
uae_u8 *dstbak, *dst;
@@ -319,12 +231,14 @@ uae_u8 *save_input (int *len, uae_u8 *dstptr)
else
dstbak = dst = xmalloc (uae_u8, 1000);
save_u32 (0);
- for (int i = 0; i < 2; i++) {
- for (int j = 0; j < 2; j++) {
+ for (int i = 0; i < 2; i++)
+ {
+ for (int j = 0; j < 2; j++)
+ {
#ifndef INPUTDEVICE_SIMPLE
save_u16 (pot_cap[i][j]);
#else
- save_u16(0);
+ save_u16(0);
#endif
}
}
@@ -332,225 +246,41 @@ uae_u8 *save_input (int *len, uae_u8 *dstptr)
return dstbak;
}
-static void freejport (struct uae_prefs *dst, int num)
+static void freejport(struct uae_prefs* dst, int num)
{
bool override = dst->jports[num].nokeyboardoverride;
- memset (&dst->jports[num], 0, sizeof (struct jport));
+ memset(&dst->jports[num], 0, sizeof (struct jport));
dst->jports[num].id = -1;
dst->jports[num].nokeyboardoverride = override;
}
-static void copyjport (const struct uae_prefs *src, struct uae_prefs *dst, int num)
+
+static void copyjport(const struct uae_prefs *src, struct uae_prefs *dst, int num)
{
if (!src)
return;
- freejport (dst, num);
+ freejport(dst, num);
memcpy(&dst->jports[num].idc, &src->jports[num].idc, sizeof(struct inputdevconfig));
dst->jports[num].id = src->jports[num].id;
dst->jports[num].mode = src->jports[num].mode;
dst->jports[num].autofire = src->jports[num].autofire;
- dst->jports[num].mousemap = src->jports[num].mousemap;
- dst->jports[num].amiberry_custom_none = src->jports[num].amiberry_custom_none;
- dst->jports[num].amiberry_custom_hotkey = src->jports[num].amiberry_custom_hotkey;
- dst->jports[num].amiberry_custom_left_trigger = src->jports[num].amiberry_custom_left_trigger;
- dst->jports[num].amiberry_custom_right_trigger = src->jports[num].amiberry_custom_right_trigger;
dst->jports[num].nokeyboardoverride = src->jports[num].nokeyboardoverride;
}
-#define MAX_STORED_JPORTS 8
-struct stored_jport
-{
- struct jport jp;
- bool inuse;
- bool defaultports;
- uae_u32 age;
-};
-static struct stored_jport stored_jports[MAX_JPORTS][8];
-static uae_u32 stored_jport_cnt;
-
-// return port where idc was previously plugged if any and forgot it.
-static int inputdevice_get_unplugged_device(struct inputdevconfig *idc)
-{
- for (int portnum = 0; portnum < MAX_JPORTS; portnum++) {
- for (int i = 0; i < MAX_STORED_JPORTS; i++) {
- struct stored_jport *jp = &stored_jports[portnum][i];
- if (jp->inuse && jp->jp.id == JPORT_UNPLUGGED) {
- if (!_tcscmp(idc->name, jp->jp.idc.name) && !_tcscmp(idc->configname, jp->jp.idc.configname)) {
- jp->inuse = false;
- return portnum;
- }
- }
- }
- }
- return -1;
-}
-
-// forget port's unplugged device
-void inputdevice_forget_unplugged_device(int portnum)
-{
- for (int i = 0; i < MAX_STORED_JPORTS; i++) {
- struct stored_jport *jp = &stored_jports[portnum][i];
- if (jp->inuse && jp->jp.id == JPORT_UNPLUGGED) {
- jp->inuse = false;
- }
- }
-}
-
-static struct jport *inputdevice_get_used_device(int portnum, int ageindex)
-{
- int idx = -1;
- int used[MAX_STORED_JPORTS] = { 0 };
- if (ageindex < 0)
- return NULL;
- while (ageindex >= 0) {
- uae_u32 age = 0;
- idx = -1;
- for (int i = 0; i < MAX_STORED_JPORTS; i++) {
- struct stored_jport *jp = &stored_jports[portnum][i];
- if (jp->inuse && !used[i] && jp->age > age) {
- age = jp->age;
- idx = i;
- }
- }
- if (idx < 0)
- return NULL;
- used[idx] = 1;
- ageindex--;
- }
- return &stored_jports[portnum][idx].jp;
-}
-
-static void inputdevice_store_clear(void)
-{
- for (int j = 0; j < MAX_JPORTS; j++) {
- for (int i = 0; i < MAX_STORED_JPORTS; i++) {
- struct stored_jport *jp = &stored_jports[j][i];
- if (!jp->defaultports)
- memset(jp, 0, sizeof(struct stored_jport));
- }
- }
-}
-
-static void inputdevice_set_newest_used_device(int portnum, struct jport *jps)
-{
- for (int i = 0; i < MAX_STORED_JPORTS; i++) {
- struct stored_jport *jp = &stored_jports[portnum][i];
- if (jp->inuse && &jp->jp == jps && !jp->defaultports) {
- stored_jport_cnt++;
- jp->age = stored_jport_cnt;
- }
- }
-}
-
-static void inputdevice_store_used_device(struct jport *jps, int portnum, bool defaultports)
-{
- if (jps->id == JPORT_NONE)
- return;
-
- // already added? if custom or kbr layout: delete all old
- for (int i = 0; i < MAX_STORED_JPORTS; i++) {
- struct stored_jport *jp = &stored_jports[portnum][i];
- if (jp->inuse && ((jps->id == jp->jp.id) || (jps->idc.configname[0] != 0 && jp->jp.idc.configname[0] != 0 && !_tcscmp(jps->idc.configname, jp->jp.idc.configname)))) {
- if (!jp->defaultports) {
- jp->inuse = false;
- }
- }
- }
-
- // delete from other ports
- for (int j = 0; j < MAX_JPORTS; j++) {
- for (int i = 0; i < MAX_STORED_JPORTS; i++) {
- struct stored_jport *jp = &stored_jports[j][i];
- if (jp->inuse && ((jps->id == jp->jp.id) || (jps->idc.configname[0] != 0 && jp->jp.idc.configname[0] != 0 && !_tcscmp(jps->idc.configname, jp->jp.idc.configname)))) {
- if (!jp->defaultports) {
- jp->inuse = false;
- }
- }
- }
- }
- // delete oldest if full
- for (int i = 0; i < MAX_STORED_JPORTS; i++) {
- struct stored_jport *jp = &stored_jports[portnum][i];
- if (!jp->inuse)
- break;
- if (i == MAX_STORED_JPORTS - 1) {
- uae_u32 age = 0xffffffff;
- int idx = -1;
- for (int j = 0; j < MAX_STORED_JPORTS; j++) {
- struct stored_jport *jp = &stored_jports[portnum][j];
- if (jp->age < age && !jp->defaultports) {
- age = jp->age;
- idx = j;
- }
- }
- if (idx >= 0) {
- struct stored_jport *jp = &stored_jports[portnum][idx];
- jp->inuse = false;
- }
- }
- }
- // add new
- for (int i = 0; i < MAX_STORED_JPORTS; i++) {
- struct stored_jport *jp = &stored_jports[portnum][i];
- if (!jp->inuse) {
- memcpy(&jp->jp, jps, sizeof(struct jport));
- write_log(_T("Stored port %d/%d d=%d: added %d %d %s %s\n"), portnum, i, defaultports, jp->jp.id, jp->jp.mode, jp->jp.idc.name, jp->jp.idc.configname);
- jp->inuse = true;
- jp->defaultports = defaultports;
- stored_jport_cnt++;
- jp->age = stored_jport_cnt;
- return;
- }
- }
-}
-
-static void inputdevice_store_unplugged_port(struct uae_prefs *p, struct inputdevconfig *idc)
-{
- struct jport jpt = { 0 };
- _tcscpy(jpt.idc.configname, idc->configname);
- _tcscpy(jpt.idc.name, idc->name);
- jpt.id = JPORT_UNPLUGGED;
- for (int i = 0; i < MAX_JPORTS; i++) {
- struct jport *jp = &p->jports[i];
- if (!_tcscmp(jp->idc.name, idc->name) && !_tcscmp(jp->idc.configname, idc->configname)) {
- write_log(_T("On the fly unplugged stored, port %d '%s' (%s)\n"), i, jpt.idc.name, jpt.idc.configname);
- inputdevice_store_used_device(&jpt, i, false);
- }
- }
-}
-
-static bool isemptykey(int keyboard, int scancode)
-{
- int j = 0;
- struct uae_input_device *na = &keyboards[keyboard];
- while (j < MAX_INPUT_DEVICE_EVENTS && na->extra[j] >= 0) {
- if (na->extra[j] == scancode) {
- for (int k = 0; k < MAX_INPUT_SUB_EVENT; k++) {
- if (na->eventid[j][k] > 0)
- return false;
- if (na->custom[j][k] != NULL)
- return false;
- }
- break;
- }
- j++;
- }
- return true;
-}
-
-static void out_config (struct zfile *f, int id, int num, const TCHAR *s1, const TCHAR *s2)
+static void out_config(struct zfile* f, int id, int num, const TCHAR* s1, const TCHAR* s2)
{
TCHAR tmp[MAX_DPATH];
- _stprintf (tmp, _T("input.%d.%s%d"), id, s1, num);
- cfgfile_write_str (f, tmp, s2);
+ _stprintf(tmp, _T("input.%d.%s%d"), id, s1, num);
+ cfgfile_write_str(f, tmp, s2);
}
-static bool write_config_head (struct zfile *f, int idnum, int devnum, const TCHAR *name, struct uae_input_device *id, struct inputdevice_functions *idf)
+static bool write_config_head(struct zfile* f, int idnum, int devnum, const TCHAR* name, struct uae_input_device* id, struct inputdevice_functions* idf)
{
- const TCHAR* s = NULL;
+ const char* s = NULL;
TCHAR tmp2[CONFIG_BLEN];
- if (idnum == GAMEPORT_INPUT_SETTINGS) {
- if (!isdevice (id))
+ if (idnum == GAMEPORT_INPUT_SETTINGS)
+ {
+ if (!isdevice(id))
return false;
if (!id->enabled)
return false;
@@ -558,71 +288,87 @@ static bool write_config_head (struct zfile *f, int idnum, int devnum, const TCH
if (id->name)
s = id->name;
- else if (devnum < idf->get_num ())
- s = idf->get_friendlyname (devnum);
- if (s) {
- _stprintf (tmp2, _T("input.%d.%s.%d.friendlyname"), idnum + 1, name, devnum);
- cfgfile_write_str (f, tmp2, s);
+ else if (devnum < idf->get_num())
+ s = idf->get_friendlyname(devnum);
+ if (s)
+ {
+ _stprintf(tmp2, _T("input.%d.%s.%d.friendlyname"), idnum + 1, name, devnum);
+ cfgfile_write_str(f, tmp2, s);
}
s = NULL;
if (id->configname)
s = id->configname;
- else if (devnum < idf->get_num ())
- s = idf->get_uniquename (devnum);
- if (s) {
- _stprintf (tmp2, _T("input.%d.%s.%d.name"), idnum + 1, name, devnum);
- cfgfile_write_str (f, tmp2, s);
+ else if (devnum < idf->get_num())
+ s = idf->get_uniquename(devnum);
+ if (s)
+ {
+ _stprintf(tmp2, _T("input.%d.%s.%d.name"), idnum + 1, name, devnum);
+ cfgfile_write_str(f, tmp2, s);
}
- if (!isdevice (id)) {
- _stprintf (tmp2, _T("input.%d.%s.%d.empty"), idnum + 1, name, devnum);
- cfgfile_write_bool (f, tmp2, true);
- if (id->enabled) {
- _stprintf (tmp2, _T("input.%d.%s.%d.disabled"), idnum + 1, name, devnum);
- cfgfile_write_bool (f, tmp2, id->enabled ? false : true);
+ if (!isdevice(id))
+ {
+ _stprintf(tmp2, _T("input.%d.%s.%d.empty"), idnum + 1, name, devnum);
+ cfgfile_write_bool(f, tmp2, true);
+ if (id->enabled)
+ {
+ _stprintf(tmp2, _T("input.%d.%s.%d.disabled"), idnum + 1, name, devnum);
+ cfgfile_write_bool(f, tmp2, id->enabled ? false : true);
}
return false;
}
- if (idnum == GAMEPORT_INPUT_SETTINGS) {
- _stprintf (tmp2, _T("input.%d.%s.%d.custom"), idnum + 1, name, devnum);
- cfgfile_write_bool (f, tmp2, true);
- } else {
- _stprintf (tmp2, _T("input.%d.%s.%d.empty"), idnum + 1, name, devnum);
- cfgfile_write_bool (f, tmp2, false);
- _stprintf (tmp2, _T("input.%d.%s.%d.disabled"), idnum + 1, name, devnum);
- cfgfile_write_bool (f, tmp2, id->enabled ? false : true);
+ if (idnum == GAMEPORT_INPUT_SETTINGS)
+ {
+ _stprintf(tmp2, _T("input.%d.%s.%d.custom"), idnum + 1, name, devnum);
+ cfgfile_write_bool(f, tmp2, true);
+ }
+ else
+ {
+ _stprintf(tmp2, _T("input.%d.%s.%d.empty"), idnum + 1, name, devnum);
+ cfgfile_write_bool(f, tmp2, false);
+ _stprintf(tmp2, _T("input.%d.%s.%d.disabled"), idnum + 1, name, devnum);
+ cfgfile_write_bool(f, tmp2, id->enabled ? false : true);
}
return true;
}
-static bool write_slot (TCHAR *p, struct uae_input_device *uid, int i, int j)
+static bool write_slot(TCHAR* p, struct uae_input_device* uid, int i, int j)
{
bool ok = false;
- if (i < 0 || j < 0) {
+ if (i < 0 || j < 0)
+ {
_tcscpy (p, _T("NULL"));
return false;
}
uae_u64 flags = uid->flags[i][j];
- if (uid->custom[i][j] && _tcslen (uid->custom[i][j]) > 0) {
- _stprintf (p, _T("'%s'.%d"), uid->custom[i][j], (int)(flags & ID_FLAG_SAVE_MASK_CONFIG));
+ if (uid->custom[i][j] && _tcslen (uid->custom[i][j]) > 0)
+ {
+ _stprintf(p, _T("'%s'.%llu"), uid->custom[i][j], flags & ID_FLAG_SAVE_MASK_CONFIG);
ok = true;
- } else if (uid->eventid[i][j] > 0) {
- _stprintf (p, _T("%s.%d"), events[uid->eventid[i][j]].confname, (int)(flags & ID_FLAG_SAVE_MASK_CONFIG));
+ }
+ else if (uid->eventid[i][j] > 0)
+ {
+ _stprintf(p, _T("%s.%llu"), events[uid->eventid[i][j]].confname, flags & ID_FLAG_SAVE_MASK_CONFIG);
ok = true;
- } else {
+ }
+ else
+ {
_tcscpy (p, _T("NULL"));
}
- if (ok && (flags & ID_FLAG_SAVE_MASK_QUALIFIERS)) {
- TCHAR *p2 = p + _tcslen (p);
+ if (ok && (flags & ID_FLAG_SAVE_MASK_QUALIFIERS))
+ {
+ TCHAR* p2 = p + _tcslen (p);
*p2++ = '.';
- for (int i = 0; i < MAX_INPUT_QUALIFIERS * 2; i++) {
- if ((ID_FLAG_QUALIFIER1 << i) & flags) {
+ for (int i = 0; i < MAX_INPUT_QUALIFIERS * 2; i++)
+ {
+ if ((ID_FLAG_QUALIFIER1 << i) & flags)
+ {
if (i & 1)
- _stprintf (p2, _T("%c"), 'a' + i / 2);
+ _stprintf(p2, _T("%c"), 'a' + i / 2);
else
- _stprintf (p2, _T("%c"), 'A' + i / 2);
+ _stprintf(p2, _T("%c"), 'A' + i / 2);
p2++;
}
}
@@ -630,11 +376,12 @@ static bool write_slot (TCHAR *p, struct uae_input_device *uid, int i, int j)
return ok;
}
-static struct inputdevice_functions *getidf (int devnum);
+static struct inputdevice_functions* getidf(int devnum);
-static void kbrlabel (TCHAR *s)
+static void kbrlabel(TCHAR* s)
{
- while (*s) {
+ while (*s)
+ {
*s = _totupper (*s);
if (*s == ' ')
*s = '_';
@@ -642,12 +389,12 @@ static void kbrlabel (TCHAR *s)
}
}
-static void write_config2 (struct zfile *f, int idnum, int i, int offset, const TCHAR *extra, struct uae_input_device *id)
+static void write_config2(struct zfile* f, int idnum, int i, int offset, const TCHAR* extra, struct uae_input_device* id)
{
TCHAR tmp2[CONFIG_BLEN], tmp3[CONFIG_BLEN], *p;
int evt, got, j, k;
- TCHAR *custom;
- const int *slotorder;
+ TCHAR* custom;
+ const int* slotorder;
int io = i + offset;
tmp2[0] = 0;
@@ -659,12 +406,14 @@ static void write_config2 (struct zfile *f, int idnum, int i, int offset, const
if (id->port[io][0] && !(id->flags[io][0] & ID_FLAG_GAMEPORTSCUSTOM_MASK))
slotorder = slotorder2;
- for (j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
-
+ for (j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
evt = id->eventid[io][slotorder[j]];
custom = id->custom[io][slotorder[j]];
- if (custom == NULL && evt <= 0) {
- for (k = j + 1; k < MAX_INPUT_SUB_EVENT; k++) {
+ if (custom == NULL && evt <= 0)
+ {
+ for (k = j + 1; k < MAX_INPUT_SUB_EVENT; k++)
+ {
if ((id->port[io][k] == 0 || id->port[io][k] == MAX_JPORTS + 1) && (id->eventid[io][slotorder[k]] > 0 || id->custom[io][slotorder[k]] != NULL))
break;
}
@@ -672,61 +421,72 @@ static void write_config2 (struct zfile *f, int idnum, int i, int offset, const
break;
}
- if (p > tmp2) {
+ if (p > tmp2)
+ {
*p++ = ',';
*p = 0;
}
- bool ok = write_slot (p, id, io, slotorder[j]);
+ bool ok = write_slot(p, id, io, slotorder[j]);
p += _tcslen (p);
- if (ok) {
- if (id->port[io][slotorder[j]] > 0 && id->port[io][slotorder[j]] < MAX_JPORTS + 1) {
+ if (ok)
+ {
+ if (id->port[io][slotorder[j]] > 0 && id->port[io][slotorder[j]] < MAX_JPORTS + 1)
+ {
int pnum = id->port[io][slotorder[j]] - 1;
- _stprintf (p, _T(".%d"), pnum);
+ _stprintf(p, _T(".%d"), pnum);
p += _tcslen (p);
- if (idnum != GAMEPORT_INPUT_SETTINGS && j == 0 && id->port[io][SPARE_SUB_EVENT] && slotorder == slotorder1) {
+ if (idnum != GAMEPORT_INPUT_SETTINGS && j == 0 && id->port[io][SPARE_SUB_EVENT] && slotorder == slotorder1)
+ {
*p++ = '.';
- write_slot (p, id, io, SPARE_SUB_EVENT);
+ write_slot(p, id, io, SPARE_SUB_EVENT);
p += _tcslen (p);
}
}
}
}
- if (p > tmp2) {
- _stprintf (tmp3, _T("input.%d.%s%d"), idnum + 1, extra, i);
- cfgfile_write_str (f, tmp3, tmp2);
+ if (p > tmp2)
+ {
+ _stprintf(tmp3, _T("input.%d.%s%d"), idnum + 1, extra, i);
+ cfgfile_write_str(f, tmp3, tmp2);
}
}
-static void write_kbr_config (struct zfile *f, int idnum, int devnum, struct uae_input_device *kbr, struct inputdevice_functions *idf)
+static void write_kbr_config(struct zfile* f, int idnum, int devnum, struct uae_input_device* kbr, struct inputdevice_functions* idf)
{
TCHAR tmp1[CONFIG_BLEN], tmp2[CONFIG_BLEN], tmp3[CONFIG_BLEN], tmp4[CONFIG_BLEN], tmp5[CONFIG_BLEN], *p;
int i, j, k, evt, skip;
- const int *slotorder;
+ const int* slotorder;
if (!keyboard_default)
return;
- if (!write_config_head (f, idnum, devnum, _T("keyboard"), kbr, idf))
+ if (!write_config_head(f, idnum, devnum, _T("keyboard"), kbr, idf))
return;
i = 0;
- while (i < MAX_INPUT_DEVICE_EVENTS && kbr->extra[i] >= 0) {
-
+ while (i < MAX_INPUT_DEVICE_EVENTS && kbr->extra[i] >= 0)
+ {
slotorder = slotorder1;
- // if gameports non-custom mapping in slot0 -> save slot8 as slot0
+ // if gameports non-custom mapping in slot0 -> save slot4 as slot0
if (kbr->port[i][0] && !(kbr->flags[i][0] & ID_FLAG_GAMEPORTSCUSTOM_MASK))
slotorder = slotorder2;
skip = 0;
k = 0;
- while (keyboard_default[k].scancode >= 0) {
- if (keyboard_default[k].scancode == kbr->extra[i]) {
+ while (keyboard_default[k].scancode >= 0)
+ {
+ if (keyboard_default[k].scancode == kbr->extra[i])
+ {
skip = 1;
- for (j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
- if (keyboard_default[k].node[j].evt != 0) {
+ for (j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
+ if (keyboard_default[k].node[j].evt != 0)
+ {
if (keyboard_default[k].node[j].evt != kbr->eventid[i][slotorder[j]] || keyboard_default[k].node[j].flags != (kbr->flags[i][slotorder[j]] & ID_FLAG_SAVE_MASK_FULL))
skip = 0;
- } else if ((kbr->flags[i][slotorder[j]] & ID_FLAG_SAVE_MASK_FULL) != 0 || kbr->eventid[i][slotorder[j]] > 0) {
+ }
+ else if ((kbr->flags[i][slotorder[j]] & ID_FLAG_SAVE_MASK_FULL) != 0 || kbr->eventid[i][slotorder[j]] > 0)
+ {
skip = 0;
}
}
@@ -738,147 +498,143 @@ static void write_kbr_config (struct zfile *f, int idnum, int devnum, struct uae
kbr->port[i][SPARE_SUB_EVENT] &&
keyboard_default[k].node[0].evt == kbr->eventid[i][SPARE_SUB_EVENT] && keyboard_default[k].node[0].flags == (kbr->flags[i][SPARE_SUB_EVENT] & ID_FLAG_SAVE_MASK_FULL);
- if (kbr->port[i][0] > 0 && !(kbr->flags[i][0] & ID_FLAG_GAMEPORTSCUSTOM_MASK) &&
+ if (kbr->port[i][0] > 0 && !(kbr->flags[i][0] & ID_FLAG_GAMEPORTSCUSTOM_MASK) &&
(kbr->eventid[i][1] <= 0 && kbr->eventid[i][2] <= 0 && kbr->eventid[i][3] <= 0) &&
(kbr->port[i][SPARE_SUB_EVENT] == 0 || isdefaultspare))
skip = 1;
if (kbr->eventid[i][0] == 0 && (kbr->flags[i][0] & ID_FLAG_SAVE_MASK_FULL) == 0 && keyboard_default[k].scancode < 0)
skip = 1;
- if (skip) {
+ if (skip)
+ {
i++;
continue;
}
-
- if (!input_get_default_keyboard(devnum)) {
- bool isempty = true;
- for (j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
- if (kbr->eventid[i][j] > 0) {
- isempty = false;
- break;
- }
- if (kbr->custom[i][j] != NULL) {
- isempty = false;
- break;
- }
- }
- if (isempty) {
- i++;
- continue;
- }
- }
-
tmp2[0] = 0;
p = tmp2;
- for (j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
- TCHAR *custom = kbr->custom[i][slotorder[j]];
+ for (j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
+ TCHAR* custom = kbr->custom[i][slotorder[j]];
evt = kbr->eventid[i][slotorder[j]];
- if (custom == NULL && evt <= 0) {
- for (k = j + 1; k < MAX_INPUT_SUB_EVENT; k++) {
+ if (custom == NULL && evt <= 0)
+ {
+ for (k = j + 1; k < MAX_INPUT_SUB_EVENT; k++)
+ {
if (kbr->eventid[i][slotorder[k]] > 0 || kbr->custom[i][slotorder[k]] != NULL)
break;
}
if (k == MAX_INPUT_SUB_EVENT)
break;
}
- if (p > tmp2) {
+ if (p > tmp2)
+ {
*p++ = ',';
*p = 0;
}
- bool ok = write_slot (p, kbr, i, slotorder[j]);
+ bool ok = write_slot(p, kbr, i, slotorder[j]);
p += _tcslen (p);
- if (ok) {
+ if (ok)
+ {
// save port number + SPARE SLOT if needed
- if (kbr->port[i][slotorder[j]] > 0 && (kbr->flags[i][slotorder[j]] & ID_FLAG_GAMEPORTSCUSTOM_MASK)) {
- _stprintf (p, _T(".%d"), kbr->port[i][slotorder[j]] - 1);
+ if (kbr->port[i][slotorder[j]] > 0 && (kbr->flags[i][slotorder[j]] & ID_FLAG_GAMEPORTSCUSTOM_MASK))
+ {
+ _stprintf(p, _T(".%d"), kbr->port[i][slotorder[j]] - 1);
p += _tcslen (p);
- if (idnum != GAMEPORT_INPUT_SETTINGS && j == 0 && kbr->port[i][SPARE_SUB_EVENT] && !isdefaultspare && slotorder == slotorder1) {
+ if (idnum != GAMEPORT_INPUT_SETTINGS && j == 0 && kbr->port[i][SPARE_SUB_EVENT] && !isdefaultspare && slotorder == slotorder1)
+ {
*p++ = '.';
- write_slot (p, kbr, i, SPARE_SUB_EVENT);
+ write_slot(p, kbr, i, SPARE_SUB_EVENT);
p += _tcslen (p);
}
}
}
}
- idf->get_widget_type (devnum, i, tmp5, NULL);
- _stprintf (tmp3, _T("%d%s%s"), kbr->extra[i], tmp5[0] ? _T(".") : _T(""), tmp5[0] ? tmp5 : _T(""));
- kbrlabel (tmp3);
- _stprintf (tmp1, _T("keyboard.%d.button.%s"), devnum, tmp3);
- _stprintf (tmp4, _T("input.%d.%s"), idnum + 1, tmp1);
- cfgfile_write_str (f, tmp4, tmp2[0] ? tmp2 : _T("NULL"));
+ idf->get_widget_type(devnum, i, tmp5, NULL);
+ _stprintf(tmp3, _T("%d%s%s"), kbr->extra[i], tmp5[0] ? _T(".") : _T(""), tmp5[0] ? tmp5 : _T(""));
+ kbrlabel(tmp3);
+ _stprintf(tmp1, _T("keyboard.%d.button.%s"), devnum, tmp3);
+ _stprintf(tmp4, _T("input.%d.%s"), idnum + 1, tmp1);
+ cfgfile_write_str(f, tmp4, tmp2[0] ? tmp2 : _T("NULL"));
i++;
}
}
-static void write_config (struct zfile *f, int idnum, int devnum, const TCHAR *name, struct uae_input_device *id, struct inputdevice_functions *idf)
+static void write_config(struct zfile* f, int idnum, int devnum, const TCHAR* name, struct uae_input_device* id, struct inputdevice_functions* idf)
{
TCHAR tmp1[MAX_DPATH];
int i;
- if (!write_config_head (f, idnum, devnum, name, id, idf))
+ if (!write_config_head(f, idnum, devnum, name, id, idf))
return;
- _stprintf (tmp1, _T("%s.%d.axis."), name, devnum);
+ _stprintf(tmp1, _T("%s.%d.axis."), name, devnum);
for (i = 0; i < ID_AXIS_TOTAL; i++)
- write_config2 (f, idnum, i, ID_AXIS_OFFSET, tmp1, id);
- _stprintf (tmp1, _T("%s.%d.button.") ,name, devnum);
+ write_config2(f, idnum, i, ID_AXIS_OFFSET, tmp1, id);
+ _stprintf(tmp1, _T("%s.%d.button."), name, devnum);
for (i = 0; i < ID_BUTTON_TOTAL; i++)
- write_config2 (f, idnum, i, ID_BUTTON_OFFSET, tmp1, id);
+ write_config2(f, idnum, i, ID_BUTTON_OFFSET, tmp1, id);
}
-static const TCHAR *kbtypes[] = { _T("amiga"), _T("pc"), NULL };
+static const TCHAR* kbtypes[] = {_T("amiga"), _T("pc"), NULL};
-void write_inputdevice_config (struct uae_prefs *p, struct zfile *f)
+void write_inputdevice_config(struct uae_prefs* p, struct zfile* f)
{
int i, id;
-// cfgfile_write (f, _T("input.config"), _T("%d"), p->input_selected_setting == GAMEPORT_INPUT_SETTINGS ? 0 : p->input_selected_setting + 1);
- cfgfile_write (f, _T("input.joymouse_speed_analog"), _T("%d"), p->input_joymouse_multiplier);
- cfgfile_write (f, _T("input.joymouse_speed_digital"), _T("%d"), p->input_joymouse_speed);
- cfgfile_write (f, _T("input.joymouse_deadzone"), _T("%d"), p->input_joymouse_deadzone);
- cfgfile_write (f, _T("input.joystick_deadzone"), _T("%d"), p->input_joystick_deadzone);
- cfgfile_write (f, _T("input.analog_joystick_multiplier"), _T("%d"), p->input_analog_joystick_mult);
- cfgfile_write (f, _T("input.analog_joystick_offset"), _T("%d"), p->input_analog_joystick_offset);
- cfgfile_write (f, _T("input.mouse_speed"), _T("%d"), p->input_mouse_speed);
- cfgfile_write (f, _T("input.autofire_speed"), _T("%d"), p->input_autofire_linecnt);
- cfgfile_dwrite_str (f, _T("input.keyboard_type"), kbtypes[p->input_keyboard_type]);
-
- // not required config saving
- //
-// for (id = 0; id < MAX_INPUT_SETTINGS; id++) {
-// TCHAR tmp[MAX_DPATH];
-// if (id < GAMEPORT_INPUT_SETTINGS) {
-// _stprintf (tmp, _T("input.%d.name"), id + 1);
-// cfgfile_dwrite_str (f, tmp, p->input_config_name[id]);
-// }
-// for (i = 0; i < MAX_INPUT_DEVICES; i++)
-// write_config (f, id, i, _T("joystick"), &p->joystick_settings[id][i], &idev[IDTYPE_JOYSTICK]);
-// for (i = 0; i < MAX_INPUT_DEVICES; i++)
-// write_config (f, id, i, _T("mouse"), &p->mouse_settings[id][i], &idev[IDTYPE_MOUSE]);
-// for (i = 0; i < MAX_INPUT_DEVICES; i++)
-// write_kbr_config (f, id, i, &p->keyboard_settings[id][i], &idev[IDTYPE_KEYBOARD]);
-// }
+ cfgfile_write(f, _T("input.config"), _T("%d"), p->input_selected_setting == GAMEPORT_INPUT_SETTINGS ? 0 : p->input_selected_setting + 1);
+ cfgfile_write(f, _T("input.joymouse_speed_analog"), _T("%d"), p->input_joymouse_multiplier);
+ cfgfile_write(f, _T("input.joymouse_speed_digital"), _T("%d"), p->input_joymouse_speed);
+ cfgfile_write(f, _T("input.joymouse_deadzone"), _T("%d"), p->input_joymouse_deadzone);
+ cfgfile_write(f, _T("input.joystick_deadzone"), _T("%d"), p->input_joystick_deadzone);
+ cfgfile_write(f, _T("input.analog_joystick_multiplier"), _T("%d"), p->input_analog_joystick_mult);
+ cfgfile_write(f, _T("input.analog_joystick_offset"), _T("%d"), p->input_analog_joystick_offset);
+ cfgfile_write(f, _T("input.mouse_speed"), _T("%d"), p->input_mouse_speed);
+ cfgfile_write(f, _T("input.autofire_speed"), _T("%d"), p->input_autofire_linecnt);
+ cfgfile_dwrite_str(f, _T("input.keyboard_type"), kbtypes[p->input_keyboard_type]);
+ cfgfile_dwrite(f, _T("input.contact_bounce"), _T("%d"), p->input_contact_bounce);
+ for (id = 0; id < MAX_INPUT_SETTINGS; id++)
+ {
+ TCHAR tmp[MAX_DPATH];
+ if (id < GAMEPORT_INPUT_SETTINGS)
+ {
+ _stprintf(tmp, _T("input.%d.name"), id + 1);
+ cfgfile_dwrite_str(f, tmp, p->input_config_name[id]);
+ }
+ for (i = 0; i < MAX_INPUT_DEVICES; i++)
+ write_config(f, id, i, _T("joystick"), &p->joystick_settings[id][i], &idev[IDTYPE_JOYSTICK]);
+ for (i = 0; i < MAX_INPUT_DEVICES; i++)
+ write_config(f, id, i, _T("mouse"), &p->mouse_settings[id][i], &idev[IDTYPE_MOUSE]);
+ for (i = 0; i < MAX_INPUT_DEVICES; i++)
+ write_kbr_config(f, id, i, &p->keyboard_settings[id][i], &idev[IDTYPE_KEYBOARD]);
+#ifndef INPUTDEVICE_SIMPLE
+ write_config (f, id, 0, _T("internal"), &p->internalevent_settings[id][0], &idev[IDTYPE_INTERNALEVENT]);
+#endif
+ }
}
-static uae_u64 getqual (const TCHAR **pp)
+static uae_u64 getqual(const TCHAR** pp)
{
- const TCHAR *p = *pp;
+ const TCHAR* p = *pp;
uae_u64 mask = 0;
- while ((*p >= 'A' && *p <= 'Z') || (*p >= 'a' && *p <= 'z')) {
+ while ((*p >= 'A' && *p <= 'Z') || (*p >= 'a' && *p <= 'z'))
+ {
bool press = (*p >= 'A' && *p <= 'Z');
int shift, inc;
- if (press) {
+ if (press)
+ {
shift = *p - 'A';
inc = 0;
- } else {
+ }
+ else
+ {
shift = *p - 'a';
inc = 1;
}
mask |= ID_FLAG_QUALIFIER1 << (shift * 2 + inc);
p++;
}
- while (*p != 0 && *p !='.' && *p != ',')
+ while (*p != 0 && *p != '.' && *p != ',')
p++;
if (*p == '.' || *p == ',')
p++;
@@ -886,9 +642,9 @@ static uae_u64 getqual (const TCHAR **pp)
return mask;
}
-static int getnum (const TCHAR **pp)
+static int getnum(const TCHAR** pp)
{
- const TCHAR *p = *pp;
+ const TCHAR* p = *pp;
int v;
if (!_tcsnicmp (p, _T("false"), 5))
@@ -898,114 +654,102 @@ static int getnum (const TCHAR **pp)
else
v = _tstol (p);
- while (*p != 0 && *p !='.' && *p != ',' && *p != '=')
+ while (*p != 0 && *p != '.' && *p != ',')
p++;
if (*p == '.' || *p == ',')
p++;
*pp = p;
return v;
}
-static TCHAR *getstring (const TCHAR **pp)
+
+static TCHAR* getstring(const TCHAR** pp)
{
- int i;
+ int i;
static TCHAR str[CONFIG_BLEN];
- const TCHAR *p = *pp;
+ const TCHAR* p = *pp;
bool quoteds = false;
bool quotedd = false;
- if (*p == 0)
- return 0;
- i = 0;
- while (*p != 0 && i < 1000 - 1) {
+ if (*p == 0)
+ return 0;
+ i = 0;
+ while (*p != 0 && i < 1000 - 1)
+ {
if (*p == '\"')
quotedd = quotedd ? false : true;
if (*p == '\'')
quoteds = quoteds ? false : true;
- if (!quotedd && !quoteds) {
+ if (!quotedd && !quoteds)
+ {
if (*p == '.' || *p == ',')
break;
}
- str[i++] = *p++;
+ str[i++] = *p++;
}
- if (*p == '.' || *p == ',')
- p++;
- str[i] = 0;
- *pp = p;
- return str;
+ if (*p == '.' || *p == ',')
+ p++;
+ str[i] = 0;
+ *pp = p;
+ return str;
}
-static void reset_inputdevice_settings (struct uae_input_device *uid)
+static void reset_inputdevice_settings(struct uae_input_device* uid)
{
- for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++) {
- for (int i = 0; i < MAX_INPUT_SUB_EVENT_ALL; i++) {
+ for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++)
+ {
+ for (int i = 0; i < MAX_INPUT_SUB_EVENT_ALL; i++)
+ {
uid->eventid[l][i] = 0;
uid->flags[l][i] = 0;
- if (uid->custom[l][i]) {
- xfree (uid->custom[l][i]);
- uid->custom[l][i] = NULL;
- }
- }
- }
-}
-static void reset_inputdevice_slot (struct uae_prefs *prefs, int slot)
-{
- for (int m = 0; m < MAX_INPUT_DEVICES; m++) {
- reset_inputdevice_settings (&prefs->joystick_settings[slot][m]);
- reset_inputdevice_settings (&prefs->mouse_settings[slot][m]);
- reset_inputdevice_settings (&prefs->keyboard_settings[slot][m]);
- }
-}
-
-static void reset_inputdevice_config_temp(void)
-{
- for (int i = 0; i < MAX_INPUT_DEVICES; i++) {
- for (int j = 0; j < IDTYPE_MAX; j++) {
- temp_uid_index[i][j] = -1;
+ if (uid->custom[l][i])
+ {
+ xfree (uid->custom[l][i]);
+ uid->custom[l][i] = NULL;
+ }
}
}
- for (int i = 0; i < IDTYPE_MAX; i++) {
- temp_uid_cnt[i] = 0;
- }
- memset(&temp_uid, 0, sizeof temp_uid);
- for (int i = 0; i < MAX_INPUT_DEVICES; i++) {
- temp_uid.matcheddevices[i] = -1;
- temp_uid.nonmatcheddevices[i] = -1;
- }
- temp_uid.idnum = -1;
- temp_uid.lastdevtype = -1;
}
-void reset_inputdevice_config (struct uae_prefs *prefs, bool reset)
+static void reset_inputdevice_slot(struct uae_prefs* prefs, int slot)
{
- for (int i = 0; i< MAX_INPUT_SETTINGS; i++)
- reset_inputdevice_slot (prefs, i);
- reset_inputdevice_config_temp();
-
- if (reset) {
- inputdevice_store_clear();
+ for (int m = 0; m < MAX_INPUT_DEVICES; m++)
+ {
+ reset_inputdevice_settings(&prefs->joystick_settings[slot][m]);
+ reset_inputdevice_settings(&prefs->mouse_settings[slot][m]);
+ reset_inputdevice_settings(&prefs->keyboard_settings[slot][m]);
}
}
-static void set_kbr_default_event (struct uae_input_device *kbr, struct uae_input_device_kbr_default *trans, int num)
+void reset_inputdevice_config(struct uae_prefs* prefs)
{
- if (!kbr->enabled || !trans)
- return;
- for (int i = 0; trans[i].scancode >= 0; i++) {
- if (kbr->extra[num] == trans[i].scancode) {
+ for (int i = 0; i < MAX_INPUT_SETTINGS; i++)
+ reset_inputdevice_slot(prefs, i);
+}
+
+static void set_kbr_default_event(struct uae_input_device* kbr, struct uae_input_device_kbr_default* trans, int num)
+{
+ for (int i = 0; trans[i].scancode >= 0; i++)
+ {
+ if (kbr->extra[num] == trans[i].scancode)
+ {
int k;
- for (k = 0; k < MAX_INPUT_SUB_EVENT; k++) {
+ for (k = 0; k < MAX_INPUT_SUB_EVENT; k++)
+ {
if (kbr->eventid[num][k] == 0)
break;
}
- if (k == MAX_INPUT_SUB_EVENT) {
+ if (k == MAX_INPUT_SUB_EVENT)
+ {
write_log (_T("corrupt default keyboard mappings\n"));
return;
}
int l = 0;
- while (k < MAX_INPUT_SUB_EVENT && trans[i].node[l].evt) {
+ while (k < MAX_INPUT_SUB_EVENT && trans[i].node[l].evt)
+ {
int evt = trans[i].node[l].evt;
if (evt < 0 || evt >= INPUTEVENT_SPC_LAST)
gui_message(_T("invalid event in default keyboard table!"));
+
kbr->eventid[num][k] = evt;
kbr->flags[num][k] = trans[i].node[l].flags;
l++;
@@ -1016,233 +760,88 @@ static void set_kbr_default_event (struct uae_input_device *kbr, struct uae_inpu
}
}
-static void clear_id (struct uae_input_device *id)
+static void clear_id(struct uae_input_device* id)
{
int i, j;
- for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
+ for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
+ {
for (j = 0; j < MAX_INPUT_SUB_EVENT_ALL; j++)
- xfree (id->custom[i][j]);
+ xfree (id->custom[i][j]);
}
- TCHAR *cn = id->configname;
- TCHAR *n = id->name;
- memset (id, 0, sizeof (struct uae_input_device));
+ TCHAR* cn = id->configname;
+ TCHAR* n = id->name;
+ memset(id, 0, sizeof (struct uae_input_device));
id->configname = cn;
id->name = n;
}
-static void set_kbr_default (struct uae_prefs *p, int index, int devnum, struct uae_input_device_kbr_default *trans)
+static void set_kbr_default(struct uae_prefs* p, int index, int devnum, struct uae_input_device_kbr_default* trans)
{
int i, j;
- struct uae_input_device *kbr;
- struct inputdevice_functions *id = &idev[IDTYPE_KEYBOARD];
+ struct uae_input_device* kbr;
+ struct inputdevice_functions* id = &idev[IDTYPE_KEYBOARD];
uae_u32 scancode;
- for (j = 0; j < MAX_INPUT_DEVICES; j++) {
+ if (!trans)
+ return;
+
+ for (j = 0; j < MAX_INPUT_DEVICES; j++)
+ {
if (devnum >= 0 && devnum != j)
continue;
kbr = &p->keyboard_settings[index][j];
- uae_s8 ena = kbr->enabled;
- clear_id (kbr);
- if (ena > 0)
- kbr->enabled = ena;
+ clear_id(kbr);
for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
kbr->extra[i] = -1;
- if (j < id->get_num ()) {
- if (input_get_default_keyboard (j))
+ if (j < id->get_num())
+ {
+ if (input_get_default_keyboard(j))
kbr->enabled = 1;
- for (i = 0; i < id->get_widget_num (j); i++) {
- id->get_widget_type (j, i, 0, &scancode);
+ for (i = 0; i < id->get_widget_num(j); i++)
+ {
+ id->get_widget_type(j, i, 0, &scancode);
kbr->extra[i] = scancode;
- if (j == 0 || kbr->enabled)
- set_kbr_default_event (kbr, trans, i);
+ set_kbr_default_event(kbr, trans, i);
}
}
}
}
-static void inputdevice_default_kb (struct uae_prefs *p, int num)
+static void inputdevice_default_kb(struct uae_prefs *p, int num)
{
if (num == GAMEPORT_INPUT_SETTINGS) {
- reset_inputdevice_slot (p, num);
+ reset_inputdevice_slot(p, num);
}
- set_kbr_default (p, num, -1, keyboard_default);
+ set_kbr_default(p, num, -1, keyboard_default);
}
-static void inputdevice_default_kb_all (struct uae_prefs *p)
+static void inputdevice_default_kb_all(struct uae_prefs* p)
{
for (int i = 0; i < MAX_INPUT_SETTINGS; i++)
- inputdevice_default_kb (p, i);
+ inputdevice_default_kb(p, i);
}
-static const int af_port1[] = {
- INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_CD32_RED,
- -1
-};
-static const int af_port2[] = {
- INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_CD32_RED,
- -1
-};
-static const int af_port3[] = {
- INPUTEVENT_PAR_JOY1_FIRE_BUTTON, INPUTEVENT_PAR_JOY1_2ND_BUTTON,
- -1
-};
-static const int af_port4[] = {
- INPUTEVENT_PAR_JOY2_FIRE_BUTTON, INPUTEVENT_PAR_JOY2_2ND_BUTTON,
- -1
-};
-static const int *af_ports[] = { af_port1, af_port2, af_port3, af_port4 };
-
-static void setautofireevent (struct uae_input_device *uid, int num, int sub, int af, int index)
-{
- if (!af)
- return;
- const int *afp = af_ports[index];
- for (int k = 0; afp[k] >= 0; k++) {
- if (afp[k] == uid->eventid[num][sub]) {
- uid->flags[num][sub] &= ~ID_FLAG_AUTOFIRE_MASK;
- if (af >= JPORT_AF_NORMAL)
- uid->flags[num][sub] |= ID_FLAG_AUTOFIRE;
-#ifndef INPUTDEVICE_SIMPLE
- if (af == JPORT_AF_TOGGLE)
- uid->flags[num][sub] |= ID_FLAG_TOGGLE;
- if (af == JPORT_AF_ALWAYS)
- uid->flags[num][sub] |= ID_FLAG_INVERTTOGGLE;
-#endif
- return;
- }
- }
-}
-
-static void setcompakbevent(struct uae_prefs *p, struct uae_input_device *uid, int l, int evt, int port, int af)
-{
- inputdevice_sparecopy(uid, l, 0);
- if (p->jports[port].nokeyboardoverride && uid->port[l][0] == 0) {
- uid->eventid[l][MAX_INPUT_SUB_EVENT - 1] = uid->eventid[l][0];
- uid->flags[l][MAX_INPUT_SUB_EVENT - 1] = uid->flags[l][0] | ID_FLAG_RESERVEDGAMEPORTSCUSTOM;
- uid->custom[l][MAX_INPUT_SUB_EVENT - 1] = my_strdup(uid->custom[l][0]);
- uid->eventid[l][MAX_INPUT_SUB_EVENT - 1] = uid->eventid[l][0];
- }
- uid->eventid[l][0] = evt;
- uid->flags[l][0] &= COMPA_RESERVED_FLAGS;
- uid->port[l][0] = port + 1;
- xfree(uid->custom[l][0]);
- uid->custom[l][0] = NULL;
- setautofireevent(uid, l, 0, af, port);
-}
-
-static int matchdevice(struct inputdevice_functions *inf, const TCHAR *configname, const TCHAR *name)
-{
- int match = -1;
- for (int j = 0; j < 2; j++) {
- bool fullmatch = j == 0;
- for (int i = 0; i < inf->get_num(); i++) {
- const TCHAR* aname1 = inf->get_friendlyname(i);
- const TCHAR* aname2 = inf->get_uniquename(i);
- if (fullmatch && (!aname1 || !name))
- continue;
- if (aname2 && configname) {
- bool matched = false;
- TCHAR bname[MAX_DPATH];
- TCHAR bname2[MAX_DPATH];
- TCHAR *p1, *p2;
- _tcscpy(bname, configname);
- _tcscpy(bname2, aname2);
- // strip possible local guid part
- p1 = _tcschr(bname, '{');
- p2 = _tcschr(bname2, '{');
- if (!p1 && !p2) {
- // check possible directinput names too
- p1 = _tcschr(bname, ' ');
- p2 = _tcschr(bname2, ' ');
- }
- if (!_tcscmp(bname, bname2)) {
- matched = true;
- } else if (p1 && p2 && p1 - bname == p2 - bname2) {
- *p1 = 0;
- *p2 = 0;
- if (bname[0] && !_tcscmp(bname2, bname))
- matched = true;
- }
- if (matched && fullmatch && _tcscmp(aname1, name) != 0)
- matched = false;
- if (matched) {
- if (match >= 0)
- match = -2;
- else
- match = i;
- }
- if (match == -2)
- break;
- }
- }
- if (match != -1)
- break;
- }
- // multiple matches -> use complete local-only id string for comparisons
- if (match == -2) {
- for (int j = 0; j < 2; j++) {
- bool fullmatch = j == 0;
- match = -1;
- for (int i = 0; i < inf->get_num(); i++) {
- const TCHAR* aname1 = inf->get_friendlyname(i);
- const TCHAR* aname2 = inf->get_uniquename(i);
- if (aname2 && configname) {
- const TCHAR *bname2 = configname;
- bool matched = false;
- if (fullmatch && (!aname1 || !name))
- continue;
- if (aname2 && bname2 && !_tcscmp(aname2, bname2))
- matched = true;
- if (matched && fullmatch && _tcscmp(aname1, name) != 0)
- matched = false;
- if (matched) {
- if (match >= 0) {
- match = -2;
- break;
- } else {
- match = i;
- }
- }
- }
- }
- if (match != -1)
- break;
- }
- }
- if (match < 0) {
- // no match, try friendly names
- for (int i = 0; i < inf->get_num(); i++) {
- const TCHAR* aname1 = inf->get_friendlyname(i);
- if (aname1 && name) {
- const TCHAR *bname1 = name;
- if (aname1 && bname1 && !_tcscmp(aname1, bname1)) {
- if (match >= 0) {
- match = -2;
- break;
- } else {
- match = i;
- }
- }
- }
- }
- }
- return match;
-}
-
-static bool read_slot (const TCHAR *parm, int num, int joystick, int button, struct uae_input_device *id, int keynum, int subnum, const struct inputevent *ie, uae_u64 flags, int port, TCHAR *custom)
+static bool read_slot(const TCHAR* parm, int num, int joystick, int button, struct uae_input_device* id, int keynum, int subnum, struct inputevent* ie, uae_u64 flags, int port, TCHAR* custom)
{
int mask;
- if (custom == NULL && ie->name == NULL) {
- if (!_tcscmp (parm, _T("NULL"))) {
- if (joystick < 0) {
+ if (custom == NULL && ie->name == NULL)
+ {
+ if (!_tcscmp (parm, _T("NULL")))
+ {
+ if (joystick < 0)
+ {
id->eventid[keynum][subnum] = 0;
id->flags[keynum][subnum] = 0;
- } else if (button) {
+ }
+ else if (button)
+ {
id->eventid[num + ID_BUTTON_OFFSET][subnum] = 0;
id->flags[num + ID_BUTTON_OFFSET][subnum] = 0;
- } else {
+ }
+ else
+ {
id->eventid[num + ID_AXIS_OFFSET][subnum] = 0;
id->flags[num + ID_AXIS_OFFSET][subnum] = 0;
}
@@ -1252,7 +851,8 @@ static bool read_slot (const TCHAR *parm, int num, int joystick, int button, str
if (custom)
ie = &events[INPUTEVENT_SPC_CUSTOM_EVENT];
- if (joystick < 0) {
+ if (joystick < 0)
+ {
if (!(ie->allow_mask & AM_K))
return false;
id->eventid[keynum][subnum] = ie - events;
@@ -1260,7 +860,9 @@ static bool read_slot (const TCHAR *parm, int num, int joystick, int button, str
id->port[keynum][subnum] = port;
xfree (id->custom[keynum][subnum]);
id->custom[keynum][subnum] = custom;
- } else if (button) {
+ }
+ else if (button)
+ {
if (joystick)
mask = AM_JOY_BUT;
else
@@ -1272,7 +874,9 @@ static bool read_slot (const TCHAR *parm, int num, int joystick, int button, str
id->port[num + ID_BUTTON_OFFSET][subnum] = port;
xfree (id->custom[num + ID_BUTTON_OFFSET][subnum]);
id->custom[num + ID_BUTTON_OFFSET][subnum] = custom;
- } else {
+ }
+ else
+ {
if (joystick)
mask = AM_JOY_AXIS;
else
@@ -1288,255 +892,191 @@ static bool read_slot (const TCHAR *parm, int num, int joystick, int button, str
return true;
}
-static const struct inputevent *readevent (const TCHAR *name, TCHAR **customp)
+static struct inputevent* readevent(const TCHAR* name, TCHAR** customp)
{
int i = 1;
- while (events[i].name) {
+ while (events[i].name)
+ {
if (!_tcscmp (events[i].confname, name))
return &events[i];
i++;
}
- if (_tcslen (name) > 2 && name[0] == '\'') {
- name++;
- const TCHAR *end = name;
- while (*end && *end != '\'')
- end++;
- if (!customp || *end == 0)
- return NULL;
- TCHAR *custom = my_strdup (name);
- custom[end - name] = 0;
+ if (_tcslen (name) > 2 && name[0] == '\'' && name[_tcslen (name) - 1] == '\'')
+ {
+ TCHAR* custom = my_strdup(name + 1);
+ custom[_tcslen (custom) - 1] = 0;
*customp = custom;
}
return &events[0];
}
-void read_inputdevice_config (struct uae_prefs *pr, const TCHAR *option, TCHAR *value)
+void read_inputdevice_config(struct uae_prefs* pr, const TCHAR* option, TCHAR* value)
{
- struct uae_input_device *id = NULL;
- const struct inputevent *ie;
- int devnum, num, button, joystick, subnum, idnum, keynum, devtype;
- const TCHAR *p;
+ struct uae_input_device* id = 0;
+ struct inputevent* ie;
+ int devnum, num, button, joystick, subnum, idnum, keynum;
+ const TCHAR* p;
TCHAR *p2, *custom;
- struct temp_uids *tid = &temp_uid;
- struct inputdevice_functions *idf = NULL;
- option += 6; /* "input." */
- p = getstring (&option);
- if (!_tcsicmp (p, _T("config"))) {
+ option += 6; /* "input." */
+ p = getstring(&option);
+ if (!strcasecmp(p, _T("config")))
+ {
pr->input_selected_setting = _tstol (value) - 1;
if (pr->input_selected_setting == -1)
pr->input_selected_setting = GAMEPORT_INPUT_SETTINGS;
if (pr->input_selected_setting < 0 || pr->input_selected_setting > MAX_INPUT_SETTINGS)
pr->input_selected_setting = 0;
}
- if (!_tcsicmp (p, _T("joymouse_speed_analog")))
- pr->input_joymouse_multiplier = _tstol (value);
- if (!_tcsicmp (p, _T("joymouse_speed_digital")))
+ if (!strcasecmp(p, _T("joymouse_speed_analog")))
+ pr->input_joymouse_multiplier = _tstol (value);
+ if (!strcasecmp(p, _T("joymouse_speed_digital")))
pr->input_joymouse_speed = _tstol (value);
- if (!_tcsicmp (p, _T("joystick_deadzone")))
+ if (!strcasecmp(p, _T("joystick_deadzone")))
pr->input_joystick_deadzone = _tstol (value);
- if (!_tcsicmp (p, _T("joymouse_deadzone")))
+ if (!strcasecmp(p, _T("joymouse_deadzone")))
pr->input_joymouse_deadzone = _tstol (value);
- if (!_tcsicmp (p, _T("mouse_speed")))
+ if (!strcasecmp(p, _T("mouse_speed")))
pr->input_mouse_speed = _tstol (value);
- if (!_tcsicmp (p, _T("autofire")))
- pr->input_autofire_linecnt = _tstol (value) * 312;
- if (!_tcsicmp (p, _T("autofire_speed")))
+ if (!strcasecmp(p, _T("autofire")))
+ pr->input_autofire_linecnt = _tstol (value) * 312;
+ if (!strcasecmp(p, _T("autofire_speed")))
pr->input_autofire_linecnt = _tstol (value);
- if (!_tcsicmp (p, _T("analog_joystick_multiplier")))
+ if (!strcasecmp(p, _T("analog_joystick_multiplier")))
pr->input_analog_joystick_mult = _tstol (value);
- if (!_tcsicmp (p, _T("analog_joystick_offset")))
+ if (!strcasecmp(p, _T("analog_joystick_offset")))
pr->input_analog_joystick_offset = _tstol (value);
- if (!_tcsicmp (p, _T("keyboard_type"))) {
- cfgfile_strval (option, value, nullptr, &pr->input_keyboard_type, kbtypes, 0);
+ if (!strcasecmp(p, _T("keyboard_type")))
+ {
+ cfgfile_strval(option, value, NULL, &pr->input_keyboard_type, kbtypes, 0);
keyboard_default = keyboard_default_table[pr->input_keyboard_type];
- inputdevice_default_kb_all (pr);
+ inputdevice_default_kb_all(pr);
}
+ if (!strcasecmp(p, _T("contact_bounce")))
+ pr->input_contact_bounce = _tstol(value);
+
idnum = _tstol (p);
if (idnum <= 0 || idnum > MAX_INPUT_SETTINGS)
return;
idnum--;
- if (idnum != tid->idnum) {
- reset_inputdevice_config_temp();
- tid->idnum = idnum;
+ if (!_tcscmp (option, _T("name")))
+ {
+ if (idnum < GAMEPORT_INPUT_SETTINGS)
+ _tcscpy (pr->input_config_name[idnum], value);
+ return;
}
- if (!_tcscmp (option, _T("name"))) {
- if (idnum < GAMEPORT_INPUT_SETTINGS)
- _tcscpy (pr->input_config_name[idnum], value);
- return;
- }
-
- if (_tcsncmp (option, _T("mouse."), 6) == 0) {
+ if (_tcsncmp (option, _T("mouse."), 6) == 0)
+ {
p = option + 6;
- } else if (_tcsncmp (option, _T("joystick."), 9) == 0) {
+ }
+ else if (_tcsncmp (option, _T("joystick."), 9) == 0)
+ {
p = option + 9;
- } else if (_tcsncmp (option, _T("keyboard."), 9) == 0) {
+ }
+ else if (_tcsncmp (option, _T("keyboard."), 9) == 0)
+ {
p = option + 9;
- } else
+#ifndef INPUTDEVICE_SIMPLE
+ } else if (_tcsncmp (option, _T("internal."), 9) == 0) {
+ p = option + 9;
+#endif
+ }
+ else
return;
- devnum = getnum (&p);
+ devnum = getnum(&p);
if (devnum < 0 || devnum >= MAX_INPUT_DEVICES)
return;
- p2 = getstring (&p);
+ p2 = getstring(&p);
if (!p2)
return;
- if (_tcsncmp (option, _T("mouse."), 6) == 0) {
+ if (_tcsncmp (option, _T("mouse."), 6) == 0)
+ {
id = &pr->mouse_settings[idnum][devnum];
joystick = 0;
- devtype = IDTYPE_MOUSE;
- } else if (_tcsncmp (option, _T("joystick."), 9) == 0) {
+ }
+ else if (_tcsncmp (option, _T("joystick."), 9) == 0)
+ {
id = &pr->joystick_settings[idnum][devnum];
joystick = 1;
- devtype = IDTYPE_JOYSTICK;
- } else if (_tcsncmp (option, _T("keyboard."), 9) == 0) {
+ }
+ else if (_tcsncmp (option, _T("keyboard."), 9) == 0)
+ {
id = &pr->keyboard_settings[idnum][devnum];
joystick = -1;
- devtype = IDTYPE_KEYBOARD;
+#ifndef INPUTDEVICE_SIMPLE
+ } else if (_tcsncmp (option, _T("internal."), 9) == 0) {
+ if (devnum > 0)
+ return;
+ id = &pr->internalevent_settings[idnum][devnum];
+ joystick = 1;
+#endif
}
if (!id)
return;
- idf = &idev[devtype];
-
- if (devtype != tid->lastdevtype) {
- tid->lastdevtype = devtype;
- }
-
- if (!_tcscmp (p2, _T("name"))) {
- xfree(tid->configname);
- tid->configname = my_strdup (value);
- tid->joystick = joystick;
- tid->devtype = devtype;
- tid->custom = false;
- tid->empty = false;
- tid->disabled = false;
+ if (!_tcscmp (p2, _T("name")))
+ {
+ xfree (id->configname);
+ id->configname = my_strdup(value);
return;
}
- if (!_tcscmp (p2, _T("friendlyname"))) {
- xfree (tid->name);
- tid->name = my_strdup (value);
- tid->joystick = joystick;
- tid->devtype = devtype;
- tid->custom = false;
- tid->empty = false;
- tid->disabled = false;
+ if (!_tcscmp (p2, _T("friendlyname")))
+ {
+ xfree (id->name);
+ id->name = my_strdup(value);
return;
}
- if (!_tcscmp (p2, _T("custom"))) {
+
+ if (!_tcscmp (p2, _T("custom")))
+ {
+ int iscustom;
p = value;
- tid->custom = getnum(&p);
- tid->joystick = joystick;
- tid->devtype = devtype;
- tid->empty = false;
- return;
- }
- if (!_tcscmp(p2, _T("empty"))) {
- p = value;
- tid->empty = getnum(&p);
- tid->joystick = joystick;
- tid->devtype = devtype;
- return;
- }
- if (!_tcscmp(p2, _T("disabled"))) {
- p = value;
- tid->disabled = getnum(&p);
- tid->joystick = joystick;
- tid->devtype = devtype;
- return;
- }
-
- bool newdev = false;
- if (temp_uid_index[devnum][tid->devtype] == -1) {
- int newdevnum = -1;
- if (tid->devtype == IDTYPE_KEYBOARD) {
- // keyboard devnum == 0: always select keyboard zero.
- if (devnum == 0) {
- newdevnum = 0;
- tid->disabled = false;
- tid->empty = false;
- } else if (tid->kbreventcnt[0] == 0) {
- write_log(_T("Previous keyboard skipped\n"));
- // if previously found keyboard had no events, next will be tried again
- newdevnum = 0;
- tid->disabled = false;
- tid->empty = false;
- } else {
- newdevnum = matchdevice(idf, tid->configname, tid->name);
- }
- } else {
- // match devices with empty names to first free slot
- if (tid->configname && tid->configname[0] == 0 && tid->name && tid->name[0] == 0) {
- for (int i = 0; i < MAX_INPUT_DEVICES; i++) {
- if (tid->matcheddevices[i] < 0) {
- newdevnum = i;
- break;
- }
- }
- } else {
- newdevnum = matchdevice(idf, tid->configname, tid->name);
- }
- }
- newdev = true;
- if (newdevnum >= 0) {
- temp_uid_index[devnum][tid->devtype] = newdevnum;
- write_log(_T("%d %d: %d -> %d (%s)\n"), idnum, tid->devtype, devnum, temp_uid_index[devnum][tid->devtype], tid->name);
- tid->matcheddevices[devnum] = newdevnum;
- } else {
- newdevnum = idf->get_num() + temp_uid_cnt[tid->devtype];
- if (newdevnum < MAX_INPUT_DEVICES) {
- temp_uid_index[devnum][tid->devtype] = newdevnum;
- temp_uid_cnt[tid->devtype]++;
- if (tid->name)
- write_log(_T("%d %d: %d -> %d (NO MATCH) (%s)\n"), idnum, tid->devtype, devnum, temp_uid_index[devnum][tid->devtype], tid->name);
- if (!tid->disabled && !tid->empty)
- tid->nonmatcheddevices[devnum] = newdevnum;
- } else {
- temp_uid_index[devnum][tid->devtype] = -1;
- }
- }
- }
-
- devnum = temp_uid_index[devnum][tid->devtype];
- if (devnum < 0) {
- if (devnum == -1)
- write_log(_T("%s (%s) not found and no free slots\n"), tid->name, tid->configname);
- temp_uid_index[devnum][tid->devtype] = -2;
- return;
- }
-
- if (tid->devtype == IDTYPE_MOUSE) {
- id = &pr->mouse_settings[idnum][devnum];
- } else if (tid->devtype == IDTYPE_JOYSTICK) {
- id = &pr->joystick_settings[idnum][devnum];
- } else if (tid->devtype == IDTYPE_KEYBOARD) {
- id = &pr->keyboard_settings[idnum][devnum];
- } else {
- return;
- }
-
- if (newdev) {
- if (!tid->initialized)
+ iscustom = getnum(&p);
+ if (idnum == GAMEPORT_INPUT_SETTINGS)
+ {
clear_id(id);
- if (!tid->empty && tid->devtype == IDTYPE_KEYBOARD && !tid->initialized) {
- set_kbr_default(pr, idnum, devnum, keyboard_default);
+ if (joystick < 0)
+ set_kbr_default(pr, idnum, devnum, keyboard_default);
+ id->enabled = iscustom;
}
- tid->initialized = true;
- id->enabled = tid->disabled == 0 ? 1 : 0;
- if (idnum == GAMEPORT_INPUT_SETTINGS) {
+ else
+ {
+ id->enabled = false;
+ }
+ return;
+ }
+
+ if (!_tcscmp (p2, _T("empty")))
+ {
+ int empty;
+ p = value;
+ empty = getnum(&p);
+ clear_id(id);
+ if (!empty)
+ {
+ if (joystick < 0)
+ set_kbr_default(pr, idnum, devnum, keyboard_default);
+ }
+ id->enabled = 1;
+ if (idnum == GAMEPORT_INPUT_SETTINGS)
id->enabled = 0;
- }
- if (tid->custom) {
- id->enabled = 1;
- }
- xfree(tid->configname);
- xfree(tid->name);
- tid->configname = NULL;
- tid->name = NULL;
+ return;
+ }
+
+ if (!_tcscmp (p2, _T("disabled")))
+ {
+ int disabled;
+ p = value;
+ disabled = getnum(&p);
+ id->enabled = disabled == 0 ? 1 : 0;
+ if (idnum == GAMEPORT_INPUT_SETTINGS)
+ id->enabled = 0;
+ return;
}
if (idnum == GAMEPORT_INPUT_SETTINGS && id->enabled == 0)
@@ -1544,88 +1084,153 @@ void read_inputdevice_config (struct uae_prefs *pr, const TCHAR *option, TCHAR *
button = 0;
keynum = 0;
- joystick = tid->joystick;
- if (joystick < 0) {
- num = getnum (&p);
- for (keynum = 0; keynum < MAX_INPUT_DEVICE_EVENTS; keynum++) {
+ if (joystick < 0)
+ {
+ num = getnum(&p);
+ for (keynum = 0; keynum < MAX_INPUT_DEVICE_EVENTS; keynum++)
+ {
if (id->extra[keynum] == num)
break;
}
if (keynum >= MAX_INPUT_DEVICE_EVENTS)
return;
- } else {
+ }
+ else
+ {
button = -1;
if (!_tcscmp (p2, _T("axis")))
button = 0;
- else if(!_tcscmp (p2, _T("button")))
+ else if (!_tcscmp (p2, _T("button")))
button = 1;
if (button < 0)
return;
- num = getnum (&p);
+ num = getnum(&p);
}
p = value;
- bool oldcustommapping = false;
custom = NULL;
- for (subnum = 0; subnum < MAX_INPUT_SUB_EVENT; subnum++) {
+ for (subnum = 0; subnum < MAX_INPUT_SUB_EVENT; subnum++)
+ {
uae_u64 flags;
int port;
xfree (custom);
custom = NULL;
- p2 = getstring (&p);
+ p2 = getstring(&p);
if (!p2)
break;
- ie = readevent (p2, &custom);
+ ie = readevent(p2, &custom);
flags = 0;
port = 0;
if (p[-1] == '.')
- flags = getnum (&p) & ID_FLAG_SAVE_MASK_CONFIG;
- if (p[-1] == '.') {
+ flags = getnum(&p) & ID_FLAG_SAVE_MASK_CONFIG;
+ if (p[-1] == '.')
+ {
if ((p[0] >= 'A' && p[0] <= 'Z') || (p[0] >= 'a' && p[0] <= 'z'))
- flags |= getqual (&p);
+ flags |= getqual(&p);
if (p[-1] == '.')
- port = getnum (&p) + 1;
+ port = getnum(&p) + 1;
}
- if (flags & ID_FLAG_RESERVEDGAMEPORTSCUSTOM)
- oldcustommapping = true;
if (idnum == GAMEPORT_INPUT_SETTINGS && port == 0)
continue;
- if (p[-1] == '.' && idnum != GAMEPORT_INPUT_SETTINGS) {
- p2 = getstring (&p);
- if (p2) {
+ if (p[-1] == '.' && idnum != GAMEPORT_INPUT_SETTINGS)
+ {
+ p2 = getstring(&p);
+ if (p2)
+ {
int flags2 = 0;
if (p[-1] == '.')
- flags2 = getnum (&p) & ID_FLAG_SAVE_MASK_CONFIG;
- if (p[-1] == '.' && ((p[0] >= 'A' && p[0] <= 'Z') || (p[0] >= 'a' && p[0] <= 'z')))
- flags |= getqual (&p);
- TCHAR *custom2 = NULL;
- const struct inputevent *ie2 = readevent (p2, &custom2);
- read_slot (p2, num, joystick, button, id, keynum, SPARE_SUB_EVENT, ie2, flags2, MAX_JPORTS + 1, custom2);
+ flags2 = getnum(&p) & ID_FLAG_SAVE_MASK_CONFIG;
+ if (p[-1] == '.' && (p[0] >= 'A' && p[0] <= 'Z') || (p[0] >= 'a' && p[0] <= 'z'))
+ flags |= getqual(&p);
+ TCHAR* custom2 = NULL;
+ struct inputevent* ie2 = readevent(p2, &custom2);
+ read_slot(p2, num, joystick, button, id, keynum, SPARE_SUB_EVENT, ie2, flags2, MAX_JPORTS + 1, custom2);
}
}
- while (*p != 0) {
+ while (*p != 0)
+ {
if (p[-1] == ',')
break;
p++;
}
- if (!read_slot (p2, num, joystick, button, id, keynum, subnum, ie, flags, port, custom))
+ if (!read_slot(p2, num, joystick, button, id, keynum, subnum, ie, flags, port, custom))
continue;
custom = NULL;
}
- if (joystick < 0 && !oldcustommapping)
- tid->kbreventcnt[devnum]++;
xfree (custom);
}
-static int mousehack_alive_cnt;
+static int mouseedge_alive, mousehack_alive_cnt;
static int lastmx, lastmy;
-static int mouseoffset_x, mouseoffset_y;
+static uaecptr magicmouse_ibase, magicmouse_gfxbase;
+static int dimensioninfo_width, dimensioninfo_height, dimensioninfo_dbl;
+static int vp_xoffset, vp_yoffset, mouseoffset_x, mouseoffset_y;
+static int tablet_maxx, tablet_maxy, tablet_maxz;
+static int tablet_resx, tablet_resy;
+static int tablet_maxax, tablet_maxay, tablet_maxaz;
static int tablet_data;
-STATIC_INLINE int mousehack_alive (void)
+int mousehack_alive(void)
{
- return mousehack_alive_cnt > 0 ? mousehack_alive_cnt : 0;
+ return mousehack_alive_cnt > 0 ? mousehack_alive_cnt : 0;
+}
+
+static uaecptr get_base(const uae_char *name)
+{
+ uaecptr v = get_long(4);
+ addrbank *b = &get_mem_bank(v);
+
+ if (!b || !b->check(v, 400) || b->flags != ABFLAG_RAM)
+ return 0;
+ v += 378; // liblist
+ while ((v = get_long(v))) {
+ uae_u32 v2;
+ uae_u8 *p;
+ b = &get_mem_bank(v);
+ if (!b || !b->check(v, 32) || b->flags != ABFLAG_RAM)
+ goto fail;
+ v2 = get_long(v + 10); // name
+ b = &get_mem_bank(v2);
+ if (!b || !b->check(v2, 20))
+ goto fail;
+ if (b->flags != ABFLAG_ROM && b->flags != ABFLAG_RAM)
+ return 0;
+ p = b->xlateaddr(v2);
+ if (!memcmp(p, name, strlen(name) + 1)) {
+ TCHAR *s = au(name);
+ write_log(_T("get_base('%s')=%08x\n"), s, v);
+ xfree(s);
+ return v;
+ }
+ }
+ return 0;
+fail:
+ {
+ TCHAR *s = au(name);
+ write_log(_T("get_base('%s') failed, invalid library list\n"), s);
+ xfree(s);
+ }
+ return 0xffffffff;
+}
+
+static uaecptr get_intuitionbase(void)
+{
+ if (magicmouse_ibase == 0xffffffff)
+ return 0;
+ if (magicmouse_ibase)
+ return magicmouse_ibase;
+ magicmouse_ibase = get_base("intuition.library");
+ return magicmouse_ibase;
+}
+static uaecptr get_gfxbase(void)
+{
+ if (magicmouse_gfxbase == 0xffffffff)
+ return 0;
+ if (magicmouse_gfxbase)
+ return magicmouse_gfxbase;
+ magicmouse_gfxbase = get_base("graphics.library");
+ return magicmouse_gfxbase;
}
#define MH_E 0
@@ -1653,160 +1258,423 @@ STATIC_INLINE int mousehack_alive (void)
#define MH_END 44
#define MH_START 4
-int inputdevice_is_tablet (void)
+int inputdevice_is_tablet(void)
{
- if (uae_boot_rom_type <= 0)
- return 0;
- if (currprefs.input_tablet == TABLET_OFF)
- return 0;
- if (currprefs.input_tablet == TABLET_MOUSEHACK)
- return -1;
- return 0;
+ int v;
+ if (uae_boot_rom_type <= 0)
+ return 0;
+ if (currprefs.input_tablet == TABLET_OFF)
+ return 0;
+ if (currprefs.input_tablet == TABLET_MOUSEHACK)
+ return -1;
+ v = is_tablet();
+ if (!v)
+ return 0;
+ if (kickstart_version < 37)
+ return v ? -1 : 0;
+ return v ? 1 : 0;
}
-static uae_u8 *mousehack_address;
+static uaecptr mousehack_address;
static bool mousehack_enabled;
-static void mousehack_reset (void)
+static void mousehack_reset(void)
{
- mouseoffset_x = mouseoffset_y = 0;
- mousehack_alive_cnt = 0;
- tablet_data = 0;
- if (rtarea_bank.baseaddr) {
- put_long_host(rtarea_bank.baseaddr + RTAREA_INTXY, 0xffffffff);
- if (mousehack_address)
- put_byte_host(mousehack_address + MH_E, 0);
- }
+ dimensioninfo_width = dimensioninfo_height = 0;
+ mouseoffset_x = mouseoffset_y = 0;
+ dimensioninfo_dbl = 0;
+ mousehack_alive_cnt = 0;
+ vp_xoffset = vp_yoffset = 0;
+ tablet_data = 0;
+ if (mousehack_address)
+ put_byte(mousehack_address + MH_E, 0);
mousehack_address = 0;
mousehack_enabled = false;
}
-static bool mousehack_enable (void)
+static bool mousehack_enable(void)
{
- int mode;
+ int mode;
if (uae_boot_rom_type <= 0 || currprefs.input_tablet == TABLET_OFF)
- return false;
+ return false;
if (mousehack_address && mousehack_enabled)
- return true;
- mode = 0x80;
- if (currprefs.input_tablet == TABLET_MOUSEHACK)
- mode |= 1;
- if (mousehack_address && rtarea_bank.baseaddr) {
- write_log (_T("Mouse driver enabled (%s)\n"), _T("mousehack"));
- put_byte_host(mousehack_address + MH_E, mode);
+ return true;
+ mode = 0x80;
+ if (currprefs.input_tablet == TABLET_MOUSEHACK)
+ mode |= 1;
+ if (inputdevice_is_tablet() > 0)
+ mode |= 2;
+ if (mousehack_address)
+ {
+ write_log (_T("Mouse driver enabled (%s)\n"), ((mode & 3) == 3 ? _T("tablet+mousehack") : ((mode & 3) == 2) ? _T("tablet") : _T("mousehack")));
+ put_byte(mousehack_address + MH_E, mode);
mousehack_enabled = true;
}
return true;
}
-void input_mousehack_mouseoffset (uaecptr pointerprefs)
+static void inputdevice_update_tablet_params(void)
{
- mouseoffset_x = (uae_s16)get_word (pointerprefs + 28);
- mouseoffset_y = (uae_s16)get_word (pointerprefs + 30);
+ uae_u8 *p;
+ if (inputdevice_is_tablet() <= 0 || !mousehack_address)
+ return;
+ p = get_real_address(mousehack_address);
+
+ p[MH_MAXX] = tablet_maxx >> 8;
+ p[MH_MAXX + 1] = tablet_maxx;
+ p[MH_MAXY] = tablet_maxy >> 8;
+ p[MH_MAXY + 1] = tablet_maxy;
+ p[MH_MAXZ] = tablet_maxz >> 8;
+ p[MH_MAXZ + 1] = tablet_maxz;
+
+ p[MH_RESX] = tablet_resx >> 8;
+ p[MH_RESX + 1] = tablet_resx;
+ p[MH_RESY] = tablet_resy >> 8;
+ p[MH_RESY + 1] = tablet_resy;
+
+ p[MH_MAXAX] = tablet_maxax >> 8;
+ p[MH_MAXAX + 1] = tablet_maxax;
+ p[MH_MAXAY] = tablet_maxay >> 8;
+ p[MH_MAXAY + 1] = tablet_maxay;
+ p[MH_MAXAZ] = tablet_maxaz >> 8;
+ p[MH_MAXAZ + 1] = tablet_maxaz;
}
-void mousehack_wakeup(void)
+void input_mousehack_mouseoffset(uaecptr pointerprefs)
{
- if (mousehack_alive_cnt == 0)
- mousehack_alive_cnt = -100;
- else if (mousehack_alive_cnt > 0)
- mousehack_alive_cnt = 100;
- if (uaeboard_bank.baseaddr) {
- uaeboard_bank.baseaddr[0x201] &= ~3;
- }
+ mouseoffset_x = uae_s16(get_word(pointerprefs + 28));
+ mouseoffset_y = uae_s16(get_word(pointerprefs + 30));
}
-int input_mousehack_status(TrapContext *ctx, int mode, uaecptr diminfo, uaecptr dispinfo, uaecptr vp, uae_u32 moffset)
+int input_mousehack_status(int mode, uaecptr diminfo, uaecptr dispinfo, uaecptr vp, uae_u32 moffset)
{
if (mode == 4) {
- return mousehack_enable () ? 1 : 0;
- } else if (mode == 5) {
- mousehack_address = (trap_get_dreg(ctx, 0) & 0xffff) + rtarea_bank.baseaddr;
- mousehack_enable ();
- } else if (mode == 0) {
+ return mousehack_enable() ? 1 : 0;
+ }
+ else if (mode == 5) {
+ mousehack_address = m68k_dreg(regs, 0);
+ mousehack_enable();
+ inputdevice_update_tablet_params();
+ }
+ else if (mode == 0) {
if (mousehack_address) {
- uae_u8 v = get_byte_host(mousehack_address + MH_E);
+ uae_u8 v = get_byte(mousehack_address + MH_E);
v |= 0x40;
- put_byte_host(mousehack_address + MH_E, v);
- write_log (_T("Tablet driver running (%08x,%02x)\n"), mousehack_address, v);
+ put_byte(mousehack_address + MH_E, v);
+ write_log(_T("Tablet driver running (%08x,%02x)\n"), mousehack_address, v);
}
- }
+ }
+ else if (mode == 1) {
+ int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
+ uae_u32 props = 0;
+ dimensioninfo_width = -1;
+ dimensioninfo_height = -1;
+ vp_xoffset = 0;
+ vp_yoffset = 0;
+ if (diminfo) {
+ x1 = get_word(diminfo + 50);
+ y1 = get_word(diminfo + 52);
+ x2 = get_word(diminfo + 54);
+ y2 = get_word(diminfo + 56);
+ dimensioninfo_width = x2 - x1 + 1;
+ dimensioninfo_height = y2 - y1 + 1;
+ }
+ if (vp) {
+ vp_xoffset = get_word(vp + 28);
+ vp_yoffset = get_word(vp + 30);
+ }
+ if (dispinfo)
+ props = get_long(dispinfo + 18);
+ dimensioninfo_dbl = (props & 0x00020000) ? 1 : 0;
+ write_log(_T("%08x %08x %08x (%dx%d)-(%dx%d) d=%dx%d %s\n"),
+ diminfo, props, vp, x1, y1, x2, y2, vp_xoffset, vp_yoffset,
+ (props & 0x00020000) ? _T("dbl") : _T(""));
+ }
+ else if (mode == 2) {
+ if (mousehack_alive_cnt == 0)
+ mousehack_alive_cnt = -100;
+ else if (mousehack_alive_cnt > 0)
+ mousehack_alive_cnt = 100;
+ }
return 1;
}
-void inputdevice_tablet_strobe (void)
+void get_custom_mouse_limits(int *w, int *h, int *dx, int *dy, int dbl);
+
+void inputdevice_tablet_strobe()
{
- mousehack_enable ();
+ mousehack_enable();
if (uae_boot_rom_type <= 0)
- return;
- if (!tablet_data)
- return;
+ return;
+ if (!tablet_data)
+ return;
if (mousehack_address)
- put_byte_host(mousehack_address + MH_CNT, get_byte_host(mousehack_address + MH_CNT) + 1);
+ put_byte(mousehack_address + MH_CNT, get_byte(mousehack_address + MH_CNT) + 1);
}
-static void inputdevice_mh_abs (int x, int y, uae_u32 buttonbits)
+void inputdevice_tablet(int x, int y, int z, int pressure, uae_u32 buttonbits, int inproximity, int ax, int ay, int az)
{
- x -= mouseoffset_x + 1;
- y -= mouseoffset_y + 2;
+ uae_u8 *p;
+ uae_u8 tmp[MH_END];
- mousehack_enable ();
- if (mousehack_address) {
- uae_u8 tmp1[4], tmp2[4];
- uae_u8 *p = mousehack_address;
+ mousehack_enable();
+ if (inputdevice_is_tablet() <= 0 || !mousehack_address)
+ return;
- memcpy (tmp1, p + MH_ABSX, sizeof tmp1);
- memcpy (tmp2, p + MH_BUTTONBITS, sizeof tmp2);
+ p = get_real_address(mousehack_address);
- //write_log (_T("%04dx%04d %08x\n"), x, y, buttonbits);
+ memcpy(tmp, p + MH_START, MH_END - MH_START);
- p[MH_ABSX] = x >> 8;
- p[MH_ABSX + 1] = x;
- p[MH_ABSY] = y >> 8;
- p[MH_ABSY + 1] = y;
+ p[MH_X] = x >> 8;
+ p[MH_X + 1] = x;
+ p[MH_Y] = y >> 8;
+ p[MH_Y + 1] = y;
+ p[MH_Z] = z >> 8;
+ p[MH_Z + 1] = z;
- p[MH_BUTTONBITS + 0] = buttonbits >> 24;
- p[MH_BUTTONBITS + 1] = buttonbits >> 16;
- p[MH_BUTTONBITS + 2] = buttonbits >> 8;
- p[MH_BUTTONBITS + 3] = buttonbits >> 0;
+ p[MH_AX] = ax >> 8;
+ p[MH_AX + 1] = ax;
+ p[MH_AY] = ay >> 8;
+ p[MH_AY + 1] = ay;
+ p[MH_AZ] = az >> 8;
+ p[MH_AZ + 1] = az;
- if (!memcmp (tmp1, p + MH_ABSX, sizeof tmp1) && !memcmp (tmp2, p + MH_BUTTONBITS, sizeof tmp2))
- return;
- p[MH_E] = 0xc0 | 1;
- p[MH_CNT]++;
- tablet_data = 1;
- }
+ p[MH_PRESSURE] = pressure >> 8;
+ p[MH_PRESSURE + 1] = pressure;
+
+ p[MH_BUTTONBITS + 0] = buttonbits >> 24;
+ p[MH_BUTTONBITS + 1] = buttonbits >> 16;
+ p[MH_BUTTONBITS + 2] = buttonbits >> 8;
+ p[MH_BUTTONBITS + 3] = buttonbits >> 0;
+
+ if (inproximity < 0) {
+ p[MH_INPROXIMITY] = p[MH_INPROXIMITY + 1] = 0xff;
+ }
+ else {
+ p[MH_INPROXIMITY] = 0;
+ p[MH_INPROXIMITY + 1] = inproximity ? 1 : 0;
+ }
+
+ if (!memcmp(tmp, p + MH_START, MH_END - MH_START))
+ return;
+
+ /*if (tablet_log & 1) {
+ static int obuttonbits, oinproximity;
+ if (inproximity != oinproximity || buttonbits != obuttonbits) {
+ obuttonbits = buttonbits;
+ oinproximity = inproximity;
+ write_log(_T("TABLET: B=%08x P=%d\n"), buttonbits, inproximity);
+ }
+ }
+ if (tablet_log & 2) {
+ write_log(_T("TABLET: X=%d Y=%d Z=%d AX=%d AY=%d AZ=%d\n"), x, y, z, ax, ay, az);
+ }*/
+
+ p[MH_E] = 0xc0 | 2;
+ p[MH_CNT]++;
}
-static void mousehack_helper (uae_u32 buttonmask)
+void inputdevice_tablet_info(int maxx, int maxy, int maxz, int maxax, int maxay, int maxaz, int xres, int yres)
{
- int x, y;
+ tablet_maxx = maxx;
+ tablet_maxy = maxy;
+ tablet_maxz = maxz;
- if (currprefs.input_tablet < TABLET_MOUSEHACK)
- return;
- x = lastmx;
- y = lastmy;
+ tablet_resx = xres;
+ tablet_resy = yres;
+ tablet_maxax = maxax;
+ tablet_maxay = maxay;
+ tablet_maxaz = maxaz;
+ inputdevice_update_tablet_params();
+}
+
+
+void getgfxoffset(float *dx, float *dy, float*, float*);
+
+static void inputdevice_mh_abs(int x, int y, uae_u32 buttonbits)
+{
+ uae_u8* p;
+ uae_u8 tmp1[4], tmp2[4];
+
+ mousehack_enable();
+ if (!mousehack_address)
+ return;
+ p = get_real_address(mousehack_address);
+
+ memcpy(tmp1, p + MH_ABSX, sizeof tmp1);
+ memcpy(tmp2, p + MH_BUTTONBITS, sizeof tmp2);
+
+ x -= mouseoffset_x + 1;
+ y -= mouseoffset_y + 2;
+
+ p[MH_ABSX] = x >> 8;
+ p[MH_ABSX + 1] = x;
+ p[MH_ABSY] = y >> 8;
+ p[MH_ABSY + 1] = y;
+
+ p[MH_BUTTONBITS + 0] = buttonbits >> 24;
+ p[MH_BUTTONBITS + 1] = buttonbits >> 16;
+ p[MH_BUTTONBITS + 2] = buttonbits >> 8;
+ p[MH_BUTTONBITS + 3] = buttonbits >> 0;
+
+ if (!memcmp(tmp1, p + MH_ABSX, sizeof tmp1) && !memcmp(tmp2, p + MH_BUTTONBITS, sizeof tmp2))
+ return;
+ p[MH_E] = 0xc0 | 1;
+ p[MH_CNT]++;
+ tablet_data = 1;
+}
+
+static void mousehack_helper(uae_u32 buttonmask)
+{
+ int x, y;
+ //float fdy, fdx, fmx, fmy;
+
+ if (!(currprefs.input_mouse_untrap & MOUSEUNTRAP_MAGIC) && currprefs.input_tablet < TABLET_MOUSEHACK)
+ return;
+ x = lastmx;
+ y = lastmy;
+ //getgfxoffset(&fdx, &fdy, &fmx, &fmy);
#ifdef PICASSO96
- if (picasso_on) {
- x -= picasso96_state.XOffset;
- y -= picasso96_state.YOffset;
- } else
+ if (picasso_on)
+ {
+ x -= picasso96_state.XOffset;
+ y -= picasso96_state.YOffset;
+ //x = int(x * fmx);
+ //y = int(y * fmy);
+ //x -= int(fdx * fmx);
+ //y -= int(fdy * fmy);
+ }
+ else
#endif
- {
- x = coord_native_to_amiga_x (x);
- y = coord_native_to_amiga_y (y) << 1;
- }
- inputdevice_mh_abs (x, y, buttonmask);
+ {
+ //x = int(x * fmx);
+ //y = int(y * fmy);
+ //x -= int(fdx * fmx) - 1;
+ //y -= int(fdy * fmy) - 2;
+ //if (x < 0)
+ // x = 0;
+ //if (x >= gfxvidinfo.outbuffer->outwidth)
+ // x = gfxvidinfo.outbuffer->outwidth - 1;
+ //if (y < 0)
+ // y = 0;
+ //if (y >= gfxvidinfo.outbuffer->outheight)
+ // y = gfxvidinfo.outbuffer->outheight - 1;
+ x = coord_native_to_amiga_x(x);
+ y = coord_native_to_amiga_y(y) << 1;
+ }
+ //inputdevice_mh_abs(x, y, buttonmask);
}
-static int getbuttonstate (int joy, int button)
+static int mouseedge_x, mouseedge_y, mouseedge_time;
+#define MOUSEEDGE_RANGE 100
+#define MOUSEEDGE_TIME 2
+
+extern void setmouseactivexy(int, int, int);
+
+//static int mouseedge()
+//{
+// int x, y, dir;
+// uaecptr ib;
+// static int melast_x, melast_y;
+// static int isnonzero;
+//
+// if (currprefs.input_magic_mouse == 0 || currprefs.input_tablet > 0)
+// return 0;
+// if (magicmouse_ibase == 0xffffffff)
+// return 0;
+// dir = 0;
+// if (!mouseedge_time) {
+// isnonzero = 0;
+// goto end;
+// }
+// ib = get_intuitionbase();
+// if (!ib)
+// return 0;
+// if (get_word(ib + 20) < 31) // version < 31
+// return 0;
+// if (get_long(ib + 34 + 0) == 0) // ViewPort == NULL
+// return 0;
+// if (get_long(ib + 60) == 0) // FirstScreen == NULL
+// return 0;
+// x = get_word(ib + 70);
+// y = get_word(ib + 68);
+// if (x || y)
+// isnonzero = 1;
+// if (!isnonzero)
+// return 0;
+// if (melast_x == x) {
+// if (mouseedge_x < -MOUSEEDGE_RANGE) {
+// mouseedge_x = 0;
+// dir |= 1;
+// goto end;
+// }
+// if (mouseedge_x > MOUSEEDGE_RANGE) {
+// mouseedge_x = 0;
+// dir |= 2;
+// goto end;
+// }
+// }
+// else {
+// mouseedge_x = 0;
+// melast_x = x;
+// }
+// if (melast_y == y) {
+// if (mouseedge_y < -MOUSEEDGE_RANGE) {
+// mouseedge_y = 0;
+// dir |= 4;
+// goto end;
+// }
+// if (mouseedge_y > MOUSEEDGE_RANGE) {
+// mouseedge_y = 0;
+// dir |= 8;
+// goto end;
+// }
+// }
+// else {
+// mouseedge_y = 0;
+// melast_y = y;
+// }
+// return 1;
+//
+//end:
+// mouseedge_time = 0;
+// if (dir) {
+// if (!picasso_on) {
+// int aw = 0, ah = 0, dx, dy;
+// get_custom_mouse_limits(&aw, &ah, &dx, &dy, dimensioninfo_dbl);
+// x += dx;
+// y += dy;
+// }
+// if (!dmaen(DMA_SPRITE))
+// setmouseactivexy(x, y, 0);
+// else
+// setmouseactivexy(x, y, dir);
+// }
+// return 1;
+//}
+
+int magicmouse_alive(void)
+{
+ return mouseedge_alive > 0;
+}
+
+STATIC_INLINE int adjust(int val)
+{
+ if (val > 127)
+ return 127;
+ else if (val < -127)
+ return -127;
+ return val;
+}
+
+static int getbuttonstate(int joy, int button)
{
return (joybutton[joy] & (1 << button)) ? 1 : 0;
}
-static int getvelocity (int num, int subnum, int pct)
+static int getvelocity(int num, int subnum, int pct)
{
int val;
int v;
@@ -1815,7 +1683,8 @@ static int getvelocity (int num, int subnum, int pct)
pct = 1000;
val = mouse_delta[num][subnum];
v = val * pct / 1000;
- if (!v) {
+ if (!v)
+ {
if (val < -maxvpos / 2)
v = -2;
else if (val < 0)
@@ -1825,49 +1694,97 @@ static int getvelocity (int num, int subnum, int pct)
else if (val > 0)
v = 1;
}
- if (!mouse_deltanoreset[num][subnum]) {
+ if (!mouse_deltanoreset[num][subnum])
+ {
mouse_delta[num][subnum] -= v;
+ /*gui_gameport_axis_change(num, subnum * 2 + 0, 0, -1);
+ gui_gameport_axis_change(num, subnum * 2 + 1, 0, -1);*/
}
return v;
}
#define MOUSEXY_MAX 16384
-static void mouseupdate (int pct, bool vsync)
+static void mouseupdate(int pct, bool vsync)
{
int v, i;
int max = 120;
+ static int mxd, myd;
- for (i = 0; i < 2; i++) {
+ if (vsync) {
+ if (mxd < 0) {
+ if (mouseedge_x > 0)
+ mouseedge_x = 0;
+ else
+ mouseedge_x += mxd;
+ mouseedge_time = MOUSEEDGE_TIME;
+ }
+ if (mxd > 0) {
+ if (mouseedge_x < 0)
+ mouseedge_x = 0;
+ else
+ mouseedge_x += mxd;
+ mouseedge_time = MOUSEEDGE_TIME;
+ }
+ if (myd < 0) {
+ if (mouseedge_y > 0)
+ mouseedge_y = 0;
+ else
+ mouseedge_y += myd;
+ mouseedge_time = MOUSEEDGE_TIME;
+ }
+ if (myd > 0) {
+ if (mouseedge_y < 0)
+ mouseedge_y = 0;
+ else
+ mouseedge_y += myd;
+ mouseedge_time = MOUSEEDGE_TIME;
+ }
+ if (mouseedge_time > 0) {
+ mouseedge_time--;
+ if (mouseedge_time == 0) {
+ mouseedge_x = 0;
+ mouseedge_y = 0;
+ }
+ }
+ mxd = 0;
+ myd = 0;
+ }
- if (mouse_port[i]) {
-
- v = getvelocity (i, 0, pct);
+ for (i = 0; i < 2; i++)
+ {
+ if (mouse_port[i])
+ {
+ v = getvelocity(i, 0, pct);
+ mxd += v;
mouse_x[i] += v;
- if (mouse_x[i] < 0) {
+ if (mouse_x[i] < 0)
+ {
mouse_x[i] += MOUSEXY_MAX;
mouse_frame_x[i] = mouse_x[i] - v;
}
- if (mouse_x[i] >= MOUSEXY_MAX) {
+ if (mouse_x[i] >= MOUSEXY_MAX)
+ {
mouse_x[i] -= MOUSEXY_MAX;
mouse_frame_x[i] = mouse_x[i] - v;
}
- v = getvelocity (i, 1, pct);
+ v = getvelocity(i, 1, pct);
+ myd += v;
mouse_y[i] += v;
- if (mouse_y[i] < 0) {
+ if (mouse_y[i] < 0)
+ {
mouse_y[i] += MOUSEXY_MAX;
mouse_frame_y[i] = mouse_y[i] - v;
}
- if (mouse_y[i] >= MOUSEXY_MAX) {
+ if (mouse_y[i] >= MOUSEXY_MAX)
+ {
mouse_y[i] -= MOUSEXY_MAX;
mouse_frame_y[i] = mouse_y[i] - v;
}
#ifndef INPUTDEVICE_SIMPLE
v = getvelocity (i, 2, pct);
- /* if v != 0, record mouse wheel key presses
- * according to the NewMouse standard */
if (v > 0)
record_key (0x7a << 1);
else if (v < 0)
@@ -1876,11 +1793,13 @@ static void mouseupdate (int pct, bool vsync)
if (!mouse_deltanoreset[i][2])
mouse_delta[i][2] = 0;
- if (mouse_frame_x[i] - mouse_x[i] > max) {
+ if (mouse_frame_x[i] - mouse_x[i] > max)
+ {
mouse_x[i] = mouse_frame_x[i] - max;
mouse_x[i] &= MOUSEXY_MAX - 1;
}
- if (mouse_frame_x[i] - mouse_x[i] < -max) {
+ if (mouse_frame_x[i] - mouse_x[i] < -max)
+ {
mouse_x[i] = mouse_frame_x[i] + max;
mouse_x[i] &= MOUSEXY_MAX - 1;
}
@@ -1891,35 +1810,38 @@ static void mouseupdate (int pct, bool vsync)
mouse_y[i] = mouse_frame_y[i] + max;
}
- if (!vsync) {
+ if (!vsync)
+ {
mouse_frame_x[i] = mouse_x[i];
mouse_frame_y[i] = mouse_y[i];
}
-
}
}
static int input_vpos, input_frame;
-
-static void readinput (void)
+extern int vpos;
+static void readinput()
{
uae_u32 totalvpos;
int diff;
- totalvpos = input_frame * current_maxvpos () + vpos;
+ totalvpos = input_frame * current_maxvpos() + vpos;
diff = totalvpos - input_vpos;
- if (diff > 0) {
- if (diff < 10) {
- mouseupdate (0, false);
- } else {
- mouseupdate (diff * 1000 / current_maxvpos (), false);
+ if (diff > 0)
+ {
+ if (diff < 10)
+ {
+ mouseupdate(0, false);
+ }
+ else
+ {
+ mouseupdate(diff * 1000 / current_maxvpos(), false);
}
}
input_vpos = totalvpos;
-
}
-static void joymousecounter (int joy)
+static void joymousecounter(int joy)
{
int left = 1, right = 1, top = 1, bot = 1;
int b9, b8, b1, b0;
@@ -1956,56 +1878,45 @@ static void joymousecounter (int joy)
mouse_y[joy] += 4;
mouse_y[joy] = (mouse_y[joy] & 0xfc) | cnty;
- if (!left || !right || !top || !bot) {
+ if (!left || !right || !top || !bot)
+ {
mouse_frame_x[joy] = mouse_x[joy];
mouse_frame_y[joy] = mouse_y[joy];
}
}
-static int inputdelay;
-
-static void inputdevice_read (void)
-{
- do {
- handle_msgpump ();
- idev[IDTYPE_MOUSE].read ();
- idev[IDTYPE_JOYSTICK].read ();
- idev[IDTYPE_KEYBOARD].read ();
- } while (handle_msgpump ());
-}
-
-static uae_u16 getjoystate (int joy)
+static uae_u16 getjoystate(int joy)
{
uae_u16 v;
- v = (uae_u8)mouse_x[joy] | (mouse_y[joy] << 8);
+ v = uae_u8(mouse_x[joy]) | (mouse_y[joy] << 8);
return v;
}
-uae_u16 JOY0DAT (void)
+uae_u16 JOY0DAT()
{
uae_u16 v;
- readinput ();
- v = getjoystate (0);
- return v;
-}
-
-uae_u16 JOY1DAT (void)
-{
- uae_u16 v;
- readinput ();
- v = getjoystate (1);
- return v;
-}
-
-uae_u16 JOYGET (int num)
-{
- uae_u16 v;
- v = getjoystate (num);
+ readinput();
+ v = getjoystate(0);
return v;
}
-void JOYSET (int num, uae_u16 dat)
+uae_u16 JOY1DAT()
+{
+ uae_u16 v;
+ readinput();
+ v = getjoystate(1);
+ return v;
+}
+
+uae_u16 JOYGET(int num)
+{
+ uae_u16 v;
+ v = getjoystate(num);
+ return v;
+}
+
+void JOYSET(int num, uae_u16 dat)
{
mouse_x[num] = dat & 0xff;
mouse_y[num] = (dat >> 8) & 0xff;
@@ -2013,7 +1924,7 @@ void JOYSET (int num, uae_u16 dat)
mouse_frame_y[num] = mouse_y[num];
}
-void JOYTEST (uae_u16 v)
+void JOYTEST(uae_u16 v)
{
mouse_x[0] &= 3;
mouse_y[0] &= 3;
@@ -2029,7 +1940,7 @@ void JOYTEST (uae_u16 v)
mouse_frame_y[1] = mouse_y[1];
}
-#if !defined(INPUTDEVICE_SIMPLE) || defined(AMIBERRY)
+#ifndef INPUTDEVICE_SIMPLE
static uae_u8 parconvert (uae_u8 v, int jd, int shift)
{
if (jd & DIR_UP)
@@ -2074,7 +1985,7 @@ uae_u8 handle_parport_joystick (int port, uae_u8 pra, uae_u8 dra)
#endif
/* p5 is 1 or floating = cd32 2-button mode */
-static bool cd32padmode (uae_u16 p5dir, uae_u16 p5dat)
+static bool cd32padmode(uae_u16 p5dir, uae_u16 p5dat)
{
if (!(potgo_value & p5dir) || ((potgo_value & p5dat) && (potgo_value & p5dir)))
return false;
@@ -2086,6 +1997,10 @@ static bool is_joystick_pullup (int joy)
{
return joymodes[joy] == JSEM_MODE_GAMEPAD;
}
+static bool is_mouse_pullup(int joy)
+{
+ return mouse_pullup;
+}
static void charge_cap (int joy, int idx, int charge)
{
@@ -2099,28 +2014,31 @@ static void charge_cap (int joy, int idx, int charge)
}
#endif
-static void cap_check (void)
+static void cap_check()
{
int joy, i;
- for (joy = 0; joy < 2; joy++) {
- for (i = 0; i < 2; i++) {
+ for (joy = 0; joy < 2; joy++)
+ {
+ for (i = 0; i < 2; i++)
+ {
#ifndef INPUTDEVICE_SIMPLE
- int charge = 0, joypot;
+ int charge = 0, dong, joypot;
#endif
uae_u16 pdir = 0x0200 << (joy * 4 + i * 2); /* output enable */
uae_u16 pdat = 0x0100 << (joy * 4 + i * 2); /* data */
uae_u16 p5dir = 0x0200 << (joy * 4);
uae_u16 p5dat = 0x0100 << (joy * 4);
- int isbutton = getbuttonstate (joy, i == 0 ? JOYBUTTON_3 : JOYBUTTON_2);
+ int isbutton = getbuttonstate(joy, i == 0 ? JOYBUTTON_3 : JOYBUTTON_2);
- if (cd32_pad_enabled[joy]) {
+ if (cd32_pad_enabled[joy])
+ {
// only red and blue can be read if CD32 pad and only if it is in normal pad mode
- isbutton |= getbuttonstate (joy, JOYBUTTON_CD32_BLUE);
+ isbutton |= getbuttonstate(joy, JOYBUTTON_CD32_BLUE);
// CD32 pad 3rd button line (P5) is always floating
if (i == 0)
isbutton = 0;
- if (cd32padmode (p5dir, p5dat))
+ if (cd32padmode(p5dir, p5dat))
continue;
}
@@ -2131,16 +2049,21 @@ static void cap_check (void)
if ((is_joystick_pullup (joy) && digital_port[joy][i]) || (mouse_port[joy]))
charge = 1; // slow charge via pull-up resistor
#endif
- if (!(potgo_value & pdir)) { // input?
+ if (!(potgo_value & pdir))
+ { // input?
if (pot_dat_act[joy][i])
pot_dat[joy][i]++;
/* first 7 or 8 lines after potgo has been started = discharge cap */
- if (pot_dat_act[joy][i] == 1) {
- if (pot_dat[joy][i] < (currprefs.ntscmode ? POTDAT_DELAY_NTSC : POTDAT_DELAY_PAL)) {
+ if (pot_dat_act[joy][i] == 1)
+ {
+ if (pot_dat[joy][i] < (currprefs.ntscmode ? POTDAT_DELAY_NTSC : POTDAT_DELAY_PAL))
+ {
#ifndef INPUTDEVICE_SIMPLE
charge = -2; /* fast discharge delay */
#endif
- } else {
+ }
+ else
+ {
pot_dat_act[joy][i] = 2;
pot_dat[joy][i] = 0;
}
@@ -2149,7 +2072,8 @@ static void cap_check (void)
if (analog_port[joy][i] && pot_dat_act[joy][i] == 2 && pot_cap[joy][i] >= joypot)
pot_dat_act[joy][i] = 0;
#endif
- if ((digital_port[joy][i] || mouse_port[joy]) && pot_dat_act[joy][i] == 2) {
+ if ((digital_port[joy][i] || mouse_port[joy]) && pot_dat_act[joy][i] == 2)
+ {
#ifdef INPUTDEVICE_SIMPLE
if (!isbutton)
#else
@@ -2157,7 +2081,9 @@ static void cap_check (void)
#endif
pot_dat_act[joy][i] = 0;
}
- } else { // output?
+ }
+ else
+ { // output?
#ifndef INPUTDEVICE_SIMPLE
charge = (potgo_value & pdat) ? 2 : -2; /* fast (dis)charge if output */
#endif
@@ -2192,47 +2118,57 @@ static void cap_check (void)
}
}
-uae_u8 handle_joystick_buttons (uae_u8 pra, uae_u8 dra)
+uae_u8 handle_joystick_buttons(uae_u8 pra, uae_u8 dra)
{
- uae_u8 but = 0;
+ uae_u8 but = 0;
int i;
- cap_check ();
+ cap_check();
for (i = 0; i < 2; i++) {
int mask = 0x40 << i;
if (cd32_pad_enabled[i]) {
uae_u16 p5dir = 0x0200 << (i * 4);
uae_u16 p5dat = 0x0100 << (i * 4);
but |= mask;
- if (!cd32padmode (p5dir, p5dat)) {
- if (getbuttonstate (i, JOYBUTTON_CD32_RED) || getbuttonstate (i, JOYBUTTON_1))
+ if (!cd32padmode(p5dir, p5dat)) {
+ if (getbuttonstate(i, JOYBUTTON_CD32_RED) || getbuttonstate(i, JOYBUTTON_1))
but &= ~mask;
}
- } else {
- if (!getbuttonstate (i, JOYBUTTON_1))
+ }
+ else {
+ if (!getbuttonstate(i, JOYBUTTON_1))
but |= mask;
+ //if (bouncy && cycles_in_range(bouncy_cycles)) {
+ // but &= ~mask;
+ // if (uaerand() & 1)
+ // but |= mask;
+ //}
if (dra & mask)
but = (but & ~mask) | (pra & mask);
}
}
- return but;
+ return but;
}
/* joystick 1 button 1 is used as a output for incrementing shift register */
-void handle_cd32_joystick_cia (uae_u8 pra, uae_u8 dra)
+void handle_cd32_joystick_cia(uae_u8 pra, uae_u8 dra)
{
static int oldstate[2];
int i;
- cap_check ();
- for (i = 0; i < 2; i++) {
+ cap_check();
+ for (i = 0; i < 2; i++)
+ {
uae_u8 but = 0x40 << i;
uae_u16 p5dir = 0x0200 << (i * 4); /* output enable P5 */
uae_u16 p5dat = 0x0100 << (i * 4); /* data P5 */
- if (cd32padmode (p5dir, p5dat)) {
- if ((dra & but) && (pra & but) != oldstate[i]) {
- if (!(pra & but)) {
+ if (cd32padmode(p5dir, p5dat))
+ {
+ if ((dra & but) && (pra & but) != oldstate[i])
+ {
+ if (!(pra & but))
+ {
cd32_shifter[i]--;
if (cd32_shifter[i] < 0)
cd32_shifter[i] = 0;
@@ -2244,19 +2180,20 @@ void handle_cd32_joystick_cia (uae_u8 pra, uae_u8 dra)
}
/* joystick port 1 button 2 is input for button state */
-static uae_u16 handle_joystick_potgor (uae_u16 potgor)
+static uae_u16 handle_joystick_potgor(uae_u16 potgor)
{
int i;
- cap_check ();
- for (i = 0; i < 2; i++) {
+ cap_check();
+ for (i = 0; i < 2; i++)
+ {
uae_u16 p9dir = 0x0800 << (i * 4); /* output enable P9 */
uae_u16 p9dat = 0x0400 << (i * 4); /* data P9 */
uae_u16 p5dir = 0x0200 << (i * 4); /* output enable P5 */
uae_u16 p5dat = 0x0100 << (i * 4); /* data P5 */
- if (cd32_pad_enabled[i] && cd32padmode (p5dir, p5dat)) {
-
+ if (cd32_pad_enabled[i] && cd32padmode(p5dir, p5dat))
+ {
/* p5 is floating in input-mode */
potgor &= ~p5dat;
potgor |= potgo_value & p5dat;
@@ -2270,9 +2207,9 @@ static uae_u16 handle_joystick_potgor (uae_u16 potgor)
potgor &= ~p9dat; /* shift at zero == return zero */
if (cd32_shifter[i] >= 2 && (joybutton[i] & ((1 << JOYBUTTON_CD32_PLAY) << (cd32_shifter[i] - 2))))
potgor &= ~p9dat;
-
- } else {
-
+ }
+ else
+ {
potgor &= ~p5dat;
#ifdef INPUTDEVICE_SIMPLE
if (getbuttonstate(i, JOYBUTTON_3) == 0)
@@ -2281,98 +2218,133 @@ static uae_u16 handle_joystick_potgor (uae_u16 potgor)
#endif
potgor |= p5dat;
- if (!cd32_pad_enabled[i] || !cd32padmode (p5dir, p5dat)) {
+ if (!cd32_pad_enabled[i] || !cd32padmode(p5dir, p5dat))
+ {
potgor &= ~p9dat;
#ifdef INPUTDEVICE_SIMPLE
- if(getbuttonstate(i, JOYBUTTON_2) == 0)
+ if (getbuttonstate(i, JOYBUTTON_2) == 0)
#else
if (pot_cap[i][1] > 100)
#endif
- potgor |= p9dat;
+ potgor |= p9dat;
}
-
}
}
return potgor;
}
-static void inject_events (const TCHAR *str)
+static int inputdelay;
+
+void inputdevice_read()
+{
+ do
+ {
+ handle_msgpump();
+ idev[IDTYPE_MOUSE].read();
+ idev[IDTYPE_JOYSTICK].read();
+ idev[IDTYPE_KEYBOARD].read();
+ }
+ while (handle_msgpump());
+}
+
+static void inject_events(const TCHAR* str)
{
bool quot = false;
bool first = true;
uae_u8 keys[300];
int keycnt = 0;
- for (;;) {
+ for (;;)
+ {
TCHAR ch = *str++;
if (!ch)
break;
- if (ch == '\'') {
+ if (ch == '\'')
+ {
first = false;
quot = !quot;
continue;
}
- if (!quot && (ch == ' ' || first)) {
- const TCHAR *s = str;
+ if (!quot && (ch == ' ' || first))
+ {
+ const TCHAR* s = str;
if (first)
s--;
while (*s == ' ')
s++;
- const TCHAR *s2 = s;
+ const TCHAR* s2 = s;
while (*s && *s != ' ')
s++;
int s2len = s - s2;
if (!s2len)
break;
- for (int i = 1; events[i].name; i++) {
- const TCHAR *cf = events[i].confname;
+ for (int i = 1; events[i].name; i++)
+ {
+ const TCHAR* cf = events[i].confname;
if (!_tcsnicmp (cf, _T("KEY_"), 4))
cf += 4;
- if (events[i].allow_mask == AM_K && !_tcsnicmp (cf, s2, _tcslen (cf)) && s2len == _tcslen (cf)) {
+ if (events[i].allow_mask == AM_K && !_tcsnicmp (cf, s2, _tcslen (cf)) && s2len == _tcslen (cf))
+ {
int j;
uae_u8 kc = events[i].data << 1;
TCHAR tch = _totupper (s2[0]);
- if (tch != s2[0]) {
+ if (tch != s2[0])
+ {
// release
- for (j = 0; j < keycnt; j++) {
+ for (j = 0; j < keycnt; j++)
+ {
if (keys[j] == kc)
keys[j] = 0xff;
}
kc |= 0x01;
- } else {
- for (j = 0; j < keycnt; j++) {
- if (keys[j] == kc) {
+ }
+ else
+ {
+ for (j = 0; j < keycnt; j++)
+ {
+ if (keys[j] == kc)
+ {
kc = 0xff;
}
}
- if (kc != 0xff) {
- for (j = 0; j < keycnt; j++) {
- if (keys[j] == 0xff) {
+ if (kc != 0xff)
+ {
+ for (j = 0; j < keycnt; j++)
+ {
+ if (keys[j] == 0xff)
+ {
keys[j] = kc;
break;
}
}
- if (j == keycnt) {
+ if (j == keycnt)
+ {
if (keycnt < sizeof keys)
keys[keycnt++] = kc;
}
}
}
- if (kc != 0xff) {
+ if (kc != 0xff)
+ {
//write_log (_T("%s\n"), cf);
- record_key (kc);
+ record_key(kc);
}
}
}
- } else if (quot) {
+ }
+ else if (quot)
+ {
ch = _totupper (ch);
- if ((ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9')) {
- for (int i = 1; events[i].name; i++) {
- if (events[i].allow_mask == AM_K && events[i].name[1] == 0 && events[i].name[0] == ch) {
- record_key (events[i].data << 1);
- record_key ((events[i].data << 1) | 0x01);
+ if ((ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))
+ {
+ for (int i = 1; events[i].name; i++)
+ {
+ if (events[i].allow_mask == AM_K && events[i].name[1] == 0 && events[i].name[0] == ch)
+ {
+ record_key(events[i].data << 1);
+ record_key((events[i].data << 1) | 0x01);
//write_log (_T("%c\n"), ch);
}
}
@@ -2380,56 +2352,156 @@ static void inject_events (const TCHAR *str)
}
first = false;
}
- while (--keycnt >= 0) {
+ while (--keycnt >= 0)
+ {
uae_u8 kc = keys[keycnt];
if (kc != 0xff)
- record_key (kc | 0x01);
+ record_key(kc | 0x01);
}
}
-void inputdevice_hsync (void)
+#ifndef INPUTDEVICE_SIMPLE
+struct delayed_event
+{
+ TCHAR *event_string;
+ int delay;
+ struct delayed_event *next;
+};
+static struct delayed_event *delayed_events;
+
+static int handle_custom_event (const TCHAR *custom)
+{
+ TCHAR *p, *buf, *nextp;
+ bool noquot = false;
+
+ if (custom == NULL)
+ return 0;
+ write_log (_T("%s\n"), custom);
+ p = buf = my_strdup_trim (custom);
+ if (p[0] != '\"')
+ noquot = true;
+ while (p && *p) {
+ TCHAR *p2;
+ if (!noquot) {
+ if (*p != '\"')
+ break;
+ p++;
+ p2 = p;
+ while (*p2 != '\"' && *p2 != 0)
+ p2++;
+ if (*p2 == '\"') {
+ *p2++ = 0;
+ nextp = p2 + 1;
+ while (*nextp == ' ')
+ nextp++;
+ }
+ }
+//write_log (L"-> '%s'\n", p);
+ if (!_tcsnicmp (p, _T("delay "), 6)) {
+ int delay = _tstol (p + 6);
+ if (delay >= 0) {
+ struct delayed_event *de = delayed_events;
+ while (de) {
+ if (de->delay < 0) {
+ de->delay = delay;
+ de->event_string = my_strdup (p2);
+ break;
+ }
+ de = de->next;
+ }
+ if (!de) {
+ de = xcalloc (delayed_event, 1);
+ de->next = delayed_events;
+ delayed_events = de;
+ de->delay = delay;
+ de->event_string = my_strdup (p2);
+ }
+ }
+ break;
+ } else if (!_tcsnicmp (p, _T("dbg "), 4)) {
+ debug_parser (p + 4, NULL, -1);
+ } else if (!_tcsnicmp (p, _T("kbr "), 4)) {
+ inject_events (p + 4);
+ } else if (!_tcsnicmp (p, _T("evt "), 4)) {
+ TCHAR *pp = _tcschr (p + 4, ' ');
+ p += 4;
+ if (pp)
+ *pp++ = 0;
+ inputdevice_uaelib (p, pp);
+ } else {
+ cfgfile_parse_line (&changed_prefs, p, 0);
+ }
+ if (noquot)
+ break;
+ p = nextp;
+ }
+ xfree (buf);
+ return 0;
+}
+#endif
+
+void inputdevice_hsync()
{
static int cnt;
- cap_check ();
+ cap_check();
- for (int i = 0; i < INPUT_QUEUE_SIZE; i++) {
- struct input_queue_struct *iq = &input_queue[i];
- if (iq->linecnt > 0) {
+#ifdef CATWEASEL
+ catweasel_hsync();
+#endif
+
+ for (int i = 0; i < INPUT_QUEUE_SIZE; i++)
+ {
+ struct input_queue_struct* iq = &input_queue[i];
+ if (iq->linecnt > 0)
+ {
iq->linecnt--;
- if (iq->linecnt == 0) {
+ if (iq->linecnt == 0)
+ {
if (iq->state)
iq->state = 0;
else
iq->state = iq->storedstate;
+#ifndef INPUTDEVICE_SIMPLE
+ if (iq->custom)
+ handle_custom_event (iq->custom);
+#endif
if (iq->evt)
- handle_input_event (iq->evt, iq->state, iq->max, 0);
+#ifdef INPUTDEVICE_SIMPLE
+ handle_input_event(iq->evt, iq->state, iq->max, 0);
+#else
+ handle_input_event (iq->evt, iq->state, iq->max, 0, false, true);
+#endif
iq->linecnt = iq->nextlinecnt;
}
}
}
- if ((++cnt & 63) == 63 ) {
- inputdevice_read ();
- } else if (inputdelay > 0) {
+ if ((++cnt & 63) == 63)
+ {
+ inputdevice_read();
+ }
+ else if (inputdelay > 0)
+ {
inputdelay--;
if (inputdelay == 0)
- inputdevice_read ();
+ inputdevice_read();
}
}
-static uae_u16 POTDAT (int joy)
+static uae_u16 POTDAT(int joy)
{
uae_u16 v = (pot_dat[joy][1] << 8) | pot_dat[joy][0];
return v;
}
-uae_u16 POT0DAT (void)
+uae_u16 POT0DAT()
{
- return POTDAT (0);
+ return POTDAT(0);
}
-uae_u16 POT1DAT (void)
+
+uae_u16 POT1DAT()
{
- return POTDAT (1);
+ return POTDAT(1);
}
/* direction=input, data pin floating, last connected logic level or previous status
@@ -2439,31 +2511,38 @@ uae_u16 POT1DAT (void)
* it takes some tens of microseconds before data pin changes state
*/
-void POTGO (uae_u16 v)
+void POTGO(uae_u16 v)
{
- int i, j;
+ int i, j;
potgo_value = potgo_value & 0x5500; /* keep state of data bits */
potgo_value |= v & 0xaa00; /* get new direction bits */
- for (i = 0; i < 8; i += 2) {
+ for (i = 0; i < 8; i += 2)
+ {
uae_u16 dir = 0x0200 << i;
- if (v & dir) {
+ if (v & dir)
+ {
uae_u16 data = 0x0100 << i;
potgo_value &= ~data;
potgo_value |= v & data;
}
}
- for (i = 0; i < 2; i++) {
- if (cd32_pad_enabled[i]) {
+ for (i = 0; i < 2; i++)
+ {
+ if (cd32_pad_enabled[i])
+ {
uae_u16 p5dir = 0x0200 << (i * 4); /* output enable P5 */
uae_u16 p5dat = 0x0100 << (i * 4); /* data P5 */
if (!(potgo_value & p5dir) || ((potgo_value & p5dat) && (potgo_value & p5dir)))
cd32_shifter[i] = 8;
}
}
- if (v & 1) {
- for (i = 0; i < 2; i++) {
- for (j = 0; j < 2; j++) {
+ if (v & 1)
+ {
+ for (i = 0; i < 2; i++)
+ {
+ for (j = 0; j < 2; j++)
+ {
pot_dat_act[i][j] = 1;
pot_dat[i][j] = 0;
}
@@ -2471,19 +2550,20 @@ void POTGO (uae_u16 v)
}
}
-uae_u16 POTGOR (void)
+uae_u16 POTGOR()
{
uae_u16 v;
- v = handle_joystick_potgor (potgo_value) & 0x5500;
- return v;
+ v = handle_joystick_potgor(potgo_value) & 0x5500;
+ return v;
}
-static int check_input_queue (int evt)
+static int check_input_queue(int evt)
{
- struct input_queue_struct *iq;
+ struct input_queue_struct* iq;
int i;
- for (i = 0; i < INPUT_QUEUE_SIZE; i++) {
+ for (i = 0; i < INPUT_QUEUE_SIZE; i++)
+ {
iq = &input_queue[i];
if (iq->evt == evt && iq->linecnt >= 0)
return i;
@@ -2491,38 +2571,65 @@ static int check_input_queue (int evt)
return -1;
}
-static void queue_input_event (int evt, int state, int max, int linecnt)
+#ifdef INPUTDEVICE_SIMPLE
+static void queue_input_event(int evt, int state, int max, int linecnt)
+#else
+static void queue_input_event (int evt, const TCHAR *custom, int state, int max, int linecnt, int autofire)
+#endif
{
- struct input_queue_struct *iq;
+ struct input_queue_struct* iq;
int idx;
if (!evt)
return;
- idx = check_input_queue (evt);
- if (state < 0 && idx >= 0) {
+ idx = check_input_queue(evt);
+ if (state < 0 && idx >= 0)
+ {
iq = &input_queue[idx];
iq->nextlinecnt = -1;
iq->linecnt = -1;
iq->evt = 0;
if (iq->state == 0 && evt > 0)
- handle_input_event (evt, 0, 1, 0);
- } else if (state >= 0 && idx < 0) {
+#ifdef INPUTDEVICE_SIMPLE
+ handle_input_event(evt, 0, 1, 0);
+#else
+ handle_input_event (evt, 0, 1, 0, false, false);
+#endif
+ }
+ else if (state >= 0 && idx < 0)
+ {
+#ifdef INPUTDEVICE_SIMPLE
if (evt == 0)
+#else
+ if (evt == 0 && custom == NULL)
+#endif
return;
- for (idx = 0; idx < INPUT_QUEUE_SIZE; idx++) {
+ for (idx = 0; idx < INPUT_QUEUE_SIZE; idx++)
+ {
iq = &input_queue[idx];
if (iq->linecnt < 0)
break;
}
- if (idx == INPUT_QUEUE_SIZE) {
+ if (idx == INPUT_QUEUE_SIZE)
+ {
write_log (_T("input queue overflow\n"));
return;
}
+#ifndef INPUTDEVICE_SIMPLE
+ xfree (iq->custom);
+ iq->custom = NULL;
+ if (custom)
+ iq->custom = my_strdup (custom);
+#endif
iq->evt = evt;
iq->state = iq->storedstate = state;
iq->max = max;
iq->linecnt = linecnt < 0 ? maxvpos + maxvpos / 2 : linecnt;
+#ifdef INPUTDEVICE_SIMPLE
iq->nextlinecnt = linecnt;
+#else
+ iq->nextlinecnt = autofire > 0 ? linecnt : -1;
+#endif
}
}
@@ -2530,189 +2637,396 @@ static uae_u8 keybuf[256];
#define MAX_PENDING_EVENTS 20
static int inputcode_pending[MAX_PENDING_EVENTS], inputcode_pending_state[MAX_PENDING_EVENTS];
-void inputdevice_add_inputcode (int code, int state)
+void inputdevice_release_all_keys(void)
{
- for (int i = 0; i < MAX_PENDING_EVENTS; i++) {
+ int i;
+
+ for (i = 0; i < 0x80; i++) {
+ if (keybuf[i] != 0) {
+ keybuf[i] = 0;
+ record_key(i << 1 | 1);
+ }
+ }
+}
+
+void inputdevice_add_inputcode(int code, int state)
+{
+ for (int i = 0; i < MAX_PENDING_EVENTS; i++)
+ {
if (inputcode_pending[i] == code && inputcode_pending_state[i] == state)
return;
}
- for (int i = 0; i < MAX_PENDING_EVENTS; i++) {
- if (inputcode_pending[i] == 0) {
- inputcode_pending[i] = code;
- inputcode_pending_state[i] = state;
+ for (int i = 0; i < MAX_PENDING_EVENTS; i++)
+ {
+ if (inputcode_pending[i] == 0)
+ {
+ inputcode_pending[i] = code;
+ inputcode_pending_state[i] = state;
return;
}
}
}
-void inputdevice_do_keyboard (int code, int state)
+void inputdevice_do_keyboard(int code, int state)
{
- if (code < 0x80) {
+#ifdef CDTV
+ if (code >= 0x72 && code <= 0x77) { // CDTV keys
+ if (cdtv_front_panel(-1)) {
+ // front panel active
+ if (!state)
+ return;
+ cdtv_front_panel(code - 0x72);
+ return;
+ }
+ }
+#endif
+ if (code < 0x80)
+ {
uae_u8 key = code | (state ? 0x00 : 0x80);
keybuf[key & 0x7f] = (key & 0x80) ? 0 : 1;
- if (record_key ((uae_u8)((key << 1) | (key >> 7)))) {
+
+ if (record_key(uae_u8((key << 1) | (key >> 7))))
+ {
}
return;
}
- inputdevice_add_inputcode (code, state);
+ inputdevice_add_inputcode(code, state);
}
-
-int find_in_array(const int arr[], int n, int key)
+// these need cpu trace data
+static bool needcputrace(int code)
{
- int index = -1;
-
- for(int i=0; i= num_elements ) { i =0 ;}
- changed_prefs.input_joymouse_multiplier = mousespeed_values[i];
- inputdevice_updateconfig (&changed_prefs, &currprefs);
-
- break;
- }
-end:
+ case AKS_STATECAPTURE:
+ case AKS_STATESAVEQUICK:
+ case AKS_STATESAVEQUICK1:
+ case AKS_STATESAVEQUICK2:
+ case AKS_STATESAVEQUICK3:
+ case AKS_STATESAVEQUICK4:
+ case AKS_STATESAVEQUICK5:
+ case AKS_STATESAVEQUICK6:
+ case AKS_STATESAVEQUICK7:
+ case AKS_STATESAVEQUICK8:
+ case AKS_STATESAVEQUICK9:
+ case AKS_STATESAVEDIALOG:
+ return true;
+ }
return false;
}
+static bool inputdevice_handle_inputcode2(int code, int state)
+{
+ static int swapperslot;
+ static int tracer_enable;
+ int newstate;
+ if (code == 0)
+ return false;
+ //if (needcputrace(code) && can_cpu_tracer() == true && is_cpu_tracer() == false && !input_play && !input_record && !debugging) {
+ // if (set_cpu_tracer(true)) {
+ // tracer_enable = 1;
+ // return true; // wait for next frame
+ // }
+ //}
+ if (state == SET_ONOFF_ON_VALUE)
+ newstate = 1;
+ else if (state == SET_ONOFF_OFF_VALUE)
+ newstate = 0;
+ else if (state)
+ newstate = -1;
+ else
+ newstate = 0;
-void inputdevice_handle_inputcode (void)
+#ifdef ARCADIA
+ switch (code)
+ {
+ case AKS_ARCADIADIAGNOSTICS:
+ arcadia_flag &= ~1;
+ arcadia_flag |= state ? 1 : 0;
+ break;
+ case AKS_ARCADIAPLY1:
+ arcadia_flag &= ~4;
+ arcadia_flag |= state ? 4 : 0;
+ break;
+ case AKS_ARCADIAPLY2:
+ arcadia_flag &= ~2;
+ arcadia_flag |= state ? 2 : 0;
+ break;
+ case AKS_ARCADIACOIN1:
+ if (state)
+ arcadia_coin[0]++;
+ break;
+ case AKS_ARCADIACOIN2:
+ if (state)
+ arcadia_coin[1]++;
+ break;
+ }
+#endif
+
+ if (!state)
+ return false;
+ switch (code)
+ {
+ case AKS_ENTERGUI:
+ gui_display(-1);
+ setsystime();
+ break;
+ case AKS_SCREENSHOT_FILE:
+ //screenshot(1, 1);
+ break;
+ case AKS_SCREENSHOT_CLIPBOARD:
+ //screenshot(0, 1);
+ break;
+#ifdef AVIOUTPUT
+ case AKS_VIDEORECORD:
+ AVIOutput_Toggle(newstate, true);
+ break;
+#endif
+#ifdef ACTION_REPLAY
+ case AKS_FREEZEBUTTON:
+ action_replay_freeze();
+ break;
+#endif
+ case AKS_FLOPPY0:
+ gui_display(0);
+ setsystime();
+ break;
+ case AKS_FLOPPY1:
+ gui_display(1);
+ setsystime();
+ break;
+ case AKS_FLOPPY2:
+ gui_display(2);
+ setsystime();
+ break;
+ case AKS_FLOPPY3:
+ gui_display(3);
+ setsystime();
+ break;
+ case AKS_EFLOPPY0:
+ disk_eject(0);
+ break;
+ case AKS_EFLOPPY1:
+ disk_eject(1);
+ break;
+ case AKS_EFLOPPY2:
+ disk_eject(2);
+ break;
+ case AKS_EFLOPPY3:
+ disk_eject(3);
+ break;
+ case AKS_PAUSE:
+ //pausemode(newstate);
+ break;
+ case AKS_WARP:
+ //warpmode(newstate);
+ break;
+ case AKS_INHIBITSCREEN:
+ toggle_inhibit_frame(IHF_SCROLLLOCK);
+ break;
+ case AKS_STATEREWIND:
+ //savestate_dorewind(-2);
+ break;
+ case AKS_STATECURRENT:
+ //savestate_dorewind(-1);
+ break;
+ case AKS_STATECAPTURE:
+ //savestate_capture(1);
+ break;
+ case AKS_VOLDOWN:
+ sound_volume(newstate <= 0 ? -1 : 1);
+ break;
+ case AKS_VOLUP:
+ sound_volume(newstate <= 0 ? 1 : -1);
+ break;
+ case AKS_VOLMUTE:
+ //sound_mute(newstate);
+ break;
+ case AKS_MVOLDOWN:
+ //master_sound_volume(newstate <= 0 ? -1 : 1);
+ break;
+ case AKS_MVOLUP:
+ //master_sound_volume(newstate <= 0 ? 1 : -1);
+ break;
+ case AKS_MVOLMUTE:
+ //master_sound_volume(0);
+ break;
+ case AKS_QUIT:
+ uae_quit();
+ break;
+ case AKS_SOFTRESET:
+ uae_reset(0, 0);
+ break;
+ case AKS_HARDRESET:
+ uae_reset(1, 1);
+ break;
+ case AKS_STATESAVEQUICK:
+ case AKS_STATESAVEQUICK1:
+ case AKS_STATESAVEQUICK2:
+ case AKS_STATESAVEQUICK3:
+ case AKS_STATESAVEQUICK4:
+ case AKS_STATESAVEQUICK5:
+ case AKS_STATESAVEQUICK6:
+ case AKS_STATESAVEQUICK7:
+ case AKS_STATESAVEQUICK8:
+ case AKS_STATESAVEQUICK9:
+ //savestate_quick((code - AKS_STATESAVEQUICK) / 2, 1);
+ break;
+ case AKS_STATERESTOREQUICK:
+ case AKS_STATERESTOREQUICK1:
+ case AKS_STATERESTOREQUICK2:
+ case AKS_STATERESTOREQUICK3:
+ case AKS_STATERESTOREQUICK4:
+ case AKS_STATERESTOREQUICK5:
+ case AKS_STATERESTOREQUICK6:
+ case AKS_STATERESTOREQUICK7:
+ case AKS_STATERESTOREQUICK8:
+ case AKS_STATERESTOREQUICK9:
+ //savestate_quick((code - AKS_STATERESTOREQUICK) / 2, 0);
+ break;
+ case AKS_SWITCHINTERPOL:
+ changed_prefs.sound_interpol++;
+ if (changed_prefs.sound_interpol > 4)
+ changed_prefs.sound_interpol = 0;
+ set_config_changed();
+ break;
+ case AKS_STATESAVEDIALOG:
+ gui_display(5);
+ break;
+ case AKS_STATERESTOREDIALOG:
+ gui_display(4);
+ break;
+ case AKS_DISKSWAPPER_NEXT:
+ swapperslot++;
+ if (swapperslot >= MAX_SPARE_DRIVES || currprefs.dfxlist[swapperslot][0] == 0)
+ swapperslot = 0;
+ break;
+ case AKS_DISKSWAPPER_PREV:
+ swapperslot--;
+ if (swapperslot < 0)
+ swapperslot = MAX_SPARE_DRIVES - 1;
+ while (swapperslot > 0) {
+ if (currprefs.dfxlist[swapperslot][0])
+ break;
+ swapperslot--;
+ }
+ break;
+ case AKS_DISKSWAPPER_INSERT0:
+ case AKS_DISKSWAPPER_INSERT1:
+ case AKS_DISKSWAPPER_INSERT2:
+ case AKS_DISKSWAPPER_INSERT3:
+ _tcscpy(changed_prefs.floppyslots[code - AKS_DISKSWAPPER_INSERT0].df, currprefs.dfxlist[swapperslot]);
+ set_config_changed();
+ break;
+ case AKS_INPUT_CONFIG_1:
+ case AKS_INPUT_CONFIG_2:
+ case AKS_INPUT_CONFIG_3:
+ case AKS_INPUT_CONFIG_4:
+ changed_prefs.input_selected_setting = currprefs.input_selected_setting = code - AKS_INPUT_CONFIG_1;
+ inputdevice_updateconfig(&changed_prefs, &currprefs);
+ break;
+ case AKS_DISK_PREV0:
+ case AKS_DISK_PREV1:
+ case AKS_DISK_PREV2:
+ case AKS_DISK_PREV3:
+ disk_prevnext(code - AKS_DISK_PREV0, -1);
+ break;
+ case AKS_DISK_NEXT0:
+ case AKS_DISK_NEXT1:
+ case AKS_DISK_NEXT2:
+ case AKS_DISK_NEXT3:
+ disk_prevnext(code - AKS_DISK_NEXT0, 1);
+ break;
+#ifdef CDTV
+ case AKS_CDTV_FRONT_PANEL_STOP:
+ case AKS_CDTV_FRONT_PANEL_PLAYPAUSE:
+ case AKS_CDTV_FRONT_PANEL_PREV:
+ case AKS_CDTV_FRONT_PANEL_NEXT:
+ case AKS_CDTV_FRONT_PANEL_REW:
+ case AKS_CDTV_FRONT_PANEL_FF:
+ cdtv_front_panel(code - AKS_CDTV_FRONT_PANEL_STOP);
+ break;
+#endif
+ }
+ return false;
+}
+
+void inputdevice_handle_inputcode()
{
bool got = false;
- for (int i = 0; i < MAX_PENDING_EVENTS; i++) {
+ for (int i = 0; i < MAX_PENDING_EVENTS; i++)
+ {
int code = inputcode_pending[i];
int state = inputcode_pending_state[i];
- if (code) {
- if (!inputdevice_handle_inputcode2 (code, state))
+ if (code)
+ {
+ if (!inputdevice_handle_inputcode2(code, state))
inputcode_pending[i] = 0;
got = true;
}
}
if (!got)
- inputdevice_handle_inputcode2 (0, 0);
+ inputdevice_handle_inputcode2(0, 0);
}
-static int getqualid (int evt)
+static int getqualid(int evt)
{
if (evt > INPUTEVENT_SPC_QUALIFIER_START && evt < INPUTEVENT_SPC_QUALIFIER_END)
return evt - INPUTEVENT_SPC_QUALIFIER1;
return -1;
}
-static uae_u64 isqual (int evt)
+static uae_u64 isqual(int evt)
{
- int num = getqualid (evt);
+ int num = getqualid(evt);
if (num < 0)
return 0;
return ID_FLAG_QUALIFIER1 << (num * 2);
}
-static int handle_input_event (int nr, int state, int max, int autofire)
+#ifdef INPUTDEVICE_SIMPLE
+static int handle_input_event(int nr, int state, int max, int autofire)
+#else
+static int handle_input_event (int nr, int state, int max, int autofire, bool canstopplayback, bool playbackevent)
+#endif
{
- const struct inputevent *ie;
+ struct inputevent* ie;
int joy;
bool isaks = false;
if (nr <= 0 || nr == INPUTEVENT_SPC_CUSTOM_EVENT)
return 0;
-#ifdef _WIN32_
// ignore normal GUI event if forced gui key is in use
- if (currprefs.win32_guikey >= 0 && nr == INPUTEVENT_SPC_ENTERGUI)
+ if (currprefs.key_for_menu >= 0 && nr == INPUTEVENT_SPC_ENTERGUI)
return 0;
-#endif
ie = &events[nr];
- if (isqual (nr))
+ if (isqual(nr))
return 0; // qualifiers do nothing
- if (ie->unit == 0 && ie->data >= AKS_FIRST) {
+ if (ie->unit == 0 && ie->data >= AKS_FIRST)
+ {
isaks = true;
+ if (!state) // release AKS_ does nothing
+ return 0;
}
- if (autofire) {
+ if (autofire)
+ {
+#ifdef INPUTDEVICE_SIMPLE
if (state)
- queue_input_event (nr, state, max, currprefs.input_autofire_linecnt);
+ queue_input_event(nr, state, max, currprefs.input_autofire_linecnt);
else
- queue_input_event (nr, -1, 0, 0);
+ queue_input_event(nr, -1, 0, 0);
+#else
+ if (state)
+ queue_input_event (nr, NULL, state, max, currprefs.input_autofire_linecnt, 1);
+ else
+ queue_input_event (nr, NULL, -1, 0, 0, 1);
+#endif
}
switch (ie->unit)
{
@@ -2721,40 +3035,48 @@ static int handle_input_event (int nr, int state, int max, int autofire)
case 3: /* ->Parallel port joystick adapter port #1 */
case 4: /* ->Parallel port joystick adapter port #2 */
joy = ie->unit - 1;
- if (ie->type & 4) {
+ if (ie->type & 4)
+ {
int old = joybutton[joy] & (1 << ie->data);
- if (state) {
+ if (state)
+ {
joybutton[joy] |= 1 << ie->data;
- } else {
+ }
+ else
+ {
joybutton[joy] &= ~(1 << ie->data);
}
-
- } else if (ie->type & 8) {
-
+ }
+ else if (ie->type & 8)
+ {
/* real mouse / analog stick mouse emulation */
int delta;
- int deadzone = max < 0 ? 0 : currprefs.input_joymouse_deadzone * max / 100;
+ int deadzone = currprefs.input_joymouse_deadzone * max / 100;
int unit = ie->data & 0x7f;
- if (max) {
- if (state <= deadzone && state >= -deadzone) {
+ if (max)
+ {
+ if (state <= deadzone && state >= -deadzone)
+ {
state = 0;
mouse_deltanoreset[joy][unit] = 0;
- } else if (state < 0) {
+ }
+ else if (state < 0)
+ {
state += deadzone;
mouse_deltanoreset[joy][unit] = 1;
- } else {
+ }
+ else
+ {
state -= deadzone;
mouse_deltanoreset[joy][unit] = 1;
}
- if (max > 0) {
- max -= deadzone;
- delta = state * currprefs.input_joymouse_multiplier / max;
- } else {
- delta = state;
- }
- } else {
+ max -= deadzone;
+ delta = state * currprefs.input_joymouse_multiplier / max;
+ }
+ else
+ {
delta = state;
mouse_deltanoreset[joy][unit] = 0;
}
@@ -2768,34 +3090,45 @@ static int handle_input_event (int nr, int state, int max, int autofire)
mouse_delta[joy][unit] += delta;
max = 32;
- } else if (ie->type & 32) { /* button mouse emulation vertical */
+ }
+ else if (ie->type & 32)
+ { /* button mouse emulation vertical */
- int speed = currprefs.input_joymouse_speed;
+ int speed = (ie->data & IE_CDTV) ? JOYMOUSE_CDTV : currprefs.input_joymouse_speed;
- if (state && (ie->data & DIR_UP)) {
+ if (state && (ie->data & DIR_UP))
+ {
mouse_delta[joy][1] = -speed;
mouse_deltanoreset[joy][1] = 1;
- } else if (state && (ie->data & DIR_DOWN)) {
+ }
+ else if (state && (ie->data & DIR_DOWN))
+ {
mouse_delta[joy][1] = speed;
mouse_deltanoreset[joy][1] = 1;
- } else
+ }
+ else
mouse_deltanoreset[joy][1] = 0;
+ }
+ else if (ie->type & 64)
+ { /* button mouse emulation horizontal */
- } else if (ie->type & 64) { /* button mouse emulation horizontal */
+ int speed = (ie->data & IE_CDTV) ? JOYMOUSE_CDTV : currprefs.input_joymouse_speed;
- int speed = currprefs.input_joymouse_speed;
-
- if (state && (ie->data & DIR_LEFT)) {
+ if (state && (ie->data & DIR_LEFT))
+ {
mouse_delta[joy][0] = -speed;
mouse_deltanoreset[joy][0] = 1;
- } else if (state && (ie->data & DIR_RIGHT)) {
+ }
+ else if (state && (ie->data & DIR_RIGHT))
+ {
mouse_delta[joy][0] = speed;
mouse_deltanoreset[joy][0] = 1;
- } else
+ }
+ else
mouse_deltanoreset[joy][0] = 0;
-
- } else if (ie->type & 128) { /* analog joystick / paddle */
-
+ }
+ else if (ie->type & 128)
+ { /* analog joystick / paddle */
#ifndef INPUTDEVICE_SIMPLE
int deadzone = currprefs.input_joymouse_deadzone * max / 100;
int unit = ie->data & 0x7f;
@@ -2832,59 +3165,105 @@ static int handle_input_event (int nr, int state, int max, int autofire)
mouse_deltanoreset[joy][0] = 1;
mouse_deltanoreset[joy][1] = 1;
#endif
-
- } else {
-
+ }
+ else
+ {
int left = oleft[joy], right = oright[joy], top = otop[joy], bot = obot[joy];
- if (ie->type & 16) {
+ if (ie->type & 16)
+ {
/* button to axis mapping */
- if (ie->data & DIR_LEFT) {
+ if (ie->data & DIR_LEFT)
+ {
left = oleft[joy] = state ? 1 : 0;
+ if (horizclear[joy] && left) {
+ horizclear[joy] = 0;
+ right = oright[joy] = 0;
+ }
}
- if (ie->data & DIR_RIGHT) {
+ if (ie->data & DIR_RIGHT)
+ {
right = oright[joy] = state ? 1 : 0;
+ if (horizclear[joy] && right) {
+ horizclear[joy] = 0;
+ left = oleft[joy] = 0;
+ }
}
- if (ie->data & DIR_UP) {
+ if (ie->data & DIR_UP)
+ {
top = otop[joy] = state ? 1 : 0;
+ if (vertclear[joy] && top) {
+ vertclear[joy] = 0;
+ bot = obot[joy] = 0;
+ }
}
- if (ie->data & DIR_DOWN) {
+ if (ie->data & DIR_DOWN)
+ {
bot = obot[joy] = state ? 1 : 0;
+ if (vertclear[joy] && bot) {
+ vertclear[joy] = 0;
+ top = otop[joy] = 0;
+ }
}
- } else {
+ }
+ else
+ {
/* "normal" joystick axis */
int deadzone = currprefs.input_joystick_deadzone * max / 100;
int neg, pos;
- if (max == 0) {
+ if (max == 0)
+ {
int cnt;
int mmax = 50, mextra = 10;
int unit = (ie->data & (4 | 8)) ? 1 : 0;
// relative events
relativecount[joy][unit] += state;
cnt = relativecount[joy][unit];
- neg = cnt < -mmax;
+ neg = cnt < -mmax;
pos = cnt > mmax;
if (cnt < -(mmax + mextra))
cnt = -(mmax + mextra);
if (cnt > (mmax + mextra))
cnt = (mmax + mextra);
relativecount[joy][unit] = cnt;
- } else {
- if (state < deadzone && state > -deadzone)
- state = 0;
- neg = state < 0 ? 1 : 0;
- pos = state > 0 ? 1 : 0;
}
- if (ie->data & DIR_LEFT) {
+ else
+ {
+ if (state < deadzone && state > -deadzone)
+ state = 0;
+ neg = state < 0 ? 1 : 0;
+ pos = state > 0 ? 1 : 0;
+ }
+ if (ie->data & DIR_LEFT)
+ {
left = oleft[joy] = neg;
+ if (horizclear[joy] && left) {
+ horizclear[joy] = 0;
+ right = oright[joy] = 0;
+ }
}
- if (ie->data & DIR_RIGHT) {
+ if (ie->data & DIR_RIGHT)
+ {
right = oright[joy] = pos;
+ if (horizclear[joy] && right) {
+ horizclear[joy] = 0;
+ left = oleft[joy] = 0;
+ }
}
- if (ie->data & DIR_UP) {
+ if (ie->data & DIR_UP)
+ {
top = otop[joy] = neg;
+ if (vertclear[joy] && top) {
+ vertclear[joy] = 0;
+ bot = obot[joy] = 0;
+ }
}
- if (ie->data & DIR_DOWN) {
+ if (ie->data & DIR_DOWN)
+ {
bot = obot[joy] = pos;
+ if (vertclear[joy] && bot) {
+ vertclear[joy] = 0;
+ top = otop[joy] = 0;
+ }
}
}
mouse_deltanoreset[joy][0] = 1;
@@ -2899,81 +3278,129 @@ static int handle_input_event (int nr, int state, int max, int autofire)
if (bot)
joydir[joy] |= DIR_DOWN;
if (joy == 0 || joy == 1)
- joymousecounter (joy);
+ joymousecounter(joy);
}
break;
case 0: /* ->KEY */
- inputdevice_do_keyboard (ie->data, state);
+ inputdevice_do_keyboard(ie->data, state);
break;
- }
+ }
return 1;
}
-static void inputdevice_checkconfig (void)
+static void inputdevice_checkconfig(void)
{
- bool changed = false;
- for (int i = 0; i < MAX_JPORTS; i++) {
- if (currprefs.jports[i].id != changed_prefs.jports[i].id ||
- currprefs.jports[i].mode != changed_prefs.jports[i].mode)
- changed = true;
- }
+ if (
+ currprefs.jports[0].id != changed_prefs.jports[0].id ||
+ currprefs.jports[1].id != changed_prefs.jports[1].id ||
+ currprefs.jports[2].id != changed_prefs.jports[2].id ||
+ currprefs.jports[3].id != changed_prefs.jports[3].id ||
+
+ currprefs.jports[0].mode != changed_prefs.jports[0].mode ||
+ currprefs.jports[1].mode != changed_prefs.jports[1].mode ||
+ currprefs.jports[2].mode != changed_prefs.jports[2].mode ||
+ currprefs.jports[3].mode != changed_prefs.jports[3].mode ||
- if (changed ||
currprefs.input_selected_setting != changed_prefs.input_selected_setting ||
currprefs.input_joymouse_multiplier != changed_prefs.input_joymouse_multiplier ||
currprefs.input_joymouse_deadzone != changed_prefs.input_joymouse_deadzone ||
currprefs.input_joystick_deadzone != changed_prefs.input_joystick_deadzone ||
currprefs.input_joymouse_speed != changed_prefs.input_joymouse_speed ||
currprefs.input_autofire_linecnt != changed_prefs.input_autofire_linecnt ||
- currprefs.input_mouse_speed != changed_prefs.input_mouse_speed) {
+ currprefs.input_mouse_speed != changed_prefs.input_mouse_speed)
+ {
+ currprefs.input_selected_setting = changed_prefs.input_selected_setting;
+ currprefs.input_joymouse_multiplier = changed_prefs.input_joymouse_multiplier;
+ currprefs.input_joymouse_deadzone = changed_prefs.input_joymouse_deadzone;
+ currprefs.input_joystick_deadzone = changed_prefs.input_joystick_deadzone;
+ currprefs.input_joymouse_speed = changed_prefs.input_joymouse_speed;
+ currprefs.input_autofire_linecnt = changed_prefs.input_autofire_linecnt;
+ currprefs.input_mouse_speed = changed_prefs.input_mouse_speed;
- currprefs.input_selected_setting = changed_prefs.input_selected_setting;
- currprefs.input_joymouse_multiplier = changed_prefs.input_joymouse_multiplier;
- currprefs.input_joymouse_deadzone = changed_prefs.input_joymouse_deadzone;
- currprefs.input_joystick_deadzone = changed_prefs.input_joystick_deadzone;
- currprefs.input_joymouse_speed = changed_prefs.input_joymouse_speed;
- currprefs.input_autofire_linecnt = changed_prefs.input_autofire_linecnt;
- currprefs.input_mouse_speed = changed_prefs.input_mouse_speed;
-
- inputdevice_updateconfig (&changed_prefs, &currprefs);
+ inputdevice_updateconfig(&changed_prefs, &currprefs);
}
}
-void inputdevice_vsync (void)
+void inputdevice_vsync()
{
input_frame++;
- mouseupdate (0, true);
+ mouseupdate(0, true);
- inputdevice_read ();
+#ifndef INPUTDEVICE_SIMPLE
+ struct delayed_event *de = delayed_events;
+ while (de) {
+ if (de->delay > 0)
+ de->delay--;
+ if (de->delay == 0) {
+ de->delay = -1;
+ if (de->event_string) {
+ TCHAR *s = de->event_string;
+ de->event_string = NULL;
+ handle_custom_event (s);
+ xfree (s);
+ }
+ }
+ de = de->next;
+ }
+#endif
+
+ inputdevice_read();
inputdelay = uaerand () % (maxvpos <= 1 ? 1 : maxvpos - 1);
- inputdevice_handle_inputcode ();
+ inputdevice_handle_inputcode();
+ if (mouseedge_alive > 0)
+ mouseedge_alive--;
+#ifdef ARCADIA
+ if (arcadia_bios)
+ arcadia_vsync();
+#endif
+ //if (mouseedge())
+ // mouseedge_alive = 10;
if (mousehack_alive_cnt > 0) {
mousehack_alive_cnt--;
- } else if (mousehack_alive_cnt < 0) {
+ //if (mousehack_alive_cnt == 0)
+ // setmouseactive(-1);
+ }
+ else if (mousehack_alive_cnt < 0) {
mousehack_alive_cnt++;
if (mousehack_alive_cnt == 0) {
mousehack_alive_cnt = 100;
+ //setmouseactive(0);
+ //setmouseactive(1);
}
}
- inputdevice_checkconfig ();
+ inputdevice_checkconfig();
}
-void inputdevice_reset (void)
+
+void inputdevice_reset()
{
- mousehack_reset ();
- if (inputdevice_is_tablet ())
- mousehack_enable ();
+ magicmouse_ibase = 0;
+ magicmouse_gfxbase = 0;
+ mousehack_reset();
+ if (inputdevice_is_tablet())
+ mousehack_enable();
+#ifndef INPUTDEVICE_SIMPLE
+ while (delayed_events) {
+ struct delayed_event *de = delayed_events;
+ delayed_events = de->next;
+ xfree (de->event_string);
+ xfree (de);
+ }
+#endif
}
-static int getoldport (struct uae_input_device *id)
+static int getoldport(struct uae_input_device* id)
{
int i, j;
- for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
- for (j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
+ for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
+ {
+ for (j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
int evt = id->eventid[i][j];
- if (evt > 0) {
+ if (evt > 0)
+ {
int unit = events[evt].unit;
if (unit >= 1 && unit <= 4)
return unit;
@@ -2983,181 +3410,211 @@ static int getoldport (struct uae_input_device *id)
return -1;
}
-static int switchdevice (struct uae_input_device *id, int num, bool buttonmode)
+static int switchdevice(struct uae_input_device* id, int num, bool buttonmode)
{
+ int i, j;
int ismouse = 0;
int newport = 0;
- int newslot = -1;
int flags = 0;
- const TCHAR *name = NULL, *fname = NULL;
+ const char* name = NULL;
int otherbuttonpressed = 0;
int acc = input_acquired;
if (num >= 4)
return 0;
- if (!target_can_autoswitchdevice())
- return 0;
-
- for (int i = 0; i < MAX_INPUT_DEVICES; i++) {
- if (id == &joysticks[i]) {
- name = idev[IDTYPE_JOYSTICK].get_uniquename (i);
- fname = idev[IDTYPE_JOYSTICK].get_friendlyname (i);
+ for (i = 0; i < MAX_INPUT_DEVICES; i++)
+ {
+ if (id == &joysticks[i])
+ {
+ name = idev[IDTYPE_JOYSTICK].get_uniquename(i);
newport = num == 0 ? 1 : 0;
- flags = idev[IDTYPE_JOYSTICK].get_flags (i);
- for (int j = 0; j < MAX_INPUT_DEVICES; j++) {
- if (j != i) {
- struct uae_input_device2 *id2 = &joysticks2[j];
+ flags = idev[IDTYPE_JOYSTICK].get_flags(i);
+ for (j = 0; j < MAX_INPUT_DEVICES; j++)
+ {
+ if (j != i)
+ {
+ struct uae_input_device2* id2 = &joysticks2[j];
if (id2->buttonmask)
otherbuttonpressed = 1;
}
}
}
- if (id == &mice[i]) {
+ if (id == &mice[i])
+ {
ismouse = 1;
- name = idev[IDTYPE_MOUSE].get_uniquename (i);
- fname = idev[IDTYPE_MOUSE].get_friendlyname (i);
+ name = idev[IDTYPE_MOUSE].get_uniquename(i);
newport = num == 0 ? 0 : 1;
- flags = idev[IDTYPE_MOUSE].get_flags (i);
+ flags = idev[IDTYPE_MOUSE].get_flags(i);
}
}
- if (!name) {
+ if (!name)
+ {
return 0;
}
- if (buttonmode) {
+ if (buttonmode)
+ {
if (num == 0 && otherbuttonpressed)
newport = newport ? 0 : 1;
- } else {
+ }
+ else
+ {
newport = num ? 1 : 0;
}
/* "GamePorts" switch if in GamePorts mode or Input mode and GamePorts port was not NONE */
- if (currprefs.input_selected_setting == GAMEPORT_INPUT_SETTINGS || currprefs.jports[newport].id != JPORT_NONE) {
- if ((num == 0 || num == 1)) {
+ if (currprefs.input_selected_setting == GAMEPORT_INPUT_SETTINGS || currprefs.jports[newport].id != JPORT_NONE)
+ {
+ if ((num == 0 || num == 1) && !JSEM_ISCUSTOM(newport, &currprefs))
+ {
bool issupermouse = false;
- int om = jsem_ismouse (num, &currprefs);
- int om1 = jsem_ismouse (0, &currprefs);
- int om2 = jsem_ismouse (1, &currprefs);
- if ((om1 >= 0 || om2 >= 0) && ismouse) {
+ int om = jsem_ismouse(num, &currprefs);
+ int om1 = jsem_ismouse(0, &currprefs);
+ int om2 = jsem_ismouse(1, &currprefs);
+ if ((om1 >= 0 || om2 >= 0) && ismouse)
+ {
return 0;
}
- if (flags) {
+ if (flags)
+ {
return 0;
}
-
#if 1
- if (ismouse) {
+ if (ismouse)
+ {
int nummouse = 0; // count number of non-supermouse mice
int supermouse = -1;
- for (int i = 0; i < idev[IDTYPE_MOUSE].get_num (); i++) {
- if (!idev[IDTYPE_MOUSE].get_flags (i))
+ for (i = 0; i < idev[IDTYPE_MOUSE].get_num(); i++)
+ {
+ if (!idev[IDTYPE_MOUSE].get_flags(i))
nummouse++;
else
supermouse = i;
}
- if (supermouse >= 0 && nummouse == 1) {
- const TCHAR* oldname = name;
- name = idev[IDTYPE_MOUSE].get_uniquename (supermouse);
- fname = idev[IDTYPE_MOUSE].get_friendlyname(supermouse);
+ if (supermouse >= 0 && nummouse == 1)
+ {
+ const char* oldname = name;
+ name = idev[IDTYPE_MOUSE].get_uniquename(supermouse);
issupermouse = true;
}
}
#endif
- inputdevice_unacquire ();
+ inputdevice_unacquire();
- if (currprefs.input_selected_setting != GAMEPORT_INPUT_SETTINGS && currprefs.jports[newport].id > JPORT_NONE) {
+ if (currprefs.input_selected_setting != GAMEPORT_INPUT_SETTINGS && currprefs.jports[newport].id > JPORT_NONE)
+ {
// disable old device
int devnum;
devnum = jsem_ismouse(newport, &currprefs);
- if (devnum >= 0) {
- if (changed_prefs.mouse_settings[currprefs.input_selected_setting][devnum].enabled) {
+ if (devnum >= 0)
+ {
+ if (changed_prefs.mouse_settings[currprefs.input_selected_setting][devnum].enabled)
+ {
changed_prefs.mouse_settings[currprefs.input_selected_setting][devnum].enabled = false;
}
}
- for (int l = 0; l < idev[IDTYPE_MOUSE].get_num(); l++) {
- if (changed_prefs.mouse_settings[currprefs.input_selected_setting][l].enabled) {
- if (idev[IDTYPE_MOUSE].get_flags(l)) {
+ for (int l = 0; l < idev[IDTYPE_MOUSE].get_num(); l++)
+ {
+ if (changed_prefs.mouse_settings[currprefs.input_selected_setting][l].enabled)
+ {
+ if (idev[IDTYPE_MOUSE].get_flags(l))
+ {
issupermouse = true;
}
}
}
- if (issupermouse) {
+ if (issupermouse)
+ {
// new mouse is supermouse, disable all other mouse devices
- for (int l = 0; l < MAX_INPUT_DEVICES; l++) {
+ for (int l = 0; l < MAX_INPUT_DEVICES; l++)
+ {
changed_prefs.mouse_settings[currprefs.input_selected_setting][l].enabled = false;
}
}
devnum = jsem_isjoy(newport, &currprefs);
- if (devnum >= 0) {
- if (changed_prefs.joystick_settings[currprefs.input_selected_setting][devnum].enabled) {
+ if (devnum >= 0)
+ {
+ if (changed_prefs.joystick_settings[currprefs.input_selected_setting][devnum].enabled)
+ {
changed_prefs.joystick_settings[currprefs.input_selected_setting][devnum].enabled = false;
}
}
}
- if (newslot >= 0) {
- TCHAR cust[100];
- _stprintf(cust, _T("custom%d"), newslot);
- inputdevice_joyport_config(&changed_prefs, cust, cust, newport, -1, 0, true);
- } else {
- inputdevice_joyport_config (&changed_prefs, name, name, newport, -1, 1, true);
- }
- inputdevice_validate_jports (&changed_prefs, -1, NULL);
- inputdevice_copyconfig (&changed_prefs, &currprefs);
+ inputdevice_joyport_config(&changed_prefs, name, newport, -1, 2, false);
+ inputdevice_validate_jports(&changed_prefs, -1);
+ inputdevice_copyconfig(&changed_prefs, &currprefs);
if (acc)
- inputdevice_acquire (TRUE);
+ inputdevice_acquire(TRUE);
return 1;
}
return 0;
-
- } else {
- int oldport = getoldport (id);
+ }
+ else
+ {
+ int oldport = getoldport(id);
int k, evt;
- const struct inputevent *ie, *ie2;
+ struct inputevent *ie, *ie2;
if (flags)
return 0;
- if (oldport <= 0) {
+ if (oldport <= 0)
+ {
return 0;
}
newport++;
/* do not switch if switching mouse and any "supermouse" mouse enabled */
- if (ismouse) {
- for (int i = 0; i < MAX_INPUT_SETTINGS; i++) {
- if (mice[i].enabled && idev[IDTYPE_MOUSE].get_flags (i)) {
+ if (ismouse)
+ {
+ for (i = 0; i < MAX_INPUT_SETTINGS; i++)
+ {
+ if (mice[i].enabled && idev[IDTYPE_MOUSE].get_flags(i))
+ {
return 0;
- }
- }
+ }
+ }
}
- for (int i = 0; i < MAX_INPUT_SETTINGS; i++) {
- if (getoldport (&joysticks[i]) == newport) {
+ for (i = 0; i < MAX_INPUT_SETTINGS; i++)
+ {
+ if (getoldport(&joysticks[i]) == newport)
+ {
joysticks[i].enabled = 0;
- }
- if (getoldport (&mice[i]) == newport) {
+ }
+ if (getoldport(&mice[i]) == newport)
+ {
mice[i].enabled = 0;
- }
- }
+ }
+ }
id->enabled = 1;
- for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
- for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
+ for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
+ {
+ for (j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
evt = id->eventid[i][j];
if (evt <= 0)
continue;
ie = &events[evt];
- if (ie->unit == oldport) {
+ if (ie->unit == oldport)
+ {
k = 1;
- while (events[k].confname) {
+ while (events[k].confname)
+ {
ie2 = &events[k];
- if (ie2->type == ie->type && ie2->data == ie->data && ie2->allow_mask == ie->allow_mask && ie2->unit == newport) {
+ if (ie2->type == ie->type && ie2->data == ie->data && ie2->allow_mask == ie->allow_mask && ie2->unit == newport)
+ {
id->eventid[i][j] = k;
break;
}
k++;
}
- } else if (ie->unit == newport) {
+ }
+ else if (ie->unit == newport)
+ {
k = 1;
- while (events[k].confname) {
+ while (events[k].confname)
+ {
ie2 = &events[k];
- if (ie2->type == ie->type && ie2->data == ie->data && ie2->allow_mask == ie->allow_mask && ie2->unit == oldport) {
+ if (ie2->type == ie->type && ie2->data == ie->data && ie2->allow_mask == ie->allow_mask && ie2->unit == oldport)
+ {
id->eventid[i][j] = k;
break;
}
@@ -3167,26 +3624,26 @@ static int switchdevice (struct uae_input_device *id, int num, bool buttonmode)
}
}
write_log (_T("inputdevice input change '%s':%d->%d\n"), name, num, newport);
- inputdevice_unacquire ();
- inputdevice_copyconfig (&currprefs, &changed_prefs);
- inputdevice_validate_jports (&changed_prefs, -1, NULL);
- inputdevice_copyconfig (&changed_prefs, &currprefs);
+ inputdevice_unacquire();
+ inputdevice_copyconfig(&currprefs, &changed_prefs);
+ inputdevice_validate_jports(&changed_prefs, -1);
+ inputdevice_copyconfig(&changed_prefs, &currprefs);
if (acc)
- inputdevice_acquire (TRUE);
+ inputdevice_acquire(TRUE);
return 1;
}
return 0;
}
-uae_u64 input_getqualifiers (void)
+uae_u64 input_getqualifiers(void)
{
return qualifiers;
}
-static bool checkqualifiers (int evt, uae_u64 flags, uae_u64 *qualmask, uae_s16 events[MAX_INPUT_SUB_EVENT_ALL])
+static bool checkqualifiers(int evt, uae_u64 flags, uae_u64* qualmask, uae_s16 events[MAX_INPUT_SUB_EVENT_ALL])
{
int i, j;
- int qualid = getqualid (evt);
+ int qualid = getqualid(evt);
int nomatch = 0;
bool isspecial = (qualifiers & (ID_FLAG_QUALIFIER_SPECIAL | ID_FLAG_QUALIFIER_SPECIAL_R)) != 0;
@@ -3197,37 +3654,43 @@ static bool checkqualifiers (int evt, uae_u64 flags, uae_u64 *qualmask, uae_s16
if ((qualifiers & (ID_FLAG_QUALIFIER_SPECIAL | ID_FLAG_QUALIFIER_SPECIAL_R)) && qualid >= 0)
return false;
- for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) {
+ for (i = 0; i < MAX_INPUT_SUB_EVENT; i++)
+ {
if (qualmask[i])
break;
}
- if (i == MAX_INPUT_SUB_EVENT) {
- // no qualifiers in any slot and no special = always match
+ if (i == MAX_INPUT_SUB_EVENT)
+ {
+ // no qualifiers in any slot and no special = always match
return isspecial == false;
}
- // do we have any subevents with qualifier set?
- for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) {
- for (j = 0; j < MAX_INPUT_QUALIFIERS; j++) {
+ for (i = 0; i < MAX_INPUT_SUB_EVENT; i++)
+ {
+ for (j = 0; j < MAX_INPUT_QUALIFIERS; j++)
+ {
uae_u64 mask = (ID_FLAG_QUALIFIER1 | ID_FLAG_QUALIFIER1_R) << (j * 2);
bool isqualmask = (qualmask[i] & mask) != 0;
bool isqual = (qualifiers & mask) != 0;
- if (isqualmask != isqual) {
+ if (isqualmask != isqual)
+ {
nomatch++;
break;
}
}
}
- if (nomatch == MAX_INPUT_SUB_EVENT) {
+ if (nomatch == MAX_INPUT_SUB_EVENT)
+ {
// no matched qualifiers in any slot
// allow all slots without qualifiers
// special = never accept
if (isspecial)
- return false;
+ return false;
return flags ? false : true;
- }
+ }
- for (i = 0; i < MAX_INPUT_QUALIFIERS; i++) {
+ for (i = 0; i < MAX_INPUT_QUALIFIERS; i++)
+ {
uae_u64 mask = (ID_FLAG_QUALIFIER1 | ID_FLAG_QUALIFIER1_R) << (i * 2);
bool isflags = (flags & mask) != 0;
bool isqual = (qualifiers & mask) != 0;
@@ -3237,36 +3700,134 @@ static bool checkqualifiers (int evt, uae_u64 flags, uae_u64 *qualmask, uae_s16
return true;
}
-static void setqualifiers (int evt, int state)
+static void setqualifiers(int evt, int state)
{
- uae_u64 mask = isqual (evt);
+ uae_u64 mask = isqual(evt);
if (!mask)
return;
if (state)
qualifiers |= mask;
else
qualifiers &= ~mask;
+ //write_log (_T("%llx\n"), qualifiers);
}
-static uae_u64 getqualmask (uae_u64 *qualmask, struct uae_input_device *id, int num, bool *qualonly)
+static uae_u64 getqualmask(uae_u64* qualmask, struct uae_input_device* id, int num, bool* qualonly)
{
uae_u64 mask = 0, mask2 = 0;
- for (int i = 0; i < MAX_INPUT_SUB_EVENT; i++) {
+ for (int i = 0; i < MAX_INPUT_SUB_EVENT; i++)
+ {
int evt = id->eventid[num][i];
mask |= id->flags[num][i];
qualmask[i] = id->flags[num][i] & ID_FLAG_QUALIFIER_MASK;
- mask2 |= isqual (evt);
+ mask2 |= isqual(evt);
}
mask &= ID_FLAG_QUALIFIER_MASK;
*qualonly = false;
- if (qualifiers & ID_FLAG_QUALIFIER_SPECIAL) {
+ if (qualifiers & ID_FLAG_QUALIFIER_SPECIAL)
+ {
// ID_FLAG_QUALIFIER_SPECIAL already active and this event has one or more qualifiers configured
*qualonly = mask2 != 0;
}
return mask;
}
-static void setbuttonstateall (struct uae_input_device *id, struct uae_input_device2 *id2, int button, int buttonstate)
+#ifndef INPUTDEVICE_SIMPLE
+static bool process_custom_event (struct uae_input_device *id, int offset, int state, uae_u64 *qualmask, int autofire, int sub)
+{
+ int idx, slotoffset, custompos;
+ TCHAR *custom;
+ uae_u64 flags, qual;
+
+ if (!id)
+ return false;
+
+ slotoffset = sub & ~3;
+ sub &= 3;
+ flags = id->flags[offset][slotoffset];
+ qual = flags & ID_FLAG_QUALIFIER_MASK;
+ custom = id->custom[offset][slotoffset];
+ int af = flags & ID_FLAG_AUTOFIRE_MASK;
+
+ for (idx = 1; idx < 4; idx++) {
+ uae_u64 flags2 = id->flags[offset][slotoffset + idx];
+ TCHAR *custom2 = id->custom[offset][slotoffset + idx];
+
+// all slots must have same qualifier
+ if ((flags2 & ID_FLAG_QUALIFIER_MASK) != qual)
+ break;
+// no slot must have autofire
+ if ((flags2 & ID_FLAG_AUTOFIRE_MASK) || (flags & ID_FLAG_AUTOFIRE_MASK))
+ break;
+ }
+// at least slot 0 and 2 must have custom
+ if (custom == NULL || id->custom[offset][slotoffset + 2] == NULL)
+ idx = -1;
+
+ if (idx < 4) {
+ id->flags[offset][slotoffset] &= ~(ID_FLAG_CUSTOMEVENT_TOGGLED1 | ID_FLAG_CUSTOMEVENT_TOGGLED2);
+ int evt2 = id->eventid[offset][slotoffset + sub];
+ uae_u64 flags2 = id->flags[offset][slotoffset + sub];
+ if (checkqualifiers (evt2, flags2, qualmask, NULL)) {
+ custom = id->custom[offset][slotoffset + sub];
+ if (state && custom) {
+ if (autofire)
+ queue_input_event (-1, custom, 1, 1, currprefs.input_autofire_linecnt, 1);
+ handle_custom_event (custom);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ if (sub != 0)
+ return false;
+
+ slotoffset = 0;
+ if (!checkqualifiers (id->eventid[offset][slotoffset], id->flags[offset][slotoffset], qualmask, NULL)) {
+ slotoffset = 4;
+ if (!checkqualifiers (id->eventid[offset][slotoffset], id->flags[offset][slotoffset], qualmask, NULL))
+ return false;
+ }
+
+ flags = id->flags[offset][slotoffset];
+ custompos = (flags & ID_FLAG_CUSTOMEVENT_TOGGLED1) ? 1 : 0;
+ custompos |= (flags & ID_FLAG_CUSTOMEVENT_TOGGLED2) ? 2 : 0;
+
+ if (state < 0) {
+ idx = 0;
+ custompos = 0;
+ } else {
+ if (state > 0) {
+ if (custompos & 1)
+ return false; // waiting for release
+ } else {
+ if (!(custompos & 1))
+ return false; // waiting for press
+ }
+ idx = custompos;
+ custompos++;
+ }
+
+ queue_input_event (-1, NULL, -1, 0, 0, 1);
+
+ if ((id->flags[offset][slotoffset + idx] & ID_FLAG_QUALIFIER_MASK) == qual) {
+ custom = id->custom[offset][slotoffset + idx];
+ if (autofire)
+ queue_input_event (-1, custom, 1, 1, currprefs.input_autofire_linecnt, 1);
+ if (custom)
+ handle_custom_event (custom);
+ }
+
+ id->flags[offset][slotoffset] &= ~(ID_FLAG_CUSTOMEVENT_TOGGLED1 | ID_FLAG_CUSTOMEVENT_TOGGLED2);
+ id->flags[offset][slotoffset] |= (custompos & 1) ? ID_FLAG_CUSTOMEVENT_TOGGLED1 : 0;
+ id->flags[offset][slotoffset] |= (custompos & 2) ? ID_FLAG_CUSTOMEVENT_TOGGLED2 : 0;
+
+ return true;
+}
+#endif
+
+static void setbuttonstateall(struct uae_input_device* id, struct uae_input_device2* id2, int button, int buttonstate)
{
static frame_time_t switchdevice_timeout;
int i;
@@ -3275,109 +3836,131 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev
uae_u32 nmask = (buttonstate ? 1 : 0) << button;
uae_u64 qualmask[MAX_INPUT_SUB_EVENT];
bool qualonly;
- bool doit = true;
if (!id->enabled) {
- frame_time_t t = read_processor_time ();
- if (!t)
- t++;
+ frame_time_t t = read_processor_time();
if (buttonstate) {
switchdevice_timeout = t;
- } else {
- if (switchdevice_timeout) {
- int port = button;
- if (t - switchdevice_timeout >= syncbase) // 1s
- port ^= 1;
- switchdevice (id, port, true);
- }
- switchdevice_timeout = 0;
- }
+ }
+ else {
+ int port = button;
+ if (t - switchdevice_timeout >= syncbase) // 1s
+ port ^= 1;
+ switchdevice(id, port, true);
+ }
return;
}
if (button >= ID_BUTTON_TOTAL)
return;
- if (doit) {
- getqualmask (qualmask, id, ID_BUTTON_OFFSET + button, &qualonly);
+ getqualmask(qualmask, id, ID_BUTTON_OFFSET + button, &qualonly);
- for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) {
- int sub = sublevdir[buttonstate == 0 ? 1 : 0][i];
- uae_u64 *flagsp = &id->flags[ID_BUTTON_OFFSET + button][sub];
- int evt = id->eventid[ID_BUTTON_OFFSET + button][sub];
- uae_u64 flags = flagsp[0];
- int autofire = (flags & ID_FLAG_AUTOFIRE) ? 1 : 0;
- int toggle = (flags & ID_FLAG_TOGGLE) ? 1 : 0;
- int inverttoggle = (flags & ID_FLAG_INVERTTOGGLE) ? 1 : 0;
- int invert = (flags & ID_FLAG_INVERT) ? 1 : 0;
- int setmode = (flags & ID_FLAG_SET_ONOFF) ? 1: 0;
- int setval = (flags & ID_FLAG_SET_ONOFF_VAL) ? SET_ONOFF_ON_VALUE : SET_ONOFF_OFF_VALUE;
- int state;
+ bool didcustom = false;
- if (buttonstate < 0) {
- state = buttonstate;
- } else if (invert) {
- state = buttonstate ? 0 : 1;
- } else {
- state = buttonstate;
- }
- if (setmode) {
- if (state)
- state = setval;
- }
+ for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) {
+ int sub = sublevdir[buttonstate == 0 ? 1 : 0][i];
+ uae_u64 *flagsp = &id->flags[ID_BUTTON_OFFSET + button][sub];
+ int evt = id->eventid[ID_BUTTON_OFFSET + button][sub];
+ TCHAR *custom = id->custom[ID_BUTTON_OFFSET + button][sub];
+ uae_u64 flags = flagsp[0];
+ int autofire = (flags & ID_FLAG_AUTOFIRE) ? 1 : 0;
+ int toggle = (flags & ID_FLAG_TOGGLE) ? 1 : 0;
+ int inverttoggle = (flags & ID_FLAG_INVERTTOGGLE) ? 1 : 0;
+ int invert = (flags & ID_FLAG_INVERT) ? 1 : 0;
+ int setmode = (flags & ID_FLAG_SET_ONOFF) ? 1 : 0;
+ int setval = (flags & ID_FLAG_SET_ONOFF_VAL) ? SET_ONOFF_ON_VALUE : SET_ONOFF_OFF_VALUE;
+ int state;
- setqualifiers (evt, state > 0);
-
- if (qualonly)
- continue;
+ if (buttonstate < 0) {
+ state = buttonstate;
+ }
+ else if (invert) {
+ state = buttonstate ? 0 : 1;
+ }
+ else {
+ state = buttonstate;
+ }
+ if (setmode) {
+ if (state)
+ state = setval;
+ }
#ifndef INPUTDEVICE_SIMPLE
- if (state < 0) {
- if (!checkqualifiers (evt, flags, qualmask, NULL))
- continue;
- handle_input_event (evt, 1, 1, 0);
- } else if (inverttoggle) {
- /* pressed = firebutton, not pressed = autofire */
- if (state) {
- queue_input_event (evt, -1, 0, 0);
- handle_input_event (evt, 2, 1, 0);
- } else {
- handle_input_event (evt, 2, 1, autofire);
- }
- } else if (toggle) {
- if (!state)
- continue;
- if (omask & mask)
- continue;
- if (!checkqualifiers (evt, flags, qualmask, NULL))
- continue;
- *flagsp ^= ID_FLAG_TOGGLED;
- int toggled = (*flagsp & ID_FLAG_TOGGLED) ? 2 : 0;
- handle_input_event (evt, toggled, 1, autofire);
- } else {
+ if (!state) {
+ didcustom |= process_custom_event (id, ID_BUTTON_OFFSET + button, state, qualmask, autofire, i);
+ }
#endif
- if (!checkqualifiers (evt, flags, qualmask, NULL)) {
- if (!state && !(flags & ID_FLAG_CANRELEASE)) {
- if (!invert)
- continue;
- } else if (state) {
- continue;
- }
- }
- if (!state)
- *flagsp &= ~ID_FLAG_CANRELEASE;
- else
- *flagsp |= ID_FLAG_CANRELEASE;
- if ((omask ^ nmask) & mask) {
- handle_input_event (evt, state, 1, autofire);
- }
-#ifndef INPUTDEVICE_SIMPLE
- }
-#endif
- }
+ setqualifiers(evt, state > 0);
- queue_input_event (-1, -1, 0, 0);
+ if (qualonly)
+ continue;
+
+#ifndef INPUTDEVICE_SIMPLE
+ if (state < 0) {
+ if (!checkqualifiers(evt, flags, qualmask, NULL))
+ continue;
+ handle_input_event(evt, 1, 1, 0, true, false);
+ didcustom |= process_custom_event(id, ID_BUTTON_OFFSET + button, state, qualmask, 0, i);
+ }
+ else if (inverttoggle) {
+ /* pressed = firebutton, not pressed = autofire */
+ if (state) {
+ queue_input_event(evt, NULL, -1, 0, 0, 1);
+ handle_input_event(evt, 1, 1, 0, true, false);
+ }
+ else {
+ handle_input_event(evt, 1, 1, autofire, true, false);
+ }
+ didcustom |= process_custom_event(id, ID_BUTTON_OFFSET + button, state, qualmask, autofire, i);
+ }
+ else if (toggle) {
+ if (!state)
+ continue;
+ if (omask & mask)
+ continue;
+ if (!checkqualifiers(evt, flags, qualmask, NULL))
+ continue;
+ *flagsp ^= ID_FLAG_TOGGLED;
+ int toggled = (*flagsp & ID_FLAG_TOGGLED) ? 1 : 0;
+ handle_input_event(evt, toggled, 1, autofire, true, false);
+ didcustom |= process_custom_event(id, ID_BUTTON_OFFSET + button, toggled, qualmask, autofire, i);
+ }
+ else {
+#endif
+ if (!checkqualifiers(evt, flags, qualmask, NULL)) {
+ if (!state && !(flags & ID_FLAG_CANRELEASE)) {
+ if (!invert)
+ continue;
+ }
+ else if (state) {
+ continue;
+ }
}
+ if (!state)
+ *flagsp &= ~ID_FLAG_CANRELEASE;
+ else
+ *flagsp |= ID_FLAG_CANRELEASE;
+ if ((omask ^ nmask) & mask) {
+#ifdef INPUTDEVICE_SIMPLE
+ handle_input_event(evt, state, 1, autofire);
+#else
+ handle_input_event (evt, state, 1, autofire, true, false);
+ if (state)
+ didcustom |= process_custom_event (id, ID_BUTTON_OFFSET + button, state, qualmask, autofire, i);
+#endif
+ }
+#ifndef INPUTDEVICE_SIMPLE
+ }
+#endif
+ }
+
+ if (!didcustom)
+#ifdef INPUTDEVICE_SIMPLE
+ queue_input_event(-1, -1, 0, 0);
+#else
+ queue_input_event (-1, NULL, -1, 0, 0, 1);
+#endif
if (id2 && ((omask ^ nmask) & mask)) {
if (buttonstate)
@@ -3393,46 +3976,50 @@ static void setbuttonstateall (struct uae_input_device *id, struct uae_input_dev
* - detect device type in ports (mouse or joystick)
*/
-static int iscd32 (int ei)
+static int iscd32(int ei)
{
- if (ei >= INPUTEVENT_JOY1_CD32_FIRST && ei <= INPUTEVENT_JOY1_CD32_LAST) {
+ if (ei >= INPUTEVENT_JOY1_CD32_FIRST && ei <= INPUTEVENT_JOY1_CD32_LAST)
+ {
cd32_pad_enabled[0] = 1;
return 1;
}
- if (ei >= INPUTEVENT_JOY2_CD32_FIRST && ei <= INPUTEVENT_JOY2_CD32_LAST) {
+ if (ei >= INPUTEVENT_JOY2_CD32_FIRST && ei <= INPUTEVENT_JOY2_CD32_LAST)
+ {
cd32_pad_enabled[1] = 1;
return 2;
}
return 0;
}
+#ifndef INPUTDEVICE_SIMPLE
static int isparport (int ei)
{
-#if !defined(INPUTDEVICE_SIMPLE) || defined(AMIBERRY)
if (ei > INPUTEVENT_PAR_JOY1_START && ei < INPUTEVENT_PAR_JOY_END) {
parport_joystick_enabled = 1;
return 1;
}
-#endif
return 0;
}
+#endif
-static int ismouse (int ei)
+static int ismouse(int ei)
{
- if (ei >= INPUTEVENT_MOUSE1_FIRST && ei <= INPUTEVENT_MOUSE1_LAST) {
+ if (ei >= INPUTEVENT_MOUSE1_FIRST && ei <= INPUTEVENT_MOUSE1_LAST)
+ {
mouse_port[0] = 1;
return 1;
}
- if (ei >= INPUTEVENT_MOUSE2_FIRST && ei <= INPUTEVENT_MOUSE2_LAST) {
+ if (ei >= INPUTEVENT_MOUSE2_FIRST && ei <= INPUTEVENT_MOUSE2_LAST)
+ {
mouse_port[1] = 1;
return 2;
}
return 0;
}
+#ifndef INPUTDEVICE_SIMPLE
static int isanalog (int ei)
{
-#ifndef INPUTDEVICE_SIMPLE
if (ei == INPUTEVENT_JOY1_HORIZ_POT || ei == INPUTEVENT_JOY1_HORIZ_POT_INV) {
analog_port[0][0] = 1;
return 1;
@@ -3449,60 +4036,66 @@ static int isanalog (int ei)
analog_port[1][1] = 1;
return 1;
}
-#endif
return 0;
}
+#endif
-static int isdigitalbutton (int ei)
+static int isdigitalbutton(int ei)
{
- if (ei == INPUTEVENT_JOY1_2ND_BUTTON) {
+ if (ei == INPUTEVENT_JOY1_2ND_BUTTON)
+ {
digital_port[0][1] = 1;
return 1;
}
- if (ei == INPUTEVENT_JOY1_3RD_BUTTON) {
+ if (ei == INPUTEVENT_JOY1_3RD_BUTTON)
+ {
digital_port[0][0] = 1;
return 1;
}
- if (ei == INPUTEVENT_JOY2_2ND_BUTTON) {
+ if (ei == INPUTEVENT_JOY2_2ND_BUTTON)
+ {
digital_port[1][1] = 1;
return 1;
}
- if (ei == INPUTEVENT_JOY2_3RD_BUTTON) {
+ if (ei == INPUTEVENT_JOY2_3RD_BUTTON)
+ {
digital_port[1][0] = 1;
return 1;
}
return 0;
}
-static void isqualifier (int ei)
+//static int islightpen(int ei)
+//{
+// if (ei >= INPUTEVENT_LIGHTPEN_FIRST && ei < INPUTEVENT_LIGHTPEN_LAST) {
+// lightpen_enabled = true;
+// return 1;
+// }
+// return 0;
+//}
+
+static void isqualifier(int ei)
{
}
-static void check_enable(int ei)
-{
- iscd32(ei);
- isparport(ei);
- ismouse(ei);
- isdigitalbutton(ei);
- isqualifier(ei);
-}
-
-static void scanevents (struct uae_prefs *p)
+static void scanevents(struct uae_prefs* p)
{
int i, j, k, ei;
- const struct inputevent *e;
- int n_joy = idev[IDTYPE_JOYSTICK].get_num ();
- int n_mouse = idev[IDTYPE_MOUSE].get_num ();
+ const struct inputevent* e;
+ int n_joy = idev[IDTYPE_JOYSTICK].get_num();
+ int n_mouse = idev[IDTYPE_MOUSE].get_num();
cd32_pad_enabled[0] = cd32_pad_enabled[1] = 0;
-#if !defined(INPUTDEVICE_SIMPLE) || defined(AMIBERRY)
+#ifndef INPUTDEVICE_SIMPLE
parport_joystick_enabled = 0;
#endif
mouse_port[0] = mouse_port[1] = 0;
qualifiers = 0;
- for (i = 0; i < NORMAL_JPORTS; i++) {
- for (j = 0; j < 2; j++) {
+ for (i = 0; i < NORMAL_JPORTS; i++)
+ {
+ for (j = 0; j < 2; j++)
+ {
digital_port[i][j] = 0;
#ifndef INPUTDEVICE_SIMPLE
analog_port[i][j] = 0;
@@ -3511,78 +4104,111 @@ static void scanevents (struct uae_prefs *p)
}
}
- for (i = 0; i < MAX_INPUT_DEVICES; i++) {
+ for (i = 0; i < MAX_INPUT_DEVICES; i++)
+ {
use_joysticks[i] = 0;
use_mice[i] = 0;
- for (k = 0; k < MAX_INPUT_SUB_EVENT; k++) {
- for (j = 0; j < ID_BUTTON_TOTAL; j++) {
-
- if ((joysticks[i].enabled && i < n_joy) || joysticks[i].enabled < 0) {
+ for (k = 0; k < MAX_INPUT_SUB_EVENT; k++)
+ {
+ for (j = 0; j < ID_BUTTON_TOTAL; j++)
+ {
+ if ((joysticks[i].enabled && i < n_joy) || joysticks[i].enabled < 0)
+ {
ei = joysticks[i].eventid[ID_BUTTON_OFFSET + j][k];
e = &events[ei];
- iscd32 (ei);
+ iscd32(ei);
+#ifndef INPUTDEVICE_SIMPLE
isparport (ei);
- ismouse (ei);
- isdigitalbutton (ei);
+#endif
+ ismouse(ei);
+ isdigitalbutton(ei);
+#ifndef INPUTDEVICE_SIMPLE
isqualifier (ei);
+#endif
if (joysticks[i].eventid[ID_BUTTON_OFFSET + j][k] > 0)
use_joysticks[i] = 1;
}
- if ((mice[i].enabled && i < n_mouse) || mice[i].enabled < 0) {
+ if ((mice[i].enabled && i < n_mouse) || mice[i].enabled < 0)
+ {
ei = mice[i].eventid[ID_BUTTON_OFFSET + j][k];
e = &events[ei];
- iscd32 (ei);
+ iscd32(ei);
+#ifndef INPUTDEVICE_SIMPLE
isparport (ei);
- ismouse (ei);
- isdigitalbutton (ei);
+#endif
+ ismouse(ei);
+ isdigitalbutton(ei);
+#ifndef INPUTDEVICE_SIMPLE
isqualifier (ei);
+#endif
if (mice[i].eventid[ID_BUTTON_OFFSET + j][k] > 0)
use_mice[i] = 1;
}
-
}
- for (j = 0; j < ID_AXIS_TOTAL; j++) {
-
- if ((joysticks[i].enabled && i < n_joy) || joysticks[i].enabled < 0) {
+ for (j = 0; j < ID_AXIS_TOTAL; j++)
+ {
+ if ((joysticks[i].enabled && i < n_joy) || joysticks[i].enabled < 0)
+ {
ei = joysticks[i].eventid[ID_AXIS_OFFSET + j][k];
- iscd32 (ei);
+ iscd32(ei);
+#ifndef INPUTDEVICE_SIMPLE
isparport (ei);
- ismouse (ei);
+#endif
+ ismouse(ei);
+#ifndef INPUTDEVICE_SIMPLE
isanalog (ei);
- isdigitalbutton (ei);
+#endif
+ isdigitalbutton(ei);
+#ifndef INPUTDEVICE_SIMPLE
isqualifier (ei);
+#endif
if (ei > 0)
use_joysticks[i] = 1;
}
- if ((mice[i].enabled && i < n_mouse) || mice[i].enabled < 0) {
+ if ((mice[i].enabled && i < n_mouse) || mice[i].enabled < 0)
+ {
ei = mice[i].eventid[ID_AXIS_OFFSET + j][k];
- iscd32 (ei);
+ iscd32(ei);
+#ifndef INPUTDEVICE_SIMPLE
isparport (ei);
- ismouse (ei);
+#endif
+ ismouse(ei);
+#ifndef INPUTDEVICE_SIMPLE
isanalog (ei);
- isdigitalbutton (ei);
+#endif
+ isdigitalbutton(ei);
+#ifndef INPUTDEVICE_SIMPLE
isqualifier (ei);
+#endif
if (ei > 0)
use_mice[i] = 1;
}
}
}
}
- memset (scancodeused, 0, sizeof scancodeused);
- for (i = 0; i < MAX_INPUT_DEVICES; i++) {
+ memset(scancodeused, 0, sizeof scancodeused);
+ for (i = 0; i < MAX_INPUT_DEVICES; i++)
+ {
use_keyboards[i] = 0;
- if (keyboards[i].enabled && i < idev[IDTYPE_KEYBOARD].get_num ()) {
+ if (keyboards[i].enabled && i < idev[IDTYPE_KEYBOARD].get_num())
+ {
j = 0;
- while (j < MAX_INPUT_DEVICE_EVENTS && keyboards[i].extra[j] >= 0) {
+ while (j < MAX_INPUT_DEVICE_EVENTS && keyboards[i].extra[j] >= 0)
+ {
use_keyboards[i] = 1;
- for (k = 0; k < MAX_INPUT_SUB_EVENT; k++) {
+ for (k = 0; k < MAX_INPUT_SUB_EVENT; k++)
+ {
ei = keyboards[i].eventid[j][k];
- iscd32 (ei);
+ iscd32(ei);
+#ifndef INPUTDEVICE_SIMPLE
isparport (ei);
- ismouse (ei);
- isdigitalbutton (ei);
+#endif
+ ismouse(ei);
+ isdigitalbutton(ei);
+#ifndef INPUTDEVICE_SIMPLE
isqualifier (ei);
+#endif
if (ei > 0)
scancodeused[i][keyboards[i].extra[j]] = ei;
}
@@ -3601,16 +4227,21 @@ static const int axistable[] = {
INPUTEVENT_JOY1_VERT, INPUTEVENT_JOY1_UP, INPUTEVENT_JOY1_DOWN,
INPUTEVENT_JOY2_HORIZ, INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT,
INPUTEVENT_JOY2_VERT, INPUTEVENT_JOY2_UP, INPUTEVENT_JOY2_DOWN,
+ INPUTEVENT_LIGHTPEN_HORIZ, INPUTEVENT_LIGHTPEN_LEFT, INPUTEVENT_LIGHTPEN_RIGHT,
+ INPUTEVENT_LIGHTPEN_VERT, INPUTEVENT_LIGHTPEN_UP, INPUTEVENT_LIGHTPEN_DOWN,
INPUTEVENT_PAR_JOY1_HORIZ, INPUTEVENT_PAR_JOY1_LEFT, INPUTEVENT_PAR_JOY1_RIGHT,
INPUTEVENT_PAR_JOY1_VERT, INPUTEVENT_PAR_JOY1_UP, INPUTEVENT_PAR_JOY1_DOWN,
INPUTEVENT_PAR_JOY2_HORIZ, INPUTEVENT_PAR_JOY2_LEFT, INPUTEVENT_PAR_JOY2_RIGHT,
INPUTEVENT_PAR_JOY2_VERT, INPUTEVENT_PAR_JOY2_UP, INPUTEVENT_PAR_JOY2_DOWN,
+ INPUTEVENT_MOUSE_CDTV_HORIZ, INPUTEVENT_MOUSE_CDTV_LEFT, INPUTEVENT_MOUSE_CDTV_RIGHT,
+ INPUTEVENT_MOUSE_CDTV_VERT, INPUTEVENT_MOUSE_CDTV_UP, INPUTEVENT_MOUSE_CDTV_DOWN,
-1
};
-int intputdevice_compa_get_eventtype (int evt, const int **axistablep)
+int intputdevice_compa_get_eventtype(int evt, const int** axistablep)
{
- for (int i = 0; axistable[i] >= 0; i += 3) {
+ for (int i = 0; axistable[i] >= 0; i += 3)
+ {
*axistablep = &axistable[i];
if (axistable[i] == evt)
return IDEV_WIDGET_AXIS;
@@ -3623,7 +4254,7 @@ int intputdevice_compa_get_eventtype (int evt, const int **axistablep)
return IDEV_WIDGET_BUTTON;
}
-static const int rem_port1[] = {
+static int rem_port1[] = {
INPUTEVENT_MOUSE1_HORIZ, INPUTEVENT_MOUSE1_VERT,
INPUTEVENT_JOY1_HORIZ, INPUTEVENT_JOY1_VERT,
#ifndef INPUTDEVICE_SIMPLE
@@ -3632,9 +4263,11 @@ static const int rem_port1[] = {
INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_2ND_BUTTON, INPUTEVENT_JOY1_3RD_BUTTON,
INPUTEVENT_JOY1_CD32_RED, INPUTEVENT_JOY1_CD32_BLUE, INPUTEVENT_JOY1_CD32_GREEN, INPUTEVENT_JOY1_CD32_YELLOW,
INPUTEVENT_JOY1_CD32_RWD, INPUTEVENT_JOY1_CD32_FFW, INPUTEVENT_JOY1_CD32_PLAY,
+ INPUTEVENT_MOUSE_CDTV_HORIZ, INPUTEVENT_MOUSE_CDTV_VERT,
+ INPUTEVENT_LIGHTPEN_HORIZ, INPUTEVENT_LIGHTPEN_VERT,
-1
};
-static const int rem_port2[] = {
+static int rem_port2[] = {
INPUTEVENT_MOUSE2_HORIZ, INPUTEVENT_MOUSE2_VERT,
INPUTEVENT_JOY2_HORIZ, INPUTEVENT_JOY2_VERT,
#ifndef INPUTDEVICE_SIMPLE
@@ -3647,101 +4280,150 @@ static const int rem_port2[] = {
-1, -1,
-1
};
-static const int rem_port3[] = {
+static int rem_port3[] = {
INPUTEVENT_PAR_JOY1_LEFT, INPUTEVENT_PAR_JOY1_RIGHT, INPUTEVENT_PAR_JOY1_UP, INPUTEVENT_PAR_JOY1_DOWN,
INPUTEVENT_PAR_JOY1_FIRE_BUTTON, INPUTEVENT_PAR_JOY1_2ND_BUTTON,
-1
};
-static const int rem_port4[] = {
+static int rem_port4[] = {
INPUTEVENT_PAR_JOY2_LEFT, INPUTEVENT_PAR_JOY2_RIGHT, INPUTEVENT_PAR_JOY2_UP, INPUTEVENT_PAR_JOY2_DOWN,
INPUTEVENT_PAR_JOY2_FIRE_BUTTON, INPUTEVENT_PAR_JOY2_2ND_BUTTON,
-1
};
-static const int *rem_ports[] = { rem_port1, rem_port2, rem_port3, rem_port4 };
-static const int ip_joy1[] = {
+static int* rem_ports[] = {rem_port1, rem_port2, rem_port3, rem_port4};
+static int af_port1[] = {
+ INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_CD32_RED,
+ -1
+};
+static int af_port2[] = {
+ INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_CD32_RED,
+ -1
+};
+static int af_port3[] = {
+ INPUTEVENT_PAR_JOY1_FIRE_BUTTON, INPUTEVENT_PAR_JOY1_2ND_BUTTON,
+ -1
+};
+static int af_port4[] = {
+ INPUTEVENT_PAR_JOY2_FIRE_BUTTON, INPUTEVENT_PAR_JOY2_2ND_BUTTON,
+ -1
+};
+static int* af_ports[] = {af_port1, af_port2, af_port3, af_port4};
+static int ip_joy1[] = {
INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT, INPUTEVENT_JOY1_UP, INPUTEVENT_JOY1_DOWN,
INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_2ND_BUTTON,
-1
};
-static const int ip_joy2[] = {
+static int ip_joy2[] = {
INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT, INPUTEVENT_JOY2_UP, INPUTEVENT_JOY2_DOWN,
INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_2ND_BUTTON,
-1
};
-static const int ip_joypad1[] = {
+static int ip_joypad1[] = {
INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT, INPUTEVENT_JOY1_UP, INPUTEVENT_JOY1_DOWN,
INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_2ND_BUTTON, INPUTEVENT_JOY1_3RD_BUTTON,
-1
};
-static const int ip_joypad2[] = {
+static int ip_joypad2[] = {
INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT, INPUTEVENT_JOY2_UP, INPUTEVENT_JOY2_DOWN,
INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_2ND_BUTTON, INPUTEVENT_JOY2_3RD_BUTTON,
-1
};
-static const int ip_joycd321[] = {
+static int ip_joycd321[] = {
INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT, INPUTEVENT_JOY1_UP, INPUTEVENT_JOY1_DOWN,
INPUTEVENT_JOY1_CD32_RED, INPUTEVENT_JOY1_CD32_BLUE, INPUTEVENT_JOY1_CD32_GREEN, INPUTEVENT_JOY1_CD32_YELLOW,
INPUTEVENT_JOY1_CD32_RWD, INPUTEVENT_JOY1_CD32_FFW, INPUTEVENT_JOY1_CD32_PLAY,
-1
};
-static const int ip_joycd322[] = {
+static int ip_joycd322[] = {
INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT, INPUTEVENT_JOY2_UP, INPUTEVENT_JOY2_DOWN,
INPUTEVENT_JOY2_CD32_RED, INPUTEVENT_JOY2_CD32_BLUE, INPUTEVENT_JOY2_CD32_GREEN, INPUTEVENT_JOY2_CD32_YELLOW,
INPUTEVENT_JOY2_CD32_RWD, INPUTEVENT_JOY2_CD32_FFW, INPUTEVENT_JOY2_CD32_PLAY,
-1
};
-static const int ip_parjoy1[] = {
+static int ip_parjoy1[] = {
INPUTEVENT_PAR_JOY1_LEFT, INPUTEVENT_PAR_JOY1_RIGHT, INPUTEVENT_PAR_JOY1_UP, INPUTEVENT_PAR_JOY1_DOWN,
INPUTEVENT_PAR_JOY1_FIRE_BUTTON, INPUTEVENT_PAR_JOY1_2ND_BUTTON,
-1
};
-static const int ip_parjoy2[] = {
+static int ip_parjoy2[] = {
INPUTEVENT_PAR_JOY2_LEFT, INPUTEVENT_PAR_JOY2_RIGHT, INPUTEVENT_PAR_JOY2_UP, INPUTEVENT_PAR_JOY2_DOWN,
INPUTEVENT_PAR_JOY2_FIRE_BUTTON, INPUTEVENT_PAR_JOY2_2ND_BUTTON,
-1
};
-static const int ip_parjoy1default[] = {
+static int ip_parjoy1default[] = {
INPUTEVENT_PAR_JOY1_LEFT, INPUTEVENT_PAR_JOY1_RIGHT, INPUTEVENT_PAR_JOY1_UP, INPUTEVENT_PAR_JOY1_DOWN,
INPUTEVENT_PAR_JOY1_FIRE_BUTTON,
-1
};
-static const int ip_parjoy2default[] = {
+static int ip_parjoy2default[] = {
INPUTEVENT_PAR_JOY2_LEFT, INPUTEVENT_PAR_JOY2_RIGHT, INPUTEVENT_PAR_JOY2_UP, INPUTEVENT_PAR_JOY2_DOWN,
INPUTEVENT_PAR_JOY2_FIRE_BUTTON,
-1
};
-static const int ip_mouse1[] = {
+static int ip_mouse1[] = {
INPUTEVENT_MOUSE1_LEFT, INPUTEVENT_MOUSE1_RIGHT, INPUTEVENT_MOUSE1_UP, INPUTEVENT_MOUSE1_DOWN,
INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_2ND_BUTTON,
-1
};
-static const int ip_mouse2[] = {
+static int ip_mouse2[] = {
INPUTEVENT_MOUSE2_LEFT, INPUTEVENT_MOUSE2_RIGHT, INPUTEVENT_MOUSE2_UP, INPUTEVENT_MOUSE2_DOWN,
INPUTEVENT_JOY2_FIRE_BUTTON, INPUTEVENT_JOY2_2ND_BUTTON,
-1
};
-static const int ip_analog1[] = {
+static int ip_mousecdtv[] =
+{
+ INPUTEVENT_MOUSE_CDTV_LEFT, INPUTEVENT_MOUSE_CDTV_RIGHT, INPUTEVENT_MOUSE_CDTV_UP, INPUTEVENT_MOUSE_CDTV_DOWN,
+ INPUTEVENT_JOY1_FIRE_BUTTON, INPUTEVENT_JOY1_2ND_BUTTON,
+ -1
+};
+static int ip_mediacdtv[] =
+{
+ INPUTEVENT_KEY_CDTV_PLAYPAUSE, INPUTEVENT_KEY_CDTV_STOP, INPUTEVENT_KEY_CDTV_PREV, INPUTEVENT_KEY_CDTV_NEXT,
+ -1
+};
+static int ip_arcadia[] = {
+ INPUTEVENT_SPC_ARCADIA_DIAGNOSTICS, INPUTEVENT_SPC_ARCADIA_PLAYER1, INPUTEVENT_SPC_ARCADIA_PLAYER2,
+ INPUTEVENT_SPC_ARCADIA_COIN1, INPUTEVENT_SPC_ARCADIA_COIN2,
+ -1
+};
+static int ip_lightpen1[] = {
+ INPUTEVENT_LIGHTPEN_HORIZ, INPUTEVENT_LIGHTPEN_VERT, INPUTEVENT_JOY1_3RD_BUTTON,
+ -1
+};
+static int ip_lightpen2[] = {
+ INPUTEVENT_LIGHTPEN_HORIZ, INPUTEVENT_LIGHTPEN_VERT, INPUTEVENT_JOY2_3RD_BUTTON,
+ -1
+};
+static int ip_analog1[] = {
INPUTEVENT_JOY1_HORIZ_POT, INPUTEVENT_JOY1_VERT_POT, INPUTEVENT_JOY1_LEFT, INPUTEVENT_JOY1_RIGHT,
-1
};
-static const int ip_analog2[] = {
+static int ip_analog2[] = {
INPUTEVENT_JOY2_HORIZ_POT, INPUTEVENT_JOY2_VERT_POT, INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT,
-1
};
-static void checkcompakb (int *kb, const int *srcmap)
+static int ip_arcadiaxa[] = {
+ -1
+};
+
+static void checkcompakb(int* kb, int* srcmap)
{
int found = 0, avail = 0;
int j, k;
k = j = 0;
- while (kb[j] >= 0) {
- struct uae_input_device *uid = &keyboards[0];
- while (kb[j] >= 0 && srcmap[k] >= 0) {
+ while (kb[j] >= 0)
+ {
+ struct uae_input_device* uid = &keyboards[0];
+ while (kb[j] >= 0 && srcmap[k] >= 0)
+ {
int id = kb[j];
- for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++) {
- if (uid->extra[l] == id) {
+ for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++)
+ {
+ if (uid->extra[l] == id)
+ {
avail++;
if (uid->eventid[l][0] == srcmap[k])
found++;
@@ -3758,16 +4440,24 @@ static void checkcompakb (int *kb, const int *srcmap)
if (avail != found || avail == 0)
return;
k = j = 0;
- while (kb[j] >= 0) {
- struct uae_input_device *uid = &keyboards[0];
- while (kb[j] >= 0) {
+ while (kb[j] >= 0)
+ {
+ struct uae_input_device* uid = &keyboards[0];
+ while (kb[j] >= 0)
+ {
int id = kb[j];
+ int evt0 = 0, evt1 = 0;
k = 0;
- while (keyboard_default[k].scancode >= 0) {
- if (keyboard_default[k].scancode == kb[j]) {
- for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++) {
- if (uid->extra[l] == id && uid->port[l][0] == 0) {
- for (int m = 0; m < MAX_INPUT_SUB_EVENT && keyboard_default[k].node[m].evt; m++) {
+ while (keyboard_default[k].scancode >= 0)
+ {
+ if (keyboard_default[k].scancode == kb[j])
+ {
+ for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++)
+ {
+ if (uid->extra[l] == id && uid->port[l][0] == 0)
+ {
+ for (int m = 0; m < MAX_INPUT_SUB_EVENT && keyboard_default[k].node[m].evt; m++)
+ {
uid->eventid[l][m] = keyboard_default[k].node[m].evt;
uid->port[l][m] = 0;
uid->flags[l][m] = 0;
@@ -3785,13 +4475,39 @@ static void checkcompakb (int *kb, const int *srcmap)
}
}
-static void inputdevice_sparerestore (struct uae_input_device *uid, int num, int sub)
+static void setautofireevent(struct uae_input_device* uid, int num, int sub, int af, int index)
{
- if (uid->port[num][SPARE_SUB_EVENT]) {
- uid->eventid[num][sub] = uid->eventid[num][SPARE_SUB_EVENT];
- uid->flags[num][sub] = uid->flags[num][SPARE_SUB_EVENT];
- uid->custom[num][sub] = uid->custom[num][SPARE_SUB_EVENT];
- } else {
+ if (!af)
+ return;
+ int* afp = af_ports[index];
+ for (int k = 0; afp[k] >= 0; k++)
+ {
+ if (afp[k] == uid->eventid[num][sub])
+ {
+ uid->flags[num][sub] &= ~ID_FLAG_AUTOFIRE_MASK;
+ if (af >= JPORT_AF_NORMAL)
+ uid->flags[num][sub] |= ID_FLAG_AUTOFIRE;
+#ifndef INPUTDEVICE_SIMPLE
+ if (af == JPORT_AF_TOGGLE)
+ uid->flags[num][sub] |= ID_FLAG_TOGGLE;
+ if (af == JPORT_AF_ALWAYS)
+ uid->flags[num][sub] |= ID_FLAG_INVERTTOGGLE;
+#endif
+ return;
+ }
+ }
+}
+
+static void inputdevice_sparerestore(struct uae_input_device* uid, int num, int sub)
+{
+ if (uid->port[num][SPARE_SUB_EVENT])
+ {
+ uid->eventid[num][sub] = uid->eventid[num][SPARE_SUB_EVENT];
+ uid->flags[num][sub] = uid->flags[num][SPARE_SUB_EVENT];
+ uid->custom[num][sub] = uid->custom[num][SPARE_SUB_EVENT];
+ }
+ else
+ {
uid->eventid[num][sub] = 0;
uid->flags[num][sub] = 0;
xfree (uid->custom[num][sub]);
@@ -3801,7 +4517,8 @@ static void inputdevice_sparerestore (struct uae_input_device *uid, int num, int
uid->flags[num][SPARE_SUB_EVENT] = 0;
uid->port[num][SPARE_SUB_EVENT] = 0;
uid->custom[num][SPARE_SUB_EVENT] = 0;
- if (uid->flags[num][MAX_INPUT_SUB_EVENT - 1] & ID_FLAG_RESERVEDGAMEPORTSCUSTOM) {
+ if (uid->flags[num][MAX_INPUT_SUB_EVENT - 1] & ID_FLAG_RESERVEDGAMEPORTSCUSTOM)
+ {
uid->eventid[num][MAX_INPUT_SUB_EVENT - 1] = 0;
uid->flags[num][MAX_INPUT_SUB_EVENT - 1] = 0;
uid->port[num][MAX_INPUT_SUB_EVENT - 1] = 0;
@@ -3809,42 +4526,62 @@ static void inputdevice_sparerestore (struct uae_input_device *uid, int num, int
}
}
-void inputdevice_sparecopy (struct uae_input_device *uid, int num, int sub)
+void inputdevice_sparecopy(struct uae_input_device* uid, int num, int sub)
{
if (uid->port[num][SPARE_SUB_EVENT] != 0)
return;
- if (uid->eventid[num][sub] <= 0 && uid->custom[num][sub] == NULL) {
+ if (uid->eventid[num][sub] <= 0 && uid->custom[num][sub] == NULL)
+ {
uid->eventid[num][SPARE_SUB_EVENT] = 0;
uid->flags[num][SPARE_SUB_EVENT] = 0;
uid->port[num][SPARE_SUB_EVENT] = 0;
xfree (uid->custom[num][SPARE_SUB_EVENT]);
uid->custom[num][SPARE_SUB_EVENT] = NULL;
- } else {
- uid->eventid[num][SPARE_SUB_EVENT] = uid->eventid[num][sub];
- uid->flags[num][SPARE_SUB_EVENT] = uid->flags[num][sub];
- uid->port[num][SPARE_SUB_EVENT] = MAX_JPORTS + 1;
- xfree (uid->custom[num][SPARE_SUB_EVENT]);
- uid->custom[num][SPARE_SUB_EVENT] = uid->custom[num][sub];
- uid->custom[num][sub] = NULL;
- }
+ }
+ else
+ {
+ uid->eventid[num][SPARE_SUB_EVENT] = uid->eventid[num][sub];
+ uid->flags[num][SPARE_SUB_EVENT] = uid->flags[num][sub];
+ uid->port[num][SPARE_SUB_EVENT] = MAX_JPORTS + 1;
+ xfree (uid->custom[num][SPARE_SUB_EVENT]);
+ uid->custom[num][SPARE_SUB_EVENT] = uid->custom[num][sub];
+ uid->custom[num][sub] = NULL;
+ }
}
-static void setcompakb (struct uae_prefs *p, int *kb, const int *srcmap, int index, int af)
+static void setcompakb(struct uae_prefs* p, int* kb, int* srcmap, int index, int af)
{
int j, k;
k = j = 0;
- while (kb[j] >= 0 && srcmap[k] >= 0) {
- while (kb[j] >= 0) {
+ while (kb[j] >= 0 && srcmap[k] >= 0)
+ {
+ while (kb[j] >= 0)
+ {
int id = kb[j];
- // default and active KB only
- for (int m = 0; m < MAX_INPUT_DEVICES; m++) {
- struct uae_input_device *uid = &keyboards[m];
- if (m == 0 || uid->enabled) {
- for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++) {
- if (uid->extra[l] == id) {
- setcompakbevent(p, uid, l, srcmap[k], index, af);
- break;
+ for (int m = 0; m < MAX_INPUT_DEVICES; m++)
+ {
+ struct uae_input_device* uid = &keyboards[m];
+ for (int l = 0; l < MAX_INPUT_DEVICE_EVENTS; l++)
+ {
+ if (uid->extra[l] == id)
+ {
+ inputdevice_sparecopy(uid, l, 0);
+
+ if (p->jports[index].nokeyboardoverride && uid->port[l][0] == 0)
+ {
+ uid->eventid[l][MAX_INPUT_SUB_EVENT - 1] = uid->eventid[l][0];
+ uid->flags[l][MAX_INPUT_SUB_EVENT - 1] = uid->flags[l][0] | ID_FLAG_RESERVEDGAMEPORTSCUSTOM;
+ uid->custom[l][MAX_INPUT_SUB_EVENT - 1] = my_strdup(uid->custom[l][0]);
+ uid->eventid[l][MAX_INPUT_SUB_EVENT - 1] = uid->eventid[l][0];
}
+
+ uid->eventid[l][0] = srcmap[k];
+ uid->flags[l][0] &= COMPA_RESERVED_FLAGS;
+ uid->port[l][0] = index + 1;
+ xfree (uid->custom[l][0]);
+ uid->custom[l][0] = NULL;
+ setautofireevent(uid, l, 0, af, index);
+ break;
}
}
}
@@ -3855,50 +4592,61 @@ static void setcompakb (struct uae_prefs *p, int *kb, const int *srcmap, int ind
}
}
-int inputdevice_get_compatibility_input (struct uae_prefs *prefs, int index, int *typelist, int *inputlist, const int **at)
+int inputdevice_get_compatibility_input(struct uae_prefs* prefs, int index, int* typelist, int* inputlist, const int** at)
{
if (index >= MAX_JPORTS || joymodes[index] < 0)
return -1;
if (typelist != NULL)
- *typelist = joymodes[index];
+ *typelist = joymodes[index];
if (at != NULL)
- *at = axistable;
+ *at = axistable;
if (inputlist == NULL)
return -1;
-
+
//write_log (_T("%d %p %p\n"), *typelist, *inputlist, *at);
int cnt;
- for (cnt = 0; joyinputs[index] && joyinputs[index][cnt] >= 0; cnt++) {
+ for (cnt = 0; joyinputs[index] && joyinputs[index][cnt] >= 0; cnt++)
+ {
inputlist[cnt] = joyinputs[index][cnt];
}
inputlist[cnt] = -1;
// find custom events (custom event = event that is mapped to same port but not included in joyinputs[]
int devnum = 0;
- while (inputdevice_get_device_status (devnum) >= 0) {
- for (int j = 0; j < inputdevice_get_widget_num (devnum); j++) {
- for (int sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++) {
+ while (inputdevice_get_device_status(devnum) >= 0)
+ {
+ for (int j = 0; j < inputdevice_get_widget_num(devnum); j++)
+ {
+ for (int sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++)
+ {
int port, k, l;
uae_u64 flags;
bool ignore = false;
- int evtnum2 = inputdevice_get_mapping (devnum, j, &flags, &port, NULL, NULL, sub);
+ int evtnum2 = inputdevice_get_mapping(devnum, j, &flags, &port, NULL, NULL, sub);
if (port - 1 != index)
continue;
- for (k = 0; axistable[k] >= 0; k += 3) {
- if (evtnum2 == axistable[k] || evtnum2 == axistable[k + 1] || evtnum2 == axistable[k + 2]) {
- for (l = 0; inputlist[l] >= 0; l++) {
- if (inputlist[l] == axistable[k] || inputlist[l] == axistable[k + 1] || inputlist[l] == axistable[k + 1]) {
+ for (k = 0; axistable[k] >= 0; k += 3)
+ {
+ if (evtnum2 == axistable[k] || evtnum2 == axistable[k + 1] || evtnum2 == axistable[k + 2])
+ {
+ for (l = 0; inputlist[l] >= 0; l++)
+ {
+ if (inputlist[l] == axistable[k] || inputlist[l] == axistable[k + 1] || inputlist[l] == axistable[k + 1])
+ {
ignore = true;
}
}
}
}
- if (!ignore) {
- for (k = 0; inputlist[k] >= 0; k++) {
+ if (!ignore)
+ {
+ for (k = 0; inputlist[k] >= 0; k++)
+ {
if (evtnum2 == inputlist[k])
break;
}
- if (inputlist[k] < 0) {
+ if (inputlist[k] < 0)
+ {
inputlist[k] = evtnum2;
inputlist[k + 1] = -1;
cnt++;
@@ -3908,14 +4656,18 @@ int inputdevice_get_compatibility_input (struct uae_prefs *prefs, int index, int
}
devnum++;
}
+
return cnt;
}
-static void clearevent (struct uae_input_device *uid, int evt)
+static void clearevent(struct uae_input_device* uid, int evt)
{
- for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
- for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
- if (uid->eventid[i][j] == evt) {
+ for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
+ {
+ for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
+ if (uid->eventid[i][j] == evt)
+ {
uid->eventid[i][j] = 0;
uid->flags[i][j] &= COMPA_RESERVED_FLAGS;
xfree (uid->custom[i][j]);
@@ -3924,40 +4676,50 @@ static void clearevent (struct uae_input_device *uid, int evt)
}
}
}
-static void clearkbrevent (struct uae_input_device *uid, int evt)
+
+static void clearkbrevent(struct uae_input_device* uid, int evt)
{
- for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
- for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
- if (uid->eventid[i][j] == evt) {
+ for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
+ {
+ for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
+ if (uid->eventid[i][j] == evt)
+ {
uid->eventid[i][j] = 0;
uid->flags[i][j] &= COMPA_RESERVED_FLAGS;
xfree (uid->custom[i][j]);
uid->custom[i][j] = NULL;
if (j == 0)
- set_kbr_default_event (uid, keyboard_default, i);
+ set_kbr_default_event(uid, keyboard_default, i);
}
}
}
}
-static void resetjport (struct uae_prefs *prefs, int index)
+static void resetjport(struct uae_prefs* prefs, int index)
{
- const int *p = rem_ports[index];
- while (*p >= 0) {
+ int* p = rem_ports[index];
+ while (*p >= 0)
+ {
int evtnum = *p++;
- for (int l = 0; l < MAX_INPUT_DEVICES; l++) {
- clearevent (&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum);
- clearevent (&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum);
- clearkbrevent (&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum);
+ for (int l = 0; l < MAX_INPUT_DEVICES; l++)
+ {
+ clearevent(&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum);
+ clearevent(&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum);
+ clearkbrevent(&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum);
}
- for (int i = 0; axistable[i] >= 0; i += 3) {
- if (evtnum == axistable[i] || evtnum == axistable[i + 1] || evtnum == axistable[i + 2]) {
- for (int j = 0; j < 3; j++) {
+ for (int i = 0; axistable[i] >= 0; i += 3)
+ {
+ if (evtnum == axistable[i] || evtnum == axistable[i + 1] || evtnum == axistable[i + 2])
+ {
+ for (int j = 0; j < 3; j++)
+ {
int evtnum2 = axistable[i + j];
- for (int l = 0; l < MAX_INPUT_DEVICES; l++) {
- clearevent (&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum2);
- clearevent (&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum2);
- clearkbrevent (&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum2);
+ for (int l = 0; l < MAX_INPUT_DEVICES; l++)
+ {
+ clearevent(&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum2);
+ clearevent(&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum2);
+ clearkbrevent(&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum2);
}
}
break;
@@ -3966,36 +4728,41 @@ static void resetjport (struct uae_prefs *prefs, int index)
}
}
-static void remove_compa_config (struct uae_prefs *prefs, int index)
+static void remove_compa_config(struct uae_prefs* prefs, int index)
{
int typelist;
- const int *atpp;
+ const int* atp;
int inputlist[MAX_COMPA_INPUTLIST];
- if (inputdevice_get_compatibility_input (prefs, index, &typelist, inputlist, &atpp) <= 0)
+ if (inputdevice_get_compatibility_input(prefs, index, &typelist, inputlist, &atp) <= 0)
return;
- for (int i = 0; inputlist[i] >= 0; i++) {
+ for (int i = 0; inputlist[i] >= 0; i++)
+ {
int evtnum = inputlist[i];
- const int *atp = atpp;
int atpidx = 0;
- while (*atp >= 0) {
- if (*atp == evtnum) {
+ while (*atp >= 0)
+ {
+ if (*atp == evtnum)
+ {
atp++;
atpidx = 2;
break;
}
- if (atp[1] == evtnum || atp[2] == evtnum) {
+ if (atp[1] == evtnum || atp[2] == evtnum)
+ {
atpidx = 1;
break;
}
atp += 3;
}
- while (atpidx >= 0) {
- for (int l = 0; l < MAX_INPUT_DEVICES; l++) {
- clearevent (&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum);
- clearevent (&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum);
- clearkbrevent (&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum);
+ while (atpidx >= 0)
+ {
+ for (int l = 0; l < MAX_INPUT_DEVICES; l++)
+ {
+ clearevent(&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum);
+ clearevent(&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum);
+ clearkbrevent(&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], evtnum);
}
evtnum = *atp++;
atpidx--;
@@ -4003,36 +4770,50 @@ static void remove_compa_config (struct uae_prefs *prefs, int index)
}
}
-static void cleardev_custom (struct uae_input_device *uid, int num, int index)
+static void cleardevgp(struct uae_input_device* uid, int num, bool nocustom, int index)
{
- for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
- for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
- if (uid[num].port[i][j] == index + 1) {
+ for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
+ {
+ for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
+ if (uid[num].port[i][j] == index + 1)
+ {
+ if (nocustom && (uid[num].flags[i][j] & ID_FLAG_GAMEPORTSCUSTOM_MASK))
+ continue;
uid[num].eventid[i][j] = 0;
uid[num].flags[i][j] &= COMPA_RESERVED_FLAGS;
xfree (uid[num].custom[i][j]);
uid[num].custom[i][j] = NULL;
uid[num].port[i][j] = 0;
if (uid[num].port[i][SPARE_SUB_EVENT])
- inputdevice_sparerestore (&uid[num], i, j);
+ inputdevice_sparerestore(&uid[num], i, j);
}
}
}
}
-static void cleardevkbr_custom(struct uae_input_device *uid, int num, int index)
+
+static void cleardevkbrgp(struct uae_input_device* uid, int num, bool nocustom, int index)
{
- for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
- for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
- if (uid[num].port[i][j] == index + 1) {
+ for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
+ {
+ for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
+ if (uid[num].port[i][j] == index + 1)
+ {
+ if (nocustom && (uid[num].flags[i][j] & ID_FLAG_GAMEPORTSCUSTOM_MASK))
+ continue;
uid[num].eventid[i][j] = 0;
uid[num].flags[i][j] &= COMPA_RESERVED_FLAGS;
xfree (uid[num].custom[i][j]);
uid[num].custom[i][j] = NULL;
uid[num].port[i][j] = 0;
- if (uid[num].port[i][SPARE_SUB_EVENT]) {
- inputdevice_sparerestore (&uid[num], i, j);
- } else if (j == 0) {
- set_kbr_default_event (&uid[num], keyboard_default, i);
+ if (uid[num].port[i][SPARE_SUB_EVENT])
+ {
+ inputdevice_sparerestore(&uid[num], i, j);
+ }
+ else if (j == 0)
+ {
+ set_kbr_default_event(&uid[num], keyboard_default, i);
}
}
}
@@ -4040,44 +4821,50 @@ static void cleardevkbr_custom(struct uae_input_device *uid, int num, int index)
}
// remove all gameports mappings mapped to port 'index'
-static void remove_custom_config (struct uae_prefs *prefs, int index)
+static void remove_custom_config(struct uae_prefs* prefs, bool nocustom, int index)
{
- for (int l = 0; l < MAX_INPUT_DEVICES; l++) {
- cleardev_custom(joysticks, l, index);
- cleardev_custom(mice, l, index);
- cleardevkbr_custom (keyboards, l, index);
+ for (int l = 0; l < MAX_INPUT_DEVICES; l++)
+ {
+ cleardevgp(joysticks, l, nocustom, index);
+ cleardevgp(mice, l, nocustom, index);
+ cleardevkbrgp(keyboards, l, nocustom, index);
}
}
// prepare port for custom mapping, remove all current Amiga side device mappings
-void inputdevice_compa_prepare_custom (struct uae_prefs *prefs, int index, int newmode, bool removeold)
+void inputdevice_compa_prepare_custom(struct uae_prefs *prefs, int index, int newmode, bool removeold)
{
int mode = prefs->jports[index].mode;
if (newmode >= 0) {
mode = newmode;
- } else if (mode == 0) {
+ }
+ else if (mode == 0) {
mode = index == 0 ? JSEM_MODE_WHEELMOUSE : (prefs->cs_cd32cd ? JSEM_MODE_JOYSTICK_CD32 : JSEM_MODE_JOYSTICK);
}
prefs->jports[index].mode = mode;
if (removeold) {
- remove_compa_config (prefs, index);
- remove_custom_config (prefs, index);
- }
-}
-// clear device before switching to new one
-void inputdevice_compa_clear (struct uae_prefs *prefs, int index)
-{
- freejport (prefs, index);
- resetjport (prefs, index);
- remove_compa_config (prefs, index);
+ prefs->jports_custom[JSEM_GETCUSTOMIDX(index, prefs)].custom[0] = 0;
+ remove_compa_config(prefs, index);
+ remove_custom_config(prefs, false, index);
+ }
}
-static void cleardev (struct uae_input_device *uid, int num)
+// clear device before switching to new one
+void inputdevice_compa_clear(struct uae_prefs* prefs, int index)
{
- for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
- inputdevice_sparecopy (&uid[num], i, 0);
- for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
+ freejport(prefs, index);
+ resetjport(prefs, index);
+ remove_compa_config(prefs, index);
+}
+
+static void cleardev(struct uae_input_device* uid, int num)
+{
+ for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
+ {
+ inputdevice_sparecopy(&uid[num], i, 0);
+ for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
uid[num].eventid[i][j] = 0;
uid[num].flags[i][j] = 0;
xfree (uid[num].custom[i][j]);
@@ -4086,79 +4873,96 @@ static void cleardev (struct uae_input_device *uid, int num)
}
}
-static void enablejoydevice (struct uae_input_device *uid, bool gameportsmode, int evtnum)
+static void enablejoydevice(struct uae_input_device* uid, bool gameportsmode, int evtnum)
{
- for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
- for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
- if ((gameportsmode && uid->eventid[i][j] == evtnum) || uid->port[i][j] > 0) {
- if (!uid->enabled)
- uid->enabled = -1;
+ for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
+ {
+ for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
+ if ((gameportsmode && uid->eventid[i][j] == evtnum) || uid->port[i][j] > 0)
+ {
+ uid->enabled = 1;
}
}
}
}
-static void setjoydevices (struct uae_prefs *prefs, bool gameportsmode, int port)
+static void setjoydevices(struct uae_prefs* prefs, bool gameportsmode, int port)
{
- for (int i = 0; joyinputs[port] && joyinputs[port][i] >= 0; i++) {
+ for (int i = 0; joyinputs[port] && joyinputs[port][i] >= 0; i++)
+ {
int evtnum = joyinputs[port][i];
- for (int l = 0; l < MAX_INPUT_DEVICES; l++) {
- enablejoydevice (&joysticks[l], gameportsmode, evtnum);
- enablejoydevice (&mice[l], gameportsmode, evtnum);
- //enablejoydevice (&keyboards[l], gameportsmode, evtnum);
+ for (int l = 0; l < MAX_INPUT_DEVICES; l++)
+ {
+ enablejoydevice(&joysticks[l], gameportsmode, evtnum);
+ enablejoydevice(&mice[l], gameportsmode, evtnum);
+ enablejoydevice(&keyboards[l], gameportsmode, evtnum);
}
- for (int k = 0; axistable[k] >= 0; k += 3) {
- if (evtnum == axistable[k] || evtnum == axistable[k + 1] || evtnum == axistable[k + 2]) {
- for (int j = 0; j < 3; j++) {
+ for (int k = 0; axistable[k] >= 0; k += 3)
+ {
+ if (evtnum == axistable[k] || evtnum == axistable[k + 1] || evtnum == axistable[k + 2])
+ {
+ for (int j = 0; j < 3; j++)
+ {
int evtnum2 = axistable[k + j];
- for (int l = 0; l < MAX_INPUT_DEVICES; l++) {
- enablejoydevice (&joysticks[l], gameportsmode, evtnum2);
- enablejoydevice (&mice[l], gameportsmode, evtnum2);
- //enablejoydevice (&keyboards[l], gameportsmode, evtnum2);
+ for (int l = 0; l < MAX_INPUT_DEVICES; l++)
+ {
+ enablejoydevice(&joysticks[l], gameportsmode, evtnum2);
+ enablejoydevice(&mice[l], gameportsmode, evtnum2);
+ enablejoydevice(&keyboards[l], gameportsmode, evtnum2);
}
}
break;
}
}
-
}
}
-static void setjoyinputs (struct uae_prefs *prefs, int port)
+static void setjoyinputs(struct uae_prefs* prefs, int port)
{
joyinputs[port] = NULL;
switch (joymodes[port])
{
- case JSEM_MODE_JOYSTICK:
- if (port >= 2)
- joyinputs[port] = port == 3 ? ip_parjoy2 : ip_parjoy1;
- else
- joyinputs[port] = port == 1 ? ip_joy2 : ip_joy1;
- break;
- case JSEM_MODE_GAMEPAD:
- joyinputs[port] = port ? ip_joypad2 : ip_joypad1;
- break;
- case JSEM_MODE_JOYSTICK_CD32:
- joyinputs[port] = port ? ip_joycd322 : ip_joycd321;
- break;
- case JSEM_MODE_JOYSTICK_ANALOG:
- joyinputs[port] = port ? ip_analog2 : ip_analog1;
- break;
- case JSEM_MODE_WHEELMOUSE:
- case JSEM_MODE_MOUSE:
- joyinputs[port] = port ? ip_mouse2 : ip_mouse1;
- break;
+ case JSEM_MODE_JOYSTICK:
+ if (port >= 2)
+ joyinputs[port] = port == 3 ? ip_parjoy2 : ip_parjoy1;
+ else
+ joyinputs[port] = port == 1 ? ip_joy2 : ip_joy1;
+ break;
+ case JSEM_MODE_GAMEPAD:
+ joyinputs[port] = port ? ip_joypad2 : ip_joypad1;
+ break;
+ case JSEM_MODE_JOYSTICK_CD32:
+ joyinputs[port] = port ? ip_joycd322 : ip_joycd321;
+ break;
+ case JSEM_MODE_JOYSTICK_ANALOG:
+ joyinputs[port] = port ? ip_analog2 : ip_analog1;
+ break;
+ case JSEM_MODE_WHEELMOUSE:
+ case JSEM_MODE_MOUSE:
+ joyinputs[port] = port ? ip_mouse2 : ip_mouse1;
+ break;
+ case JSEM_MODE_LIGHTPEN:
+ joyinputs[port] = port ? ip_lightpen2 : ip_lightpen1;
+ break;
+ case JSEM_MODE_MOUSE_CDTV:
+ joyinputs[port] = ip_mousecdtv;
+ break;
}
//write_log (_T("joyinput %d = %p\n"), port, joyinputs[port]);
}
-static void setautofire (struct uae_input_device *uid, int port, int af)
+static void setautofire(struct uae_input_device* uid, int port, int af)
{
- const int *afp = af_ports[port];
- for (int k = 0; afp[k] >= 0; k++) {
- for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
- for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
- if (uid->eventid[i][j] == afp[k]) {
+ int* afp = af_ports[port];
+ for (int k = 0; afp[k] >= 0; k++)
+ {
+ for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
+ {
+ for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
+ if (uid->eventid[i][j] == afp[k])
+ {
uid->flags[i][j] &= ~ID_FLAG_AUTOFIRE_MASK;
if (af >= JPORT_AF_NORMAL)
uid->flags[i][j] |= ID_FLAG_AUTOFIRE;
@@ -4174,58 +4978,77 @@ static void setautofire (struct uae_input_device *uid, int port, int af)
}
}
-static void setautofires (struct uae_prefs *prefs, int port, int af)
+static void setautofires(struct uae_prefs* prefs, int port, int af)
{
- for (int l = 0; l < MAX_INPUT_DEVICES; l++) {
- setautofire (&joysticks[l], port, af);
- setautofire (&mice[l], port, af);
- setautofire (&keyboards[l], port, af);
+ for (int l = 0; l < MAX_INPUT_DEVICES; l++)
+ {
+ setautofire(&joysticks[l], port, af);
+ setautofire(&mice[l], port, af);
+ setautofire(&keyboards[l], port, af);
}
}
// merge gameport settings with current input configuration
-static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
+static void compatibility_copy(struct uae_prefs* prefs, bool gameports)
{
- int used[MAX_INPUT_DEVICES] = { 0 };
+ int used[MAX_INPUT_DEVICES] = {0};
int i, joy;
- for (i = 0; i < MAX_JPORTS; i++) {
+ for (i = 0; i < MAX_JPORTS; i++)
+ {
joymodes[i] = prefs->jports[i].mode;
- joyinputs[i]= NULL;
- // remove all mappings from this port
+ joyinputs[i] = NULL;
+ // remove all mappings from this port, except if custom
if (gameports)
- remove_compa_config (prefs, i);
- remove_custom_config (prefs, i);
- setjoyinputs (prefs, i);
+ remove_compa_config(prefs, i);
+ remove_custom_config(prefs, false, i);
+ setjoyinputs(prefs, i);
}
- for (i = 0; i < 2; i++) {
- if (prefs->jports[i].id >= 0 && joymodes[i] <= 0) {
+ for (i = 0; i < 2; i++)
+ {
+ int af = prefs->jports[i].autofire;
+ if (prefs->jports[i].id >= 0 && joymodes[i] <= 0)
+ {
int mode = prefs->jports[i].mode;
- if (jsem_ismouse (i, prefs) >= 0) {
+ if (jsem_ismouse(i, prefs) >= 0)
+ {
switch (mode)
{
- case JSEM_MODE_DEFAULT:
- case JSEM_MODE_MOUSE:
- case JSEM_MODE_WHEELMOUSE:
- default:
+ case JSEM_MODE_DEFAULT:
+ case JSEM_MODE_MOUSE:
+ case JSEM_MODE_WHEELMOUSE:
+ default:
joymodes[i] = JSEM_MODE_WHEELMOUSE;
joyinputs[i] = i ? ip_mouse2 : ip_mouse1;
break;
+#ifndef INPUTDEVICE_SIMPLE
+ case JSEM_MODE_LIGHTPEN:
+ joymodes[i] = JSEM_MODE_LIGHTPEN;
+ joyinputs[i] = i ? ip_lightpen2 : ip_lightpen1;
+ break;
+ case JSEM_MODE_MOUSE_CDTV:
+ joymodes[i] = JSEM_MODE_MOUSE_CDTV;
+ joyinputs[i] = ip_mousecdtv;
+ break;
+#endif
}
- } else if (jsem_isjoy (i, prefs) >= 0) {
+ }
+ else if (jsem_isjoy(i, prefs) >= 0)
+ {
switch (mode)
{
- case JSEM_MODE_DEFAULT:
- case JSEM_MODE_JOYSTICK:
+ case JSEM_MODE_DEFAULT:
+ case JSEM_MODE_JOYSTICK:
#ifndef INPUTDEVICE_SIMPLE
case JSEM_MODE_GAMEPAD:
#endif
- case JSEM_MODE_JOYSTICK_CD32:
- default:
+ case JSEM_MODE_JOYSTICK_CD32:
+ default:
{
bool iscd32 = mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd);
- if (iscd32) {
+ if (iscd32)
+ {
joymodes[i] = JSEM_MODE_JOYSTICK_CD32;
joyinputs[i] = i ? ip_joycd322 : ip_joycd321;
#ifndef INPUTDEVICE_SIMPLE
@@ -4233,7 +5056,9 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
joymodes[i] = JSEM_MODE_GAMEPAD;
joyinputs[i] = i ? ip_joypad2 : ip_joypad1;
#endif
- } else {
+ }
+ else
+ {
joymodes[i] = JSEM_MODE_JOYSTICK;
joyinputs[i] = i ? ip_joy2 : ip_joy1;
}
@@ -4245,13 +5070,25 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
joyinputs[i] = i ? ip_analog2 : ip_analog1;
break;
#endif
- case JSEM_MODE_MOUSE:
- case JSEM_MODE_WHEELMOUSE:
- joymodes[i] = JSEM_MODE_WHEELMOUSE;
- joyinputs[i] = i ? ip_mouse2 : ip_mouse1;
+ case JSEM_MODE_MOUSE:
+ case JSEM_MODE_WHEELMOUSE:
+ joymodes[i] = JSEM_MODE_WHEELMOUSE;
+ joyinputs[i] = i ? ip_mouse2 : ip_mouse1;
+ break;
+#ifndef INPUTDEVICE_SIMPLE
+ case JSEM_MODE_LIGHTPEN:
+ joymodes[i] = JSEM_MODE_LIGHTPEN;
+ joyinputs[i] = i ? ip_lightpen2 : ip_lightpen1;
break;
+ case JSEM_MODE_MOUSE_CDTV:
+ joymodes[i] = JSEM_MODE_MOUSE_CDTV;
+ joyinputs[i] = ip_mousecdtv;
+ break;
+#endif
}
- } else if (prefs->jports[i].id >= 0) {
+ }
+ else if (prefs->jports[i].id >= 0)
+ {
joymodes[i] = i ? JSEM_MODE_JOYSTICK : JSEM_MODE_WHEELMOUSE;
joyinputs[i] = i ? ip_joy2 : ip_mouse1;
}
@@ -4261,6 +5098,7 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
#ifndef INPUTDEVICE_SIMPLE
for (i = 2; i < MAX_JPORTS; i++) {
if (prefs->jports[i].id >= 0 && joymodes[i] <= 0) {
+ int mode = prefs->jports[i].mode;
if (jsem_isjoy (i, prefs) >= 0) {
joymodes[i] = JSEM_MODE_JOYSTICK;
joyinputs[i] = i == 3 ? ip_parjoy2 : ip_parjoy1;
@@ -4272,26 +5110,29 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
}
#endif
- for (i = 0; i < 2; i++) {
+ for (i = 0; i < 2; i++)
+ {
int af = prefs->jports[i].autofire;
- if (prefs->jports[i].id >= 0) {
+ if (prefs->jports[i].id >= 0)
+ {
int mode = prefs->jports[i].mode;
- if ((joy = jsem_ismouse (i, prefs)) >= 0) {
+ if ((joy = jsem_ismouse(i, prefs)) >= 0)
+ {
if (gameports)
- cleardev (mice, joy);
+ cleardev(mice, joy);
switch (mode)
{
case JSEM_MODE_DEFAULT:
case JSEM_MODE_MOUSE:
case JSEM_MODE_WHEELMOUSE:
default:
- input_get_default_mouse (mice, joy, i, af, !gameports, mode != JSEM_MODE_MOUSE, false);
+ input_get_default_mouse(mice, joy, i, af, !gameports, mode != JSEM_MODE_MOUSE, false);
joymodes[i] = JSEM_MODE_WHEELMOUSE;
break;
case JSEM_MODE_JOYSTICK:
case JSEM_MODE_GAMEPAD:
case JSEM_MODE_JOYSTICK_CD32:
- input_get_default_joystick (mice, joy, i, af, mode, !gameports, true);
+ input_get_default_joystick(mice, joy, i, af, mode, !gameports, true);
joymodes[i] = mode;
break;
#ifndef INPUTDEVICE_SIMPLE
@@ -4301,20 +5142,23 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
break;
#endif
}
- _tcsncpy (prefs->jports[i].idc.name, idev[IDTYPE_MOUSE].get_friendlyname (joy), MAX_JPORTNAME - 1);
- _tcsncpy (prefs->jports[i].idc.configname, idev[IDTYPE_MOUSE].get_uniquename (joy), MAX_JPORTNAME - 1);
+ _tcsncpy(prefs->jports[i].idc.name, idev[IDTYPE_MOUSE].get_friendlyname (joy), MAX_JPORTNAME - 1);
+ _tcsncpy(prefs->jports[i].idc.configname, idev[IDTYPE_MOUSE].get_uniquename (joy), MAX_JPORTNAME - 1);
}
}
}
- for (i = 1; i >= 0; i--) {
+ for (i = 1; i >= 0; i--)
+ {
int af = prefs->jports[i].autofire;
- if (prefs->jports[i].id >= 0) {
+ if (prefs->jports[i].id >= 0)
+ {
int mode = prefs->jports[i].mode;
- joy = jsem_isjoy (i, prefs);
- if (joy >= 0) {
+ joy = jsem_isjoy(i, prefs);
+ if (joy >= 0)
+ {
if (gameports)
- cleardev (joysticks, joy);
+ cleardev(joysticks, joy);
switch (mode)
{
case JSEM_MODE_DEFAULT:
@@ -4324,19 +5168,19 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
#endif
case JSEM_MODE_JOYSTICK_CD32:
default:
- {
- bool iscd32 = mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd);
- input_get_default_joystick (joysticks, joy, i, af, mode, !gameports, false);
- if (iscd32)
- joymodes[i] = JSEM_MODE_JOYSTICK_CD32;
+ {
+ bool iscd32 = mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd);
+ input_get_default_joystick(joysticks, joy, i, af, mode, !gameports, false);
+ if (iscd32)
+ joymodes[i] = JSEM_MODE_JOYSTICK_CD32;
#ifndef INPUTDEVICE_SIMPLE
else if (mode == JSEM_MODE_GAMEPAD)
joymodes[i] = JSEM_MODE_GAMEPAD;
#endif
- else
- joymodes[i] = JSEM_MODE_JOYSTICK;
- break;
- }
+ else
+ joymodes[i] = JSEM_MODE_JOYSTICK;
+ break;
+ }
#ifndef INPUTDEVICE_SIMPLE
case JSEM_MODE_JOYSTICK_ANALOG:
input_get_default_joystick_analog (joysticks, joy, i, af, !gameports, false);
@@ -4345,46 +5189,59 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
#endif
case JSEM_MODE_MOUSE:
case JSEM_MODE_WHEELMOUSE:
- input_get_default_mouse (joysticks, joy, i, af, !gameports, mode == JSEM_MODE_WHEELMOUSE, true);
+ input_get_default_mouse(joysticks, joy, i, af, !gameports, mode == JSEM_MODE_WHEELMOUSE, true);
joymodes[i] = JSEM_MODE_WHEELMOUSE;
break;
+#ifndef INPUTDEVICE_SIMPLE
+ case JSEM_MODE_MOUSE_CDTV:
+ joymodes[i] = JSEM_MODE_MOUSE_CDTV;
+ input_get_default_joystick (joysticks, joy, i, af, mode, !gameports, false);
+ break;
+#endif
}
- _tcsncpy (prefs->jports[i].idc.name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1);
- _tcsncpy (prefs->jports[i].idc.configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1);
+ _tcsncpy(prefs->jports[i].idc.name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1);
+ _tcsncpy(prefs->jports[i].idc.configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1);
used[joy] = 1;
}
}
}
- if (gameports) {
+ if (gameports)
+ {
// replace possible old mappings with default keyboard mapping
- for (i = KBR_DEFAULT_MAP_FIRST; i <= KBR_DEFAULT_MAP_LAST; i++) {
- checkcompakb (keyboard_default_kbmaps[i], ip_joy2);
- checkcompakb (keyboard_default_kbmaps[i], ip_joy1);
+ for (i = KBR_DEFAULT_MAP_FIRST; i <= KBR_DEFAULT_MAP_LAST; i++)
+ {
+ checkcompakb(keyboard_default_kbmaps[i], ip_joy2);
+ checkcompakb(keyboard_default_kbmaps[i], ip_joy1);
#ifndef INPUTDEVICE_SIMPLE
checkcompakb (keyboard_default_kbmaps[i], ip_joypad2);
checkcompakb (keyboard_default_kbmaps[i], ip_joypad1);
checkcompakb (keyboard_default_kbmaps[i], ip_parjoy2);
checkcompakb (keyboard_default_kbmaps[i], ip_parjoy1);
#endif
- checkcompakb (keyboard_default_kbmaps[i], ip_mouse2);
- checkcompakb (keyboard_default_kbmaps[i], ip_mouse1);
+ checkcompakb(keyboard_default_kbmaps[i], ip_mouse2);
+ checkcompakb(keyboard_default_kbmaps[i], ip_mouse1);
}
- for (i = KBR_DEFAULT_MAP_CD32_FIRST; i <= KBR_DEFAULT_MAP_CD32_LAST; i++) {
- checkcompakb (keyboard_default_kbmaps[i], ip_joycd321);
- checkcompakb (keyboard_default_kbmaps[i], ip_joycd322);
+ for (i = KBR_DEFAULT_MAP_CD32_FIRST; i <= KBR_DEFAULT_MAP_CD32_LAST; i++)
+ {
+ checkcompakb(keyboard_default_kbmaps[i], ip_joycd321);
+ checkcompakb(keyboard_default_kbmaps[i], ip_joycd322);
}
}
- for (i = 0; i < 2; i++) {
- if (prefs->jports[i].id >= 0) {
- int *kb = NULL;
+ for (i = 0; i < 2; i++)
+ {
+ if (prefs->jports[i].id >= 0)
+ {
+ int* kb = NULL;
int mode = prefs->jports[i].mode;
int af = prefs->jports[i].autofire;
for (joy = 0; used[joy]; joy++);
- if (JSEM_ISANYKBD (i, prefs)) {
+ if (JSEM_ISANYKBD (i, prefs))
+ {
bool cd32 = mode == JSEM_MODE_JOYSTICK_CD32 || (mode == JSEM_MODE_DEFAULT && prefs->cs_cd32cd);
- if (JSEM_ISNUMPAD (i, prefs)) {
+ if (JSEM_ISNUMPAD (i, prefs))
+ {
if (cd32)
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CD32_NP];
#ifndef INPUTDEVICE_SIMPLE
@@ -4393,7 +5250,9 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
#endif
else
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_NP];
- } else if (JSEM_ISCURSOR (i, prefs)) {
+ }
+ else if (JSEM_ISCURSOR (i, prefs))
+ {
if (cd32)
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CD32_CK];
#ifndef INPUTDEVICE_SIMPLE
@@ -4402,7 +5261,9 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
#endif
else
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CK];
- } else if (JSEM_ISSOMEWHEREELSE (i, prefs)) {
+ }
+ else if (JSEM_ISSOMEWHEREELSE (i, prefs))
+ {
if (cd32)
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CD32_SE];
#ifndef INPUTDEVICE_SIMPLE
@@ -4412,7 +5273,8 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
else
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_SE];
}
- if (kb) {
+ if (kb)
+ {
switch (mode)
{
case JSEM_MODE_JOYSTICK:
@@ -4421,22 +5283,25 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
#endif
case JSEM_MODE_JOYSTICK_CD32:
case JSEM_MODE_DEFAULT:
- if (cd32) {
- setcompakb (prefs, kb, i ? ip_joycd322 : ip_joycd321, i, af);
+ if (cd32)
+ {
+ setcompakb(prefs, kb, i ? ip_joycd322 : ip_joycd321, i, af);
joymodes[i] = JSEM_MODE_JOYSTICK_CD32;
#ifndef INPUTDEVICE_SIMPLE
} else if (mode == JSEM_MODE_GAMEPAD) {
setcompakb (prefs, kb, i ? ip_joypad2 : ip_joypad1, i, af);
joymodes[i] = JSEM_MODE_GAMEPAD;
#endif
- } else {
- setcompakb (prefs, kb, i ? ip_joy2 : ip_joy1, i, af);
+ }
+ else
+ {
+ setcompakb(prefs, kb, i ? ip_joy2 : ip_joy1, i, af);
joymodes[i] = JSEM_MODE_JOYSTICK;
}
break;
case JSEM_MODE_MOUSE:
case JSEM_MODE_WHEELMOUSE:
- setcompakb (prefs, kb, i ? ip_mouse2 : ip_mouse1, i, af);
+ setcompakb(prefs, kb, i ? ip_mouse2 : ip_mouse1, i, af);
joymodes[i] = JSEM_MODE_WHEELMOUSE;
break;
}
@@ -4446,18 +5311,19 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
}
}
-//#ifndef INPUTDEVICE_SIMPLE
+#ifndef INPUTDEVICE_SIMPLE
// parport
for (i = 2; i < MAX_JPORTS; i++) {
int af = prefs->jports[i].autofire;
if (prefs->jports[i].id >= 0) {
+ int *kb = NULL;
joy = jsem_isjoy (i, prefs);
if (joy >= 0) {
if (gameports)
cleardev (joysticks, joy);
input_get_default_joystick (joysticks, joy, i, af, 0, !gameports, false);
- _tcsncpy (prefs->jports[i].idc.name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1);
- _tcsncpy (prefs->jports[i].idc.configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1);
+ _tcsncpy (prefs->jports[i].name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1);
+ _tcsncpy (prefs->jports[i].configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1);
used[joy] = 1;
joymodes[i] = JSEM_MODE_JOYSTICK;
}
@@ -4474,6 +5340,10 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_CK];
else if (JSEM_ISSOMEWHEREELSE (i, prefs))
kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_SE];
+ else if (JSEM_ISXARCADE1 (i, prefs))
+ kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_XA1];
+ else if (JSEM_ISXARCADE2 (i, prefs))
+ kb = keyboard_default_kbmaps[KBR_DEFAULT_MAP_XA2];
if (kb) {
setcompakb (prefs, kb, i == 3 ? ip_parjoy2default : ip_parjoy1default, i, prefs->jports[i].autofire);
used[joy] = 1;
@@ -4482,205 +5352,224 @@ static void compatibility_copy (struct uae_prefs *prefs, bool gameports)
}
}
}
-//#endif
+#endif
- for (i = 0; i < MAX_JPORTS; i++) {
+ for (i = 0; i < MAX_JPORTS; i++)
+ {
if (gameports)
- setautofires (prefs, i, prefs->jports[i].autofire);
+ setautofires(prefs, i, prefs->jports[i].autofire);
}
- for (i = 0; i < MAX_JPORTS; i++) {
- setjoyinputs (prefs, i);
- setjoydevices (prefs, gameports, i);
+ for (i = 0; i < MAX_JPORTS; i++)
+ {
+ setjoyinputs(prefs, i);
+ setjoydevices(prefs, gameports, i);
}
}
-static void disableifempty2 (struct uae_input_device *uid)
+static void disableifempty2(struct uae_input_device* uid)
{
- for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
- for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
+ for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
+ {
+ for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
if (uid->eventid[i][j] > 0 || uid->custom[i][j] != NULL)
return;
}
}
- if (uid->enabled < 0)
- uid->enabled = 0;
-}
-static void disableifempty (struct uae_prefs *prefs)
-{
- for (int l = 0; l < MAX_INPUT_DEVICES; l++) {
- disableifempty2 (&joysticks[l]);
- disableifempty2 (&mice[l]);
- if (!input_get_default_keyboard(l))
- disableifempty2 (&keyboards[l]);
- }
+ uid->enabled = false;
}
-static void matchdevices (struct inputdevice_functions *inf, struct uae_input_device *uid)
+static void disableifempty(struct uae_prefs* prefs)
+{
+ for (int l = 0; l < MAX_INPUT_DEVICES; l++)
+ {
+ disableifempty2(&joysticks[l]);
+ disableifempty2(&mice[l]);
+ disableifempty2(&keyboards[l]);
+ }
+#ifndef INPUTDEVICE_SIMPLE
+ prefs->internalevent_settings[0]->enabled = true;
+#endif
+}
+
+static void matchdevices(struct inputdevice_functions* inf, struct uae_input_device* uid)
{
int i, j;
- for (int l = 0; l < 2; l++) {
- bool fullmatch = l == 0;
+ for (i = 0; i < inf->get_num(); i++)
+ {
+ const char* aname1 = inf->get_friendlyname(i);
+ const char* aname2 = inf->get_uniquename(i);
int match = -1;
- for (i = 0; i < inf->get_num (); i++) {
- const TCHAR* aname1 = inf->get_friendlyname(i);
- const TCHAR* aname2 = inf->get_uniquename(i);
- for (j = 0; j < MAX_INPUT_DEVICES; j++) {
- if (aname2 && uid[j].configname) {
- bool matched = false;
- TCHAR bname[MAX_DPATH];
- TCHAR bname2[MAX_DPATH];
- TCHAR *p1 ,*p2;
- TCHAR *bname1 = uid[j].name;
-
- if (fullmatch && (!bname1 || aname1))
- continue;
- _tcscpy (bname, uid[j].configname);
- _tcscpy (bname2, aname2);
- // strip possible local guid part
- p1 = _tcschr (bname, '{');
- p2 = _tcschr (bname2, '{');
- if (!p1 && !p2) {
- // check possible directinput names too
- p1 = _tcschr (bname, ' ');
- p2 = _tcschr (bname2, ' ');
- }
- if (!_tcscmp (bname, bname2)) {
+ for (j = 0; j < MAX_INPUT_DEVICES; j++)
+ {
+ if (aname2 && uid[j].configname)
+ {
+ bool matched = false;
+ TCHAR bname[MAX_DPATH];
+ TCHAR bname2[MAX_DPATH];
+ TCHAR *p1, *p2;
+ _tcscpy (bname, uid[j].configname);
+ _tcscpy (bname2, aname2);
+ // strip possible local guid part
+ p1 = _tcschr (bname, '{');
+ p2 = _tcschr (bname2, '{');
+ if (!p1 && !p2)
+ {
+ // check possible directinput names too
+ p1 = _tcschr (bname, ' ');
+ p2 = _tcschr (bname2, ' ');
+ }
+ if (!_tcscmp (bname, bname2))
+ {
+ matched = true;
+ }
+ else if (p1 && p2 && p1 - bname == p2 - bname2)
+ {
+ *p1 = 0;
+ *p2 = 0;
+ if (bname && !_tcscmp (bname2, bname))
matched = true;
- } else if (p1 && p2 && p1 - bname == p2 - bname2) {
- *p1 = 0;
- *p2 = 0;
- if (bname[0] && !_tcscmp (bname2, bname))
- matched = true;
- }
- if (matched && fullmatch && _tcscmp(aname1, bname1) != 0)
- matched = false;
- if (matched) {
- if (match >= 0)
- match = -2;
- else
- match = j;
- }
- if (match == -2)
- break;
+ }
+ if (matched)
+ {
+ if (match >= 0)
+ match = -2;
+ else
+ match = j;
+ }
+ if (match == -2)
+ break;
+ }
+ }
+ // multiple matches -> use complete local-only id string for comparisons
+ if (match == -2)
+ {
+ for (j = 0; j < MAX_INPUT_DEVICES; j++)
+ {
+ TCHAR* bname2 = uid[j].configname;
+ if (aname2 && bname2 && !_tcscmp (aname2, bname2))
+ {
+ match = j;
+ break;
}
}
- if (!fullmatch) {
- // multiple matches -> use complete local-only id string for comparisons
- if (match == -2) {
- for (j = 0; j < MAX_INPUT_DEVICES; j++) {
- TCHAR *bname2 = uid[j].configname;
- if (aname2 && bname2 && !_tcscmp (aname2, bname2)) {
- match = j;
- break;
- }
- }
- }
- if (match < 0) {
- // no match, try friendly names only
- for (j = 0; j < MAX_INPUT_DEVICES; j++) {
- TCHAR *bname1 = uid[j].name;
- if (aname1 && bname1 && !_tcscmp (aname1, bname1)) {
- match = j;
- break;
- }
- }
- }
- }
- if (match >= 0) {
- j = match;
- if (j != i) {
- struct uae_input_device *tmp = xmalloc (struct uae_input_device, 1);
- memcpy (tmp, &uid[j], sizeof (struct uae_input_device));
- memcpy (&uid[j], &uid[i], sizeof (struct uae_input_device));
- memcpy (&uid[i], tmp, sizeof (struct uae_input_device));
- xfree (tmp);
+ }
+ if (match < 0)
+ {
+ // no match, try friend names
+ for (j = 0; j < MAX_INPUT_DEVICES; j++)
+ {
+ TCHAR* bname1 = uid[j].name;
+ if (aname1 && bname1 && !_tcscmp (aname1, bname1))
+ {
+ match = j;
+ break;
}
}
}
if (match >= 0)
- break;
+ {
+ j = match;
+ if (j != i)
+ {
+ struct uae_input_device* tmp = xmalloc (struct uae_input_device, 1);
+ memcpy(tmp, &uid[j], sizeof (struct uae_input_device));
+ memcpy(&uid[j], &uid[i], sizeof (struct uae_input_device));
+ memcpy(&uid[i], tmp, sizeof (struct uae_input_device));
+ xfree (tmp);
+ }
+ }
}
- for (i = 0; i < inf->get_num (); i++) {
+ for (i = 0; i < inf->get_num(); i++)
+ {
if (uid[i].name == NULL)
- uid[i].name = my_strdup (inf->get_friendlyname (i));
+ uid[i].name = my_strdup(inf->get_friendlyname(i));
if (uid[i].configname == NULL)
- uid[i].configname = my_strdup (inf->get_uniquename (i));
+ uid[i].configname = my_strdup(inf->get_uniquename(i));
}
}
-static void matchdevices_all (struct uae_prefs *prefs)
+static void matchdevices_all(struct uae_prefs* prefs)
{
int i;
- for (i = 0; i < MAX_INPUT_SETTINGS; i++) {
- matchdevices (&idev[IDTYPE_MOUSE], prefs->mouse_settings[i]);
- matchdevices (&idev[IDTYPE_JOYSTICK], prefs->joystick_settings[i]);
- matchdevices (&idev[IDTYPE_KEYBOARD], prefs->keyboard_settings[i]);
+ for (i = 0; i < MAX_INPUT_SETTINGS; i++)
+ {
+ matchdevices(&idev[IDTYPE_MOUSE], prefs->mouse_settings[i]);
+ matchdevices(&idev[IDTYPE_JOYSTICK], prefs->joystick_settings[i]);
+ matchdevices(&idev[IDTYPE_KEYBOARD], prefs->keyboard_settings[i]);
}
}
-bool inputdevice_set_gameports_mapping (struct uae_prefs *prefs, int devnum, int num, int evtnum, uae_u64 flags, int port, int input_selected_setting)
+bool inputdevice_set_gameports_mapping(struct uae_prefs* prefs, int devnum, int num, int evtnum, uae_u64 flags, int port, int input_selected_setting)
{
TCHAR name[256];
- const struct inputevent *ie;
+ struct inputevent* ie;
int sub;
- if (evtnum < 0) {
+ if (evtnum < 0)
+ {
joysticks = prefs->joystick_settings[input_selected_setting];
mice = prefs->mouse_settings[input_selected_setting];
keyboards = prefs->keyboard_settings[input_selected_setting];
- for (sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++) {
+ for (sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++)
+ {
int port2 = 0;
- inputdevice_get_mapping (devnum, num, NULL, &port2, NULL, NULL, sub);
- if (port2 == port + 1) {
- inputdevice_set_mapping (devnum, num, NULL, NULL, 0, 0, sub);
+ inputdevice_get_mapping(devnum, num, NULL, &port2, NULL, NULL, sub);
+ if (port2 == port + 1)
+ {
+ inputdevice_set_mapping(devnum, num, NULL, NULL, 0, 0, sub);
}
}
return true;
}
- ie = inputdevice_get_eventinfo (evtnum);
- if (!inputdevice_get_eventname (ie, name))
+ ie = inputdevice_get_eventinfo(evtnum);
+ if (!inputdevice_get_eventname(ie, name))
return false;
joysticks = prefs->joystick_settings[input_selected_setting];
mice = prefs->mouse_settings[input_selected_setting];
keyboards = prefs->keyboard_settings[input_selected_setting];
sub = 0;
- if (inputdevice_get_widget_type (devnum, num, NULL, false) != IDEV_WIDGET_KEY) {
- for (sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++) {
+ if (inputdevice_get_widget_type(devnum, num, NULL) != IDEV_WIDGET_KEY)
+ {
+ for (sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++)
+ {
int port2 = 0;
- int evt = inputdevice_get_mapping (devnum, num, NULL, &port2, NULL, NULL, sub);
+ int evt = inputdevice_get_mapping(devnum, num, NULL, &port2, NULL, NULL, sub);
if (port2 == port + 1 && evt == evtnum)
break;
- if (!inputdevice_get_mapping (devnum, num, NULL, NULL, NULL, NULL, sub))
+ if (!inputdevice_get_mapping(devnum, num, NULL, NULL, NULL, NULL, sub))
break;
}
}
if (sub >= MAX_INPUT_SUB_EVENT)
sub = MAX_INPUT_SUB_EVENT - 1;
- inputdevice_set_mapping (devnum, num, name, NULL, IDEV_MAPPED_GAMEPORTSCUSTOM1 | flags, port + 1, sub);
+ inputdevice_set_mapping(devnum, num, name, NULL, IDEV_MAPPED_GAMEPORTSCUSTOM1 | flags, port + 1, sub);
joysticks = prefs->joystick_settings[prefs->input_selected_setting];
mice = prefs->mouse_settings[prefs->input_selected_setting];
keyboards = prefs->keyboard_settings[prefs->input_selected_setting];
- if (prefs->input_selected_setting != GAMEPORT_INPUT_SETTINGS) {
+ if (prefs->input_selected_setting != GAMEPORT_INPUT_SETTINGS)
+ {
int xport;
uae_u64 xflags;
TCHAR xname[MAX_DPATH], xcustom[MAX_DPATH];
- inputdevice_get_mapping (devnum, num, &xflags, &xport, xname, xcustom, 0);
+ inputdevice_get_mapping(devnum, num, &xflags, &xport, xname, xcustom, 0);
if (xport == 0)
- inputdevice_set_mapping (devnum, num, xname, xcustom, xflags, MAX_JPORTS + 1, SPARE_SUB_EVENT);
- inputdevice_set_mapping (devnum, num, name, NULL, IDEV_MAPPED_GAMEPORTSCUSTOM1 | flags, port + 1, 0);
+ inputdevice_set_mapping(devnum, num, xname, xcustom, xflags, MAX_JPORTS + 1, SPARE_SUB_EVENT);
+ inputdevice_set_mapping(devnum, num, name, NULL, IDEV_MAPPED_GAMEPORTSCUSTOM1 | flags, port + 1, 0);
}
return true;
}
-static void resetinput (void)
+static void resetinput()
{
cd32_shifter[0] = cd32_shifter[1] = 8;
- for (int i = 0; i < MAX_JPORTS; i++) {
+ for (int i = 0; i < MAX_JPORTS; i++)
+ {
oleft[i] = 0;
oright[i] = 0;
otop[i] = 0;
@@ -4693,279 +5582,210 @@ static void resetinput (void)
mouse_delta[i][1] = 0;
mouse_deltanoreset[i][2] = 0;
mouse_delta[i][2] = 0;
- }
- memset (keybuf, 0, sizeof keybuf);
+ }
+ memset(keybuf, 0, sizeof keybuf);
for (int i = 0; i < INPUT_QUEUE_SIZE; i++)
input_queue[i].linecnt = input_queue[i].nextlinecnt = -1;
- for (int i = 0; i < MAX_INPUT_SUB_EVENT; i++) {
+ for (int i = 0; i < MAX_INPUT_SUB_EVENT; i++)
+ {
sublevdir[0][i] = i;
sublevdir[1][i] = MAX_INPUT_SUB_EVENT - i - 1;
}
}
-void inputdevice_copyjports(struct uae_prefs *srcprefs, struct uae_prefs *dstprefs)
+void inputdevice_updateconfig_internal(const struct uae_prefs* srcprrefs, struct uae_prefs* dstprefs)
{
- for (int i = 0; i < MAX_JPORTS; i++) {
- copyjport(srcprefs, dstprefs, i);
- }
-}
+ int i;
-void inputdevice_updateconfig_internal (struct uae_prefs *srcprefs, struct uae_prefs *dstprefs)
-{
keyboard_default = keyboard_default_table[currprefs.input_keyboard_type];
- inputdevice_copyjports(srcprefs, dstprefs);
- resetinput ();
+ copyjport(srcprrefs, dstprefs, 0);
+ copyjport(srcprrefs, dstprefs, 1);
+ copyjport(srcprrefs, dstprefs, 2);
+ copyjport(srcprrefs, dstprefs, 3);
+
+ resetinput();
joysticks = dstprefs->joystick_settings[dstprefs->input_selected_setting];
mice = dstprefs->mouse_settings[dstprefs->input_selected_setting];
keyboards = dstprefs->keyboard_settings[dstprefs->input_selected_setting];
+#ifndef INPUTDEVICE_SIMPLE
+ internalevents = dstprefs->internalevent_settings[dstprefs->input_selected_setting];
+#endif
- matchdevices_all (dstprefs);
+ matchdevices_all(dstprefs);
- memset (joysticks2, 0, sizeof joysticks2);
- memset (mice2, 0, sizeof mice2);
-
- int input_selected_setting = dstprefs->input_selected_setting;
+ memset(joysticks2, 0, sizeof joysticks2);
+ memset(mice2, 0, sizeof mice2);
joysticks = dstprefs->joystick_settings[GAMEPORT_INPUT_SETTINGS];
mice = dstprefs->mouse_settings[GAMEPORT_INPUT_SETTINGS];
keyboards = dstprefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS];
- dstprefs->input_selected_setting = GAMEPORT_INPUT_SETTINGS;
-
- for (int i = 0; i < MAX_INPUT_SETTINGS; i++) {
+#ifndef INPUTDEVICE_SIMPLE
+ internalevents = dstprefs->internalevent_settings[GAMEPORT_INPUT_SETTINGS];
+#endif
+ for (i = 0; i < MAX_INPUT_SETTINGS; i++)
+ {
joysticks[i].enabled = 0;
mice[i].enabled = 0;
}
- compatibility_copy (dstprefs, true);
-
- dstprefs->input_selected_setting = input_selected_setting;
-
+ compatibility_copy(dstprefs, true);
joysticks = dstprefs->joystick_settings[dstprefs->input_selected_setting];
mice = dstprefs->mouse_settings[dstprefs->input_selected_setting];
keyboards = dstprefs->keyboard_settings[dstprefs->input_selected_setting];
-
- if (dstprefs->input_selected_setting != GAMEPORT_INPUT_SETTINGS) {
- compatibility_copy (dstprefs, false);
- }
-
- disableifempty (dstprefs);
- scanevents (dstprefs);
-
- if (srcprefs) {
- for (int i = 0; i < MAX_JPORTS; i++) {
- copyjport(dstprefs, srcprefs, i);
- }
- }
-}
-
-void inputdevice_updateconfig (struct uae_prefs *srcprefs, struct uae_prefs *dstprefs)
-{
- inputdevice_updateconfig_internal (srcprefs, dstprefs);
-
- set_config_changed ();
-
- for (int i = 0; i < MAX_JPORTS; i++) {
- inputdevice_store_used_device(&dstprefs->jports[i], i, false);
- }
-}
-
#ifndef INPUTDEVICE_SIMPLE
+ internalevents = dstprefs->internalevent_settings[dstprefs->input_selected_setting];
+#endif
+
+ if (dstprefs->input_selected_setting != GAMEPORT_INPUT_SETTINGS)
+ {
+ compatibility_copy(dstprefs, false);
+ }
+
+ disableifempty(dstprefs);
+ scanevents(dstprefs);
+}
+
+void inputdevice_updateconfig(const struct uae_prefs* srcprefs, struct uae_prefs* dstprefs)
+{
+ inputdevice_updateconfig_internal(srcprefs, dstprefs);
+
+ set_config_changed();
+}
+
/* called when devices get inserted or removed
* store old devices temporarily, enumerate all devices
* restore old devices back (order may have changed)
*/
-void inputdevice_devicechange (struct uae_prefs *prefs)
+void inputdevice_devicechange(struct uae_prefs *prefs)
{
int acc = input_acquired;
int i, idx;
- TCHAR *jports_name[MAX_JPORTS];
- TCHAR *jports_configname[MAX_JPORTS];
- int jportskb[MAX_JPORTS], jportscustom[MAX_JPORTS];
- int jportsmode[MAX_JPORTS];
+ TCHAR *jports[MAX_JPORTS];
+ int jportskb[MAX_JPORTS], jportsmode[MAX_JPORTS];
int jportid[MAX_JPORTS], jportaf[MAX_JPORTS];
for (i = 0; i < MAX_JPORTS; i++) {
+ jports[i] = NULL;
jportskb[i] = -1;
- jportscustom[i] = -1;
jportid[i] = prefs->jports[i].id;
jportaf[i] = prefs->jports[i].autofire;
- jports_name[i] = NULL;
- jports_configname[i] = NULL;
- idx = inputdevice_getjoyportdevice (i, prefs->jports[i].id);
- if (idx >= JSEM_LASTKBD + inputdevice_get_device_total(IDTYPE_MOUSE) + inputdevice_get_device_total(IDTYPE_JOYSTICK)) {
- jportscustom[i] = idx - (JSEM_LASTKBD + inputdevice_get_device_total(IDTYPE_MOUSE) + inputdevice_get_device_total(IDTYPE_JOYSTICK));
- } else if (idx >= JSEM_LASTKBD) {
- if (prefs->jports[i].idc.name[0] == 0 && prefs->jports[i].idc.configname[0] == 0) {
- struct inputdevice_functions *idf;
- int devidx;
- idx -= JSEM_LASTKBD;
- idf = getidf (idx);
- devidx = inputdevice_get_device_index (idx);
- jports_name[i] = my_strdup (idf->get_friendlyname (devidx));
- jports_configname[i] = my_strdup (idf->get_uniquename (devidx));
- }
- } else {
+ idx = inputdevice_getjoyportdevice(i, prefs->jports[i].id);
+ if (idx >= JSEM_LASTKBD) {
+ struct inputdevice_functions *idf;
+ int devidx;
+ idx -= JSEM_LASTKBD;
+ idf = getidf(idx);
+ devidx = inputdevice_get_device_index(idx);
+ jports[i] = my_strdup(idf->get_uniquename(devidx));
+ }
+ else {
jportskb[i] = idx;
}
jportsmode[i] = prefs->jports[i].mode;
- if (jports_name[i] == NULL)
- jports_name[i] = my_strdup(prefs->jports[i].idc.name);
- if (jports_configname[i] == NULL)
- jports_configname[i] = my_strdup(prefs->jports[i].idc.configname);
}
- // store old devices
- struct inputdevconfig devcfg[MAX_INPUT_DEVICES][IDTYPE_MAX] = { 0 };
- int dev_nums[IDTYPE_MAX];
- for (int j = 0; j <= IDTYPE_KEYBOARD; j++) {
- struct inputdevice_functions *inf = &idev[j];
- dev_nums[j] = inf->get_num();
- for (i = 0; i < dev_nums[j]; i++) {
- TCHAR *un = inf->get_uniquename(i);
- TCHAR *fn = inf->get_friendlyname(i);
- _tcscpy(devcfg[i][j].name, fn);
- _tcscpy(devcfg[i][j].configname, un);
- }
- }
+ inputdevice_unacquire();
+ idev[IDTYPE_JOYSTICK].close();
+ idev[IDTYPE_MOUSE].close();
+ idev[IDTYPE_KEYBOARD].close();
+ idev[IDTYPE_JOYSTICK].init();
+ idev[IDTYPE_MOUSE].init();
+ idev[IDTYPE_KEYBOARD].init();
+ matchdevices(&idev[IDTYPE_MOUSE], mice);
+ matchdevices(&idev[IDTYPE_JOYSTICK], joysticks);
+ matchdevices(&idev[IDTYPE_KEYBOARD], keyboards);
- inputdevice_unacquire ();
- idev[IDTYPE_JOYSTICK].close ();
- idev[IDTYPE_MOUSE].close ();
- idev[IDTYPE_KEYBOARD].close ();
- idev[IDTYPE_JOYSTICK].init ();
- idev[IDTYPE_MOUSE].init ();
- idev[IDTYPE_KEYBOARD].init ();
- matchdevices (&idev[IDTYPE_MOUSE], mice);
- matchdevices (&idev[IDTYPE_JOYSTICK], joysticks);
- matchdevices (&idev[IDTYPE_KEYBOARD], keyboards);
-
- // find out which one was removed or inserted
- for (int j = 0; j <= IDTYPE_KEYBOARD; j++) {
- struct inputdevice_functions *inf = &idev[j];
- int num = inf->get_num();
- bool df[MAX_INPUT_DEVICES];
- for (i = 0; i < MAX_INPUT_DEVICES; i++) {
- TCHAR *fn2 = devcfg[i][j].name;
- TCHAR *un2 = devcfg[i][j].configname;
- df[i] = false;
- if (fn2[0] && un2[0]) {
- for (int k = 0; k < num; k++) {
- TCHAR *un = inf->get_uniquename(k);
- TCHAR *fn = inf->get_friendlyname(k);
- if (!_tcscmp(fn2, fn) && !_tcscmp(un2, un)) {
- devcfg[i][j].name[0] = 0;
- devcfg[i][j].configname[0] = 0;
- df[k] = true;
- }
- }
- }
- }
- for (i = 0; i < MAX_INPUT_DEVICES; i++) {
- if (devcfg[i][j].name[0]) {
- write_log(_T("REMOVED: %s (%s)\n"), devcfg[i][j].name, devcfg[i][j].configname);
- inputdevice_store_unplugged_port(prefs, &devcfg[i][j]);
- }
- if (i < num && df[i] == false) {
- struct inputdevconfig idc;
- _tcscpy(idc.configname, inf->get_uniquename(i));
- _tcscpy(idc.name, inf->get_friendlyname(i));
- write_log(_T("INSERTED: %s (%s)\n"), idc.name, idc.configname);
- int portnum = inputdevice_get_unplugged_device(&idc);
- if (portnum >= 0) {
- write_log(_T("Inserting to port %d\n"), portnum);
- jportscustom[i] = -1;
- xfree(jports_name[portnum]);
- xfree(jports_configname[portnum]);
- jports_name[portnum] = my_strdup(idc.name);
- jports_configname[portnum] = my_strdup(idc.configname);
- } else {
- write_log(_T("Not inserted to any port\n"));
- }
- }
- }
- }
-
- bool fixedports[MAX_JPORTS];
for (i = 0; i < MAX_JPORTS; i++) {
- freejport (prefs, i);
- fixedports[i] = false;
- }
- for (i = 0; i < MAX_JPORTS; i++) {
- bool found = true;
- if (jportscustom[i] >= 0) {
- TCHAR tmp[10];
- _stprintf(tmp, _T("custom%d"), jportscustom[i]);
- found = inputdevice_joyport_config(prefs, tmp, NULL, i, jportsmode[i], 0, true) != 0;
- } else if (jports_name[i][0] || jports_configname[i][0]) {
- if (!inputdevice_joyport_config (prefs, jports_name[i], jports_configname[i], i, jportsmode[i], 1, true)) {
- found = inputdevice_joyport_config (prefs, jports_name[i], NULL, i, jportsmode[i], 1, true) != 0;
- }
- if (!found) {
- inputdevice_joyport_config(prefs, _T("joydefault"), NULL, i, jportsmode[i], 0, true);
- }
- } else if (jportskb[i] >= 0) {
- TCHAR tmp[10];
- _stprintf (tmp, _T("kbd%d"), jportskb[i] + 1);
- found = inputdevice_joyport_config (prefs, tmp, NULL, i, jportsmode[i], 0, true) != 0;
-
+ freejport(prefs, i);
+ //if (jportid[i] == JPORT_CUSTOM) {
+ // inputdevice_joyport_config(prefs, _T("custom"), i, jportsmode[i], 0, true);
+ //}
+ //else
+ if (jports[i]) {
+ inputdevice_joyport_config(prefs, jports[i], i, jportsmode[i], 2, true);
+ }
+ else if (jportskb[i] >= 0) {
+ TCHAR tmp[10];
+ _stprintf(tmp, _T("kbd%d"), jportskb[i]);
+ inputdevice_joyport_config(prefs, tmp, i, jportsmode[i], 0, true);
}
- fixedports[i] = found;
prefs->jports[i].autofire = jportaf[i];
- xfree (jports_name[i]);
- xfree (jports_configname[i]);
- inputdevice_validate_jports(prefs, i, fixedports);
+ xfree(jports[i]);
}
if (prefs == &changed_prefs)
- inputdevice_copyconfig (&changed_prefs, &currprefs);
+ inputdevice_copyconfig(&changed_prefs, &currprefs);
if (acc)
- inputdevice_acquire (TRUE);
- set_config_changed ();
-}
+ inputdevice_acquire(TRUE);
+#ifdef RETROPLATFORM
+ rp_enumdevices();
#endif
+ set_config_changed();
+}
// set default prefs to all input configuration settings
-void inputdevice_default_prefs (struct uae_prefs *p)
+void inputdevice_default_prefs(struct uae_prefs* p)
{
- inputdevice_init ();
+ inputdevice_init();
p->input_selected_setting = GAMEPORT_INPUT_SETTINGS;
-#if defined (PANDORA) || defined(ANDROID)
- p->input_joymouse_multiplier = 20;
-#else
- p->input_joymouse_multiplier = 2;
-#endif
+ p->input_joymouse_multiplier = 2;
p->input_joymouse_deadzone = 33;
p->input_joystick_deadzone = 33;
p->input_joymouse_speed = 10;
p->input_analog_joystick_mult = 15;
p->input_analog_joystick_offset = -1;
p->input_mouse_speed = 100;
- p->input_autofire_linecnt = 8 * 312;
+ p->input_autofire_linecnt = 8 * 312;
p->input_keyboard_type = 0;
keyboard_default = keyboard_default_table[p->input_keyboard_type];
- inputdevice_default_kb_all (p);
+ inputdevice_default_kb_all(p);
}
// set default keyboard and keyboard>joystick layouts
-void inputdevice_setkeytranslation (struct uae_input_device_kbr_default **trans, int **kbmaps)
+void inputdevice_setkeytranslation(struct uae_input_device_kbr_default** trans, int** kbmaps)
{
keyboard_default_table = trans;
keyboard_default_kbmaps = kbmaps;
}
// return true if keyboard/scancode pair is mapped
-int inputdevice_iskeymapped (int keyboard, int scancode)
+int inputdevice_iskeymapped(int keyboard, int scancode)
{
+ struct uae_input_device* na = &keyboards[keyboard];
+
if (!keyboards || scancode < 0)
return 0;
return scancodeused[keyboard][scancode];
}
-static void rqualifiers (uae_u64 flags, bool release)
+int inputdevice_synccapslock(int oldcaps, int *capstable)
+{
+ struct uae_input_device *na = &keyboards[0];
+ int j, i;
+
+ if (!keyboards)
+ return -1;
+ for (j = 0; na->extra[j]; j++) {
+ if (na->extra[j] == INPUTEVENT_KEY_CAPS_LOCK) {
+ for (i = 0; capstable[i]; i += 2) {
+ if (na->extra[j] == capstable[i]) {
+ if (oldcaps != capstable[i + 1]) {
+ oldcaps = capstable[i + 1];
+ inputdevice_translatekeycode(0, capstable[i], oldcaps ? -1 : 0);
+ }
+ return i;
+ }
+ }
+ }
+ }
+ return -1;
+}
+
+static void rqualifiers(uae_u64 flags, bool release)
{
uae_u64 mask = ID_FLAG_QUALIFIER1 << 1;
for (int i = 0; i < MAX_INPUT_QUALIFIERS; i++) {
@@ -4976,19 +5796,20 @@ static void rqualifiers (uae_u64 flags, bool release)
for (int ii = 0; ii < MAX_INPUT_SUB_EVENT; ii++) {
int qevt = qualifiers_evt[i][ii];
if (qevt > 0) {
- write_log (_T("Released %d '%s'\n"), qevt, events[qevt].name);
- inputdevice_do_keyboard (events[qevt].data, 0);
+ write_log(_T("Released %d '%s'\n"), qevt, events[qevt].name);
+ inputdevice_do_keyboard(events[qevt].data, 0);
}
}
}
- } else {
+ }
+ else {
if ((mask & qualifiers_r)) {
qualifiers_r &= ~mask;
for (int ii = 0; ii < MAX_INPUT_SUB_EVENT; ii++) {
int qevt = qualifiers_evt[i][ii];
if (qevt > 0) {
- write_log (_T("Pressed %d '%s'\n"), qevt, events[qevt].name);
- inputdevice_do_keyboard (events[qevt].data, 1);
+ write_log(_T("Pressed %d '%s'\n"), qevt, events[qevt].name);
+ inputdevice_do_keyboard(events[qevt].data, 1);
}
}
}
@@ -4998,44 +5819,48 @@ static void rqualifiers (uae_u64 flags, bool release)
}
}
-static int inputdevice_translatekeycode_2 (int keyboard, int scancode, int keystate, bool qualifiercheckonly)
+static int inputdevice_translatekeycode_2(int keyboard, int scancode, int keystate, bool qualifiercheckonly)
{
- struct uae_input_device *na = &keyboards[keyboard];
+ struct uae_input_device* na = &keyboards[keyboard];
int j, k;
int handled = 0;
+ bool didcustom = false;
if (!keyboards || scancode < 0)
return handled;
j = 0;
- while (j < MAX_INPUT_DEVICE_EVENTS && na->extra[j] >= 0) {
- if (na->extra[j] == scancode) {
+ while (j < MAX_INPUT_DEVICE_EVENTS && na->extra[j] >= 0)
+ {
+ if (na->extra[j] == scancode)
+ {
bool qualonly;
uae_u64 qualmask[MAX_INPUT_SUB_EVENT];
- getqualmask (qualmask, na, j, &qualonly);
+ getqualmask(qualmask, na, j, &qualonly);
if (qualonly)
qualifiercheckonly = true;
- for (k = 0; k < MAX_INPUT_SUB_EVENT; k++) {/* send key release events in reverse order */
- uae_u64 *flagsp = &na->flags[j][sublevdir[keystate == 0 ? 1 : 0][k]];
+ for (k = 0; k < MAX_INPUT_SUB_EVENT; k++)
+ {/* send key release events in reverse order */
+ uae_u64* flagsp = &na->flags[j][sublevdir[keystate == 0 ? 1 : 0][k]];
int evt = na->eventid[j][sublevdir[keystate == 0 ? 1 : 0][k]];
uae_u64 flags = *flagsp;
int autofire = (flags & ID_FLAG_AUTOFIRE) ? 1 : 0;
-#ifndef INPUTDEVICE_SIMPLE
int toggle = (flags & ID_FLAG_TOGGLE) ? 1 : 0;
int inverttoggle = (flags & ID_FLAG_INVERTTOGGLE) ? 1 : 0;
-#endif
int invert = (flags & ID_FLAG_INVERT) ? 1 : 0;
- int setmode = (flags & ID_FLAG_SET_ONOFF) ? 1: 0;
+ int setmode = (flags & ID_FLAG_SET_ONOFF) ? 1 : 0;
int setval = (flags & ID_FLAG_SET_ONOFF_VAL) ? SET_ONOFF_ON_VALUE : SET_ONOFF_OFF_VALUE;
int toggled;
int state;
if (keystate < 0) {
state = keystate;
- } else if (invert) {
+ }
+ else if (invert) {
state = keystate ? 0 : 1;
- } else {
+ }
+ else {
state = keystate;
}
if (setmode) {
@@ -5043,59 +5868,106 @@ static int inputdevice_translatekeycode_2 (int keyboard, int scancode, int keyst
state = setval;
}
- setqualifiers (evt, state > 0);
-
- if (qualifiercheckonly) {
- if (!state && (flags & ID_FLAG_CANRELEASE)) {
+ setqualifiers(evt, state > 0);
+ if (qualifiercheckonly)
+ {
+ if (!state && (flags & ID_FLAG_CANRELEASE))
+ {
*flagsp &= ~ID_FLAG_CANRELEASE;
- handle_input_event (evt, state, 1, autofire);
+#ifdef INPUTDEVICE_SIMPLE
+ handle_input_event(evt, state, 1, autofire);
+#else
+ handle_input_event (evt, state, 1, autofire, true, false);
+ if (k == 0) {
+ process_custom_event (na, j, state, qualmask, autofire, k);
+ }
+#endif
}
continue;
- }
+ }
+ // if evt == caps and scan == caps: sync with native caps led
+ if (evt == INPUTEVENT_KEY_CAPS_LOCK) {
+ int v;
+ if (state < 0)
+ state = 1;
+ v = target_checkcapslock(scancode, &state);
+ if (v < 0)
+ continue;
+ if (v > 0)
+ toggle = 0;
+ } else if (state < 0) {
+ // it was caps lock resync, ignore, not mapped to caps
+ continue;
+ }
#ifndef INPUTDEVICE_SIMPLE
+ if (!state) {
+ didcustom |= process_custom_event (na, j, state, qualmask, autofire, k);
+ }
+
if (inverttoggle) {
na->flags[j][sublevdir[state == 0 ? 1 : 0][k]] &= ~ID_FLAG_TOGGLED;
if (state) {
- queue_input_event (evt, -1, 0, 0);
- handled |= handle_input_event (evt, 2, 1, 0);
+ queue_input_event (evt, NULL, -1, 0, 0, 1);
+ handled |= handle_input_event (evt, 1, 1, 0, true, false);
} else {
- handled |= handle_input_event (evt, 2, 1, autofire);
+ handled |= handle_input_event (evt, 1, 1, autofire, true, false);
}
+ didcustom |= process_custom_event (na, j, state, qualmask, autofire, k);
} else if (toggle) {
if (!state)
continue;
if (!checkqualifiers (evt, flags, qualmask, na->eventid[j]))
continue;
*flagsp ^= ID_FLAG_TOGGLED;
- toggled = (*flagsp & ID_FLAG_TOGGLED) ? 2 : 0;
- handled |= handle_input_event (evt, toggled, 1, autofire);
+ toggled = (*flagsp & ID_FLAG_TOGGLED) ? 1 : 0;
+ handled |= handle_input_event (evt, toggled, 1, autofire, true, false);
+ if (k == 0) {
+ didcustom |= process_custom_event (na, j, state, qualmask, autofire, k);
+ }
} else {
#endif
- rqualifiers (flags, state ? true : false);
- if (!checkqualifiers (evt, flags, qualmask, na->eventid[j])) {
- if (!state && !(flags & ID_FLAG_CANRELEASE)) {
- if (!invert)
- continue;
- } else if (state) {
- continue;
- }
- }
-
- if (state) {
+ rqualifiers(flags, state ? true : false);
+ if (!checkqualifiers(evt, flags, qualmask, na->eventid[j]))
+ {
+ if (!state && !(flags & ID_FLAG_CANRELEASE))
+ {
if (!invert)
- *flagsp |= ID_FLAG_CANRELEASE;
- } else {
- if (!(flags & ID_FLAG_CANRELEASE) && !invert)
continue;
- *flagsp &= ~ID_FLAG_CANRELEASE;
- }
- handled |= handle_input_event (evt, state, 1, autofire);
+ }
+ else if (state)
+ {
+ continue;
+ }
+ }
+
+ if (state)
+ {
+ if (!invert)
+ *flagsp |= ID_FLAG_CANRELEASE;
+ }
+ else
+ {
+ if (!(flags & ID_FLAG_CANRELEASE) && !invert)
+ continue;
+ *flagsp &= ~ID_FLAG_CANRELEASE;
+ }
+#ifdef INPUTDEVICE_SIMPLE
+ handled |= handle_input_event(evt, state, 1, autofire);
+#else
+ handled |= handle_input_event (evt, state, 1, autofire, true, false);
+ didcustom |= process_custom_event (na, j, state, qualmask, autofire, k);
+#endif
#ifndef INPUTDEVICE_SIMPLE
}
#endif
}
- queue_input_event (-1, -1, 0, 0);
+ if (!didcustom)
+#ifdef INPUTDEVICE_SIMPLE
+ queue_input_event(-1, -1, 0, 0);
+#else
+ queue_input_event (-1, NULL, -1, 0, 0, 1);
+#endif
return handled;
}
j++;
@@ -5103,59 +5975,174 @@ static int inputdevice_translatekeycode_2 (int keyboard, int scancode, int keyst
return handled;
}
-// main keyboard press/release entry point
-int inputdevice_translatekeycode (int keyboard, int scancode, int state)
+#define IECODE_UP_PREFIX 0x80
+#define RAW_STEALTH 0x68
+#define STEALTHF_E0KEY 0x08
+#define STEALTHF_UPSTROKE 0x04
+#define STEALTHF_SPECIAL 0x02
+#define STEALTHF_E1KEY 0x01
+
+static void sendmmcodes(int code, int newstate)
{
- // if not default keyboard and all events are empty: use default keyboard
- if (!input_get_default_keyboard(keyboard) && isemptykey(keyboard, scancode)) {
- keyboard = input_get_default_keyboard(-1);
- }
- if (inputdevice_translatekeycode_2 (keyboard, scancode, state, false))
+ uae_u8 b;
+
+ b = RAW_STEALTH | IECODE_UP_PREFIX;
+ record_key(((b << 1) | (b >> 7)) & 0xff);
+ b = IECODE_UP_PREFIX;
+ if ((code >> 8) == 0x01)
+ b |= STEALTHF_E0KEY;
+ if ((code >> 8) == 0x02)
+ b |= STEALTHF_E1KEY;
+ if (!newstate)
+ b |= STEALTHF_UPSTROKE;
+ record_key(((b << 1) | (b >> 7)) & 0xff);
+ b = ((code >> 4) & 0x0f) | IECODE_UP_PREFIX;
+ record_key(((b << 1) | (b >> 7)) & 0xff);
+ b = (code & 0x0f) | IECODE_UP_PREFIX;
+ record_key(((b << 1) | (b >> 7)) & 0xff);
+}
+
+// main keyboard press/release entry point
+int inputdevice_translatekeycode(int keyboard, int scancode, int state)
+{
+ if (inputdevice_translatekeycode_2(keyboard, scancode, state, false))
return 1;
+ if (currprefs.mmkeyboard && scancode > 0)
+ sendmmcodes(scancode, state);
return 0;
}
-void inputdevice_checkqualifierkeycode (int keyboard, int scancode, int state)
+
+void inputdevice_checkqualifierkeycode(int keyboard, int scancode, int state)
{
- inputdevice_translatekeycode_2 (keyboard, scancode, state, true);
+ inputdevice_translatekeycode_2(keyboard, scancode, state, true);
}
-void inputdevice_init (void)
+static const TCHAR *internaleventlabels[] = {
+ _T("CPU reset"),
+ _T("Keyboard reset"),
+ NULL
+};
+static int init_int ()
+{
+ return 1;
+}
+static void close_int ()
+{
+}
+static int acquire_int (int num, int flags)
+{
+ return 1;
+}
+static void unacquire_int (int num)
+{
+}
+static void read_int ()
+{
+}
+static int get_int_num ()
+{
+ return 1;
+}
+static TCHAR *get_int_friendlyname (int num)
+{
+ return _T("Internal events");
+}
+static TCHAR *get_int_uniquename (int num)
+{
+ return _T("INTERNALEVENTS1");
+}
+static int get_int_widget_num (int num)
+{
+ int i;
+ for (i = 0; internaleventlabels[i]; i++);
+ return i;
+}
+static int get_int_widget_type (int kb, int num, TCHAR *name, uae_u32 *code)
+{
+ if (code)
+ *code = num;
+ if (name)
+ _tcscpy (name, internaleventlabels[num]);
+ return IDEV_WIDGET_BUTTON;
+}
+static int get_int_widget_first (int kb, int type)
+{
+ return 0;
+}
+static int get_int_flags (int num)
+{
+ return 0;
+}
+#ifndef INPUTDEVICE_SIMPLE
+static struct inputdevice_functions inputdevicefunc_internalevent = {
+ init_int, close_int, acquire_int, unacquire_int, read_int,
+ get_int_num, get_int_friendlyname, get_int_uniquename,
+ get_int_widget_num, get_int_widget_type,
+ get_int_widget_first,
+ get_int_flags
+};
+
+void send_internalevent (int eventid)
+{
+ setbuttonstateall (&internalevents[0], NULL, eventid, -1);
+}
+#endif
+
+void inputdevice_init()
{
idev[IDTYPE_JOYSTICK] = inputdevicefunc_joystick;
- idev[IDTYPE_JOYSTICK].init ();
+ idev[IDTYPE_JOYSTICK].init();
idev[IDTYPE_MOUSE] = inputdevicefunc_mouse;
- idev[IDTYPE_MOUSE].init ();
+ idev[IDTYPE_MOUSE].init();
idev[IDTYPE_KEYBOARD] = inputdevicefunc_keyboard;
- idev[IDTYPE_KEYBOARD].init ();
+ idev[IDTYPE_KEYBOARD].init();
+#ifndef INPUTDEVICE_SIMPLE
+ idev[IDTYPE_INTERNALEVENT] = inputdevicefunc_internalevent;
+ idev[IDTYPE_INTERNALEVENT].init ();
+#endif
}
-void inputdevice_close (void)
+void inputdevice_close()
{
- idev[IDTYPE_JOYSTICK].close ();
- idev[IDTYPE_MOUSE].close ();
- idev[IDTYPE_KEYBOARD].close ();
+ idev[IDTYPE_JOYSTICK].close();
+ idev[IDTYPE_MOUSE].close();
+ idev[IDTYPE_KEYBOARD].close();
+#ifndef INPUTDEVICE_SIMPLE
+ idev[IDTYPE_INTERNALEVENT].close ();
+ inprec_close(true);
+#endif
}
-static struct uae_input_device *get_uid (const struct inputdevice_functions *id, int devnum)
+static struct uae_input_device* get_uid(const struct inputdevice_functions* id, int devnum)
{
- struct uae_input_device *uid = 0;
- if (id == &idev[IDTYPE_JOYSTICK]) {
+ struct uae_input_device* uid = 0;
+ if (id == &idev[IDTYPE_JOYSTICK])
+ {
uid = &joysticks[devnum];
- } else if (id == &idev[IDTYPE_MOUSE]) {
+ }
+ else if (id == &idev[IDTYPE_MOUSE])
+ {
uid = &mice[devnum];
- } else if (id == &idev[IDTYPE_KEYBOARD]) {
+ }
+ else if (id == &idev[IDTYPE_KEYBOARD])
+ {
uid = &keyboards[devnum];
+#ifndef INPUTDEVICE_SIMPLE
+ } else if (id == &idev[IDTYPE_INTERNALEVENT]) {
+ uid = &internalevents[devnum];
+#endif
}
return uid;
}
-static int get_event_data (const struct inputdevice_functions *id, int devnum, int num, int *eventid, TCHAR **custom, uae_u64 *flags, int *port, int sub)
+static int get_event_data(const struct inputdevice_functions* id, int devnum, int num, int* eventid, TCHAR** custom, uae_u64* flags, int* port, int sub)
{
- const struct uae_input_device *uid = get_uid (id, devnum);
- int type = id->get_widget_type (devnum, num, 0, 0);
+ const struct uae_input_device* uid = get_uid(id, devnum);
+ int type = id->get_widget_type(devnum, num, 0, 0);
int i;
- if (type == IDEV_WIDGET_BUTTON || type == IDEV_WIDGET_BUTTONAXIS) {
- i = num - id->get_widget_first (devnum, IDEV_WIDGET_BUTTON) + ID_BUTTON_OFFSET;
+ if (type == IDEV_WIDGET_BUTTON || type == IDEV_WIDGET_BUTTONAXIS)
+ {
+ i = num - id->get_widget_first(devnum, IDEV_WIDGET_BUTTON) + ID_BUTTON_OFFSET;
*eventid = uid->eventid[i][sub];
if (flags)
*flags = uid->flags[i][sub];
@@ -5164,8 +6151,10 @@ static int get_event_data (const struct inputdevice_functions *id, int devnum, i
if (custom)
*custom = uid->custom[i][sub];
return i;
- } else if (type == IDEV_WIDGET_AXIS) {
- i = num - id->get_widget_first (devnum, type) + ID_AXIS_OFFSET;
+ }
+ else if (type == IDEV_WIDGET_AXIS)
+ {
+ i = num - id->get_widget_first(devnum, type) + ID_AXIS_OFFSET;
*eventid = uid->eventid[i][sub];
if (flags)
*flags = uid->flags[i][sub];
@@ -5174,8 +6163,10 @@ static int get_event_data (const struct inputdevice_functions *id, int devnum, i
if (custom)
*custom = uid->custom[i][sub];
return i;
- } else if (type == IDEV_WIDGET_KEY) {
- i = num - id->get_widget_first (devnum, type);
+ }
+ else if (type == IDEV_WIDGET_KEY)
+ {
+ i = num - id->get_widget_first(devnum, type);
*eventid = uid->eventid[i][sub];
if (flags)
*flags = uid->flags[i][sub];
@@ -5188,25 +6179,27 @@ static int get_event_data (const struct inputdevice_functions *id, int devnum, i
return -1;
}
-static TCHAR *stripstrdup (const TCHAR *s)
+static TCHAR* stripstrdup(const TCHAR* s)
{
- TCHAR *out = my_strdup (s);
+ TCHAR* out = my_strdup(s);
if (!out)
return NULL;
- for (int i = 0; out[i]; i++) {
+ for (int i = 0; out[i]; i++)
+ {
if (out[i] < ' ')
out[i] = ' ';
}
return out;
}
-static int put_event_data (const struct inputdevice_functions *id, int devnum, int num, int eventid, TCHAR *custom, uae_u64 flags, int port, int sub)
+static int put_event_data(const struct inputdevice_functions* id, int devnum, int num, int eventid, TCHAR* custom, uae_u64 flags, int port, int sub)
{
- struct uae_input_device *uid = get_uid (id, devnum);
- int type = id->get_widget_type (devnum, num, 0, 0);
+ struct uae_input_device* uid = get_uid(id, devnum);
+ int type = id->get_widget_type(devnum, num, 0, 0);
int i, ret;
- for (i = 0; i < MAX_INPUT_QUALIFIERS; i++) {
+ for (i = 0; i < MAX_INPUT_QUALIFIERS; i++)
+ {
uae_u64 mask1 = ID_FLAG_QUALIFIER1 << (i * 2);
uae_u64 mask2 = mask1 << 1;
if ((flags & (mask1 | mask2)) == (mask1 | mask2))
@@ -5220,26 +6213,40 @@ static int put_event_data (const struct inputdevice_functions *id, int devnum, i
flags = 0;
ret = -1;
- if (type == IDEV_WIDGET_BUTTON || type == IDEV_WIDGET_BUTTONAXIS) {
- i = num - id->get_widget_first (devnum, IDEV_WIDGET_BUTTON) + ID_BUTTON_OFFSET;
+ if (type == IDEV_WIDGET_BUTTON || type == IDEV_WIDGET_BUTTONAXIS)
+ {
+ i = num - id->get_widget_first(devnum, IDEV_WIDGET_BUTTON) + ID_BUTTON_OFFSET;
uid->eventid[i][sub] = eventid;
uid->flags[i][sub] = flags;
uid->port[i][sub] = port;
xfree (uid->custom[i][sub]);
+#ifndef INPUTDEVICE_SIMPLE
+ uid->custom[i][sub] = custom && _tcslen (custom) > 0 ? stripstrdup (custom) : NULL;
+#endif
ret = i;
- } else if (type == IDEV_WIDGET_AXIS) {
- i = num - id->get_widget_first (devnum, type) + ID_AXIS_OFFSET;
+ }
+ else if (type == IDEV_WIDGET_AXIS)
+ {
+ i = num - id->get_widget_first(devnum, type) + ID_AXIS_OFFSET;
uid->eventid[i][sub] = eventid;
uid->flags[i][sub] = flags;
uid->port[i][sub] = port;
xfree (uid->custom[i][sub]);
+#ifndef INPUTDEVICE_SIMPLE
+ uid->custom[i][sub] = custom && _tcslen (custom) > 0 ? stripstrdup (custom) : NULL;
+#endif
ret = i;
- } else if (type == IDEV_WIDGET_KEY) {
- i = num - id->get_widget_first (devnum, type);
+ }
+ else if (type == IDEV_WIDGET_KEY)
+ {
+ i = num - id->get_widget_first(devnum, type);
uid->eventid[i][sub] = eventid;
uid->flags[i][sub] = flags;
uid->port[i][sub] = port;
xfree (uid->custom[i][sub]);
+#ifndef INPUTDEVICE_SIMPLE
+ uid->custom[i][sub] = custom && _tcslen (custom) > 0 ? stripstrdup (custom) : NULL;
+#endif
ret = i;
}
if (ret < 0)
@@ -5249,14 +6256,17 @@ static int put_event_data (const struct inputdevice_functions *id, int devnum, i
return ret;
}
-static int is_event_used (const struct inputdevice_functions *id, int devnum, int isnum, int isevent)
+static int is_event_used(const struct inputdevice_functions* id, int devnum, int isnum, int isevent)
{
- struct uae_input_device *uid = get_uid (id, devnum);
+ struct uae_input_device* uid = get_uid(id, devnum);
int num, evt, sub;
- for (num = 0; num < id->get_widget_num (devnum); num++) {
- for (sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++) {
- if (get_event_data (id, devnum, num, &evt, NULL, NULL, NULL, sub) >= 0) {
+ for (num = 0; num < id->get_widget_num(devnum); num++)
+ {
+ for (sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++)
+ {
+ if (get_event_data(id, devnum, num, &evt, NULL, NULL, NULL, sub) >= 0)
+ {
if (evt == isevent && isnum != num)
return 1;
}
@@ -5266,11 +6276,11 @@ static int is_event_used (const struct inputdevice_functions *id, int devnum, in
}
// device based index from global device index
-int inputdevice_get_device_index (int devnum)
+int inputdevice_get_device_index(int devnum)
{
- int jcnt = idev[IDTYPE_JOYSTICK].get_num ();
- int mcnt = idev[IDTYPE_MOUSE].get_num ();
- int kcnt = idev[IDTYPE_KEYBOARD].get_num ();
+ int jcnt = idev[IDTYPE_JOYSTICK].get_num();
+ int mcnt = idev[IDTYPE_MOUSE].get_num();
+ int kcnt = idev[IDTYPE_KEYBOARD].get_num();
if (devnum < jcnt)
return devnum;
@@ -5278,49 +6288,114 @@ int inputdevice_get_device_index (int devnum)
return devnum - jcnt;
else if (devnum < jcnt + mcnt + kcnt)
return devnum - (jcnt + mcnt);
+#ifndef INPUTDEVICE_SIMPLE
+ else if (devnum < jcnt + mcnt + kcnt + INTERNALEVENT_COUNT)
+ return devnum - (jcnt + mcnt + kcnt);
+#endif
return -1;
}
+static int getdevnum(int type, int devnum)
+{
+ int jcnt = idev[IDTYPE_JOYSTICK].get_num();
+ int mcnt = idev[IDTYPE_MOUSE].get_num();
+ int kcnt = idev[IDTYPE_KEYBOARD].get_num();
+
+ if (type == IDTYPE_JOYSTICK)
+ return devnum;
+ else if (type == IDTYPE_MOUSE)
+ return jcnt + devnum;
+ else if (type == IDTYPE_KEYBOARD)
+ return jcnt + mcnt + devnum;
+#ifndef INPUTDEVICE_SIMPLE
+ else if (type == IDTYPE_INTERNALEVENT)
+ return jcnt + mcnt + kcnt + devnum;
+#endif
+ return -1;
+}
+
+static int gettype(int devnum)
+{
+ int jcnt = idev[IDTYPE_JOYSTICK].get_num();
+ int mcnt = idev[IDTYPE_MOUSE].get_num();
+ int kcnt = idev[IDTYPE_KEYBOARD].get_num();
+
+ if (devnum < jcnt)
+ return IDTYPE_JOYSTICK;
+ else if (devnum < jcnt + mcnt)
+ return IDTYPE_MOUSE;
+ else if (devnum < jcnt + mcnt + kcnt)
+ return IDTYPE_KEYBOARD;
+#ifndef INPUTDEVICE_SIMPLE
+ else if (devnum < jcnt + mcnt + kcnt + INTERNALEVENT_COUNT)
+ return IDTYPE_INTERNALEVENT;
+#endif
+ return -1;
+}
+
+static struct inputdevice_functions* getidf(int devnum)
+{
+ int type = gettype(devnum);
+ if (type < 0)
+ return NULL;
+ return &idev[type];
+}
+
+struct inputevent* inputdevice_get_eventinfo(int evt)
+{
+ if (evt > 0 && !events[evt].name)
+ return NULL;
+ return &events[evt];
+}
+
+
/* returns number of devices of type "type" */
-int inputdevice_get_device_total (int type)
+int inputdevice_get_device_total(int type)
{
- return idev[type].get_num ();
+ return idev[type].get_num();
}
+
/* returns the name of device */
-const TCHAR *inputdevice_get_device_name (int type, int devnum)
+const char* inputdevice_get_device_name(int type, int devnum)
{
- return idev[type].get_friendlyname (devnum);
+ return idev[type].get_friendlyname(devnum);
}
+
/* returns the name of device */
-const TCHAR *inputdevice_get_device_name2 (int devnum)
+const char* inputdevice_get_device_name2(int devnum)
{
- return getidf (devnum)->get_friendlyname (inputdevice_get_device_index (devnum));
+ return getidf(devnum)->get_friendlyname(inputdevice_get_device_index(devnum));
}
+
/* returns machine readable name of device */
-const TCHAR *inputdevice_get_device_unique_name (int type, int devnum)
+const char* inputdevice_get_device_unique_name(int type, int devnum)
{
- return idev[type].get_uniquename (devnum);
+ return idev[type].get_uniquename(devnum);
}
+
/* returns state (enabled/disabled) */
-int inputdevice_get_device_status (int devnum)
+int inputdevice_get_device_status(int devnum)
{
- const struct inputdevice_functions *idf = getidf (devnum);
+ const struct inputdevice_functions* idf = getidf(devnum);
if (idf == NULL)
return -1;
- struct uae_input_device *uid = get_uid (idf, inputdevice_get_device_index (devnum));
- return uid->enabled != 0;
+ struct uae_input_device* uid = get_uid(idf, inputdevice_get_device_index(devnum));
+ return uid->enabled;
}
/* set state (enabled/disabled) */
-void inputdevice_set_device_status (int devnum, int enabled)
+void inputdevice_set_device_status(int devnum, int enabled)
{
- const struct inputdevice_functions *idf = getidf (devnum);
- int num = inputdevice_get_device_index (devnum);
- struct uae_input_device *uid = get_uid (idf, num);
- if (enabled) { // disable incompatible devices ("super device" vs "raw device")
- for (int i = 0; i < idf->get_num (); i++) {
- if (idf->get_flags (i) != idf->get_flags (num)) {
- struct uae_input_device *uid2 = get_uid (idf, i);
+ const struct inputdevice_functions* idf = getidf(devnum);
+ int num = inputdevice_get_device_index(devnum);
+ struct uae_input_device* uid = get_uid(idf, num);
+ if (enabled)
+ { // disable incompatible devices ("super device" vs "raw device")
+ for (int i = 0; i < idf->get_num(); i++)
+ {
+ if (idf->get_flags(i) != idf->get_flags(num))
+ {
+ struct uae_input_device* uid2 = get_uid(idf, i);
uid2->enabled = 0;
}
}
@@ -5329,14 +6404,14 @@ void inputdevice_set_device_status (int devnum, int enabled)
}
/* returns number of axis/buttons and keys from selected device */
-int inputdevice_get_widget_num (int devnum)
+int inputdevice_get_widget_num(int devnum)
{
- const struct inputdevice_functions *idf = getidf (devnum);
- return idf->get_widget_num (inputdevice_get_device_index (devnum));
+ const struct inputdevice_functions* idf = getidf(devnum);
+ return idf->get_widget_num(inputdevice_get_device_index(devnum));
}
// return name of event, do not use ie->name directly
-bool inputdevice_get_eventname (const struct inputevent *ie, TCHAR *out)
+bool inputdevice_get_eventname(const struct inputevent* ie, TCHAR* out)
{
if (!out)
return false;
@@ -5344,44 +6419,60 @@ bool inputdevice_get_eventname (const struct inputevent *ie, TCHAR *out)
return true;
}
-int inputdevice_iterate (int devnum, int num, TCHAR *name, int *af)
+int inputdevice_iterate(int devnum, int num, TCHAR* name, int* af)
{
- const struct inputdevice_functions *idf = getidf (devnum);
+ const struct inputdevice_functions* idf = getidf(devnum);
static int id_iterator;
- const struct inputevent *ie;
+ struct inputevent* ie;
int mask, data, type;
uae_u64 flags;
- int devindex = inputdevice_get_device_index (devnum);
+ int devindex = inputdevice_get_device_index(devnum);
*af = 0;
*name = 0;
- for (;;) {
+ for (;;)
+ {
ie = &events[++id_iterator];
- if (!ie->confname) {
+ if (!ie->confname)
+ {
id_iterator = 0;
return 0;
}
mask = 0;
- type = idf->get_widget_type (devindex, num, NULL, NULL);
- if (type == IDEV_WIDGET_BUTTON || type == IDEV_WIDGET_BUTTONAXIS) {
- if (idf == &idev[IDTYPE_JOYSTICK]) {
+ type = idf->get_widget_type(devindex, num, NULL, NULL);
+ if (type == IDEV_WIDGET_BUTTON || type == IDEV_WIDGET_BUTTONAXIS)
+ {
+ if (idf == &idev[IDTYPE_JOYSTICK])
+ {
mask |= AM_JOY_BUT;
- } else {
+ }
+ else
+ {
mask |= AM_MOUSE_BUT;
}
- } else if (type == IDEV_WIDGET_AXIS) {
- if (idf == &idev[IDTYPE_JOYSTICK]) {
+ }
+ else if (type == IDEV_WIDGET_AXIS)
+ {
+ if (idf == &idev[IDTYPE_JOYSTICK])
+ {
mask |= AM_JOY_AXIS;
- } else {
+ }
+ else
+ {
mask |= AM_MOUSE_AXIS;
}
- } else if (type == IDEV_WIDGET_KEY) {
+ }
+ else if (type == IDEV_WIDGET_KEY)
+ {
mask |= AM_K;
}
- if (ie->allow_mask & AM_INFO) {
- const struct inputevent *ie2 = ie + 1;
- while (!(ie2->allow_mask & AM_INFO)) {
- if (is_event_used (idf, devindex, ie2 - ie, -1)) {
+ if (ie->allow_mask & AM_INFO)
+ {
+ struct inputevent* ie2 = ie + 1;
+ while (!(ie2->allow_mask & AM_INFO))
+ {
+ if (is_event_used(idf, devindex, ie2 - ie, -1))
+ {
ie2++;
continue;
}
@@ -5394,25 +6485,25 @@ int inputdevice_iterate (int devnum, int num, TCHAR *name, int *af)
}
if (!(ie->allow_mask & mask))
continue;
- get_event_data (idf, devindex, num, &data, NULL, &flags, NULL, 0);
- inputdevice_get_eventname (ie, name);
+ get_event_data(idf, devindex, num, &data, NULL, &flags, NULL, 0);
+ inputdevice_get_eventname(ie, name);
*af = (flags & ID_FLAG_AUTOFIRE) ? 1 : 0;
return 1;
}
}
// return mapped event from devnum/num/sub
-int inputdevice_get_mapping (int devnum, int num, uae_u64 *pflags, int *pport, TCHAR *name, TCHAR *custom, int sub)
+int inputdevice_get_mapping(int devnum, int num, uae_u64* pflags, int* pport, TCHAR* name, TCHAR* custom, int sub)
{
- const struct inputdevice_functions *idf = getidf (devnum);
- const struct uae_input_device *uid = get_uid (idf, inputdevice_get_device_index (devnum));
+ const struct inputdevice_functions* idf = getidf(devnum);
+ const struct uae_input_device* uid = get_uid(idf, inputdevice_get_device_index(devnum));
int port, data;
uae_u64 flags = 0, flag;
- int devindex = inputdevice_get_device_index (devnum);
- TCHAR *customp = NULL;
+ int devindex = inputdevice_get_device_index(devnum);
+ TCHAR* customp = NULL;
if (name)
- _tcscpy (name, _T(""));
+ _tcscpy (name, _T(""));
if (custom)
custom[0] = 0;
if (pflags)
@@ -5421,26 +6512,22 @@ int inputdevice_get_mapping (int devnum, int num, uae_u64 *pflags, int *pport, T
*pport = 0;
if (uid == 0 || num < 0)
return 0;
- if (get_event_data (idf, devindex, num, &data, &customp, &flag, &port, sub) < 0)
+ if (get_event_data(idf, devindex, num, &data, &customp, &flag, &port, sub) < 0)
return 0;
if (customp && custom)
- _tcscpy (custom, customp);
+ _tcscpy (custom, customp);
if (flag & ID_FLAG_AUTOFIRE)
flags |= IDEV_MAPPED_AUTOFIRE_SET;
-#ifndef INPUTDEVICE_SIMPLE
if (flag & ID_FLAG_TOGGLE)
flags |= IDEV_MAPPED_TOGGLE;
if (flag & ID_FLAG_INVERTTOGGLE)
flags |= IDEV_MAPPED_INVERTTOGGLE;
-#endif
if (flag & ID_FLAG_INVERT)
flags |= IDEV_MAPPED_INVERT;
if (flag & ID_FLAG_GAMEPORTSCUSTOM1)
flags |= IDEV_MAPPED_GAMEPORTSCUSTOM1;
-#ifndef INPUTDEVICE_SIMPLE
if (flag & ID_FLAG_GAMEPORTSCUSTOM2)
flags |= IDEV_MAPPED_GAMEPORTSCUSTOM2;
-#endif
if (flag & ID_FLAG_QUALIFIER_MASK)
flags |= flag & ID_FLAG_QUALIFIER_MASK;
if (flag & ID_FLAG_SET_ONOFF)
@@ -5457,27 +6544,29 @@ int inputdevice_get_mapping (int devnum, int num, uae_u64 *pflags, int *pport, T
flags |= IDEV_MAPPED_AUTOFIRE_POSSIBLE;
if (pflags)
*pflags = flags;
- inputdevice_get_eventname (&events[data], name);
+ inputdevice_get_eventname(&events[data], name);
return data;
}
// set event name/custom/flags to devnum/num/sub
-int inputdevice_set_mapping (int devnum, int num, const TCHAR *name, TCHAR *custom, uae_u64 flags, int port, int sub)
+int inputdevice_set_mapping(int devnum, int num, const TCHAR* name, TCHAR* custom, uae_u64 flags, int port, int sub)
{
- const struct inputdevice_functions *idf = getidf (devnum);
- const struct uae_input_device *uid = get_uid (idf, inputdevice_get_device_index (devnum));
+ const struct inputdevice_functions* idf = getidf(devnum);
+ const struct uae_input_device* uid = get_uid(idf, inputdevice_get_device_index(devnum));
int eid, data, portp, amask;
uae_u64 flag;
TCHAR ename[256];
- int devindex = inputdevice_get_device_index (devnum);
- TCHAR *customp = NULL;
+ int devindex = inputdevice_get_device_index(devnum);
+ TCHAR* customp = NULL;
if (uid == 0 || num < 0)
return 0;
- if (name) {
+ if (name)
+ {
eid = 1;
- while (events[eid].name) {
- inputdevice_get_eventname (&events[eid], ename);
+ while (events[eid].name)
+ {
+ inputdevice_get_eventname(&events[eid], ename);
if (!_tcscmp(ename, name))
break;
eid++;
@@ -5486,61 +6575,55 @@ int inputdevice_set_mapping (int devnum, int num, const TCHAR *name, TCHAR *cust
return 0;
if (events[eid].allow_mask & AM_INFO)
return 0;
- } else {
+ }
+ else
+ {
eid = 0;
}
- if (get_event_data (idf, devindex, num, &data, &customp, &flag, &portp, sub) < 0)
+ if (get_event_data(idf, devindex, num, &data, &customp, &flag, &portp, sub) < 0)
return 0;
- if (data >= 0) {
+ if (data >= 0)
+ {
amask = events[eid].allow_mask;
flag &= ~(ID_FLAG_AUTOFIRE_MASK | ID_FLAG_GAMEPORTSCUSTOM_MASK | IDEV_MAPPED_QUALIFIER_MASK | ID_FLAG_INVERT);
- if (amask & AM_AF) {
+ if (amask & AM_AF)
+ {
flag |= (flags & IDEV_MAPPED_AUTOFIRE_SET) ? ID_FLAG_AUTOFIRE : 0;
-#ifndef INPUTDEVICE_SIMPLE
flag |= (flags & IDEV_MAPPED_TOGGLE) ? ID_FLAG_TOGGLE : 0;
flag |= (flags & IDEV_MAPPED_INVERTTOGGLE) ? ID_FLAG_INVERTTOGGLE : 0;
-#endif
}
flag |= (flags & IDEV_MAPPED_INVERT) ? ID_FLAG_INVERT : 0;
flag |= (flags & IDEV_MAPPED_GAMEPORTSCUSTOM1) ? ID_FLAG_GAMEPORTSCUSTOM1 : 0;
-#ifndef INPUTDEVICE_SIMPLE
flag |= (flags & IDEV_MAPPED_GAMEPORTSCUSTOM2) ? ID_FLAG_GAMEPORTSCUSTOM2 : 0;
-#endif
flag |= flags & IDEV_MAPPED_QUALIFIER_MASK;
flag &= ~(IDEV_MAPPED_SET_ONOFF | IDEV_MAPPED_SET_ONOFF_VAL);
- if (amask & AM_SETTOGGLE) {
+ if (amask & AM_SETTOGGLE)
+ {
flag |= (flags & IDEV_MAPPED_SET_ONOFF) ? ID_FLAG_SET_ONOFF : 0;
flag |= (flags & IDEV_MAPPED_SET_ONOFF_VAL) ? ID_FLAG_SET_ONOFF_VAL : 0;
}
if (port >= 0)
portp = port;
- put_event_data (idf, devindex, num, eid, custom, flag, portp, sub);
+ put_event_data(idf, devindex, num, eid, custom, flag, portp, sub);
return 1;
}
return 0;
}
-int inputdevice_get_widget_type (int devnum, int num, TCHAR *name, bool inccode)
+int inputdevice_get_widget_type(int devnum, int num, TCHAR* name)
{
- uae_u32 code = 0;
- const struct inputdevice_functions *idf = getidf (devnum);
- int r = idf->get_widget_type (inputdevice_get_device_index (devnum), num, name, &code);
- if (r && inccode && &idev[IDTYPE_KEYBOARD] == idf) {
- TCHAR *p = name + _tcslen(name);
- if (_tcsncmp(name, _T("KEY_"), 4))
- _stprintf(p, _T(" [0x%02X]"), code);
- }
- return r;
+ const struct inputdevice_functions* idf = getidf(devnum);
+ return idf->get_widget_type(inputdevice_get_device_index(devnum), num, name, 0);
}
static int config_change;
-void inputdevice_config_change (void)
+void inputdevice_config_change()
{
config_change = 1;
}
-int inputdevice_config_change_test (void)
+int inputdevice_config_change_test()
{
int v = config_change;
config_change = 0;
@@ -5548,37 +6631,45 @@ int inputdevice_config_change_test (void)
}
// copy configuration #src to configuration #dst
-void inputdevice_copyconfig (struct uae_prefs *src, struct uae_prefs *dst)
+void inputdevice_copyconfig(const struct uae_prefs* src, struct uae_prefs* dst)
{
+ int i, j;
+
dst->input_selected_setting = src->input_selected_setting;
- dst->input_joymouse_multiplier = src->input_joymouse_multiplier;
+ dst->input_joymouse_multiplier = src->input_joymouse_multiplier;
dst->input_joymouse_deadzone = src->input_joymouse_deadzone;
dst->input_joystick_deadzone = src->input_joystick_deadzone;
dst->input_joymouse_speed = src->input_joymouse_speed;
dst->input_mouse_speed = src->input_mouse_speed;
- dst->input_autofire_linecnt = src->input_autofire_linecnt;
- strcpy(dst->open_gui,src->open_gui);
- strcpy(dst->quit_amiberry,src->quit_amiberry);
- dst->amiberry_use_retroarch_quit = src->amiberry_use_retroarch_quit;
- dst->amiberry_use_retroarch_menu = src->amiberry_use_retroarch_menu;
- dst->amiberry_use_retroarch_reset = src->amiberry_use_retroarch_reset;
+ dst->input_autofire_linecnt = src->input_autofire_linecnt;
+ dst->input_tablet = src->input_tablet;
- for (int i = 0; i < MAX_JPORTS; i++) {
- copyjport (src, dst, i);
- }
-
- for (int i = 0; i < MAX_INPUT_SETTINGS; i++) {
- for (int j = 0; j < MAX_INPUT_DEVICES; j++) {
- memcpy (&dst->joystick_settings[i][j], &src->joystick_settings[i][j], sizeof (struct uae_input_device));
- memcpy (&dst->mouse_settings[i][j], &src->mouse_settings[i][j], sizeof (struct uae_input_device));
- memcpy (&dst->keyboard_settings[i][j], &src->keyboard_settings[i][j], sizeof (struct uae_input_device));
+ dst->amiberry_customControls = src->amiberry_customControls;
+
+ dst->key_for_menu = src->key_for_menu;
+ dst->key_for_quit = src->key_for_quit;
+ dst->button_for_menu = src->button_for_menu;
+ dst->button_for_quit = src->button_for_quit;
+
+ copyjport(src, dst, 0);
+ copyjport(src, dst, 1);
+ copyjport(src, dst, 2);
+ copyjport(src, dst, 3);
+
+ for (i = 0; i < MAX_INPUT_SETTINGS; i++)
+ {
+ for (j = 0; j < MAX_INPUT_DEVICES; j++)
+ {
+ memcpy(&dst->joystick_settings[i][j], &src->joystick_settings[i][j], sizeof (struct uae_input_device));
+ memcpy(&dst->mouse_settings[i][j], &src->mouse_settings[i][j], sizeof (struct uae_input_device));
+ memcpy(&dst->keyboard_settings[i][j], &src->keyboard_settings[i][j], sizeof (struct uae_input_device));
}
}
- inputdevice_updateconfig (src, dst);
+ inputdevice_updateconfig(src, dst);
}
-static void swapevent (struct uae_input_device *uid, int i, int j, int evt)
+static void swapevent(struct uae_input_device* uid, int i, int j, int evt)
{
uid->eventid[i][j] = evt;
int port = uid->port[i][j];
@@ -5593,7 +6684,7 @@ static void swapevent (struct uae_input_device *uid, int i, int j, int evt)
uid->port[i][j] = port;
}
-static void swapjoydevice (struct uae_input_device *uid, const int **swaps)
+static void swapjoydevice(struct uae_input_device *uid, int **swaps)
{
for (int i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
for (int j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
@@ -5602,9 +6693,10 @@ static void swapjoydevice (struct uae_input_device *uid, const int **swaps)
int evtnum;
for (int kk = 0; (evtnum = swaps[k][kk]) >= 0 && !found; kk++) {
if (uid->eventid[i][j] == evtnum) {
- swapevent (uid, i, j, swaps[1 - k][kk]);
+ swapevent(uid, i, j, swaps[1 - k][kk]);
found = true;
- } else {
+ }
+ else {
for (int jj = 0; axistable[jj] >= 0; jj += 3) {
if (evtnum == axistable[jj] || evtnum == axistable[jj + 1] || evtnum == axistable[jj + 2]) {
for (int ii = 0; ii < 3; ii++) {
@@ -5612,7 +6704,7 @@ static void swapjoydevice (struct uae_input_device *uid, const int **swaps)
int evtnum2 = swaps[1 - k][kk];
for (int m = 0; axistable[m] >= 0; m += 3) {
if (evtnum2 == axistable[m] || evtnum2 == axistable[m + 1] || evtnum2 == axistable[m + 2]) {
- swapevent (uid, i, j, axistable[m + ii]);
+ swapevent(uid, i, j, axistable[m + ii]);
found = true;
}
}
@@ -5628,25 +6720,39 @@ static void swapjoydevice (struct uae_input_device *uid, const int **swaps)
}
// swap gameports ports, remember to handle customized ports too
-void inputdevice_swap_compa_ports (struct uae_prefs *prefs, int portswap)
+void inputdevice_swap_compa_ports(struct uae_prefs* prefs, int portswap)
{
struct jport tmp;
- memcpy (&tmp, &prefs->jports[portswap], sizeof (struct jport));
- memcpy (&prefs->jports[portswap], &prefs->jports[portswap + 1], sizeof (struct jport));
- memcpy (&prefs->jports[portswap + 1], &tmp, sizeof (struct jport));
- inputdevice_updateconfig (NULL, prefs);
+#if 0
+ if ((prefs->jports[portswap].id == JPORT_CUSTOM || prefs->jports[portswap + 1].id == JPORT_CUSTOM)) {
+ const int *swaps[2];
+ swaps[0] = rem_ports[portswap];
+ swaps[1] = rem_ports[portswap + 1];
+ for (int l = 0; l < MAX_INPUT_DEVICES; l++) {
+ swapjoydevice(&prefs->joystick_settings[GAMEPORT_INPUT_SETTINGS][l], swaps);
+ swapjoydevice(&prefs->mouse_settings[GAMEPORT_INPUT_SETTINGS][l], swaps);
+ swapjoydevice(&prefs->keyboard_settings[GAMEPORT_INPUT_SETTINGS][l], swaps);
+ }
+ }
+#endif
+ memcpy(&tmp, &prefs->jports[portswap], sizeof (struct jport));
+ memcpy(&prefs->jports[portswap], &prefs->jports[portswap + 1], sizeof (struct jport));
+ memcpy(&prefs->jports[portswap + 1], &tmp, sizeof (struct jport));
+ inputdevice_updateconfig(NULL, prefs);
}
// swap device "devnum" ports 0<>1 and 2<>3
-void inputdevice_swap_ports (struct uae_prefs *p, int devnum)
+void inputdevice_swap_ports(struct uae_prefs* p, int devnum)
{
- const struct inputdevice_functions *idf = getidf (devnum);
- struct uae_input_device *uid = get_uid (idf, inputdevice_get_device_index (devnum));
+ const struct inputdevice_functions* idf = getidf(devnum);
+ struct uae_input_device* uid = get_uid(idf, inputdevice_get_device_index(devnum));
int i, j, k, event, unit;
const struct inputevent *ie, *ie2;
- for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++) {
- for (j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
+ for (i = 0; i < MAX_INPUT_DEVICE_EVENTS; i++)
+ {
+ for (j = 0; j < MAX_INPUT_SUB_EVENT; j++)
+ {
event = uid->eventid[i][j];
if (event <= 0)
continue;
@@ -5655,10 +6761,12 @@ void inputdevice_swap_ports (struct uae_prefs *p, int devnum)
continue;
unit = ie->unit;
k = 1;
- while (events[k].confname) {
+ while (events[k].confname)
+ {
ie2 = &events[k];
if (ie2->type == ie->type && ie2->data == ie->data && ie2->unit - 1 == ((ie->unit - 1) ^ 1) &&
- ie2->allow_mask == ie->allow_mask && uid->port[i][j] == 0) {
+ ie2->allow_mask == ie->allow_mask && uid->port[i][j] == 0)
+ {
uid->eventid[i][j] = k;
break;
}
@@ -5669,27 +6777,37 @@ void inputdevice_swap_ports (struct uae_prefs *p, int devnum)
}
//memcpy (p->joystick_settings[dst], p->joystick_settings[src], sizeof (struct uae_input_device) * MAX_INPUT_DEVICES);
-static void copydev (struct uae_input_device *dst, struct uae_input_device *src, int selectedwidget)
+static void copydev(struct uae_input_device* dst, struct uae_input_device* src, int selectedwidget)
{
- for (int i = 0; i < MAX_INPUT_DEVICES; i++) {
- for (int j = 0; j < MAX_INPUT_DEVICE_EVENTS; j++) {
- if (j == selectedwidget || selectedwidget < 0) {
- for (int k = 0; k < MAX_INPUT_SUB_EVENT_ALL; k++) {
- xfree (dst[i].custom[j][k]);
- }
- }
+ for (int i = 0; i < MAX_INPUT_DEVICES; i++)
+ {
+ for (int j = 0; j < MAX_INPUT_DEVICE_EVENTS; j++)
+ {
+ if (j == selectedwidget || selectedwidget < 0)
+ {
+ for (int k = 0; k < MAX_INPUT_SUB_EVENT_ALL; k++)
+ {
+ xfree (dst[i].custom[j][k]);
+ }
+ }
+ }
+ if (selectedwidget < 0)
+ {
+ xfree (dst[i].configname);
+ xfree (dst[i].name);
}
- if (selectedwidget < 0) {
- xfree (dst[i].configname);
- xfree (dst[i].name);
- }
}
- if (selectedwidget < 0) {
- memcpy (dst, src, sizeof (struct uae_input_device) * MAX_INPUT_DEVICES);
- } else {
+ if (selectedwidget < 0)
+ {
+ memcpy(dst, src, sizeof (struct uae_input_device) * MAX_INPUT_DEVICES);
+ }
+ else
+ {
int j = selectedwidget;
- for (int i = 0; i < MAX_INPUT_DEVICES; i++) {
- for (int k = 0; k < MAX_INPUT_SUB_EVENT_ALL; k++) {
+ for (int i = 0; i < MAX_INPUT_DEVICES; i++)
+ {
+ for (int k = 0; k < MAX_INPUT_SUB_EVENT_ALL; k++)
+ {
dst[i].eventid[j][k] = src[i].eventid[j][k];
dst[i].custom[j][k] = src[i].custom[j][k];
dst[i].flags[j][k] = src[i].flags[j][k];
@@ -5698,128 +6816,121 @@ static void copydev (struct uae_input_device *dst, struct uae_input_device *src,
dst[i].extra[j] = src[i].extra[j];
}
}
- for (int i = 0; i < MAX_INPUT_DEVICES; i++) {
- for (int j = 0; j < MAX_INPUT_DEVICE_EVENTS; j++) {
- if (j == selectedwidget || selectedwidget < 0) {
- for (int k = 0; k < MAX_INPUT_SUB_EVENT_ALL; k++) {
- if (dst[i].custom)
- dst[i].custom[j][k] = my_strdup (dst[i].custom[j][k]);
- }
- }
+ for (int i = 0; i < MAX_INPUT_DEVICES; i++)
+ {
+ for (int j = 0; j < MAX_INPUT_DEVICE_EVENTS; j++)
+ {
+ if (j == selectedwidget || selectedwidget < 0)
+ {
+ for (int k = 0; k < MAX_INPUT_SUB_EVENT_ALL; k++)
+ {
+ if (dst[i].custom)
+ dst[i].custom[j][k] = my_strdup(dst[i].custom[j][k]);
+ }
+ }
}
- if (selectedwidget < 0) {
- dst[i].configname = my_strdup (dst[i].configname);
- dst[i].name = my_strdup (dst[i].name);
+ if (selectedwidget < 0)
+ {
+ dst[i].configname = my_strdup(dst[i].configname);
+ dst[i].name = my_strdup(dst[i].name);
}
- }
+ }
}
// copy whole configuration #x-slot to another
// +1 = default
// +2 = default (pc keyboard)
-void inputdevice_copy_single_config (struct uae_prefs *p, int src, int dst, int devnum, int selectedwidget)
+void inputdevice_copy_single_config(struct uae_prefs* p, int src, int dst, int devnum, int selectedwidget)
{
- if (selectedwidget >= 0) {
+ if (selectedwidget >= 0)
+ {
if (devnum < 0)
return;
- if (gettype (devnum) != IDTYPE_KEYBOARD)
+ if (gettype(devnum) != IDTYPE_KEYBOARD)
return;
}
- if (src >= MAX_INPUT_SETTINGS) {
- if (gettype (devnum) == IDTYPE_KEYBOARD) {
+ if (src >= MAX_INPUT_SETTINGS)
+ {
+ if (gettype(devnum) == IDTYPE_KEYBOARD)
+ {
p->input_keyboard_type = src > MAX_INPUT_SETTINGS ? 1 : 0;
keyboard_default = keyboard_default_table[p->input_keyboard_type];
- inputdevice_default_kb (p, dst);
+ inputdevice_default_kb(p, dst);
}
}
if (src == dst)
return;
- if (src < MAX_INPUT_SETTINGS) {
- if (devnum < 0 || gettype (devnum) == IDTYPE_JOYSTICK)
- copydev (p->joystick_settings[dst], p->joystick_settings[src], selectedwidget);
- if (devnum < 0 || gettype (devnum) == IDTYPE_MOUSE)
- copydev (p->mouse_settings[dst], p->mouse_settings[src], selectedwidget);
- if (devnum < 0 || gettype (devnum) == IDTYPE_KEYBOARD)
- copydev (p->keyboard_settings[dst], p->keyboard_settings[src], selectedwidget);
+ if (src < MAX_INPUT_SETTINGS)
+ {
+ if (devnum < 0 || gettype(devnum) == IDTYPE_JOYSTICK)
+ copydev(p->joystick_settings[dst], p->joystick_settings[src], selectedwidget);
+ if (devnum < 0 || gettype(devnum) == IDTYPE_MOUSE)
+ copydev(p->mouse_settings[dst], p->mouse_settings[src], selectedwidget);
+ if (devnum < 0 || gettype(devnum) == IDTYPE_KEYBOARD)
+ copydev(p->keyboard_settings[dst], p->keyboard_settings[src], selectedwidget);
}
}
-void inputdevice_acquire (int allmode)
+void inputdevice_acquire(int allmode)
{
int i;
//write_log (_T("inputdevice_acquire\n"));
for (i = 0; i < MAX_INPUT_DEVICES; i++)
- idev[IDTYPE_JOYSTICK].unacquire (i);
+ idev[IDTYPE_JOYSTICK].unacquire(i);
for (i = 0; i < MAX_INPUT_DEVICES; i++)
- idev[IDTYPE_MOUSE].unacquire (i);
+ idev[IDTYPE_MOUSE].unacquire(i);
for (i = 0; i < MAX_INPUT_DEVICES; i++)
- idev[IDTYPE_KEYBOARD].unacquire (i);
+ idev[IDTYPE_KEYBOARD].unacquire(i);
- for (i = 0; i < MAX_INPUT_DEVICES; i++) {
- if ((use_joysticks[i] && allmode >= 0) || (allmode && !idev[IDTYPE_JOYSTICK].get_flags (i)))
- idev[IDTYPE_JOYSTICK].acquire (i, 0);
+ for (i = 0; i < MAX_INPUT_DEVICES; i++)
+ {
+ if ((use_joysticks[i] && allmode >= 0) || (allmode && !idev[IDTYPE_JOYSTICK].get_flags(i)))
+ idev[IDTYPE_JOYSTICK].acquire(i, 0);
}
- for (i = 0; i < MAX_INPUT_DEVICES; i++) {
- if ((use_mice[i] && allmode >= 0) || (allmode && !idev[IDTYPE_MOUSE].get_flags (i)))
- idev[IDTYPE_MOUSE].acquire (i, allmode < 0);
+ for (i = 0; i < MAX_INPUT_DEVICES; i++)
+ {
+ if ((use_mice[i] && allmode >= 0) || (allmode && !idev[IDTYPE_MOUSE].get_flags(i)))
+ idev[IDTYPE_MOUSE].acquire(i, allmode < 0);
}
- // Always acquire first + enabled keyboards
- for (i = 0; i < MAX_INPUT_DEVICES; i++) {
- if (use_keyboards[i] || i == 0)
- idev[IDTYPE_KEYBOARD].acquire (i, allmode < 0);
+ for (i = 0; i < MAX_INPUT_DEVICES; i++)
+ {
+ if ((use_keyboards[i] && allmode >= 0) || (allmode < 0 && !idev[IDTYPE_KEYBOARD].get_flags(i)))
+ idev[IDTYPE_KEYBOARD].acquire(i, allmode < 0);
}
if (input_acquired)
return;
- idev[IDTYPE_JOYSTICK].acquire (-1, 0);
- idev[IDTYPE_MOUSE].acquire (-1, 0);
- idev[IDTYPE_KEYBOARD].acquire (-1, 0);
+ idev[IDTYPE_JOYSTICK].acquire(-1, 0);
+ idev[IDTYPE_MOUSE].acquire(-1, 0);
+ idev[IDTYPE_KEYBOARD].acquire(-1, 0);
// if (!input_acquired)
// write_log (_T("input devices acquired (%s)\n"), allmode ? "all" : "selected only");
input_acquired = 1;
}
-void inputdevice_unacquire(bool emulationactive, int inputmask)
+void inputdevice_unacquire()
{
int i;
- //write_log (_T("inputdevice_unacquire %d %d\n"), emulationactive, inputmask);
+ //write_log (_T("inputdevice_unacquire\n"));
- if (!emulationactive)
- inputmask = 0;
-
-
- if (!(inputmask & 4)) {
- for (i = 0; i < MAX_INPUT_DEVICES; i++)
- idev[IDTYPE_JOYSTICK].unacquire (i);
- }
- if (!(inputmask & 2)) {
- for (i = 0; i < MAX_INPUT_DEVICES; i++)
- idev[IDTYPE_MOUSE].unacquire (i);
- }
- if (!(inputmask & 1)) {
- for (i = 0; i < MAX_INPUT_DEVICES; i++)
- idev[IDTYPE_KEYBOARD].unacquire (i);
- }
+ for (i = 0; i < MAX_INPUT_DEVICES; i++)
+ idev[IDTYPE_JOYSTICK].unacquire(i);
+ for (i = 0; i < MAX_INPUT_DEVICES; i++)
+ idev[IDTYPE_MOUSE].unacquire(i);
+ for (i = 0; i < MAX_INPUT_DEVICES; i++)
+ idev[IDTYPE_KEYBOARD].unacquire(i);
if (!input_acquired)
return;
input_acquired = 0;
- if (!(inputmask & 4))
- idev[IDTYPE_JOYSTICK].unacquire (-1);
- if (!(inputmask & 2))
- idev[IDTYPE_MOUSE].unacquire (-1);
- if (!(inputmask & 1))
- idev[IDTYPE_KEYBOARD].unacquire (-1);
-}
-
-void inputdevice_unacquire(void)
-{
- inputdevice_unacquire(false, 0);
+ idev[IDTYPE_JOYSTICK].unacquire(-1);
+ idev[IDTYPE_MOUSE].unacquire(-1);
+ idev[IDTYPE_KEYBOARD].unacquire(-1);
}
/* Call this function when host machine's joystick/joypad/etc button state changes
@@ -5832,26 +6943,58 @@ void inputdevice_unacquire(void)
* state = 0 -> button released
*/
-void setjoybuttonstate (int joy, int button, int state)
+void setjoybuttonstate(int joy, int button, int state)
{
- setbuttonstateall (&joysticks[joy], &joysticks2[joy], button, state ? 1 : 0);
+ setbuttonstateall(&joysticks[joy], &joysticks2[joy], button, state ? 1 : 0);
}
-void setmousebuttonstate (int mouse, int button, int state)
+/* buttonmask = 1 = normal toggle button, 0 = mouse wheel turn or similar
+*/
+void setjoybuttonstateall (int joy, uae_u32 buttonbits, uae_u32 buttonmask)
+{
+ int i;
+
+ for (i = 0; i < ID_BUTTON_TOTAL; i++) {
+ if (buttonmask & (1 << i))
+ setbuttonstateall(&joysticks[joy], &joysticks2[joy], i, (buttonbits & (1 << i)) ? 1 : 0);
+ else if (buttonbits & (1 << i))
+ setbuttonstateall(&joysticks[joy], &joysticks2[joy], i, -1);
+ }
+}
+/* mouse buttons (just like joystick buttons)
+*/
+void setmousebuttonstateall(int mouse, uae_u32 buttonbits, uae_u32 buttonmask)
+{
+ int i;
+ uae_u32 obuttonmask = mice2[mouse].buttonmask;
+
+ for (i = 0; i < ID_BUTTON_TOTAL; i++) {
+ if (buttonmask & (1 << i))
+ setbuttonstateall(&mice[mouse], &mice2[mouse], i, (buttonbits & (1 << i)) ? 1 : 0);
+ else if (buttonbits & (1 << i))
+ setbuttonstateall(&mice[mouse], &mice2[mouse], i, -1);
+ }
+ if (obuttonmask != mice2[mouse].buttonmask)
+ mousehack_helper(mice2[mouse].buttonmask);
+}
+
+void setmousebuttonstate(int mouse, int button, int state)
{
uae_u32 obuttonmask = mice2[mouse].buttonmask;
- setbuttonstateall (&mice[mouse], &mice2[mouse], button, state);
+
+ setbuttonstateall(&mice[mouse], &mice2[mouse], button, state);
if (obuttonmask != mice2[mouse].buttonmask)
- mousehack_helper (mice2[mouse].buttonmask);
+ mousehack_helper(mice2[mouse].buttonmask);
}
+
/* same for joystick axis (analog or digital)
* (0 = center, -max = full left/top, max = full right/bottom)
*/
-void setjoystickstate (int joy, int axis, int state, int max)
+void setjoystickstate(int joy, int axis, int state, int max)
{
- struct uae_input_device *id = &joysticks[joy];
- struct uae_input_device2 *id2 = &joysticks2[joy];
+ struct uae_input_device* id = &joysticks[joy];
+ struct uae_input_device2* id2 = &joysticks2[joy];
int deadzone = currprefs.input_joymouse_deadzone * max / 100;
int i, v1, v2;
@@ -5865,7 +7008,8 @@ void setjoystickstate (int joy, int axis, int state, int max)
//write_log (_T("%d:%d new=%d old=%d state=%d max=%d\n"), joy, axis, v1, v2, state, max);
- if (!joysticks[joy].enabled) {
+ if (!joysticks[joy].enabled)
+ {
if (v1 > 0)
v1 = 1;
else if (v1 < 0)
@@ -5874,17 +7018,21 @@ void setjoystickstate (int joy, int axis, int state, int max)
v2 = 1;
else if (v2 < 0)
v2 = -1;
- if (v1 && v1 != v2 && (axis == 0 || axis == 1)) {
+ if (v1 && v1 != v2 && (axis == 0 || axis == 1))
+ {
static int prevdir;
static struct timeval tv1;
struct timeval tv2;
- gettimeofday (&tv2, NULL);
- if ((uae_s64)tv2.tv_sec * 1000000 + tv2.tv_usec < (uae_s64)tv1.tv_sec * 1000000 + tv1.tv_usec + 500000 && prevdir == v1) {
- switchdevice (&joysticks[joy], v1 < 0 ? 0 : 1, false);
+ gettimeofday(&tv2, NULL);
+ if ((uae_s64)tv2.tv_sec * 1000000 + tv2.tv_usec < (uae_s64)tv1.tv_sec * 1000000 + tv1.tv_usec + 500000 && prevdir == v1)
+ {
+ switchdevice(&joysticks[joy], v1 < 0 ? 0 : 1, false);
tv1.tv_sec = 0;
tv1.tv_usec = 0;
prevdir = 0;
- } else {
+ }
+ else
+ {
tv1.tv_sec = tv2.tv_sec;
tv1.tv_usec = tv2.tv_usec;
prevdir = v1;
@@ -5892,54 +7040,66 @@ void setjoystickstate (int joy, int axis, int state, int max)
}
return;
}
- for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) {
+ for (i = 0; i < MAX_INPUT_SUB_EVENT; i++)
+ {
uae_u64 flags = id->flags[ID_AXIS_OFFSET + axis][i];
int state2 = v1;
if (flags & ID_FLAG_INVERT)
state2 = -state2;
- if (state2 != id2->states[axis][i]) {
+ if (state2 != id2->states[axis][i])
+ {
//write_log(_T("-> %d %d\n"), i, state2);
- handle_input_event (id->eventid[ID_AXIS_OFFSET + axis][i], state2, max, flags & ID_FLAG_AUTOFIRE);
+#ifdef INPUTDEVICE_SIMPLE
+ handle_input_event(id->eventid[ID_AXIS_OFFSET + axis][i], state2, max, flags & ID_FLAG_AUTOFIRE);
+#else
+ handle_input_event (id->eventid[ID_AXIS_OFFSET + axis][i], state2, max, flags & ID_FLAG_AUTOFIRE, true, false);
+#endif
id2->states[axis][i] = state2;
}
}
id2->states[axis][MAX_INPUT_SUB_EVENT] = v1;
}
-int getjoystickstate (int joy)
+
+int getjoystickstate(int joy)
{
return joysticks[joy].enabled;
}
-void setmousestate (int mouse, int axis, int data, int isabs)
+void setmousestate(int mouse, int axis, int data, int isabs)
{
int i, v, diff;
int *mouse_p, *oldm_p;
float d;
- struct uae_input_device *id = &mice[mouse];
+ struct uae_input_device* id = &mice[mouse];
static float fract[MAX_INPUT_DEVICES][MAX_INPUT_DEVICE_EVENTS];
- if (!mice[mouse].enabled) {
- if (isabs && currprefs.input_tablet > 0) {
+ if (!mice[mouse].enabled)
+ {
+ if (isabs && currprefs.input_tablet > 0)
+ {
if (axis == 0)
lastmx = data;
else
lastmy = data;
if (axis)
- mousehack_helper (mice2[mouse].buttonmask);
+ mousehack_helper(mice2[mouse].buttonmask);
}
return;
}
d = 0;
mouse_p = &mouse_axis[mouse][axis];
oldm_p = &oldm_axis[mouse][axis];
- if (!isabs) {
+ if (!isabs)
+ {
// eat relative movements while in mousehack mode
- if (currprefs.input_tablet == TABLET_MOUSEHACK && mousehack_alive () && axis < 2)
+ if (currprefs.input_tablet == TABLET_MOUSEHACK && mousehack_alive())
return;
*oldm_p = *mouse_p;
*mouse_p += data;
d = (*mouse_p - *oldm_p) * currprefs.input_mouse_speed / 100.0f;
- } else {
+ }
+ else
+ {
d = data - *oldm_p;
*oldm_p = data;
*mouse_p += d;
@@ -5948,51 +7108,111 @@ void setmousestate (int mouse, int axis, int data, int isabs)
else
lastmy = data;
if (axis)
- mousehack_helper (mice2[mouse].buttonmask);
- if (currprefs.input_tablet == TABLET_MOUSEHACK && mousehack_alive () && axis < 2)
+ mousehack_helper(mice2[mouse].buttonmask);
+ if (currprefs.input_tablet == TABLET_MOUSEHACK && mousehack_alive())
return;
}
- v = (int)d;
+ v = int(d);
fract[mouse][axis] += d - v;
- diff = (int)fract[mouse][axis];
+ diff = int(fract[mouse][axis]);
v += diff;
fract[mouse][axis] -= diff;
- for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) {
+ for (i = 0; i < MAX_INPUT_SUB_EVENT; i++)
+ {
uae_u64 flags = id->flags[ID_AXIS_OFFSET + axis][i];
if (!isabs && (flags & ID_FLAG_INVERT))
v = -v;
- handle_input_event (id->eventid[ID_AXIS_OFFSET + axis][i], v, 0, 0);
- }
+#ifdef INPUTDEVICE_SIMPLE
+ handle_input_event(id->eventid[ID_AXIS_OFFSET + axis][i], v, 0, 0);
+#else
+ handle_input_event (id->eventid[ID_AXIS_OFFSET + axis][i], v, 0, 0, true, false);
+#endif
+ }
}
-int getmousestate (int joy)
+int getmousestate(int joy)
{
return mice[joy].enabled;
}
-int jsem_isjoy (int port, const struct uae_prefs *p)
+void warpmode(int mode)
+{
+ int fr, fr2;
+
+ fr = currprefs.gfx_framerate;
+ if (fr == 0)
+ fr = -1;
+ fr2 = currprefs.turbo_emulation;
+ if (fr2 == -1)
+ fr2 = 0;
+
+ if (mode < 0) {
+ if (currprefs.turbo_emulation) {
+ changed_prefs.gfx_framerate = currprefs.gfx_framerate = fr2;
+ currprefs.turbo_emulation = 0;
+ }
+ else {
+ currprefs.turbo_emulation = fr;
+ }
+ }
+ else if (mode == 0 && currprefs.turbo_emulation) {
+ if (currprefs.turbo_emulation > 0)
+ changed_prefs.gfx_framerate = currprefs.gfx_framerate = fr2;
+ currprefs.turbo_emulation = 0;
+ }
+ else if (mode > 0 && !currprefs.turbo_emulation) {
+ currprefs.turbo_emulation = fr;
+ }
+ if (currprefs.turbo_emulation) {
+ if (!currprefs.cpu_cycle_exact && !currprefs.blitter_cycle_exact)
+ changed_prefs.gfx_framerate = currprefs.gfx_framerate = 10;
+ pause_sound();
+ }
+ else {
+ resume_sound();
+ }
+ compute_vsynctime();
+#ifdef RETROPLATFORM
+ rp_turbo_cpu(currprefs.turbo_emulation);
+#endif
+ changed_prefs.turbo_emulation = currprefs.turbo_emulation;
+ set_config_changed();
+ setsystime();
+}
+
+void pausemode(int mode)
+{
+ if (mode < 0)
+ pause_emulation = pause_emulation ? 0 : 9;
+ else
+ pause_emulation = mode;
+ set_config_changed();
+ setsystime();
+}
+
+int jsem_isjoy(int port, const struct uae_prefs* p)
{
int v = JSEM_DECODEVAL (port, p);
if (v < JSEM_JOYS)
return -1;
v -= JSEM_JOYS;
- if (v >= inputdevice_get_device_total (IDTYPE_JOYSTICK))
+ if (v >= inputdevice_get_device_total(IDTYPE_JOYSTICK))
return -1;
return v;
}
-int jsem_ismouse (int port, const struct uae_prefs *p)
+int jsem_ismouse(int port, const struct uae_prefs* p)
{
int v = JSEM_DECODEVAL (port, p);
if (v < JSEM_MICE)
return -1;
v -= JSEM_MICE;
- if (v >= inputdevice_get_device_total (IDTYPE_MOUSE))
+ if (v >= inputdevice_get_device_total(IDTYPE_MOUSE))
return -1;
return v;
}
-int jsem_iskbdjoy (int port, const struct uae_prefs *p)
+int jsem_iskbdjoy(int port, const struct uae_prefs* p)
{
int v = JSEM_DECODEVAL (port, p);
if (v < JSEM_KBDLAYOUT)
@@ -6003,7 +7223,9 @@ int jsem_iskbdjoy (int port, const struct uae_prefs *p)
return v;
}
-static bool fixjport (struct jport *port, int add, bool always)
+static struct jport stored_ports[MAX_JPORTS];
+
+static bool fixjport(struct jport *port, int add, bool always)
{
bool wasinvalid = false;
int vv = port->id;
@@ -6012,265 +7234,254 @@ static bool fixjport (struct jport *port, int add, bool always)
if (vv >= JSEM_JOYS && vv < JSEM_MICE) {
vv -= JSEM_JOYS;
vv += add;
- if (vv >= inputdevice_get_device_total (IDTYPE_JOYSTICK))
+ if (vv >= inputdevice_get_device_total(IDTYPE_JOYSTICK))
vv = 0;
vv += JSEM_JOYS;
- } else if (vv >= JSEM_MICE && vv < JSEM_END) {
+ }
+ else if (vv >= JSEM_MICE && vv < JSEM_END) {
vv -= JSEM_MICE;
vv += add;
- if (vv >= inputdevice_get_device_total (IDTYPE_MOUSE))
+ if (vv >= inputdevice_get_device_total(IDTYPE_MOUSE))
vv = 0;
vv += JSEM_MICE;
- } else if (vv >= JSEM_KBDLAYOUT && vv < JSEM_LASTKBD) {
+ }
+ else if (vv >= JSEM_KBDLAYOUT && vv < JSEM_LASTKBD) {
vv -= JSEM_KBDLAYOUT;
vv += add;
if (vv >= JSEM_LASTKBD)
vv = 0;
vv += JSEM_KBDLAYOUT;
}
+ else if (vv >= JSEM_CUSTOM && vv < JSEM_CUSTOM + MAX_JPORTS_CUSTOM) {
+ vv -= JSEM_CUSTOM;
+ vv += add;
+ if (vv >= MAX_JPORTS_CUSTOM)
+ vv = 0;
+ vv += JSEM_CUSTOM;
+ }
if (port->id != vv || always) {
port->idc.shortid[0] = 0;
port->idc.configname[0] = 0;
port->idc.name[0] = 0;
if (vv >= JSEM_JOYS && vv < JSEM_MICE) {
- _tcscpy(port->idc.name, inputdevice_get_device_name (IDTYPE_JOYSTICK, vv - JSEM_JOYS));
- _tcscpy(port->idc.configname, inputdevice_get_device_unique_name (IDTYPE_JOYSTICK, vv - JSEM_JOYS));
- } else if (vv >= JSEM_MICE && vv < JSEM_END) {
- _tcscpy(port->idc.name, inputdevice_get_device_name (IDTYPE_MOUSE, vv - JSEM_MICE));
- _tcscpy(port->idc.configname, inputdevice_get_device_unique_name (IDTYPE_MOUSE, vv - JSEM_MICE));
- } else if (vv >= JSEM_KBDLAYOUT && vv < JSEM_CUSTOM) {
+ _tcscpy(port->idc.name, inputdevice_get_device_name(IDTYPE_JOYSTICK, vv - JSEM_JOYS));
+ _tcscpy(port->idc.configname, inputdevice_get_device_unique_name(IDTYPE_JOYSTICK, vv - JSEM_JOYS));
+ }
+ else if (vv >= JSEM_MICE && vv < JSEM_END) {
+ _tcscpy(port->idc.name, inputdevice_get_device_name(IDTYPE_MOUSE, vv - JSEM_MICE));
+ _tcscpy(port->idc.configname, inputdevice_get_device_unique_name(IDTYPE_MOUSE, vv - JSEM_MICE));
+ }
+ else if (vv >= JSEM_KBDLAYOUT && vv < JSEM_CUSTOM) {
_stprintf(port->idc.shortid, _T("kbd%d"), vv - JSEM_KBDLAYOUT + 1);
}
wasinvalid = true;
+#if 0
+ write_log(_T("fixjport %d %d %d (%s)\n"), port->id, vv, add, port->name);
+#endif
}
port->id = vv;
return wasinvalid;
}
-static void inputdevice_get_previous_joy(struct uae_prefs *p, int portnum)
+void inputdevice_validate_jports(struct uae_prefs* p, int changedport)
{
- struct jport *jpx = &p->jports[portnum];
- bool found = false;
- int idx = 0;
- for (;;) {
- struct jport *jp = inputdevice_get_used_device(portnum, idx);
- if (!jp)
- break;
- if (jp->idc.configname[0]) {
- found = inputdevice_joyport_config(p, jp->idc.name, jp->idc.configname, portnum, jp->mode, 1, true) != 0;
- if (!found && jp->id == JPORT_UNPLUGGED)
- found = inputdevice_joyport_config(p, jp->idc.name, NULL, portnum, jp->mode, 1, true) != 0;
- } else if (jp->id < JSEM_JOYS && jp->id >= 0) {
- jpx->id = jp->id;
- found = true;
- }
- if (found) {
- jpx->mode = jp->mode;
- jpx->autofire = jp->autofire;
- inputdevice_set_newest_used_device(portnum, jp);
- break;
- }
- idx++;
+ int i, j;
+ for (i = 0; i < MAX_JPORTS; i++) {
+ fixjport(&p->jports[i], 0, changedport == i);
}
- if (!found) {
- if (default_keyboard_layout[portnum] > 0) {
- p->jports[portnum].id = default_keyboard_layout[portnum] - 1;
- } else {
- p->jports[portnum].id = JPORT_NONE;
- }
- }
-}
-
-void inputdevice_validate_jports (struct uae_prefs *p, int changedport, bool *fixedports)
-{
- for (int i = 0; i < MAX_JPORTS; i++) {
- fixjport (&p->jports[i], 0, changedport == i);
- }
-
- for (int i = 0; i < MAX_JPORTS; i++) {
+ for (i = 0; i < MAX_JPORTS; i++)
+ {
if (p->jports[i].id < 0)
continue;
- for (int j = 0; j < MAX_JPORTS; j++) {
+ for (j = 0; j < MAX_JPORTS; j++)
+ {
if (p->jports[j].id < 0)
continue;
if (j == i)
continue;
- if (p->jports[i].id == p->jports[j].id) {
+ if (p->jports[i].id == p->jports[j].id)
+ {
+ if (i == changedport)
+ {
+ restore_inputdevice_config(p, j);
+ }
+ else if (j == changedport)
+ {
+ restore_inputdevice_config(p, i);
+ }
int cnt = 0;
- for (;;) {
+ while (p->jports[i].id == p->jports[j].id)
+ {
int k;
- if (i == changedport) {
+ if (i == changedport)
+ {
k = j;
- if (fixedports && fixedports[k]) {
- k = i;
- }
- } else {
+ }
+ else
+ {
k = i;
}
- // same in other slots too?
- bool other = false;
- for (int l = 0; l < MAX_JPORTS; l++) {
- if (l == k)
- continue;
- if (p->jports[l].id == p->jports[k].id) {
- other = true;
- }
- }
-
- if (!other && p->jports[i].id != p->jports[j].id)
+ fixjport(&p->jports[k], 1, false);
+ cnt++;
+ if (cnt > 10)
+ p->jports[k].id = JSEM_KBDLAYOUT;
+ if (cnt > 20)
break;
-
- struct jport *jp = NULL;
- for (;;) {
- jp = inputdevice_get_used_device(k, cnt);
- cnt++;
- if (!jp)
- break;
- if (jp->id < 0)
- continue;
- memcpy(&p->jports[k].id, jp, sizeof(struct jport));
- if (fixjport(&p->jports[k], 0, false))
- continue;
- inputdevice_set_newest_used_device(k, &p->jports[k]);
- break;
- }
- if (jp)
- continue;
- freejport(p, k);
- break;
}
}
}
}
}
+static void inputdevice_inserted(struct uae_prefs* p, int portnum, int id, int type)
+{
+ for (int k = 0; k < MAX_JPORTS; k++)
+ {
+ if (p->jports[k].id == id && k != portnum)
+ {
+ if (type == IDTYPE_JOYSTICK)
+ {
+ // if this joystick is already in port 0, reset port 0 back to original
+ if (k == 0 && portnum == 1)
+ {
+ memcpy(&p->jports[0], &stored_ports[0], sizeof (struct jport));
+ return;
+ }
+ }
+ else if (type == IDTYPE_MOUSE)
+ {
+ return;
+ }
+ return;
+ }
+ }
+}
+
+void store_inputdevice_config(struct uae_prefs* p)
+{
+ for (int i = 0; i < MAX_JPORTS; i++)
+ {
+ memcpy(&stored_ports[i], &p->jports[i], sizeof (struct jport));
+ }
+}
+
+void restore_inputdevice_config(struct uae_prefs* p, int portnum)
+{
+ memcpy(&p->jports[portnum], &stored_ports[portnum], sizeof (struct jport));
+}
+
void inputdevice_joyport_config_store(struct uae_prefs *p, const TCHAR *value, int portnum, int mode, int type)
{
struct jport *jp = &p->jports[portnum];
if (type == 2) {
_tcscpy(jp->idc.name, value);
- } else if (type == 1) {
+ }
+ else if (type == 1) {
_tcscpy(jp->idc.configname, value);
- } else {
+ }
+ else {
_tcscpy(jp->idc.shortid, value);
}
if (mode >= 0)
jp->mode = mode;
}
-int inputdevice_joyport_config (struct uae_prefs *p, const TCHAR *value1, const TCHAR *value2, int portnum, int mode, int type, bool candefault)
+int inputdevice_joyport_config(struct uae_prefs* p, const TCHAR* value, int portnum, int mode, int type, bool validate)
{
switch (type)
{
- case 1: // check and set
- case 2: // check only
+ case 1:
+ case 2:
{
- for (int j = 0; j < 2; j++) {
- int matched = -1;
- struct inputdevice_functions *idf;
- int dtype = IDTYPE_MOUSE;
+ int i, j;
+ for (j = 0; j < MAX_JPORTS; j++)
+ {
+ struct inputdevice_functions* idf;
+ int type = IDTYPE_MOUSE;
int idnum = JSEM_MICE;
- if (j > 0) {
- dtype = IDTYPE_JOYSTICK;
+ if (j > 0)
+ {
+ type = IDTYPE_JOYSTICK;
idnum = JSEM_JOYS;
}
- idf = &idev[dtype];
- if (value1 && value2) {
- for (int i = 0; i < idf->get_num(); i++) {
- const TCHAR* name1 = idf->get_friendlyname(i);
- const TCHAR* name2 = idf->get_uniquename(i);
- if (name2 && !_tcscmp(name2, value2) && name1 && !_tcscmp(name1, value1)) {
- // config+friendlyname matched: don't bother to check for duplicates
- matched = i;
- break;
- }
- }
- }
- if (matched < 0 && value2) {
- matched = -1;
- for (int i = 0; i < idf->get_num (); i++) {
- const TCHAR* name2 = idf->get_uniquename(i);
- if (name2 && !_tcscmp (name2, value2)) {
- if (matched >= 0) {
- matched = -2;
- break;
- } else {
- matched = i;
- }
- }
- }
- }
- if (matched < 0 && value1) {
- matched = -1;
- for (int i = 0; i < idf->get_num (); i++) {
- const TCHAR* name1 = idf->get_friendlyname(i);
- if (name1 && !_tcscmp (name1, value1)) {
- if (matched >= 0) {
- matched = -2;
- break;
- } else {
- matched = i;
- }
- }
- }
- }
- if (matched >= 0) {
- if (type == 1) {
- if (value1)
- _tcscpy(p->jports[portnum].idc.name, value1);
- if (value2)
- _tcscpy(p->jports[portnum].idc.configname, value2);
- p->jports[portnum].id = idnum + matched;
+ idf = &idev[type];
+ for (i = 0; i < idf->get_num(); i++)
+ {
+ const char* name2 = idf->get_uniquename(i);
+ if (name2 && !_tcscmp (name2, value))
+ {
+ if (validate)
+ inputdevice_inserted(p, portnum, idnum + i, type);
+ p->jports[portnum].id = idnum + i;
if (mode >= 0)
p->jports[portnum].mode = mode;
- set_config_changed ();
+ return 1;
+ }
+ }
+ for (i = 0; i < idf->get_num(); i++)
+ {
+ const char* name1 = idf->get_friendlyname(i);
+ if (name1 && !_tcscmp (name1, value))
+ {
+ if (validate)
+ inputdevice_inserted(p, portnum, idnum + i, type);
+ p->jports[portnum].id = idnum + i;
+ if (mode >= 0)
+ p->jports[portnum].mode = mode;
+ return 1;
}
- return 1;
}
}
- return 0;
}
break;
case 0:
{
int start = JPORT_NONE, got = 0, max = -1;
int type = -1;
- const TCHAR *pp = NULL;
- if (_tcsncmp (value1, _T("kbd"), 3) == 0) {
+ const TCHAR* pp = 0;
+ if (_tcsncmp (value, _T("kbd"), 3) == 0)
+ {
start = JSEM_KBDLAYOUT;
- pp = value1 + 3;
+ pp = value + 3;
got = 1;
max = JSEM_LASTKBD;
- } else if (_tcscmp(value1, _T("joydefault")) == 0) {
+ }
+ else if (_tcsncmp (value, _T("joy"), 3) == 0)
+ {
type = IDTYPE_JOYSTICK;
start = JSEM_JOYS;
+ pp = value + 3;
got = 1;
- } else if (_tcscmp(value1, _T("mousedefault")) == 0) {
+ max = idev[IDTYPE_JOYSTICK].get_num();
+ }
+ else if (_tcsncmp (value, _T("mouse"), 5) == 0)
+ {
type = IDTYPE_MOUSE;
start = JSEM_MICE;
+ pp = value + 5;
got = 1;
- } else if (_tcsncmp (value1, _T("joy"), 3) == 0) {
- type = IDTYPE_JOYSTICK;
- start = JSEM_JOYS;
- pp = value1 + 3;
- got = 1;
- max = idev[IDTYPE_JOYSTICK].get_num ();
- } else if (_tcsncmp (value1, _T("mouse"), 5) == 0) {
- type = IDTYPE_MOUSE;
- start = JSEM_MICE;
- pp = value1 + 5;
- got = 1;
- max = idev[IDTYPE_MOUSE].get_num ();
- } else if (_tcscmp(value1, _T("none")) == 0) {
+ max = idev[IDTYPE_MOUSE].get_num();
+ }
+ else if (_tcscmp (value, _T("none")) == 0)
+ {
got = 2;
}
- if (got) {
- if (pp && max != 0) {
+ else if (_tcscmp (value, _T("custom")) == 0)
+ {
+ got = 2;
+ start = JSEM_CUSTOM;
+ }
+ if (got)
+ {
+ if (pp && max != 0)
+ {
int v = _tstol (pp);
- if (start >= 0) {
+ if (start >= 0)
+ {
if (start == JSEM_KBDLAYOUT && v > 0)
v--;
- if (v >= 0) {
+ if (v >= 0)
+ {
if (v >= max)
v = 0;
start += v;
@@ -6278,22 +7489,21 @@ int inputdevice_joyport_config (struct uae_prefs *p, const TCHAR *value1, const
}
}
}
- if (got >= 2) {
+ if (got == 2)
+ {
+ if (validate)
+ inputdevice_inserted(p, portnum, start, type);
p->jports[portnum].id = start;
if (mode >= 0)
p->jports[portnum].mode = mode;
if (start < JSEM_JOYS)
- default_keyboard_layout[portnum] = start + 1;
- if (got == 2 && candefault) {
- inputdevice_store_used_device(&p->jports[portnum], portnum, false);
- }
- set_config_changed ();
+ default_keyboard_layout[portnum] = start;
return 1;
}
- // joystick not found, select previously used or default
- if (start == JSEM_JOYS && p->jports[portnum].id < JSEM_JOYS) {
- inputdevice_get_previous_joy(p, portnum);
- set_config_changed ();
+ // joystick not found, select default
+ if (start == JSEM_JOYS && p->jports[portnum].id < JSEM_JOYS)
+ {
+ p->jports[portnum].id = default_keyboard_layout[portnum];
return 1;
}
}
@@ -6303,116 +7513,108 @@ int inputdevice_joyport_config (struct uae_prefs *p, const TCHAR *value1, const
return 0;
}
-int inputdevice_getjoyportdevice (int port, int val)
+int inputdevice_getjoyportdevice(int port, int val)
{
int idx;
- if (val < 0) {
+ if (val == JSEM_CUSTOM)
+ {
+ idx = inputdevice_get_device_total(IDTYPE_JOYSTICK) + JSEM_LASTKBD;
+ if (port < 2)
+ idx += inputdevice_get_device_total(IDTYPE_MOUSE);
+ }
+ else if (val < 0)
+ {
idx = -1;
- } else if (val >= JSEM_MICE) {
+ }
+ else if (val >= JSEM_MICE)
+ {
idx = val - JSEM_MICE;
- if (idx >= inputdevice_get_device_total (IDTYPE_MOUSE))
+ if (idx >= inputdevice_get_device_total(IDTYPE_MOUSE))
idx = 0;
else
- idx += inputdevice_get_device_total (IDTYPE_JOYSTICK);
+ idx += inputdevice_get_device_total(IDTYPE_JOYSTICK);
idx += JSEM_LASTKBD;
- } else if (val >= JSEM_JOYS) {
+ }
+ else if (val >= JSEM_JOYS)
+ {
idx = val - JSEM_JOYS;
- if (idx >= inputdevice_get_device_total (IDTYPE_JOYSTICK))
+ if (idx >= inputdevice_get_device_total(IDTYPE_JOYSTICK))
idx = 0;
idx += JSEM_LASTKBD;
- } else {
+ }
+ else
+ {
idx = val - JSEM_KBDLAYOUT;
}
return idx;
}
-void inputdevice_fix_prefs(struct uae_prefs *p, bool userconfig)
+// for state recorder use only!
+
+uae_u8 *save_inputstate(int *len, uae_u8 *dstptr)
{
- struct jport jport_config_store[MAX_JPORTS];
+ uae_u8 *dstbak, *dst;
+ if (dstptr)
+ dstbak = dst = dstptr;
+ else
+ dstbak = dst = xmalloc(uae_u8, 1000);
for (int i = 0; i < MAX_JPORTS; i++) {
- memcpy(&jport_config_store[i], &p->jports[i], sizeof(struct jport));
+ save_u16(joydir[i]);
+ save_u16(joybutton[i]);
+ save_u16(otop[i]);
+ save_u16(obot[i]);
+ save_u16(oleft[i]);
+ save_u16(oright[i]);
}
-
- bool defaultports = userconfig == false;
- bool matched[MAX_JPORTS];
- // configname+friendlyname first
- for (int i = 0; i < MAX_JPORTS; i++) {
- struct jport *jp = &jport_config_store[i];
- matched[i] = false;
- if (jp->idc.configname[0] && jp->idc.name[0]) {
- if (inputdevice_joyport_config(p, jp->idc.name, jp->idc.configname, i, jp->mode, 1, userconfig)) {
- inputdevice_validate_jports(p, i, matched);
- inputdevice_store_used_device(&p->jports[i], i, defaultports);
- matched[i] = true;
- write_log(_T("Port%d: COMBO '%s' + '%s' matched\n"), i, jp->idc.name, jp->idc.configname);
- }
+ for (int i = 0; i < NORMAL_JPORTS; i++) {
+ save_u16(cd32_shifter[i]);
+ for (int j = 0; j < 2; j++) {
+ save_u16(pot_cap[i][j]);
+ save_u16(joydirpot[i][j]);
}
}
- // configname next
- for (int i = 0; i < MAX_JPORTS; i++) {
- if (!matched[i]) {
- struct jport *jp = &jport_config_store[i];
- if (jp->idc.configname[0]) {
- if (inputdevice_joyport_config(p, NULL, jp->idc.configname, i, jp->mode, 1, userconfig)) {
- inputdevice_validate_jports(p, i, matched);
- inputdevice_store_used_device(&p->jports[i], i, defaultports);
- matched[i] = true;
- write_log(_T("Port%d: CONFIG '%s' matched\n"), i, jp->idc.configname);
- }
- }
- }
- }
- // friendly name next
- for (int i = 0; i < MAX_JPORTS; i++) {
- if (!matched[i]) {
- struct jport *jp = &jport_config_store[i];
- if (jp->idc.name[0]) {
- if (inputdevice_joyport_config(p, jp->idc.name, NULL, i, jp->mode, 1, userconfig)) {
- inputdevice_validate_jports(p, i, matched);
- inputdevice_store_used_device(&p->jports[i], i, defaultports);
- matched[i] = true;
- write_log(_T("Port%d: NAME '%s' matched\n"), i, jp->idc.name);
- }
- }
- }
- }
- // joyportX last and only if no name/configname
- for (int i = 0; i < MAX_JPORTS; i++) {
- if (!matched[i]) {
- struct jport *jp = &jport_config_store[i];
- if (jp->idc.shortid[0] && !jp->idc.name[0] && !jp->idc.configname[0]) {
- if (inputdevice_joyport_config(p, jp->idc.shortid, NULL, i, jp->mode, 0, userconfig)) {
- inputdevice_validate_jports(p, i, matched);
- inputdevice_store_used_device(&p->jports[i], i, defaultports);
- matched[i] = true;
- write_log(_T("Port%d: ID '%s' matched\n"), i, jp->idc.shortid);
- }
- }
- if (!matched[i]) {
- if (jp->idc.configname[0] && jp->idc.name[0]) {
- struct jport jpt = { 0 };
- memcpy(&jpt.idc, &jp->idc, sizeof(struct inputdevconfig));
- jpt.id = JPORT_UNPLUGGED;
- write_log(_T("Unplugged stored, port %d '%s' (%s)\n"), i, jp->idc.name, jp->idc.configname);
- inputdevice_store_used_device(&jpt, i, defaultports);
- freejport(p, i);
- inputdevice_get_previous_joy(p, i);
- matched[i] = true;
- }
- }
- }
- }
- for (int i = 0; i < MAX_JPORTS; i++) {
- if (!matched[i]) {
- struct jport *jp = &jport_config_store[i];
- freejport(p, i);
- if (jp->id != JPORT_NONE) {
- inputdevice_get_previous_joy(p, i);
- write_log(_T("Port%d: ID=%d getting previous: %d\n"), i, jp->id, p->jports[i].id);
- } else {
- write_log(_T("Port%d: NONE\n"), i);
- }
+ for (int i = 0; i < NORMAL_JPORTS; i++) {
+ for (int j = 0; j < MOUSE_AXIS_TOTAL; j++) {
+ save_u16(mouse_delta[i][j]);
+ save_u16(mouse_deltanoreset[i][j]);
}
+ save_u16(mouse_frame_x[i]);
+ save_u16(mouse_frame_y[i]);
}
+ *len = dst - dstbak;
+ return dstbak;
}
+
+uae_u8 *restore_inputstate(uae_u8 *src)
+{
+ for (int i = 0; i < MAX_JPORTS; i++) {
+ joydir[i] = restore_u16();
+ joybutton[i] = restore_u16();
+ otop[i] = restore_u16();
+ obot[i] = restore_u16();
+ oleft[i] = restore_u16();
+ oright[i] = restore_u16();
+ }
+ for (int i = 0; i < NORMAL_JPORTS; i++) {
+ cd32_shifter[i] = restore_u16();
+ for (int j = 0; j < 2; j++) {
+ pot_cap[i][j] = restore_u16();
+ joydirpot[i][j] = restore_u16();
+ }
+ }
+ for (int i = 0; i < NORMAL_JPORTS; i++) {
+ for (int j = 0; j < MOUSE_AXIS_TOTAL; j++) {
+ mouse_delta[i][j] = restore_u16();
+ mouse_deltanoreset[i][j] = restore_u16();
+ }
+ mouse_frame_x[i] = restore_u16();
+ mouse_frame_y[i] = restore_u16();
+ }
+ return src;
+}
+
+void clear_inputstate()
+{
+
+}
\ No newline at end of file
diff --git a/src/jit/compemu.h b/src/jit/compemu.h
index 247dfed4..5ea9ca9e 100644
--- a/src/jit/compemu.h
+++ b/src/jit/compemu.h
@@ -2,7 +2,7 @@
* compiler/compemu.h - Public interface and definitions
*
* Copyright (c) 2001-2004 Milan Jurik of ARAnyM dev team (see AUTHORS)
- *
+ *
* Inspired by Christian Bauer's Basilisk II
*
* This file is part of the ARAnyM project which builds a new and powerful
@@ -29,16 +29,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef COMPEMU_H
-#define COMPEMU_H
-
typedef uae_u32 uintptr;
+#define panicbug printf
+
/* Flags for Bernie during development/debugging. Should go away eventually */
#define DISTRUST_CONSISTENT_MEM 0
-/* Now that we do block chaining, and also have linked lists on each tag,
- TAGMASK can be much smaller and still do its job. Saves several megs
- of memory! */
#define TAGMASK 0x0000ffff
#define TAGSIZE (TAGMASK+1)
#define MAXRUN 1024
@@ -49,13 +45,15 @@ extern uae_u32 start_pc;
struct blockinfo_t;
-typedef struct {
- uae_u16* location;
- uae_u8 cycles;
- uae_u8 specmem;
+typedef struct
+{
+ uae_u16* location;
+ uae_u8 cycles;
+ uae_u8 specmem;
} cpu_history;
-typedef union {
+typedef union
+{
cpuop_func* handler;
struct blockinfo_t* bi;
} cacheline;
@@ -77,6 +75,8 @@ typedef union {
#define USE_CHECKSUM_INFO 1
#endif
+#define USE_ALIAS 1
+#define USE_F_ALIAS 1
#define COMP_DEBUG 0
#if COMP_DEBUG
@@ -131,6 +131,7 @@ typedef union {
/* Functions exposed to newcpu, or to what was moved from newcpu.c to
* compemu_support.c */
+extern void compiler_init(void);
extern void compiler_exit(void);
extern void init_comp(void);
extern void flush(int save_regs);
@@ -142,8 +143,8 @@ extern void set_cache_state(int enabled);
extern int get_cache_state(void);
extern uae_u32 get_jitted_size(void);
#ifdef JIT
-extern void flush_icache(int n);
-extern void flush_icache_hard(int n);
+extern void (*flush_icache)(uaecptr ptr, int n);
+extern void flush_icache_hard(uaecptr ptr, int n);
#endif
extern void alloc_cache(void);
extern void compile_block(cpu_history* pc_hist, int blocklen, int totcyles);
@@ -156,6 +157,9 @@ extern uae_u8* comp_pc_p;
extern void* pushall_call_handler;
#define VREGS 32
+#ifdef USE_JIT_FPU
+#define VFREGS 16
+#endif
#define INMEM 1
#define CLEAN 2
@@ -163,28 +167,42 @@ extern void* pushall_call_handler;
#define UNDEF 4
#define ISCONST 5
-typedef struct {
- uae_u32* mem;
- uae_u32 val;
- uae_u8 status;
- uae_s8 realreg; /* gb-- realreg can hold -1 */
- uae_u8 realind; /* The index in the holds[] array */
- uae_u8 validsize;
- uae_u8 dirtysize;
+typedef struct
+{
+ uae_u32* mem;
+ uae_u32 val;
+ uae_u8 status;
+ uae_s8 realreg; /* gb-- realreg can hold -1 */
+ uae_u8 realind; /* The index in the holds[] array */
+ uae_u8 validsize;
+ uae_u8 dirtysize;
} reg_status;
-typedef struct {
+#ifdef USE_JIT_FPU
+typedef struct
+{
+ uae_u32* mem;
+ double val;
+ uae_u8 status;
+ uae_s8 realreg; /* gb-- realreg can hold -1 */
+ uae_u8 realind;
+ uae_u8 needflush;
+} freg_status;
+#endif
+
+typedef struct
+{
uae_u8 use_flags;
uae_u8 set_flags;
uae_u8 is_addx;
- uae_u8 cflow;
+ uae_u8 cflow;
} op_properties;
extern op_properties prop[65536];
STATIC_INLINE int end_block(uae_u16 opcode)
{
- return (prop[opcode].cflow & fl_end_block);
+ return (prop[opcode].cflow & fl_end_block);
}
#define PC_P 16
@@ -209,13 +227,24 @@ STATIC_INLINE int end_block(uae_u16 opcode)
#define FS2 10
#define FS3 11
-typedef struct {
- uae_u32 touched;
- uae_s8 holds[VREGS];
- uae_u8 nholds;
- uae_u8 locked;
+typedef struct
+{
+ uae_u32 touched;
+ uae_s8 holds[VREGS];
+ uae_u8 nholds;
+ uae_u8 locked;
} n_status;
+#ifdef USE_JIT_FPU
+typedef struct
+{
+ uae_u32 touched;
+ uae_s8 holds[VFREGS];
+ uae_u8 nholds;
+ uae_u8 locked;
+} fn_status;
+#endif
+
/* For flag handling */
#define NADA 1
#define TRASH 2
@@ -226,23 +255,31 @@ typedef struct {
#define NF_TOMEM 1
#define NF_HANDLER 2
-typedef struct {
+typedef struct
+{
/* Integer part */
reg_status state[VREGS];
n_status nat[N_REGS];
uae_u32 flags_on_stack;
uae_u32 flags_in_flags;
uae_u32 flags_are_important;
+#ifdef USE_JIT_FPU
+ /* FPU part */
+ freg_status fate[VFREGS];
+ fn_status fat[N_FREGS];
+#endif
} bigstate;
-typedef struct {
+typedef struct
+{
/* Integer part */
- uae_s8 virt[VREGS];
- uae_s8 nat[N_REGS];
+ uae_s8 virt[VREGS];
+ uae_s8 nat[N_REGS];
} smallstate;
extern int touchcnt;
+
#define IMM uae_s32
#define RR1 uae_u32
#define RR2 uae_u32
@@ -274,12 +311,10 @@ extern int touchcnt;
#if defined(CPU_arm)
#include "compemu_midfunc_arm.h"
#include "compemu_midfunc_arm2.h"
+#else
+#include "compemu_midfunc_x86.h"
#endif
-//#if defined(CPU_i386) || defined(CPU_x86_64)
-//#include "compemu_midfunc_x86.h"
-//#endif
-
#undef DECLARE_MIDFUNC
extern int failure;
@@ -309,21 +344,24 @@ extern void register_branch(uae_u32 not_taken, uae_u32 taken, uae_u8 cond);
struct blockinfo_t;
-typedef struct dep_t {
- uae_u32* jmp_off;
- struct blockinfo_t* target;
- struct blockinfo_t* source;
- struct dep_t** prev_p;
- struct dep_t* next;
+typedef struct dep_t
+{
+ uae_u32* jmp_off;
+ struct blockinfo_t* target;
+ struct blockinfo_t* source;
+ struct dep_t** prev_p;
+ struct dep_t* next;
} dependency;
-typedef struct checksum_info_t {
- uae_u8 *start_p;
- uae_u32 length;
- struct checksum_info_t *next;
+typedef struct checksum_info_t
+{
+ uae_u8 *start_p;
+ uae_u32 length;
+ struct checksum_info_t *next;
} checksum_info;
-typedef struct blockinfo_t {
+typedef struct blockinfo_t
+{
uae_s32 count;
cpuop_func* direct_handler_to_use;
cpuop_func* handler_to_use;
@@ -335,7 +373,6 @@ typedef struct blockinfo_t {
cpuop_func* direct_pen;
cpuop_func* direct_pcc;
- uae_u8* nexthandler;
uae_u8* pc_p;
uae_u32 c1;
@@ -360,6 +397,11 @@ typedef struct blockinfo_t {
dependency dep[2]; /* Holds things we depend on */
dependency* deplist; /* List of things that depend on this */
smallstate env;
+
+#ifdef JIT_DEBUG
+ /* (gb) size of the compiled block (direct handler) */
+ uae_u32 direct_handler_size;
+#endif
} blockinfo;
#define BI_INVALID 0
@@ -381,9 +423,3 @@ void comp_fbcc_opp (uae_u32 opcode);
void comp_fsave_opp (uae_u32 opcode);
void comp_frestore_opp (uae_u32 opcode);
void comp_fpp_opp (uae_u32 opcode, uae_u16 extra);
-
-void jit_abort(const TCHAR *format,...);
-
-#define uae_p32(x) ((uae_u32)(x))
-
-#endif /* COMPEMU_H */
diff --git a/src/jit/compemu_support.cpp b/src/jit/compemu_support.cpp
index 699033ce..32624363 100644
--- a/src/jit/compemu_support.cpp
+++ b/src/jit/compemu_support.cpp
@@ -29,6 +29,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
#define writemem_special writemem
#define readmem_special readmem
@@ -43,22 +44,10 @@
#include "custom.h"
#include "comptbl.h"
#include "compemu.h"
-#include
+#include "SDL.h"
#define DEBUG 0
-
-#if DEBUG
-#define PROFILE_COMPILE_TIME 1
-#define PROFILE_UNTRANSLATED_INSNS 1
-#endif
-
-#ifndef UNUSED
-#define UNUSED(x) ((void)x)
-#endif
-
-#define jit_log(format, ...) \
- write_log("JIT: " format "\n", ##__VA_ARGS__);
-#define jit_log2(format, ...)
+#include "debug.h"
#ifdef JIT_DEBUG
#undef abort
@@ -70,28 +59,11 @@
} while (0)
#endif
-#ifdef PROFILE_COMPILE_TIME
-#include
-static uae_u32 compile_count = 0;
-static clock_t compile_time = 0;
-static clock_t emul_start_time = 0;
-static clock_t emul_end_time = 0;
-#endif
-
-#ifdef PROFILE_UNTRANSLATED_INSNS
-static int untranslated_top_ten = 30;
-static uae_u32 raw_cputbl_count[65536] = { 0, };
-static uae_u16 opcode_nums[65536];
-
-
-static int untranslated_compfn(const void *e1, const void *e2)
-{
- return raw_cputbl_count[*(const uae_u16 *)e1] < raw_cputbl_count[*(const uae_u16 *)e2];
-}
-#endif
-
#define NATMEM_OFFSETX (uae_u32)natmem_offset
+// %%% BRIAN KING WAS HERE %%%
+#include
+extern void jit_abort(const TCHAR*,...);
static compop_func *compfunctbl[65536];
static compop_func *nfcompfunctbl[65536];
#ifdef NOFLAGS_SUPPORT
@@ -100,19 +72,31 @@ static cpuop_func *nfcpufunctbl[65536];
uae_u8* comp_pc_p;
// gb-- Extra data for Basilisk II/JIT
+#ifdef JIT_DEBUG
+static int JITDebug = 0; // Enable runtime disassemblers through mon?
+#else
+const int JITDebug= 0; // Don't use JIT debug mode at all
+#endif
#if USE_INLINING
-#define follow_const_jumps (true)
+static int follow_const_jumps = 1; // Flag: translation through constant jumps
#else
const int follow_const_jumps = 0;
#endif
-static uae_u32 cache_size = 0; // Size of total cache allocated for compiled blocks
static uae_u32 current_cache_size = 0; // Cache grows upwards: how much has been consumed already
-#define avoid_fpu (true)
-static const int align_loops = 0; // Align the start of loops
-static const int align_jumps = 0; // Align the start of jumps
-static int optcount[10] = {
+static int lazy_flush = 1; // Flag: lazy translation cache invalidation
+static int avoid_fpu = 1; // Flag: compile FPU instructions ?
+const int tune_alignment = 1; // Tune code alignments for running CPU ?
+const int tune_nop_fillers = 1; // Tune no-op fillers for architecture
+static int setzflg_uses_bsf = 0; // setzflg virtual instruction can use native BSF instruction correctly?
+static int align_loops = 0; // Align the start of loops
+static int align_jumps = 0; // Align the start of jumps
+static int optcount[10] = {
+#ifdef UAE
4, // How often a block has to be executed before it is translated
+#else
+ 10, // How often a block has to be executed before it is translated
+#endif
0, // How often to use naive translation
0, 0, 0, 0,
-1, -1, -1, -1
@@ -125,6 +109,11 @@ STATIC_INLINE bool is_const_jump(uae_u32 opcode)
return (prop[opcode].cflow == fl_const_jump);
}
+STATIC_INLINE bool may_trap(uae_u32 opcode)
+{
+ return (prop[opcode].cflow & fl_trap);
+}
+
STATIC_INLINE unsigned int cft_map (unsigned int f)
{
return f;
@@ -141,11 +130,11 @@ static int branch_cc;
static int redo_current_block;
int segvcount = 0;
-uae_u8* current_compile_p = NULL;
+static uae_u8* current_compile_p = NULL;
static uae_u8* max_compile_start;
uae_u8* compiled_code = NULL;
const int POPALLSPACE_SIZE = 2048; /* That should be enough space */
-uae_u8 *popallspace = NULL;
+static uae_u8 *popallspace = NULL;
void* pushall_call_handler = NULL;
static void* popall_do_nothing = NULL;
@@ -156,18 +145,16 @@ static void* popall_recompile_block = NULL;
static void* popall_check_checksum = NULL;
/* The 68k only ever executes from even addresses. So right now, we
- * waste half the entries in this array
- * UPDATE: We now use those entries to store the start of the linked
- * lists that we maintain for each hash result.
- */
+ waste half the entries in this array
+ UPDATE: We now use those entries to store the start of the linked
+ lists that we maintain for each hash result. */
static cacheline cache_tags[TAGSIZE];
static int letit=0;
static blockinfo* hold_bi[MAX_HOLD_BI];
-blockinfo* active;
-blockinfo* dormant;
+static blockinfo* active;
+static blockinfo* dormant;
-#if !defined (WIN32) || !defined(ANDROID)
-#include
+#ifdef AMIBERRY
void cache_free (uae_u8 *cache, int size)
{
@@ -184,7 +171,7 @@ uae_u8 *cache_alloc (int size)
}
else
memset(cache, 0, size);
- return (uae_u8 *) cache;
+ return static_cast(cache);
}
#endif
@@ -195,7 +182,6 @@ extern const struct cputbl op_smalltbl_0_nf[];
#endif
extern const struct comptbl op_smalltbl_0_comp_nf[];
extern const struct comptbl op_smalltbl_0_comp_ff[];
-
#ifdef NOFLAGS_SUPPORT
/* 68020 + 68881 */
extern const struct cputbl op_smalltbl_1_nf[];
@@ -209,6 +195,11 @@ extern const struct cputbl op_smalltbl_4_nf[];
extern const struct cputbl op_smalltbl_5_nf[];
#endif
+//static void flush_icache_hard(uaecptr ptr, int n);
+static void flush_icache_lazy(uaecptr ptr, int n);
+static void flush_icache_none(uaecptr ptr, int n);
+void (*flush_icache)(uaecptr ptr, int n) = flush_icache_none;
+
static bigstate live;
static smallstate empty_ss;
static smallstate default_ss;
@@ -221,15 +212,18 @@ static int readreg_specific(int r, int size, int spec);
static int writereg_specific(int r, int size, int spec);
static void prepare_for_call_1(void);
static void prepare_for_call_2(void);
-STATIC_INLINE void align_target(uae_u32 a);
+#ifndef ALIGN_NOT_NEEDED
+static void align_target(uae_u32 a);
+#endif
-STATIC_INLINE void flush_cpu_icache(void *from, void *to);
-STATIC_INLINE void write_jmp_target(uae_u32 *jmpaddr, cpuop_func* a);
-STATIC_INLINE void emit_jmp_target(uae_u32 a);
+static void inline flush_cpu_icache(void *from, void *to);
+static void inline write_jmp_target(uae_u32 *jmpaddr, cpuop_func* a);
+static void inline emit_jmp_target(uae_u32 a);
uae_u32 m68k_pc_offset;
/* Flag handling is complicated.
+
*
* x86 instructions create flags, which quite often are exactly what we
* want. So at times, the "68k" flags are actually in the x86 flags.
@@ -318,7 +312,7 @@ STATIC_INLINE void add_to_cl_list(blockinfo* bi)
cache_tags[cl].handler = bi->handler_to_use;
}
-void raise_in_cl_list(blockinfo* bi)
+STATIC_INLINE void raise_in_cl_list(blockinfo* bi)
{
remove_from_cl_list(bi);
add_to_cl_list(bi);
@@ -373,14 +367,14 @@ STATIC_INLINE void adjust_jmpdep(dependency* d, cpuop_func* a)
STATIC_INLINE void set_dhtu(blockinfo* bi, cpuop_func* dh)
{
- jit_log2("bi is %p", bi);
+ D2(panicbug("bi is %p\n", bi));
if (dh != bi->direct_handler_to_use) {
dependency* x = bi->deplist;
- jit_log2("bi->deplist=%p", bi->deplist);
+ D2(panicbug("bi->deplist=%p\n", bi->deplist));
while (x) {
- jit_log2("x is %p", x);
- jit_log2("x->next is %p", x->next);
- jit_log2("x->prev_p is %p", x->prev_p);
+ D2(panicbug("x is %p\n", x));
+ D2(panicbug("x->next is %p\n", x->next));
+ D2(panicbug("x->prev_p is %p\n", x->prev_p));
if (x->jmp_off) {
adjust_jmpdep(x, dh);
@@ -391,29 +385,32 @@ STATIC_INLINE void set_dhtu(blockinfo* bi, cpuop_func* dh)
}
}
-void invalidate_block(blockinfo* bi)
+static inline void invalidate_block(blockinfo* bi)
{
- int i;
+ int i;
- bi->optlevel = 0;
- bi->count = optcount[0]-1;
- bi->handler = NULL;
- bi->handler_to_use = (cpuop_func *)popall_execute_normal;
- bi->direct_handler = NULL;
- set_dhtu(bi, bi->direct_pen);
- bi->needed_flags = 0xff;
+ bi->optlevel = 0;
+ bi->count = optcount[0] - 1;
+ bi->handler = NULL;
+ bi->handler_to_use = (cpuop_func*)popall_execute_normal;
+ bi->direct_handler = NULL;
+ set_dhtu(bi, bi->direct_pen);
+ bi->needed_flags = 0xff;
bi->status = BI_INVALID;
- for (i=0; i<2; i++) {
- bi->dep[i].jmp_off = NULL;
- bi->dep[i].target = NULL;
- }
- remove_deps(bi);
+ for (i = 0; i<2; i++) {
+ bi->dep[i].jmp_off = NULL;
+ bi->dep[i].target = NULL;
+ }
+ remove_deps(bi);
}
STATIC_INLINE void create_jmpdep(blockinfo* bi, int i, uae_u32* jmpaddr, uae_u32 target)
{
blockinfo* tbi = get_blockinfo_addr((void*)(uintptr)target);
+ Dif(!tbi) {
+ jit_abort (_T("JIT: Could not create jmpdep!\n"));
+ }
bi->dep[i].jmp_off = jmpaddr;
bi->dep[i].source = bi;
bi->dep[i].target = tbi;
@@ -449,6 +446,9 @@ STATIC_INLINE void mark_callers_recompile(blockinfo * bi)
if (x->jmp_off) {
blockinfo *cbi = x->source;
+ Dif(cbi->status == BI_INVALID) {
+ jit_abort(_T("invalid block in dependency list\n")); // FIXME?
+ }
if (cbi->status == BI_ACTIVE || cbi->status == BI_NEED_CHECK) {
block_need_recompile(cbi);
mark_callers_recompile(cbi);
@@ -460,7 +460,7 @@ STATIC_INLINE void mark_callers_recompile(blockinfo * bi)
/* nothing */
}
else {
- jit_log2("Status %d in mark_callers", cbi->status); // FIXME?
+ D2(panicbug(_T("Status %d in mark_callers\n"), cbi->status)); // FIXME?
}
}
x = next;
@@ -494,7 +494,7 @@ STATIC_INLINE blockinfo* get_blockinfo_addr_new(void* addr, int setstate)
static void prepare_block(blockinfo* bi);
-/* Management of blockinfos.
+/* Managment of blockinfos.
A blockinfo struct is allocated whenever a new block has to be
compiled. If the list of free blockinfos is empty, we allocate a new
@@ -638,30 +638,24 @@ STATIC_INLINE void alloc_blockinfos(void)
if (hold_bi[i])
return;
bi=hold_bi[i]=alloc_blockinfo();
+
prepare_block(bi);
}
}
-bool check_prefs_changed_comp(bool checkonly)
+/********************************************************************
+ * Preferences handling. This is just a convenient place to put it *
+ ********************************************************************/
+bool check_prefs_changed_comp (void)
{
- bool changed = 0;
+ bool changed = 0;
- if (currprefs.fpu_strict != changed_prefs.fpu_strict ||
- currprefs.cachesize != changed_prefs.cachesize)
- changed = 1;
-
- if (checkonly)
- return changed;
-
- currprefs.fpu_strict = changed_prefs.fpu_strict;
-
- if (currprefs.cachesize != changed_prefs.cachesize) {
- currprefs.cachesize = changed_prefs.cachesize;
- alloc_cache();
- changed = 1;
- }
-
- return changed;
+ if (currprefs.cachesize != changed_prefs.cachesize) {
+ currprefs.cachesize = changed_prefs.cachesize;
+ alloc_cache();
+ changed = 1;
+ }
+ return changed;
}
/********************************************************************
@@ -677,15 +671,10 @@ STATIC_INLINE void emit_byte(uae_u8 x)
STATIC_INLINE void emit_long(uae_u32 x)
{
- *((uae_u32*)target) = x;
+ *reinterpret_cast(target) = x;
target += 4;
}
-STATIC_INLINE void skip_long()
-{
- target += 4;
-}
-
#define MAX_COMPILE_PTR max_compile_start
STATIC_INLINE uae_u32 reverse32(uae_u32 v)
@@ -713,6 +702,7 @@ STATIC_INLINE uae_u8* get_target(void)
return get_target_noopt();
}
+
/********************************************************************
* New version of data buffer: interleave data and code *
********************************************************************/
@@ -805,9 +795,8 @@ STATIC_INLINE void clobber_flags(void);
#if defined(CPU_arm)
#include "codegen_arm.cpp"
-#endif
-#if defined(CPU_i386) || defined(CPU_x86_64)
-#include "codegen_x86.cpp"
+#else
+#include "compemu_raw_x86.cpp"
#endif
@@ -819,6 +808,9 @@ static void make_flags_live_internal(void)
{
if (live.flags_in_flags == VALID)
return;
+ Dif (live.flags_on_stack == TRASH) {
+ jit_abort (_T("JIT: Want flags, got something on stack, but it is TRASH\n"));
+ }
if (live.flags_on_stack == VALID) {
int tmp;
tmp = readreg_specific(FLAGTMP, 4, FLAG_NREG2);
@@ -828,7 +820,7 @@ static void make_flags_live_internal(void)
live.flags_in_flags = VALID;
return;
}
- jit_abort("Huh? live.flags_in_flags=%d, live.flags_on_stack=%d, but need to make live",
+ jit_abort (_T("JIT: Huh? live.flags_in_flags=%d, live.flags_on_stack=%d, but need to make live\n"),
live.flags_in_flags, live.flags_on_stack);
}
@@ -840,7 +832,9 @@ static void flags_to_stack(void)
live.flags_on_stack = VALID;
return;
}
- {
+ Dif (live.flags_in_flags != VALID)
+ jit_abort(_T("flags_to_stack != VALID"));
+ else {
int tmp;
tmp = writereg_specific(FLAGTMP, 4, FLAG_NREG1);
raw_flags_to_reg(tmp);
@@ -951,6 +945,11 @@ static void evict(int r)
tomem(r);
rr = live.state[r].realreg;
+ Dif (live.nat[rr].locked &&
+ live.nat[rr].nholds == 1) {
+ jit_abort (_T("JIT: register %d in nreg %d is locked!\n"), r, live.state[r].realreg);
+ }
+
live.nat[rr].nholds--;
if (live.nat[rr].nholds != live.state[r].realind) { /* Was not last */
int topreg = live.nat[rr].holds[live.nat[rr].nholds];
@@ -973,6 +972,9 @@ STATIC_INLINE void free_nreg(int r)
vr = live.nat[r].holds[i];
evict(vr);
}
+ Dif (live.nat[r].nholds != 0) {
+ jit_abort (_T("JIT: Failed to free nreg %d, nholds is %d\n"), r, live.nat[r].nholds);
+ }
}
/* Use with care! */
@@ -1024,6 +1026,8 @@ static int alloc_reg_hinted(int r, int size, int willclobber, int hint)
break;
}
}
+ Dif (bestreg == -1)
+ jit_abort(_T("alloc_reg_hinted bestreg=-1"));
if (live.nat[bestreg].nholds > 0) {
free_nreg(bestreg);
@@ -1032,6 +1036,10 @@ static int alloc_reg_hinted(int r, int size, int willclobber, int hint)
int rr = live.state[r].realreg;
/* This will happen if we read a partially dirty register at a
bigger size */
+ Dif (willclobber || live.state[r].validsize >= size)
+ jit_abort(_T("willclobber || live.state[r].validsize>=size"));
+ Dif (live.nat[rr].nholds != 1)
+ jit_abort(_T("live.nat[rr].nholds!=1"));
if (size == 4 && live.state[r].validsize == 2) {
compemu_raw_mov_l_rm(bestreg, (uintptr)live.state[r].mem);
compemu_raw_MERGE_rr(rr, bestreg);
@@ -1095,6 +1103,8 @@ static int alloc_reg_hinted(int r, int size, int willclobber, int hint)
static void unlock2(int r)
{
+ Dif (!live.nat[r].locked)
+ jit_abort(_T("unlock2 %d not locked"), r);
live.nat[r].locked--;
}
@@ -1158,6 +1168,10 @@ STATIC_INLINE void make_exclusive(int r, int size, int spec)
i--; /* Try that index again! */
}
}
+ Dif (live.nat[rr].nholds != 1) {
+ jit_abort (_T("JIT: natreg %d holds %d vregs, %d not exclusive\n"),
+ rr, live.nat[rr].nholds, r);
+ }
return;
}
@@ -1202,7 +1216,7 @@ STATIC_INLINE int readreg_general(int r, int size, int spec)
int answer = -1;
if (live.state[r].status == UNDEF) {
- jit_log("WARNING: Unexpected read of undefined register %d", r);
+ D(panicbug("JIT: WARNING: Unexpected read of undefined register %d\n", r));
}
if (isinreg(r) && live.state[r].validsize >= size) {
@@ -1263,6 +1277,9 @@ STATIC_INLINE int writereg_general(int r, int size, int spec)
int ndsize = size > live.state[r].dirtysize ? size : live.state[r].dirtysize;
n = live.state[r].realreg;
+ Dif (live.nat[n].nholds != 1)
+ jit_abort(_T("live.nat[%d].nholds!=1"), n);
+
live.state[r].dirtysize = ndsize;
live.state[r].validsize = nvsize;
answer = n;
@@ -1289,6 +1306,11 @@ STATIC_INLINE int writereg_general(int r, int size, int spec)
if (size == 4) {
live.state[r].val = 0;
}
+ else {
+ Dif (live.state[r].val) {
+ jit_abort (_T("JIT: Problem with val\n"));
+ }
+ }
set_status(r, DIRTY);
return answer;
}
@@ -1309,12 +1331,17 @@ STATIC_INLINE int rmw_general(int r, int wsize, int rsize)
int answer = -1;
if (live.state[r].status == UNDEF) {
- jit_log("WARNING: Unexpected read of undefined register %d", r);
+ D(panicbug("JIT: WARNING: Unexpected read of undefined register %d\n", r));
}
make_exclusive(r, 0, -1);
+ Dif (wsize < rsize) {
+ jit_abort (_T("JIT: Cannot handle wsize= rsize) {
n = live.state[r].realreg;
+ Dif (live.nat[n].nholds != 1)
+ jit_abort(_T("live.nat[n].nholds!=1"), n);
answer = n;
if (answer < 0)
@@ -1335,6 +1362,9 @@ STATIC_INLINE int rmw_general(int r, int wsize, int rsize)
live.nat[answer].locked++;
live.nat[answer].touched = touchcnt++;
+ Dif (live.state[r].val) {
+ jit_abort (_T("JIT: Problem with val(rmw)\n"));
+ }
return answer;
}
@@ -1343,15 +1373,303 @@ static int rmw(int r, int wsize, int rsize)
return rmw_general(r, wsize, rsize);
}
+/********************************************************************
+ * FPU register status handling. EMIT TIME! *
+ ********************************************************************/
+
+#ifdef USE_JIT_FPU
+static void f_tomem(int r)
+{
+ if (live.fate[r].status == DIRTY) {
+#if USE_LONG_DOUBLE
+ raw_fmov_ext_mr((uintptr)live.fate[r].mem, live.fate[r].realreg);
+#else
+ raw_fmov_mr((uintptr)live.fate[r].mem, live.fate[r].realreg);
+#endif
+ live.fate[r].status = CLEAN;
+ }
+}
+
+static void f_tomem_drop(int r)
+{
+ if (live.fate[r].status == DIRTY) {
+#if USE_LONG_DOUBLE
+ raw_fmov_ext_mr_drop((uintptr)live.fate[r].mem, live.fate[r].realreg);
+#else
+ raw_fmov_mr_drop((uintptr)live.fate[r].mem, live.fate[r].realreg);
+#endif
+ live.fate[r].status = INMEM;
+ }
+}
+
+
+STATIC_INLINE int f_isinreg(int r)
+{
+ return live.fate[r].status == CLEAN || live.fate[r].status == DIRTY;
+}
+
+static void f_evict(int r)
+{
+ int rr;
+
+ if (!f_isinreg(r))
+ return;
+ rr = live.fate[r].realreg;
+ if (live.fat[rr].nholds == 1)
+ f_tomem_drop(r);
+ else
+ f_tomem(r);
+
+ Dif (live.fat[rr].locked &&
+ live.fat[rr].nholds==1) {
+ jit_abort (_T("JIT: FPU register %d in nreg %d is locked!\n"),r,live.fate[r].realreg);
+ }
+ live.fat[rr].nholds--;
+ if (live.fat[rr].nholds!=live.fate[r].realind) { /* Was not last */
+ int topreg=live.fat[rr].holds[live.fat[rr].nholds];
+ int thisind=live.fate[r].realind;
+ live.fat[rr].holds[thisind]=topreg;
+ live.fate[topreg].realind=thisind;
+ }
+ live.fate[r].status=INMEM;
+ live.fate[r].realreg=-1;
+}
+
+STATIC_INLINE void f_free_nreg(int r)
+{
+ int i=live.fat[r].nholds;
+
+ while (i) {
+ int vr;
+
+ --i;
+ vr=live.fat[r].holds[i];
+ f_evict(vr);
+ }
+ Dif (live.fat[r].nholds!=0) {
+ jit_abort (_T("JIT: Failed to free nreg %d, nholds is %d\n"),r,live.fat[r].nholds);
+ }
+}
+
+
+/* Use with care! */
+STATIC_INLINE void f_isclean(int r)
+{
+ if (!f_isinreg(r))
+ return;
+ live.fate[r].status=CLEAN;
+}
+
+STATIC_INLINE void f_disassociate(int r)
+{
+ f_isclean(r);
+ f_evict(r);
+}
+
+
+
+static int f_alloc_reg(int r, int willclobber)
+{
+ int bestreg;
+ uae_s32 when;
+ int i;
+ uae_s32 badness;
+ bestreg=-1;
+ when=2000000000;
+ for (i=N_FREGS;i--;) {
+ badness=live.fat[i].touched;
+ if (live.fat[i].nholds==0)
+ badness=0;
+
+ if (!live.fat[i].locked && badness0) {
+ f_free_nreg(bestreg);
+ }
+ if (f_isinreg(r)) {
+ f_evict(r);
+ }
+
+ if (!willclobber) {
+ if (live.fate[r].status!=UNDEF) {
+#if USE_LONG_DOUBLE
+ raw_fmov_ext_rm(bestreg,(uintptr)live.fate[r].mem);
+#else
+ raw_fmov_rm(bestreg,(uintptr)live.fate[r].mem);
+#endif
+ }
+ live.fate[r].status=CLEAN;
+ }
+ else {
+ live.fate[r].status=DIRTY;
+ }
+ live.fate[r].realreg=bestreg;
+ live.fate[r].realind=live.fat[bestreg].nholds;
+ live.fat[bestreg].touched=touchcnt++;
+ live.fat[bestreg].holds[live.fat[bestreg].nholds]=r;
+ live.fat[bestreg].nholds++;
+
+ return bestreg;
+}
+
+static void f_unlock(int r)
+{
+ Dif (!live.fat[r].locked)
+ jit_abort(_T("unlock %d"), r);
+ live.fat[r].locked--;
+}
+
+static void f_setlock(int r)
+{
+ live.fat[r].locked++;
+}
+
+STATIC_INLINE int f_readreg(int r)
+{
+ int n;
+ int answer=-1;
+
+ if (f_isinreg(r)) {
+ n=live.fate[r].realreg;
+ answer=n;
+ }
+ /* either the value was in memory to start with, or it was evicted and
+ is in memory now */
+ if (answer<0)
+ answer=f_alloc_reg(r,0);
+
+ live.fat[answer].locked++;
+ live.fat[answer].touched=touchcnt++;
+ return answer;
+}
+
+STATIC_INLINE void f_make_exclusive(int r, int clobber)
+{
+ freg_status oldstate;
+ int rr=live.fate[r].realreg;
+ int nr;
+ int nind;
+ int ndirt=0;
+ int i;
+
+ if (!f_isinreg(r))
+ return;
+ if (live.fat[rr].nholds==1)
+ return;
+ for (i=0;i : compile FPU instructions : %s", !avoid_fpu ? "yes" : "no"));
- initialized = true;
+ // Initialize target CPU (check for features, e.g. CMOV, rat stalls)
+ raw_init_cpu();
+
+ // Translation cache flush mechanism
+ lazy_flush = 1; //(bx_options.jit.jitlazyflush == 0) ? 0 : 1;
+ flush_icache = lazy_flush ? flush_icache_lazy : flush_icache_hard;
+
+ // Compiler features
+#if USE_INLINING
+ follow_const_jumps = 1; //bx_options.jit.jitinline;
+#endif
+
+ // Build compiler tables
+ // build_comp(); // moved to newcpu.cpp -> build_cpufunctbl
+
+ initialized = 1;
#ifdef PROFILE_UNTRANSLATED_INSNS
- jit_log(" : gather statistics on untranslated insns count");
+ bug(" : gather statistics on untranslated insns count\n");
#endif
#ifdef PROFILE_COMPILE_TIME
- jit_log(" : gather statistics on translation time");
+ bug(" : gather statistics on translation time");
emul_start_time = clock();
#endif
}
@@ -1419,7 +1767,7 @@ void compiler_exit(void)
// Deallocate translation cache
if (compiled_code) {
- cache_free(compiled_code, cache_size * 1024);
+ cache_free(compiled_code, currprefs.cachesize * 1024);
compiled_code = 0;
}
@@ -1430,11 +1778,11 @@ void compiler_exit(void)
}
#ifdef PROFILE_COMPILE_TIME
- jit_log("### Compile Block statistics");
- jit_log("Number of calls to compile_block : %d", compile_count);
+ bug("### Compile Block statistics");
+ bug("Number of calls to compile_block : %d", compile_count);
uae_u32 emul_time = emul_end_time - emul_start_time;
- jit_log("Total emulation time : %.1f sec", double(emul_time)/double(CLOCKS_PER_SEC));
- jit_log("Total compilation time : %.1f sec (%.1f%%)", double(compile_time)/double(CLOCKS_PER_SEC), 100.0*double(compile_time)/double(emul_time));
+ bug("Total emulation time : %.1f sec", double(emul_time)/double(CLOCKS_PER_SEC));
+ bug("Total compilation time : %.1f sec (%.1f%%)", double(compile_time)/double(CLOCKS_PER_SEC), 100.0*double(compile_time)/double(emul_time));
#endif
#ifdef PROFILE_UNTRANSLATED_INSNS
@@ -1443,9 +1791,9 @@ void compiler_exit(void)
opcode_nums[i] = i;
untranslated_count += raw_cputbl_count[i];
}
- jit_log("Sorting out untranslated instructions count...");
+ bug("Sorting out untranslated instructions count...\n");
qsort(opcode_nums, 65536, sizeof(uae_u16), untranslated_compfn);
- jit_log("Rank Opc Count Name");
+ bug("Rank Opc Count Name\n");
for (int i = 0; i < untranslated_top_ten && i < 65536; i++) {
uae_u32 count = raw_cputbl_count[opcode_nums[i]];
struct instr *dp;
@@ -1463,7 +1811,7 @@ void compiler_exit(void)
untranslated_top_ten++; // Ignore this
}
else
- jit_log("%03d: %04x %10u %s", i, opcode_nums[i], count, lookup->name);
+ bug("%03d: %04x %10u %s\n", i, opcode_nums[i], count, lookup->name);
}
#endif
}
@@ -1473,12 +1821,25 @@ void init_comp(void)
int i;
uae_s8* au = always_used;
+#ifdef RECORD_REGISTER_USAGE
+ for (i=0; i<16; i++)
+ reg_count_local[i] = 0;
+#endif
+
for (i=0; i= uae_p32(kickmem_bank.baseaddr) &&
- addr < uae_p32(kickmem_bank.baseaddr + 8 * 65536));
+ return (addr >= (uae_u32)kickmem_bank.baseaddr &&
+ addr < (uae_u32)kickmem_bank.baseaddr + 8 * 65536);
}
static void flush_all(void)
@@ -1598,6 +2018,12 @@ static void flush_all(void)
tomem(i);
}
}
+#ifdef USE_JIT_FPU
+ for (i = 0; i < VFREGS; i++)
+ if (f_isinreg(i))
+ f_evict(i);
+ raw_fp_cleanup_drop();
+#endif
}
/* Make sure all registers that will get clobbered by a call are
@@ -1619,6 +2045,12 @@ static void prepare_for_call_2(void)
free_nreg(i);
}
+#ifdef USE_JIT_FPU
+ for (i = 0; i < N_FREGS; i++)
+ if (live.fat[i].nholds > 0)
+ f_free_nreg(i);
+#endif
+
live.flags_in_flags = TRASH; /* Note: We assume we already rescued the
flags at the very start of the call_r
functions! */
@@ -1887,7 +2319,7 @@ void calc_disp_ea_020(int base, uae_u32 dp, int target, int tmp)
void set_cache_state(int enabled)
{
if (enabled != letit)
- flush_icache_hard(3);
+ flush_icache_hard(0, 3);
letit = enabled;
}
@@ -1906,28 +2338,24 @@ uae_u32 get_jitted_size(void)
void alloc_cache(void)
{
if (compiled_code) {
- flush_icache_hard(3);
- cache_free(compiled_code, cache_size * 1024);
+ flush_icache_hard(0, 3);
+ cache_free(compiled_code, currprefs.cachesize * 1024);
compiled_code = 0;
}
- cache_size = currprefs.cachesize;
- if (cache_size == 0)
+ if (currprefs.cachesize == 0)
return;
- while (!compiled_code && cache_size) {
- compiled_code = cache_alloc(cache_size * 1024);
- if (compiled_code == NULL) {
- cache_size /= 2;
- }
+ while (!compiled_code && currprefs.cachesize) {
+ compiled_code = cache_alloc(currprefs.cachesize * 1024);
+ if (!compiled_code)
+ currprefs.cachesize /= 2;
}
-
if (compiled_code) {
- jit_log("Actual translation cache size : %d KB at %p-%p", cache_size, compiled_code, compiled_code + cache_size*1024);
#if defined(CPU_arm) && !defined(ARMV6T2)
- max_compile_start = compiled_code + cache_size*1024 - BYTES_PER_INST - DATA_BUFFER_SIZE;
+ max_compile_start = compiled_code + currprefs.cachesize*1024 - BYTES_PER_INST - DATA_BUFFER_SIZE;
#else
- max_compile_start = compiled_code + cache_size*1024 - BYTES_PER_INST;
+ max_compile_start = compiled_code + currprefs.cachesize*1024 - BYTES_PER_INST;
#endif
current_compile_p = compiled_code;
current_cache_size = 0;
@@ -1944,6 +2372,7 @@ static void calc_checksum(blockinfo* bi, uae_u32* c1, uae_u32* c2)
#if USE_CHECKSUM_INFO
checksum_info *csi = bi->csi;
+ Dif(!csi) abort();
while (csi) {
uae_s32 len = csi->length;
uintptr tmp = (uintptr)csi->start_p;
@@ -1998,6 +2427,8 @@ static void recompile_block(void)
perceived cache miss... */
blockinfo* bi = get_blockinfo_addr(regs.pc_p);
+ Dif (!bi)
+ jit_abort(_T("recompile_block"));
raise_in_cl_list(bi);
execute_normal();
return;
@@ -2006,11 +2437,20 @@ static void recompile_block(void)
static void cache_miss(void)
{
blockinfo* bi = get_blockinfo_addr(regs.pc_p);
+#if COMP_DEBUG
+ uae_u32 cl = cacheline(regs.pc_p);
+ blockinfo* bi2 = get_blockinfo(cl);
+#endif
if (!bi) {
execute_normal(); /* Compile this block now */
return;
}
+#if COMP_DEBUG
+ Dif (!bi2 || bi == bi2) {
+ jit_abort (_T("Unexplained cache miss %p %p\n"), bi, bi2);
+ }
+#endif
raise_in_cl_list(bi);
return;
}
@@ -2025,6 +2465,8 @@ STATIC_INLINE int block_check_checksum(blockinfo* bi)
if (bi->status != BI_NEED_CHECK)
return 1; /* This block is in a checked state */
+// checksum_count++;
+
if (bi->c1 || bi->c2)
calc_checksum(bi, &c1, &c2);
else {
@@ -2043,7 +2485,7 @@ STATIC_INLINE int block_check_checksum(blockinfo* bi)
isgood = called_check_checksum(bi) != 0;
}
if (isgood) {
- jit_log2("reactivate %p/%p (%x %x/%x %x)", bi, bi->pc_p, c1, c2, bi->c1, bi->c2);
+ D2(bug("JIT: reactivate %p/%p (%x %x/%x %x)", bi, bi->pc_p, c1, c2, bi->c1, bi->c2));
remove_from_list(bi);
add_to_active(bi);
raise_in_cl_list(bi);
@@ -2052,7 +2494,7 @@ STATIC_INLINE int block_check_checksum(blockinfo* bi)
else {
/* This block actually changed. We need to invalidate it,
and set it up to be recompiled */
- jit_log2("discard %p/%p (%x %x/%x %x)", bi, bi->pc_p, c1, c2, bi->c1, bi->c2);
+ D2(bug("JIT: discard %p/%p (%x %x/%x %x)", bi, bi->pc_p, c1, c2, bi->c1, bi->c2));
invalidate_block(bi);
raise_in_cl_list(bi);
}
@@ -2110,7 +2552,7 @@ STATIC_INLINE void match_states(blockinfo* bi)
certain vregs) */
for (i = 0; i < 16; i++) {
if (s->virt[i] == L_UNNEEDED) {
- jit_log2("unneeded reg %d at %p", i, target);
+ D2(panicbug("unneeded reg %d at %p\n", i, target));
COMPCALL(forget_about)(i); // FIXME
}
}
@@ -2139,15 +2581,8 @@ STATIC_INLINE void create_popalls(void)
{
int i, r;
- if (popallspace == NULL) {
- if ((popallspace = cache_alloc (POPALLSPACE_SIZE)) == NULL) {
- jit_log("WARNING: Could not allocate popallspace!");
- /* This is not fatal if JIT is not used. If JIT is
- * turned on, it will crash, but it would have crashed
- * anyway. */
- return;
- }
- }
+ if (popallspace == NULL)
+ popallspace = cache_alloc (POPALLSPACE_SIZE);
int stack_space = STACK_OFFSET;
for (i = 0; i< N_REGS; i++) {
@@ -2157,7 +2592,6 @@ STATIC_INLINE void create_popalls(void)
stack_space %= STACK_ALIGN;
if (stack_space)
stack_space = STACK_ALIGN - stack_space;
-
current_compile_p = popallspace;
set_target(current_compile_p);
@@ -2174,53 +2608,67 @@ STATIC_INLINE void create_popalls(void)
In summary, JIT generated code is not leaf so we have to deal
with it here to maintain correct stack alignment. */
+#ifndef ALIGN_NOT_NEEDED
align_target(align_jumps);
+#endif
current_compile_p = get_target();
pushall_call_handler = get_target();
raw_push_regs_to_preserve();
raw_dec_sp(stack_space);
- compemu_raw_init_r_regstruct((uintptr)®s);
+ compemu_raw_init_r_regstruct(uintptr(®s));
r = REG_PC_TMP;
- compemu_raw_mov_l_rm(r, uae_p32(®s.pc_p));
+ compemu_raw_mov_l_rm(r,uintptr(®s.pc_p));
compemu_raw_and_TAGMASK(r);
- compemu_raw_jmp_m_indexed(uae_p32(cache_tags), r, SIZEOF_VOID_P);
+ compemu_raw_jmp_m_indexed(uintptr(cache_tags), r, SIZEOF_VOID_P);
/* now the exit points */
+#ifndef ALIGN_NOT_NEEDED
align_target(align_jumps);
+#endif
popall_do_nothing = get_target();
raw_inc_sp(stack_space);
raw_pop_preserved_regs();
- compemu_raw_jmp(uae_p32(do_nothing));
+ compemu_raw_jmp(uintptr(do_nothing));
+#ifndef ALIGN_NOT_NEEDED
align_target(align_jumps);
+#endif
popall_execute_normal = get_target();
raw_inc_sp(stack_space);
raw_pop_preserved_regs();
- compemu_raw_jmp(uae_p32(execute_normal));
+ compemu_raw_jmp(uintptr(execute_normal));
+#ifndef ALIGN_NOT_NEEDED
align_target(align_jumps);
+#endif
popall_cache_miss = get_target();
raw_inc_sp(stack_space);
raw_pop_preserved_regs();
- compemu_raw_jmp(uae_p32(cache_miss));
+ compemu_raw_jmp(uintptr(cache_miss));
+#ifndef ALIGN_NOT_NEEDED
align_target(align_jumps);
+#endif
popall_recompile_block = get_target();
raw_inc_sp(stack_space);
raw_pop_preserved_regs();
- compemu_raw_jmp(uae_p32(recompile_block));
+ compemu_raw_jmp((uintptr)recompile_block);
+#ifndef ALIGN_NOT_NEEDED
align_target(align_jumps);
+#endif
popall_exec_nostats = get_target();
raw_inc_sp(stack_space);
raw_pop_preserved_regs();
- compemu_raw_jmp(uae_p32(exec_nostats));
+ compemu_raw_jmp((uintptr)exec_nostats);
+#ifndef ALIGN_NOT_NEEDED
align_target(align_jumps);
+#endif
popall_check_checksum = get_target();
raw_inc_sp(stack_space);
raw_pop_preserved_regs();
- compemu_raw_jmp(uae_p32(check_checksum));
+ compemu_raw_jmp((uintptr)check_checksum);
#if defined(CPU_arm) && !defined(ARMV6T2)
reset_data_buffer();
@@ -2245,13 +2693,17 @@ static void prepare_block(blockinfo* bi)
int i;
set_target(current_compile_p);
+#ifndef ALIGN_NOT_NEEDED
align_target(align_jumps);
+#endif
bi->direct_pen = (cpuop_func *)get_target();
compemu_raw_mov_l_rm(0, (uintptr)&(bi->pc_p));
compemu_raw_mov_l_mr((uintptr)®s.pc_p, 0);
compemu_raw_jmp((uintptr)popall_execute_normal);
+#ifndef ALIGN_NOT_NEEDED
align_target(align_jumps);
+#endif
bi->direct_pcc = (cpuop_func *)get_target();
compemu_raw_mov_l_rm(0, (uintptr)&(bi->pc_p));
compemu_raw_mov_l_mr((uintptr)®s.pc_p, 0);
@@ -2316,7 +2768,7 @@ void build_comp(void)
cflow &= ~fl_const_jump;
prop[cft_map(tbl[i].opcode)].cflow = cflow;
- bool uses_fpu = (tbl[i].specific & COMP_OPCODE_USES_FPU) != 0;
+ int uses_fpu = (tbl[i].specific & 32) != 0;
if (uses_fpu && avoid_fpu)
compfunctbl[cft_map(tbl[i].opcode)] = NULL;
else
@@ -2324,7 +2776,7 @@ void build_comp(void)
}
for (i = 0; nftbl[i].opcode < 65536; i++) {
- int uses_fpu = tbl[i].specific & COMP_OPCODE_USES_FPU;
+ int uses_fpu = tbl[i].specific & 32;
if (uses_fpu && avoid_fpu)
nfcompfunctbl[cft_map(nftbl[i].opcode)] = NULL;
else
@@ -2389,7 +2841,7 @@ void build_comp(void)
if (compfunctbl[cft_map(opcode)])
count++;
}
- jit_log("Supposedly %d compileable opcodes!",count);
+// D(bug(" : supposedly %d compileable opcodes!",count));
/* Initialise state */
create_popalls();
@@ -2411,10 +2863,19 @@ void build_comp(void)
default_ss = empty_ss;
}
-void flush_icache_hard(int n)
+static void flush_icache_none(uaecptr ptr, int n)
+{
+ /* Nothing to do. */
+}
+
+void flush_icache_hard(uaecptr ptr, int n)
{
blockinfo* bi, *dbi;
+// hard_flush_count++;
+ D(bug("JIT: Flush Icache_hard(%d/%x/%p), %u KB\n",
+ n, regs.pc, regs.pc_p, current_cache_size / 1024));
+ UNUSED(n);
bi = active;
while(bi) {
cache_tags[cacheline(bi->pc_p)].handler = (cpuop_func *)popall_execute_normal;
@@ -2449,11 +2910,12 @@ void flush_icache_hard(int n)
we simply mark everything as "needs to be checked".
*/
-void flush_icache(int n)
+STATIC_INLINE void flush_icache_lazy(uaecptr ptr, int n)
{
blockinfo* bi;
blockinfo* bi2;
+// soft_flush_count++;
if (!active)
return;
@@ -2496,6 +2958,39 @@ STATIC_INLINE unsigned int get_opcode_cft_map(unsigned int f)
}
#define DO_GET_OPCODE(a) (get_opcode_cft_map((uae_u16)*(a)))
+#ifdef JIT_DEBUG
+static uae_u8 *last_regs_pc_p = 0;
+static uae_u8 *last_compiled_block_addr = 0;
+
+void compiler_dumpstate(void)
+{
+ if (!JITDebug)
+ return;
+
+ bug("### Host addresses");
+ bug("MEM_BASE : %x", NATMEM_OFFSET);
+ bug("PC_P : %p", ®s.pc_p);
+ bug("SPCFLAGS : %p", ®s.spcflags);
+ bug("D0-D7 : %p-%p", ®s.regs[0], ®s.regs[7]);
+ bug("A0-A7 : %p-%p", ®s.regs[8], ®s.regs[15]);
+ bug("");
+
+ bug("### M68k processor state");
+ m68k_dumpstate(stderr, 0);
+ bug("");
+
+ bug("### Block in Atari address space");
+ bug("M68K block : %p",
+ (void *)(uintptr)last_regs_pc_p);
+ if (last_regs_pc_p != 0) {
+ bug("Native block : %p (%d bytes)",
+ (void *)last_compiled_block_addr,
+ get_blockinfo_addr(last_regs_pc_p)->direct_handler_size);
+ }
+ bug("");
+}
+#endif
+
void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
{
if (letit && compiled_code && currprefs.cpu_model >= 68020) {
@@ -2503,6 +2998,9 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
compile_count++;
clock_t start_time = clock();
#endif
+#ifdef JIT_DEBUG
+ bool disasm_block = false;
+#endif
/* OK, here we need to 'compile' a block */
int i;
@@ -2510,7 +3008,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
int was_comp = 0;
uae_u8 liveflags[MAXRUN+1];
#if USE_CHECKSUM_INFO
- bool trace_in_rom = isinrom((uintptr)pc_hist[0].location) != 0;
+ bool trace_in_rom = isinrom((uintptr)pc_hist[0].location);
uintptr max_pcp = (uintptr)pc_hist[blocklen - 1].location;
uintptr min_pcp = max_pcp;
#else
@@ -2525,7 +3023,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
redo_current_block = 0;
if (current_compile_p >= MAX_COMPILE_PTR)
- flush_icache_hard(3);
+ flush_icache_hard(0, 3);
alloc_blockinfos();
@@ -2533,11 +3031,26 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
bi2 = get_blockinfo(cl);
optlev = bi->optlevel;
+ if (bi->status != BI_INVALID) {
+ Dif (bi != bi2) {
+ /* I don't think it can happen anymore. Shouldn't, in
+ any case. So let's make sure... */
+ jit_abort (_T("JIT: WOOOWOO count=%d, ol=%d %p %p\n"),
+ bi->count, bi->optlevel, bi->handler_to_use,
+ cache_tags[cl].handler);
+ }
+
+ Dif (bi->count != -1 && bi->status != BI_NEED_RECOMP) {
+ panicbug("bi->count=%d, bi->status=%d,bi->optlevel=%d\n", bi->count, bi->status, bi->optlevel);
+ /* What the heck? We are not supposed to be here! */
+ jit_abort(_T("BI_TARGETTED"));
+ }
+ }
if (bi->count == -1) {
- optlev++;
- while (!optcount[optlev])
- optlev++;
- bi->count = optcount[optlev] - 1;
+ optlev++;
+ while (!optcount[optlev])
+ optlev++;
+ bi->count = optcount[optlev] - 1;
}
current_block_pc_p = (uintptr)pc_hist[0].location;
@@ -2591,7 +3104,9 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
bi->needed_flags = liveflags[0];
/* This is the non-direct handler */
+#ifndef ALIGN_NOT_NEEDED
align_target(align_loops);
+#endif
was_comp = 0;
bi->direct_handler = (cpuop_func *)get_target();
@@ -2618,12 +3133,20 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
init_comp();
was_comp = 1;
+#ifdef JIT_DEBUG
+ if (JITDebug) {
+ compemu_raw_mov_l_mi((uintptr)&last_regs_pc_p, (uintptr)pc_hist[0].location);
+ compemu_raw_mov_l_mi((uintptr)&last_compiled_block_addr, current_block_start_target);
+ }
+#endif
+
for (i = 0; i < blocklen && get_target_noopt() < MAX_COMPILE_PTR; i++) {
cpuop_func **cputbl;
compop_func **comptbl;
uae_u32 opcode = DO_GET_OPCODE(pc_hist[i].location);
needed_flags = (liveflags[i+1] & prop[opcode].set_flags);
special_mem = pc_hist[i].specmem;
+ D(bug(" 0x%08x: %04x (special_mem=%d, needed_flags=%d)\n", pc_hist[i].location, opcode, special_mem, needed_flags));
if (!needed_flags) {
#ifdef NOFLAGS_SUPPORT
cputbl=nfcpufunctbl;
@@ -2659,7 +3182,6 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
was_comp = 0;
#endif
}
-
if (failure) {
if (was_comp) {
flush(1);
@@ -2684,9 +3206,10 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
#endif
compemu_raw_jz_b_oponly();
branchadd = (uae_s8 *)get_target();
- compemu_raw_sub_l_mi(uae_p32(&countdown), scaled_cycles(totcycles));
+ compemu_raw_sub_l_mi((uintptr)&countdown, scaled_cycles(totcycles));
compemu_raw_jmp((uintptr)popall_do_nothing);
*(branchadd - 4) = (((uintptr)get_target() - (uintptr)branchadd) - 4) >> 2;
+ D(bug(" branchadd(byte) to 0x%08x: 0x%02x\n", branchadd, *branchadd));
}
}
}
@@ -2713,7 +3236,7 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
tmp = live; /* ouch! This is big... */
compemu_raw_jcc_l_oponly(cc);
branchadd = (uae_u32*)get_target();
- skip_long();
+ emit_long(0);
/* predicted outcome */
tbi = get_blockinfo_addr_new((void*)t1, 1);
@@ -2727,9 +3250,12 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
emit_jmp_target(get_handler(t1));
create_jmpdep(bi, 0, tba, t1);
+#ifndef ALIGN_NOT_NEEDED
align_target(align_jumps);
+#endif
/* not-predicted outcome */
write_jmp_target(branchadd, (cpuop_func*)get_target());
+ D(bug(" write_jmp_target to 0x%08x: 0x%08x\n", branchadd, get_target()));
live = tmp; /* Ouch again */
tbi = get_blockinfo_addr_new((void*)t2, 1);
match_states(tbi);
@@ -2819,7 +3345,14 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
current_cache_size += get_target() - (uae_u8 *)current_compile_p;
+#ifdef JIT_DEBUG
+ if (JITDebug)
+ bi->direct_handler_size = get_target() - (uae_u8 *)current_block_start_target;
+#endif
+
+#ifndef ALIGN_NOT_NEEDED
align_target(align_jumps);
+#endif
/* This is the non-direct handler */
bi->handler =
bi->handler_to_use = (cpuop_func *)get_target();
@@ -2837,11 +3370,10 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
flush_cpu_icache((void *)current_block_start_target, (void *)target);
current_compile_p = get_target();
raise_in_cl_list(bi);
- bi->nexthandler=current_compile_p;
/* We will flush soon, anyway, so let's do it now */
if (current_compile_p >= MAX_COMPILE_PTR)
- flush_icache_hard(3);
+ flush_icache_hard(0, 3);
bi->status = BI_ACTIVE;
if (redo_current_block)
@@ -2850,9 +3382,35 @@ void compile_block(cpu_history* pc_hist, int blocklen, int totcycles)
#ifdef PROFILE_COMPILE_TIME
compile_time += (clock() - start_time);
#endif
- /* Account for compilation time */
- do_extra_cycles(totcycles);
}
}
-#endif /* JIT */
+
+void dump_compiler(uae_u32* sp)
+{
+ int i, j;
+
+ for(i=-16; i<16; i+=4)
+ {
+ printf("0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", sp + i, sp[i], sp[i+1], sp[i+2], sp[i+3]);
+ }
+
+ printf("compile cache: 0x%08x - 0x%08x\n", compiled_code, compiled_code + currprefs.cachesize * 1024);
+ printf("start_pc_p=0x%08x, start_pc=0x%08x, current_block_pc_p=0x%08x\n", start_pc_p, start_pc, current_block_pc_p);
+ printf("current_block_start_target=0x%08x, needed_flags=%d\n", current_block_start_target, needed_flags);
+ printf("current_compile_p=0x%08x, max_compile_start=0x%08x\n", current_compile_p, max_compile_start);
+
+/*
+ printf("PC history:\n");
+ for(i=trace_pc_idx - 16, j=0; i < trace_pc_idx; ++i, ++j)
+ {
+ printf("0x%08x (%d) \t", i >= 0 ? trace_pc[i] : trace_pc[i + TRACE_PC_HISTORY],
+ i >= 0 ? trace_pc_i[i] : trace_pc_i[i + TRACE_PC_HISTORY]);
+ if((j & 3) == 3)
+ printf("\n");
+ }
+*/
+}
+
+
+#endif
\ No newline at end of file
diff --git a/src/linetoscr.cpp b/src/linetoscr.cpp
index d6b71760..5ce9cac1 100644
--- a/src/linetoscr.cpp
+++ b/src/linetoscr.cpp
@@ -1,32 +1,37 @@
-/* Note:
- * p_xcolors[] contains 16-bit color information in both words
- * p_acolors contains 16-bit color information in both words
+/*
+ * UAE - The portable Amiga emulator.
+ *
+ * This file was generated by genlinetoscr. Don't edit.
*/
-
STATIC_INLINE uae_u32 merge_words(uae_u32 val, uae_u32 val2)
{
- __asm__ (
- "pkhbt %[o], %[o], %[d], lsl #16 \n\t"
- : [o] "+r" (val) : [d] "r" (val2) );
- return val;
+ __asm__(
+ "pkhbt %[o], %[o], %[d], lsl #16 \n\t"
+ : [o] "+r" (val) : [d] "r" (val2));
+ return val;
}
STATIC_INLINE uae_u32 double_word(uae_u32 val)
{
- __asm__ (
- "pkhbt %[o], %[o], %[o], lsl #16 \n\t"
- : [o] "+r" (val) );
- return val;
+ __asm__(
+ "pkhbt %[o], %[o], %[o], lsl #16 \n\t"
+ : [o] "+r" (val));
+ return val;
}
-
-static int NOINLINE linetoscr_16 (int spix, int dpix, int dpix_end)
+
+static int NOINLINE linetoscr_16(int spix, int dpix, int dpix_end)
{
uae_u16 *buf = (uae_u16 *) xlinebuffer;
if (bplham) {
int rem;
if (((uintptr_t)&buf[dpix]) & 2) {
- buf[dpix++] = ham_linebuf[spix++];
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ buf[dpix++] = dpix_val;
}
if (dpix >= dpix_end)
return spix;
@@ -34,23 +39,39 @@ static int NOINLINE linetoscr_16 (int spix, int dpix, int dpix_end)
if (rem)
dpix_end--;
while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
- out_val = *((uae_u32 *)&ham_linebuf[spix]);
- spix += 2;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
*((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
- buf[dpix++] = ham_linebuf[spix++];
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ buf[dpix++] = dpix_val;
}
} else if (bpldualpf) {
int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
int rem;
if (((uintptr_t)&buf[dpix]) & 2) {
uae_u32 spix_val;
- spix_val = pixdata.apixels[spix++];
- buf[dpix++] = p_acolors[lookup[spix_val]];
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ buf[dpix++] = dpix_val;
}
if (dpix >= dpix_end)
return spix;
@@ -62,28 +83,36 @@ static int NOINLINE linetoscr_16 (int spix, int dpix, int dpix_end)
uae_u32 dpix_val;
uae_u32 out_val;
- spix_val = pixdata.apixels[spix++];
- out_val = p_acolors[lookup[spix_val]];
- spix_val = pixdata.apixels[spix++];
+ spix_val = pixdata.apixels[spix];
dpix_val = p_acolors[lookup[spix_val]];
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ spix++;
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
uae_u32 spix_val;
- spix_val = pixdata.apixels[spix++];
- buf[dpix++] = p_acolors[lookup[spix_val]];
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ buf[dpix++] = dpix_val;
}
} else if (bplehb) {
int rem;
if (((uintptr_t)&buf[dpix]) & 2) {
uae_u32 spix_val;
uae_u32 dpix_val;
- spix_val = pixdata.apixels[spix++];
+ spix_val = pixdata.apixels[spix];
if (spix_val <= 31)
dpix_val = p_acolors[spix_val];
else
dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
buf[dpix++] = dpix_val;
}
if (dpix >= dpix_end)
@@ -96,35 +125,43 @@ static int NOINLINE linetoscr_16 (int spix, int dpix, int dpix_end)
uae_u32 dpix_val;
uae_u32 out_val;
- spix_val = pixdata.apixels[spix++];
- if (spix_val <= 31)
- out_val = p_acolors[spix_val];
- else
- out_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
- spix_val = pixdata.apixels[spix++];
+ spix_val = pixdata.apixels[spix];
if (spix_val <= 31)
dpix_val = p_acolors[spix_val];
else
dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ spix++;
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
uae_u32 spix_val;
uae_u32 dpix_val;
- spix_val = pixdata.apixels[spix++];
+ spix_val = pixdata.apixels[spix];
if (spix_val <= 31)
dpix_val = p_acolors[spix_val];
else
dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
buf[dpix++] = dpix_val;
}
} else {
int rem;
if (((uintptr_t)&buf[dpix]) & 2) {
uae_u32 spix_val;
- spix_val = pixdata.apixels[spix++];
- buf[dpix++] = p_acolors[spix_val];
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ buf[dpix++] = dpix_val;
}
if (dpix >= dpix_end)
return spix;
@@ -136,61 +173,271 @@ static int NOINLINE linetoscr_16 (int spix, int dpix, int dpix_end)
uae_u32 dpix_val;
uae_u32 out_val;
- spix_val = pixdata.apixels[spix++];
- out_val = p_acolors[spix_val];
- spix_val = pixdata.apixels[spix++];
+ spix_val = pixdata.apixels[spix];
dpix_val = p_acolors[spix_val];
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ spix++;
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
uae_u32 spix_val;
- spix_val = pixdata.apixels[spix++];
- buf[dpix++] = p_acolors[spix_val];
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ buf[dpix++] = dpix_val;
}
}
return spix;
}
-static int NOINLINE linetoscr_16_stretch1 (int spix, int dpix, int dpix_end)
+static int NOINLINE linetoscr_16_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_stretch1(int spix, int dpix, int dpix_end)
{
uae_u16 *buf = (uae_u16 *) xlinebuffer;
if (bplham) {
while (dpix < dpix_end) {
- uae_u32 out_val = ham_linebuf[spix++];
- *((uae_u32 *)&buf[dpix]) = double_word(out_val);
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
} else if (bpldualpf) {
int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
while (dpix < dpix_end) {
uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
- spix_val = pixdata.apixels[spix++];
- *((uae_u32 *)&buf[dpix]) = p_acolors[lookup[spix_val]];
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
} else if (bplehb) {
while (dpix < dpix_end) {
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
- spix_val = pixdata.apixels[spix++];
+ spix_val = pixdata.apixels[spix];
if (spix_val <= 31)
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
else
- out_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x0777];
- *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
} else {
while (dpix < dpix_end) {
uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
- spix_val = pixdata.apixels[spix++];
- *((uae_u32 *)&buf[dpix]) = p_acolors[spix_val];
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
}
@@ -198,15 +445,254 @@ static int NOINLINE linetoscr_16_stretch1 (int spix, int dpix, int dpix_end)
return spix;
}
-static int NOINLINE linetoscr_16_shrink1 (int spix, int dpix, int dpix_end)
+static int NOINLINE linetoscr_16_stretch1_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 15);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_stretch2(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_stretch2_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val & 15);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 2] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 3] = get_genlock_transparency(lookup[spix_val]);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val & 31);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink1(int spix, int dpix, int dpix_end)
{
uae_u16 *buf = (uae_u16 *) xlinebuffer;
if (bplham) {
int rem;
if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
uae_u32 dpix_val;
- dpix_val = ham_linebuf[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
spix += 2;
buf[dpix++] = dpix_val;
}
@@ -216,21 +702,26 @@ static int NOINLINE linetoscr_16_shrink1 (int spix, int dpix, int dpix_end)
if (rem)
dpix_end--;
while (dpix < dpix_end) {
+ uae_u32 spix_val;
uae_u32 dpix_val;
uae_u32 out_val;
- out_val = ham_linebuf[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
spix += 2;
- dpix_val = ham_linebuf[spix];
+ out_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
spix += 2;
- out_val = merge_words(out_val, dpix_val);
-
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
*((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
+ uae_u32 spix_val;
uae_u32 dpix_val;
- dpix_val = ham_linebuf[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
spix += 2;
buf[dpix++] = dpix_val;
}
@@ -256,12 +747,14 @@ static int NOINLINE linetoscr_16_shrink1 (int spix, int dpix, int dpix_end)
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
- out_val = p_acolors[lookup[spix_val]];
+ dpix_val = p_acolors[lookup[spix_val]];
spix += 2;
+ out_val = dpix_val;
spix_val = pixdata.apixels[spix];
dpix_val = p_acolors[lookup[spix_val]];
spix += 2;
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
@@ -297,17 +790,19 @@ static int NOINLINE linetoscr_16_shrink1 (int spix, int dpix, int dpix_end)
spix_val = pixdata.apixels[spix];
if (spix_val <= 31)
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
else
- out_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
spix += 2;
+ out_val = dpix_val;
spix_val = pixdata.apixels[spix];
if (spix_val <= 31)
dpix_val = p_acolors[spix_val];
else
dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
spix += 2;
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
@@ -325,9 +820,11 @@ static int NOINLINE linetoscr_16_shrink1 (int spix, int dpix, int dpix_end)
int rem;
if (((uintptr_t)&buf[dpix]) & 2) {
uae_u32 spix_val;
+ uae_u32 dpix_val;
spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
spix += 2;
- buf[dpix++] = p_acolors[spix_val];
+ buf[dpix++] = dpix_val;
}
if (dpix >= dpix_end)
return spix;
@@ -340,19 +837,2217 @@ static int NOINLINE linetoscr_16_shrink1 (int spix, int dpix, int dpix_end)
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
spix += 2;
+ out_val = dpix_val;
spix_val = pixdata.apixels[spix];
dpix_val = p_acolors[spix_val];
spix += 2;
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
uae_u32 spix_val;
+ uae_u32 dpix_val;
spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
spix += 2;
- buf[dpix++] = p_acolors[spix_val];
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink1_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 2;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 2;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 2;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink1f(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink1f_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink2(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink2_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink2f(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink2f_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
}
}
@@ -367,11 +3062,15 @@ static int NOINLINE linetoscr_16_spr(int spix, int dpix, int dpix_end)
if (bplham) {
while (dpix < dpix_end) {
uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
- out_val = ham_linebuf[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
sprpix_val = pixdata.apixels[spix];
spix++;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix, 0, sprpix_val, 0);
if (sprcol) {
@@ -386,12 +3085,14 @@ static int NOINLINE linetoscr_16_spr(int spix, int dpix, int dpix_end)
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
sprpix_val = spix_val;
- out_val = p_acolors[lookup[spix_val]];
+ dpix_val = p_acolors[lookup[spix_val]];
spix++;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix, 1, sprpix_val, 0);
if (sprcol) {
@@ -405,15 +3106,17 @@ static int NOINLINE linetoscr_16_spr(int spix, int dpix, int dpix_end)
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
sprpix_val = spix_val;
if (spix_val <= 31)
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
else
- out_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
spix++;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix, 0, sprpix_val, 0);
if (sprcol) {
@@ -427,12 +3130,14 @@ static int NOINLINE linetoscr_16_spr(int spix, int dpix, int dpix_end)
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
sprpix_val = spix_val;
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
spix++;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix, 0, sprpix_val, 0);
if (sprcol) {
@@ -447,6 +3152,113 @@ static int NOINLINE linetoscr_16_spr(int spix, int dpix, int dpix_end)
return spix;
}
+static int NOINLINE linetoscr_16_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
static int NOINLINE linetoscr_16_stretch1_spr(int spix, int dpix, int dpix_end)
{
uae_u16 *buf = (uae_u16 *) xlinebuffer;
@@ -456,11 +3268,14 @@ static int NOINLINE linetoscr_16_stretch1_spr(int spix, int dpix, int dpix_end)
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
- out_val = ham_linebuf[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
sprpix_val = pixdata.apixels[spix];
spix++;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix, 0, sprpix_val, 0);
if (sprcol) {
@@ -468,20 +3283,22 @@ static int NOINLINE linetoscr_16_stretch1_spr(int spix, int dpix, int dpix_end)
out_val = spcol;
}
}
- *((uae_u32 *)&buf[dpix]) = double_word(out_val);
- dpix += 2;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
}
} else if (bpldualpf) {
int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
sprpix_val = spix_val;
- out_val = p_acolors[lookup[spix_val]];
+ dpix_val = p_acolors[lookup[spix_val]];
spix++;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix, 1, sprpix_val, 0);
if (sprcol) {
@@ -489,22 +3306,24 @@ static int NOINLINE linetoscr_16_stretch1_spr(int spix, int dpix, int dpix_end)
out_val = spcol;
}
}
- *((uae_u32 *)&buf[dpix]) = double_word(out_val);
- dpix += 2;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
}
} else if (bplehb) {
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
sprpix_val = spix_val;
if (spix_val <= 31)
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
else
- out_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
spix++;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix, 0, sprpix_val, 0);
if (sprcol) {
@@ -512,19 +3331,21 @@ static int NOINLINE linetoscr_16_stretch1_spr(int spix, int dpix, int dpix_end)
out_val = spcol;
}
}
- *((uae_u32 *)&buf[dpix]) = double_word(out_val);
- dpix += 2;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
}
} else {
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
sprpix_val = spix_val;
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
spix++;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix, 0, sprpix_val, 0);
if (sprcol) {
@@ -532,8 +3353,364 @@ static int NOINLINE linetoscr_16_stretch1_spr(int spix, int dpix, int dpix_end)
out_val = spcol;
}
}
- *((uae_u32 *)&buf[dpix]) = double_word(out_val);
- dpix += 2;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_stretch1_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_stretch2_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_stretch2_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 2] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 3] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
}
}
@@ -549,11 +3726,14 @@ static int NOINLINE linetoscr_16_shrink1_spr(int spix, int dpix, int dpix_end)
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
- out_val = ham_linebuf[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
sprpix_val = pixdata.apixels[spix];
spix += 2;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix, 0, sprpix_val, 0);
if (sprcol) {
@@ -568,12 +3748,14 @@ static int NOINLINE linetoscr_16_shrink1_spr(int spix, int dpix, int dpix_end)
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
sprpix_val = spix_val;
- out_val = p_acolors[lookup[spix_val]];
+ dpix_val = p_acolors[lookup[spix_val]];
spix += 2;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix, 1, sprpix_val, 0);
if (sprcol) {
@@ -587,15 +3769,17 @@ static int NOINLINE linetoscr_16_shrink1_spr(int spix, int dpix, int dpix_end)
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
sprpix_val = spix_val;
if (spix_val <= 31)
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
else
- out_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
spix += 2;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix, 0, sprpix_val, 0);
if (sprcol) {
@@ -609,12 +3793,14 @@ static int NOINLINE linetoscr_16_shrink1_spr(int spix, int dpix, int dpix_end)
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
sprpix_val = spix_val;
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
spix += 2;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix, 0, sprpix_val, 0);
if (sprcol) {
@@ -629,24 +3815,1014 @@ static int NOINLINE linetoscr_16_shrink1_spr(int spix, int dpix, int dpix_end)
return spix;
}
+static int NOINLINE linetoscr_16_shrink1_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink1f_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink1f_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink2_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix += 4;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink2_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink2f_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_16_shrink2f_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
#ifdef AGA
static int NOINLINE linetoscr_16_aga_spronly(int spix, int dpix, int dpix_end)
{
uae_u16 *buf = (uae_u16 *) xlinebuffer;
uae_u8 sprcol;
- while (dpix < dpix_end) {
- uae_u32 out_val;
-
- spix++;
- out_val = p_acolors[0];
- if (spritepixels[dpix].data) {
- sprcol = render_sprites (dpix, 0, 0, 1);
- if (sprcol) {
- out_val = p_acolors[sprcol];
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
}
+ buf[dpix++] = out_val;
}
- buf[dpix++] = out_val;
}
return spix;
@@ -659,28 +4835,87 @@ static int NOINLINE linetoscr_16_stretch1_aga_spronly(int spix, int dpix, int dp
uae_u16 *buf = (uae_u16 *) xlinebuffer;
uae_u8 sprcol;
- while (dpix < dpix_end) {
- uae_u32 out_val;
-
- spix++;
- out_val = p_acolors[0];
- {
- uae_u32 out_val1 = out_val;
- uae_u32 out_val2 = out_val;
- if (spritepixels[dpix + 0].data) {
- sprcol = render_sprites (dpix + 0, 0, 0, 1);
- if (sprcol) {
- out_val1 = p_acolors[sprcol];
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
}
}
- if (spritepixels[dpix + 1].data) {
- sprcol = render_sprites (dpix + 1, 0, 0, 1);
- if (sprcol) {
- out_val2 = p_acolors[sprcol];
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_stretch2_aga_spronly(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
}
- }
- buf[dpix++] = out_val1;
- buf[dpix++] = out_val2;
}
}
@@ -694,18 +4929,50 @@ static int NOINLINE linetoscr_16_shrink1_aga_spronly(int spix, int dpix, int dpi
uae_u16 *buf = (uae_u16 *) xlinebuffer;
uae_u8 sprcol;
- while (dpix < dpix_end) {
- uae_u32 out_val;
-
- spix++;
- out_val = p_acolors[0];
- if (spritepixels[dpix].data) {
- sprcol = render_sprites (dpix, 0, 0, 1);
- if (sprcol) {
- out_val = p_acolors[sprcol];
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
}
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink1f_aga_spronly(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
}
- buf[dpix++] = out_val;
}
return spix;
@@ -718,18 +4985,22 @@ static int NOINLINE linetoscr_16_shrink2_aga_spronly(int spix, int dpix, int dpi
uae_u16 *buf = (uae_u16 *) xlinebuffer;
uae_u8 sprcol;
- while (dpix < dpix_end) {
- uae_u32 out_val;
-
- spix++;
- out_val = p_acolors[0];
- if (spritepixels[dpix].data) {
- sprcol = render_sprites (dpix, 0, 0, 1);
- if (sprcol) {
- out_val = p_acolors[sprcol];
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
}
+ buf[dpix++] = out_val;
}
- buf[dpix++] = out_val;
}
return spix;
@@ -737,17 +5008,49 @@ static int NOINLINE linetoscr_16_shrink2_aga_spronly(int spix, int dpix, int dpi
#endif
#ifdef AGA
-static int NOINLINE linetoscr_16_aga (int spix, int dpix, int dpix_end)
+static int NOINLINE linetoscr_16_shrink2f_aga_spronly(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_aga(int spix, int dpix, int dpix_end)
{
uae_u16 *buf = (uae_u16 *) xlinebuffer;
uae_u8 xor_val = bplxor;
uae_u8 and_val = bpland;
-
+
if (bplham) {
int rem;
if (((uintptr_t)&buf[dpix]) & 2) {
- buf[dpix++] = ham_linebuf[spix];
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
spix++;
+ buf[dpix++] = dpix_val;
}
if (dpix >= dpix_end)
return spix;
@@ -755,16 +5058,28 @@ static int NOINLINE linetoscr_16_aga (int spix, int dpix, int dpix_end)
if (rem)
dpix_end--;
while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
- out_val = *((uae_u32 *)&ham_linebuf[spix]);
- spix += 2;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
*((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
- buf[dpix++] = ham_linebuf[spix];
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
spix++;
+ buf[dpix++] = dpix_val;
}
} else if (bpldualpf) {
int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
@@ -774,11 +5089,13 @@ static int NOINLINE linetoscr_16_aga (int spix, int dpix, int dpix_end)
uae_u32 spix_val;
uae_u32 dpix_val;
spix_val = pixdata.apixels[spix];
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- dpix_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix++;
buf[dpix++] = dpix_val;
}
@@ -793,31 +5110,39 @@ static int NOINLINE linetoscr_16_aga (int spix, int dpix, int dpix_end)
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- out_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix++;
+ out_val = dpix_val;
spix_val = pixdata.apixels[spix];
- val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- dpix_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix++;
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
uae_u32 spix_val;
uae_u32 dpix_val;
spix_val = pixdata.apixels[spix];
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- dpix_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix++;
buf[dpix++] = dpix_val;
}
@@ -829,7 +5154,7 @@ static int NOINLINE linetoscr_16_aga (int spix, int dpix, int dpix_end)
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
if (pixdata.apixels[spix] & 0x20) {
unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- dpix_val = CONVERT_RGB_16 (c);
+ dpix_val = CONVERT_RGB (c);
} else
dpix_val = p_acolors[spix_val];
spix++;
@@ -848,18 +5173,20 @@ static int NOINLINE linetoscr_16_aga (int spix, int dpix, int dpix_end)
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
if (pixdata.apixels[spix] & 0x20) {
unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- out_val = CONVERT_RGB_16 (c);
- } else
- out_val = p_acolors[spix_val];
- spix++;
- spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
- if (pixdata.apixels[spix] & 0x20) {
- unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- dpix_val = CONVERT_RGB_16 (c);
+ dpix_val = CONVERT_RGB (c);
} else
dpix_val = p_acolors[spix_val];
spix++;
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ out_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
@@ -868,7 +5195,7 @@ static int NOINLINE linetoscr_16_aga (int spix, int dpix, int dpix_end)
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
if (pixdata.apixels[spix] & 0x20) {
unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- dpix_val = CONVERT_RGB_16 (c);
+ dpix_val = CONVERT_RGB (c);
} else
dpix_val = p_acolors[spix_val];
spix++;
@@ -877,112 +5204,12 @@ static int NOINLINE linetoscr_16_aga (int spix, int dpix, int dpix_end)
} else {
int rem;
if (((uintptr_t)&buf[dpix]) & 2) {
- uae_u32 spix_val;
- spix_val = (pixdata.apixels[spix++] ^ xor_val) & and_val;
- buf[dpix++] = p_acolors[spix_val];
- }
- if (dpix >= dpix_end)
- return spix;
- rem = (((uintptr_t)&buf[dpix_end]) & 2);
- if (rem)
- dpix_end--;
- while (dpix < dpix_end) {
uae_u32 spix_val;
uae_u32 dpix_val;
- uae_u32 out_val;
-
- spix_val = (pixdata.apixels[spix++] ^ xor_val) & and_val;
- out_val = p_acolors[spix_val];
- spix_val = (pixdata.apixels[spix++] ^ xor_val) & and_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
dpix_val = p_acolors[spix_val];
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
- dpix += 2;
- }
- if (rem) {
- uae_u32 spix_val;
- spix_val = (pixdata.apixels[spix++] ^ xor_val) & and_val;
- buf[dpix++] = p_acolors[spix_val];
- }
- }
-
- return spix;
-}
-#endif
-
-#ifdef AGA
-static int NOINLINE linetoscr_16_stretch1_aga (int spix, int dpix, int dpix_end)
-{
- uae_u16 *buf = (uae_u16 *) xlinebuffer;
- uae_u8 xor_val = bplxor;
- uae_u8 and_val = bpland;
-
- if (bplham) {
- while (dpix < dpix_end) {
- uae_u32 out_val;
- out_val = ham_linebuf[spix++];
- *((uae_u32 *)&buf[dpix]) = double_word(out_val);
- dpix += 2;
- }
- } else if (bpldualpf) {
- int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
- int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
- while (dpix < dpix_end) {
- uae_u32 spix_val;
- uae_u32 out_val;
-
- spix_val = pixdata.apixels[spix];
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- out_val = p_acolors[val];
spix++;
- *((uae_u32 *)&buf[dpix]) = out_val;
- dpix += 2;
- }
- } else if (bplehb) {
- while (dpix < dpix_end) {
- uae_u32 spix_val;
- uae_u32 out_val;
-
- spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
- if (pixdata.apixels[spix] & 0x20) {
- unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- out_val = CONVERT_RGB (c);
- } else
- out_val = p_acolors[spix_val];
- spix++;
- *((uae_u32 *)&buf[dpix]) = out_val;
- dpix += 2;
- }
- } else {
- while (dpix < dpix_end) {
- uae_u32 spix_val;
- uae_u32 out_val;
-
- spix_val = (pixdata.apixels[spix++] ^ xor_val) & and_val;
- out_val = p_acolors[spix_val];
- *((uae_u32 *)&buf[dpix]) = out_val;
- dpix += 2;
- }
- }
-
- return spix;
-}
-#endif
-
-#ifdef AGA
-static int NOINLINE linetoscr_16_shrink1_aga (int spix, int dpix, int dpix_end)
-{
- uae_u16 *buf = (uae_u16 *) xlinebuffer;
- uae_u8 xor_val = bplxor;
- uae_u8 and_val = bpland;
-
- if (bplham) {
- int rem;
- if (((uintptr_t)&buf[dpix]) & 2) {
- buf[dpix++] = ham_linebuf[spix];
- spix += 2;
+ buf[dpix++] = dpix_val;
}
if (dpix >= dpix_end)
return spix;
@@ -990,20 +5217,82 @@ static int NOINLINE linetoscr_16_shrink1_aga (int spix, int dpix, int dpix_end)
if (rem)
dpix_end--;
while (dpix < dpix_end) {
+ uae_u32 spix_val;
uae_u32 dpix_val;
uae_u32 out_val;
- out_val = ham_linebuf[spix];
- spix += 2;
- dpix_val = ham_linebuf[spix];
- spix += 2;
- out_val = merge_words(out_val, dpix_val);
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
*((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
- buf[dpix++] = ham_linebuf[spix];
- spix += 2;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_aga_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ buf[dpix++] = dpix_val;
}
} else if (bpldualpf) {
int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
@@ -1013,11 +5302,577 @@ static int NOINLINE linetoscr_16_shrink1_aga (int spix, int dpix, int dpix_end)
uae_u32 spix_val;
uae_u32 dpix_val;
spix_val = pixdata.apixels[spix];
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- dpix_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_stretch1_aga(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_stretch1_aga_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 1] = get_genlock_transparency((spix_val >> 2) & 63);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_stretch2_aga(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_stretch2_aga_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 1] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 2] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 3] = get_genlock_transparency((spix_val >> 2) & 63);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 2] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 3] = get_genlock_transparency(lookup[spix_val]);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val & 31);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink1_aga(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 2;
+ out_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 2;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix += 2;
buf[dpix++] = dpix_val;
}
@@ -1032,31 +5887,39 @@ static int NOINLINE linetoscr_16_shrink1_aga (int spix, int dpix, int dpix_end)
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- out_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix += 2;
+ out_val = dpix_val;
spix_val = pixdata.apixels[spix];
- val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- dpix_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix += 2;
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
uae_u32 spix_val;
uae_u32 dpix_val;
spix_val = pixdata.apixels[spix];
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- dpix_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix += 2;
buf[dpix++] = dpix_val;
}
@@ -1068,7 +5931,7 @@ static int NOINLINE linetoscr_16_shrink1_aga (int spix, int dpix, int dpix_end)
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
if (pixdata.apixels[spix] & 0x20) {
unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- dpix_val = CONVERT_RGB_16 (c);
+ dpix_val = CONVERT_RGB (c);
} else
dpix_val = p_acolors[spix_val];
spix += 2;
@@ -1087,18 +5950,20 @@ static int NOINLINE linetoscr_16_shrink1_aga (int spix, int dpix, int dpix_end)
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
if (pixdata.apixels[spix] & 0x20) {
unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- out_val = CONVERT_RGB_16 (c);
- } else
- out_val = p_acolors[spix_val];
- spix += 2;
- spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
- if (pixdata.apixels[spix] & 0x20) {
- unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- dpix_val = CONVERT_RGB_16 (c);
+ dpix_val = CONVERT_RGB (c);
} else
dpix_val = p_acolors[spix_val];
spix += 2;
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ out_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
@@ -1107,7 +5972,7 @@ static int NOINLINE linetoscr_16_shrink1_aga (int spix, int dpix, int dpix_end)
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
if (pixdata.apixels[spix] & 0x20) {
unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- dpix_val = CONVERT_RGB_16 (c);
+ dpix_val = CONVERT_RGB (c);
} else
dpix_val = p_acolors[spix_val];
spix += 2;
@@ -1116,35 +5981,41 @@ static int NOINLINE linetoscr_16_shrink1_aga (int spix, int dpix, int dpix_end)
} else {
int rem;
if (((uintptr_t)&buf[dpix]) & 2) {
- uae_u32 spix_val;
- spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
- spix += 2;
- buf[dpix++] = p_acolors[spix_val];
- }
- if (dpix >= dpix_end)
- return spix;
- rem = (((uintptr_t)&buf[dpix_end]) & 2);
- if (rem)
- dpix_end--;
- while (dpix < dpix_end) {
uae_u32 spix_val;
uae_u32 dpix_val;
- uae_u32 out_val;
-
- spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
- out_val = p_acolors[spix_val];
- spix += 2;
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
dpix_val = p_acolors[spix_val];
spix += 2;
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
uae_u32 spix_val;
+ uae_u32 dpix_val;
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
spix += 2;
- buf[dpix++] = p_acolors[spix_val];
+ buf[dpix++] = dpix_val;
}
}
@@ -1153,17 +6024,22 @@ static int NOINLINE linetoscr_16_shrink1_aga (int spix, int dpix, int dpix_end)
#endif
#ifdef AGA
-static int NOINLINE linetoscr_16_shrink2_aga (int spix, int dpix, int dpix_end)
+static int NOINLINE linetoscr_16_shrink1_aga_genlock(int spix, int dpix, int dpix_end)
{
uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
uae_u8 xor_val = bplxor;
uae_u8 and_val = bpland;
if (bplham) {
int rem;
if (((uintptr_t)&buf[dpix]) & 2) {
- buf[dpix++] = ham_linebuf[spix];
- spix += 4;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 2;
+ buf[dpix++] = dpix_val;
}
if (dpix >= dpix_end)
return spix;
@@ -1171,20 +6047,29 @@ static int NOINLINE linetoscr_16_shrink2_aga (int spix, int dpix, int dpix_end)
if (rem)
dpix_end--;
while (dpix < dpix_end) {
+ uae_u32 spix_val;
uae_u32 dpix_val;
uae_u32 out_val;
- out_val = ham_linebuf[spix];
- spix += 4;
- dpix_val = ham_linebuf[spix];
- spix += 4;
- out_val = merge_words(out_val, dpix_val);
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 2;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
*((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
- buf[dpix++] = ham_linebuf[spix];
- spix += 4;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 2;
+ buf[dpix++] = dpix_val;
}
} else if (bpldualpf) {
int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
@@ -1194,11 +6079,990 @@ static int NOINLINE linetoscr_16_shrink2_aga (int spix, int dpix, int dpix_end)
uae_u32 spix_val;
uae_u32 dpix_val;
spix_val = pixdata.apixels[spix];
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- dpix_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 2;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink1f_aga(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink1f_aga_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink2_aga(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 4;
+ out_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix += 4;
buf[dpix++] = dpix_val;
}
@@ -1213,31 +7077,39 @@ static int NOINLINE linetoscr_16_shrink2_aga (int spix, int dpix, int dpix_end)
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- out_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix += 4;
+ out_val = dpix_val;
spix_val = pixdata.apixels[spix];
- val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- dpix_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix += 4;
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
uae_u32 spix_val;
uae_u32 dpix_val;
spix_val = pixdata.apixels[spix];
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- dpix_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix += 4;
buf[dpix++] = dpix_val;
}
@@ -1249,7 +7121,7 @@ static int NOINLINE linetoscr_16_shrink2_aga (int spix, int dpix, int dpix_end)
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
if (pixdata.apixels[spix] & 0x20) {
unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- dpix_val = CONVERT_RGB_16 (c);
+ dpix_val = CONVERT_RGB (c);
} else
dpix_val = p_acolors[spix_val];
spix += 4;
@@ -1268,18 +7140,20 @@ static int NOINLINE linetoscr_16_shrink2_aga (int spix, int dpix, int dpix_end)
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
if (pixdata.apixels[spix] & 0x20) {
unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- out_val = CONVERT_RGB_16 (c);
- } else
- out_val = p_acolors[spix_val];
- spix += 4;
- spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
- if (pixdata.apixels[spix] & 0x20) {
- unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- dpix_val = CONVERT_RGB_16 (c);
+ dpix_val = CONVERT_RGB (c);
} else
dpix_val = p_acolors[spix_val];
spix += 4;
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ out_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
@@ -1288,7 +7162,7 @@ static int NOINLINE linetoscr_16_shrink2_aga (int spix, int dpix, int dpix_end)
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
if (pixdata.apixels[spix] & 0x20) {
unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- dpix_val = CONVERT_RGB_16 (c);
+ dpix_val = CONVERT_RGB (c);
} else
dpix_val = p_acolors[spix_val];
spix += 4;
@@ -1298,9 +7172,11 @@ static int NOINLINE linetoscr_16_shrink2_aga (int spix, int dpix, int dpix_end)
int rem;
if (((uintptr_t)&buf[dpix]) & 2) {
uae_u32 spix_val;
+ uae_u32 dpix_val;
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
spix += 4;
- buf[dpix++] = p_acolors[spix_val];
+ buf[dpix++] = dpix_val;
}
if (dpix >= dpix_end)
return spix;
@@ -1313,19 +7189,1482 @@ static int NOINLINE linetoscr_16_shrink2_aga (int spix, int dpix, int dpix_end)
uae_u32 out_val;
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
spix += 4;
+ out_val = dpix_val;
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
dpix_val = p_acolors[spix_val];
spix += 4;
- *((uae_u32 *)&buf[dpix]) = merge_words(out_val, dpix_val);
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
dpix += 2;
}
if (rem) {
uae_u32 spix_val;
+ uae_u32 dpix_val;
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
spix += 4;
- buf[dpix++] = p_acolors[spix_val];
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink2_aga_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink2f_aga(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink2f_aga_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else if (bplehb) {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ } else {
+ int rem;
+ if (((uintptr_t)&buf[dpix]) & 2) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
+ }
+ if (dpix >= dpix_end)
+ return spix;
+ rem = (((uintptr_t)&buf[dpix_end]) & 2);
+ if (rem)
+ dpix_end--;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = (out_val & 0xFFFF) | (dpix_val << 16);
+ *((uae_u32 *)&buf[dpix]) = out_val;
+ dpix += 2;
+ }
+ if (rem) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ buf[dpix++] = dpix_val;
}
}
@@ -1344,10 +8683,15 @@ static int NOINLINE linetoscr_16_aga_spr(int spix, int dpix, int dpix_end)
if (bplham) {
while (dpix < dpix_end) {
uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
sprpix_val = pixdata.apixels[spix];
- out_val = ham_linebuf[spix++];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
if (sprcol) {
@@ -1362,16 +8706,20 @@ static int NOINLINE linetoscr_16_aga_spr(int spix, int dpix, int dpix_end)
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
sprpix_val = spix_val;
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- out_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix++;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
if (sprcol) {
@@ -1384,16 +8732,18 @@ static int NOINLINE linetoscr_16_aga_spr(int spix, int dpix, int dpix_end)
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
sprpix_val = pixdata.apixels[spix];
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
if (pixdata.apixels[spix] & 0x20) {
unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- out_val = CONVERT_RGB (c);
+ dpix_val = CONVERT_RGB (c);
} else
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
spix++;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
if (sprcol) {
@@ -1406,12 +8756,14 @@ static int NOINLINE linetoscr_16_aga_spr(int spix, int dpix, int dpix_end)
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
sprpix_val = pixdata.apixels[spix];
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
spix++;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
if (sprcol) {
@@ -1426,6 +8778,121 @@ static int NOINLINE linetoscr_16_aga_spr(int spix, int dpix, int dpix_end)
}
#endif
+#ifdef AGA
+static int NOINLINE linetoscr_16_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
#ifdef AGA
static int NOINLINE linetoscr_16_stretch1_aga_spr(int spix, int dpix, int dpix_end)
{
@@ -1438,11 +8905,14 @@ static int NOINLINE linetoscr_16_stretch1_aga_spr(int spix, int dpix, int dpix_e
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
sprpix_val = pixdata.apixels[spix];
- out_val = ham_linebuf[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
spix++;
+ out_val = dpix_val;
{
uae_u32 out_val1 = out_val;
uae_u32 out_val2 = out_val;
@@ -1468,16 +8938,20 @@ static int NOINLINE linetoscr_16_stretch1_aga_spr(int spix, int dpix, int dpix_e
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
sprpix_val = spix_val;
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- out_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix++;
+ out_val = dpix_val;
{
uae_u32 out_val1 = out_val;
uae_u32 out_val2 = out_val;
@@ -1501,16 +8975,18 @@ static int NOINLINE linetoscr_16_stretch1_aga_spr(int spix, int dpix, int dpix_e
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
sprpix_val = pixdata.apixels[spix];
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
if (pixdata.apixels[spix] & 0x20) {
unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- out_val = CONVERT_RGB (c);
+ dpix_val = CONVERT_RGB (c);
} else
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
spix++;
+ out_val = dpix_val;
{
uae_u32 out_val1 = out_val;
uae_u32 out_val2 = out_val;
@@ -1534,12 +9010,14 @@ static int NOINLINE linetoscr_16_stretch1_aga_spr(int spix, int dpix, int dpix_e
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
sprpix_val = pixdata.apixels[spix];
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
spix++;
+ out_val = dpix_val;
{
uae_u32 out_val1 = out_val;
uae_u32 out_val2 = out_val;
@@ -1565,6 +9043,634 @@ static int NOINLINE linetoscr_16_stretch1_aga_spr(int spix, int dpix, int dpix_e
}
#endif
+#ifdef AGA
+static int NOINLINE linetoscr_16_stretch1_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 1] = get_genlock_transparency((spix_val >> 2) & 63);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ }
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ }
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ }
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ }
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_stretch2_aga_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_stretch2_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 1] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 2] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 3] = get_genlock_transparency((spix_val >> 2) & 63);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ genlock_buf[dpix + 2] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ genlock_buf[dpix + 3] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 2] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 3] = get_genlock_transparency(lookup[spix_val]);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ genlock_buf[dpix + 2] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ genlock_buf[dpix + 3] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val & 31);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ genlock_buf[dpix + 2] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ genlock_buf[dpix + 3] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ genlock_buf[dpix + 2] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ genlock_buf[dpix + 3] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ }
+
+ return spix;
+}
+#endif
+
#ifdef AGA
static int NOINLINE linetoscr_16_shrink1_aga_spr(int spix, int dpix, int dpix_end)
{
@@ -1576,11 +9682,15 @@ static int NOINLINE linetoscr_16_shrink1_aga_spr(int spix, int dpix, int dpix_en
if (bplham) {
while (dpix < dpix_end) {
uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
sprpix_val = pixdata.apixels[spix];
- out_val = ham_linebuf[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
spix += 2;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
if (sprcol) {
@@ -1595,16 +9705,20 @@ static int NOINLINE linetoscr_16_shrink1_aga_spr(int spix, int dpix, int dpix_en
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
sprpix_val = spix_val;
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- out_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix += 2;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
if (sprcol) {
@@ -1617,16 +9731,18 @@ static int NOINLINE linetoscr_16_shrink1_aga_spr(int spix, int dpix, int dpix_en
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
sprpix_val = pixdata.apixels[spix];
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
if (pixdata.apixels[spix] & 0x20) {
unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- out_val = CONVERT_RGB (c);
+ dpix_val = CONVERT_RGB (c);
} else
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
spix += 2;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
if (sprcol) {
@@ -1639,12 +9755,14 @@ static int NOINLINE linetoscr_16_shrink1_aga_spr(int spix, int dpix, int dpix_en
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
sprpix_val = pixdata.apixels[spix];
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
spix += 2;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
if (sprcol) {
@@ -1659,6 +9777,434 @@ static int NOINLINE linetoscr_16_shrink1_aga_spr(int spix, int dpix, int dpix_en
}
#endif
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink1_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink1f_aga_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink1f_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel16 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
#ifdef AGA
static int NOINLINE linetoscr_16_shrink2_aga_spr(int spix, int dpix, int dpix_end)
{
@@ -1670,11 +10216,15 @@ static int NOINLINE linetoscr_16_shrink2_aga_spr(int spix, int dpix, int dpix_en
if (bplham) {
while (dpix < dpix_end) {
uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
sprpix_val = pixdata.apixels[spix];
- out_val = ham_linebuf[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
spix += 4;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
if (sprcol) {
@@ -1689,16 +10239,20 @@ static int NOINLINE linetoscr_16_shrink2_aga_spr(int spix, int dpix, int dpix_en
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
spix_val = pixdata.apixels[spix];
sprpix_val = spix_val;
- uae_u8 val = lookup[spix_val];
- if (lookup_no[spix_val])
- val += dblpfofs[bpldualpf2of];
- val ^= xor_val;
- out_val = p_acolors[val];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
spix += 4;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
if (sprcol) {
@@ -1711,16 +10265,18 @@ static int NOINLINE linetoscr_16_shrink2_aga_spr(int spix, int dpix, int dpix_en
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
sprpix_val = pixdata.apixels[spix];
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
if (pixdata.apixels[spix] & 0x20) {
unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
- out_val = CONVERT_RGB (c);
+ dpix_val = CONVERT_RGB (c);
} else
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
spix += 4;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
if (sprcol) {
@@ -1733,12 +10289,14 @@ static int NOINLINE linetoscr_16_shrink2_aga_spr(int spix, int dpix, int dpix_en
while (dpix < dpix_end) {
uae_u32 sprpix_val;
uae_u32 spix_val;
+ uae_u32 dpix_val;
uae_u32 out_val;
sprpix_val = pixdata.apixels[spix];
spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
- out_val = p_acolors[spix_val];
+ dpix_val = p_acolors[spix_val];
spix += 4;
+ out_val = dpix_val;
if (spritepixels[dpix].data) {
sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
if (sprcol) {
@@ -1752,3 +10310,7314 @@ static int NOINLINE linetoscr_16_shrink2_aga_spr(int spix, int dpix, int dpix_en
return spix;
}
#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink2_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink2f_aga_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_16_shrink2f_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u16 *buf = (uae_u16 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel16 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel16 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel16 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+static int NOINLINE linetoscr_32(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_stretch1(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_stretch1_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 15);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_stretch2(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_stretch2_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val & 15);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 2] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 3] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink1(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 2;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 2;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink1_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink1f(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink1f_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink2(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink2_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink2f(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink2f_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_stretch1_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_stretch1_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_stretch2_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_stretch2_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val & 15);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 2] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 3] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink1_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix += 2;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 2;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 2;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink1_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink1f_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink1f_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink2_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix += 4;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink2_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink2f_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+static int NOINLINE linetoscr_32_shrink2f_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = p_xcolors[spix_val];
+ sprpix_val = pixdata.apixels[spix];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 15);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2 : dblpf_ind1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[lookup[spix_val]];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 1, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ if (spix_val <= 31)
+ dpix_val = p_acolors[spix_val];
+ else
+ dpix_val = p_xcolors[(colors_for_drawing.color_regs_ecs[spix_val - 32] >> 1) & 0x777];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix, 0, sprpix_val, 0);
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ if (sprcol) {
+ uae_u32 spcol = p_acolors[sprcol];
+ out_val = spcol;
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_aga_spronly(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_stretch1_aga_spronly(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ }
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_stretch2_aga_spronly(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink1_aga_spronly(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink1f_aga_spronly(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink2_aga_spronly(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink2f_aga_spronly(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+
+ if (1) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = 0;
+ spix++;
+ out_val = p_acolors[0];
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_aga(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_aga_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_stretch1_aga(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_stretch1_aga_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 1] = get_genlock_transparency((spix_val >> 2) & 63);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_stretch2_aga(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_stretch2_aga_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 1] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 2] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 3] = get_genlock_transparency((spix_val >> 2) & 63);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 2] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 3] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink1_aga(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 2;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 2;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink1_aga_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink1f_aga(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink1f_aga_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink2_aga(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 4;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 4;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink2_aga_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink2f_aga(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink2f_aga_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_aga_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_stretch1_aga_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ }
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ }
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ }
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ }
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_stretch1_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 1] = get_genlock_transparency((spix_val >> 2) & 63);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ }
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ }
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ }
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ }
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_stretch2_aga_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_stretch2_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 1] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 2] = get_genlock_transparency((spix_val >> 2) & 63);
+ genlock_buf[dpix + 3] = get_genlock_transparency((spix_val >> 2) & 63);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ genlock_buf[dpix + 2] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ genlock_buf[dpix + 3] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 1] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 2] = get_genlock_transparency(lookup[spix_val]);
+ genlock_buf[dpix + 3] = get_genlock_transparency(lookup[spix_val]);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ genlock_buf[dpix + 2] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ genlock_buf[dpix + 3] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val & 31);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val & 31);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ genlock_buf[dpix + 2] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ genlock_buf[dpix + 3] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 1] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 2] = get_genlock_transparency(spix_val);
+ genlock_buf[dpix + 3] = get_genlock_transparency(spix_val);
+ {
+ uae_u32 out_val1 = out_val;
+ uae_u32 out_val2 = out_val;
+ uae_u32 out_val3 = out_val;
+ uae_u32 out_val4 = out_val;
+ if (spritepixels[dpix + 0].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val1 = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 1].data) {
+ sprcol = render_sprites (dpix + 1, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val2 = p_acolors[sprcol];
+ genlock_buf[dpix + 1] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 2].data) {
+ sprcol = render_sprites (dpix + 2, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val3 = p_acolors[sprcol];
+ genlock_buf[dpix + 2] = get_genlock_transparency(sprcol);
+ }
+ }
+ if (spritepixels[dpix + 3].data) {
+ sprcol = render_sprites (dpix + 3, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val4 = p_acolors[sprcol];
+ genlock_buf[dpix + 3] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val1;
+ buf[dpix++] = out_val2;
+ buf[dpix++] = out_val3;
+ buf[dpix++] = out_val4;
+ }
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink1_aga_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 2;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 2;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink1_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 2;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink1f_aga_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink1f_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ dpix_val = merge_2pixel32 (dpix_val, tmp_val);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink2_aga_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 4;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 4;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink2_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix += 4;
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink2f_aga_spr(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
+#ifdef AGA
+static int NOINLINE linetoscr_32_shrink2f_aga_spr_genlock(int spix, int dpix, int dpix_end)
+{
+ uae_u32 *buf = (uae_u32 *) xlinebuffer;
+ uae_u8 *genlock_buf = xlinebuffer_genlock;
+ uae_u8 sprcol;
+ uae_u8 xor_val = bplxor;
+ uae_u8 and_val = bpland;
+
+ if (bplham) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val2 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ spix++;
+ tmp_val3 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = ham_linebuf[spix];
+ dpix_val = CONVERT_RGB (spix_val);
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency((spix_val >> 2) & 63);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bpldualpf) {
+ int *lookup = bpldualpfpri ? dblpf_ind2_aga : dblpf_ind1_aga;
+ int *lookup_no = bpldualpfpri ? dblpf_2nd2 : dblpf_2nd1;
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val2 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ spix++;
+ tmp_val3 = dpix_val;
+ spix_val = pixdata.apixels[spix];
+ sprpix_val = spix_val;
+ {
+ uae_u8 val = lookup[spix_val];
+ if (lookup_no[spix_val])
+ val += dblpfofs[bpldualpf2of];
+ val ^= xor_val;
+ dpix_val = p_acolors[val];
+ }
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(lookup[spix_val]);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 1, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else if (bplehb) {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ if (pixdata.apixels[spix] & 0x20) {
+ unsigned int c = (colors_for_drawing.color_regs_aga[spix_val & 0x1f] >> 1) & 0x7F7F7F;
+ dpix_val = CONVERT_RGB (c);
+ } else
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val & 31);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ } else {
+ while (dpix < dpix_end) {
+ uae_u32 sprpix_val;
+ uae_u32 spix_val;
+ uae_u32 dpix_val;
+ uae_u32 out_val;
+
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ {
+ uae_u32 tmp_val, tmp_val2, tmp_val3;
+ spix++;
+ tmp_val = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val2 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ spix++;
+ tmp_val3 = dpix_val;
+ sprpix_val = pixdata.apixels[spix];
+ spix_val = (pixdata.apixels[spix] ^ xor_val) & and_val;
+ dpix_val = p_acolors[spix_val];
+ tmp_val = merge_2pixel32 (tmp_val, tmp_val2);
+ tmp_val2 = merge_2pixel32 (tmp_val3, dpix_val);
+ dpix_val = merge_2pixel32 (tmp_val, tmp_val2);
+ spix++;
+ }
+ out_val = dpix_val;
+ genlock_buf[dpix] = get_genlock_transparency(spix_val);
+ if (spritepixels[dpix].data) {
+ sprcol = render_sprites (dpix + 0, 0, sprpix_val, 1);
+ if (sprcol) {
+ out_val = p_acolors[sprcol];
+ genlock_buf[dpix] = get_genlock_transparency(sprcol);
+ }
+ }
+ buf[dpix++] = out_val;
+ }
+ }
+
+ return spix;
+}
+#endif
+
diff --git a/src/machdep/maccess.h b/src/machdep/maccess.h
index 49db277a..d86f1210 100644
--- a/src/machdep/maccess.h
+++ b/src/machdep/maccess.h
@@ -1,100 +1,96 @@
- /*
- * UAE - The Un*x Amiga Emulator
- *
- * Memory access functions
- *
- * Copyright 1996 Bernd Schmidt
- */
+/*
+ * UAE - The Un*x Amiga Emulator
+ *
+ * Memory access functions
+ *
+ * Copyright 1996 Bernd Schmidt
+ */
#ifndef MACCESS_UAE_H
#define MACCESS_UAE_H
-#ifdef ARMV6_ASSEMBLY
+#define ALIGN_POINTER_TO32(p) ((~(unsigned long)(p)) & 3)
-STATIC_INLINE uae_u16 do_get_mem_word(uae_u16 *_GCCRES_ a)
+ #ifdef ARMV6_ASSEMBLY
+
+ STATIC_INLINE uae_u32 do_get_mem_long(uae_u32 *a)
+ {
+ uae_u32 v;
+ __asm__ (
+ "ldr %[v], [%[a]] \n\t"
+ "rev %[v], %[v] \n\t"
+ : [v] "=r" (v) : [a] "r" (a) );
+ return v;
+ }
+ #else
+STATIC_INLINE uae_u32 do_get_mem_long(uae_u32 *a)
{
- uae_u16 v;
- __asm__ (
- "ldrh %[v], [%[a]] \n\t"
- "rev16 %[v], %[v] \n\t"
- : [v] "=r" (v) : [a] "r" (a) );
- return v;
-}
-#else
-STATIC_INLINE uae_u16 do_get_mem_word(uae_u16 *_GCCRES_ a)
-{
- uae_u8 *b = (uae_u8 *)a;
-
- return (*b << 8) | (*(b+1));
-}
-#endif
-
-
-#ifdef ARMV6_ASSEMBLY
-
-STATIC_INLINE uae_u32 do_get_mem_long(uae_u32 *a)
-{
- uae_u32 v;
- __asm__ (
- "ldr %[v], [%[a]] \n\t"
- "rev %[v], %[v] \n\t"
- : [v] "=r" (v) : [a] "r" (a) );
- return v;
-}
-#else
-STATIC_INLINE uae_u32 do_get_mem_long(uae_u32 *_GCCRES_ a)
-{
- uae_u8 *b = (uae_u8 *)a;
-
- return (*b << 24) | (*(b+1) << 16) | (*(b+2) << 8) | (*(b+3));
-}
-#endif
-
-
-STATIC_INLINE uae_u8 do_get_mem_byte(uae_u8 *_GCCRES_ a)
-{
- return *a;
-}
-
-#ifdef ARMV6_ASSEMBLY
-STATIC_INLINE void do_put_mem_word(uae_u16 *_GCCRES_ a, uae_u16 v)
-{
- __asm__ (
- "rev16 r2, %[v] \n\t"
- "strh r2, [%[a]] \n\t"
- : : [v] "r" (v), [a] "r" (a) : "r2", "memory" );
-}
-#else
-STATIC_INLINE void do_put_mem_word(uae_u16 *_GCCRES_ a, uae_u16 v)
-{
- uae_u8 *b = (uae_u8 *)a;
-
- *b = v >> 8;
- *(b+1) = v;
+ uae_u8 *b = (uae_u8 *)a;
+ return (*b << 24) | (*(b + 1) << 16) | (*(b + 2) << 8) | (*(b + 3));
}
#endif
#ifdef ARMV6_ASSEMBLY
-STATIC_INLINE void do_put_mem_long(uae_u32 *_GCCRES_ a, uae_u32 v)
+
+STATIC_INLINE uae_u16 do_get_mem_word(uae_u16 *a)
{
- __asm__ (
- "rev r2, %[v] \n\t"
- "str r2, [%[a]] \n\t"
- : : [v] "r" (v), [a] "r" (a) : "r2", "memory" );
+ uae_u16 v;
+ __asm__ (
+ "ldrh %[v], [%[a]] \n\t"
+ "rev16 %[v], %[v] \n\t"
+ : [v] "=r" (v) : [a] "r" (a) );
+ return v;
}
#else
-STATIC_INLINE void do_put_mem_long(uae_u32 *_GCCRES_ a, uae_u32 v)
+STATIC_INLINE uae_u16 do_get_mem_word(uae_u16 *a)
{
- uae_u8 *b = (uae_u8 *)a;
-
- *b = v >> 24;
- *(b+1) = v >> 16;
- *(b+2) = v >> 8;
- *(b+3) = v;
+ uae_u8 *b = (uae_u8 *)a;
+
+ return (*b << 8) | (*(b + 1));
}
#endif
-STATIC_INLINE void do_put_mem_byte(uae_u8 *_GCCRES_ a, uae_u8 v)
+#define do_get_mem_byte(a) ((uae_u32)*(uae_u8 *)(a))
+
+#ifdef ARMV6_ASSEMBLY
+STATIC_INLINE void do_put_mem_long(uae_u32 *a, uae_u32 v)
+{
+ __asm__ (
+ "rev r2, %[v] \n\t"
+ "str r2, [%[a]] \n\t"
+ : : [v] "r" (v), [a] "r" (a) : "r2", "memory" );
+}
+#else
+STATIC_INLINE void do_put_mem_long(uae_u32 *a, uae_u32 v)
+{
+ uae_u8 *b = (uae_u8 *)a;
+
+ *b = v >> 24;
+ *(b + 1) = v >> 16;
+ *(b + 2) = v >> 8;
+ *(b + 3) = v;
+}
+#endif
+
+#ifdef ARMV6_ASSEMBLY
+STATIC_INLINE void do_put_mem_word(uae_u16 *a, uae_u16 v)
+{
+ __asm__ (
+ "rev16 r2, %[v] \n\t"
+ "strh r2, [%[a]] \n\t"
+ : : [v] "r" (v), [a] "r" (a) : "r2", "memory" );
+}
+#else
+STATIC_INLINE void do_put_mem_word(uae_u16 *a, uae_u16 v)
+{
+ uae_u8 *b = (uae_u8 *)a;
+
+ *b = v >> 8;
+ *(b + 1) = (uae_u8)v;
+}
+#endif
+
+STATIC_INLINE void do_put_mem_byte(uae_u8 *a, uae_u8 v)
{
*a = v;
}
@@ -102,8 +98,4 @@ STATIC_INLINE void do_put_mem_byte(uae_u8 *_GCCRES_ a, uae_u8 v)
#define call_mem_get_func(func, addr) ((*func)(addr))
#define call_mem_put_func(func, addr, v) ((*func)(addr, v))
-#undef MD_HAVE_MEM_1_FUNCS
-
-#define ALIGN_POINTER_TO32(p) ((~(unsigned long)(p)) & 3)
-
#endif
diff --git a/src/main.cpp b/src/main.cpp
index 6ebc1d2a..79538a92 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -25,14 +25,20 @@
#include "gui.h"
#include "zfile.h"
#include "autoconf.h"
+#include "traps.h"
+#include "osemu.h"
#include "picasso96.h"
+#include "bsdsocket.h"
#include "native2amiga.h"
+#include "akiko.h"
#include "savestate.h"
-#include "filesys.h"
#include "blkdev.h"
+#include "uaeresource.h"
#include "gfxboard.h"
-#include "devices.h"
+
+#ifdef JIT
#include "jit/compemu.h"
+#endif
#ifdef USE_SDL
#include "SDL.h"
@@ -48,320 +54,515 @@ SDL_DisplayMode sdlMode;
#include
#include "keyboard.h"
-long int version = 256*65536L*UAEMAJOR + 65536L*UAEMINOR + UAESUBREV;
+long int version = 256 * 65536L*UAEMAJOR + 65536L*UAEMINOR + UAESUBREV;
struct uae_prefs currprefs, changed_prefs;
int config_changed;
-bool no_gui = 0;
-bool cloanto_rom = 0;
-bool kickstart_rom = 1;
+bool no_gui = false, quit_to_gui = false;
+bool cloanto_rom = false;
+bool kickstart_rom = true;
+bool console_emulation = false;
struct gui_info gui_data;
+TCHAR warning_buffer[256];
+
TCHAR optionsfile[256];
-void my_trim (TCHAR *s)
+static uae_u32 randseed;
+static int oldhcounter;
+
+uae_u32 uaesrand(uae_u32 seed)
+{
+ oldhcounter = -1;
+ randseed = seed;
+ //randseed = 0x12345678;
+ //write_log (_T("seed=%08x\n"), randseed);
+ return randseed;
+}
+uae_u32 uaerand()
+{
+ if (oldhcounter != hsync_counter) {
+ srand(hsync_counter ^ randseed);
+ oldhcounter = hsync_counter;
+ }
+ uae_u32 r = rand();
+ //write_log (_T("rand=%08x\n"), r);
+ return r;
+}
+uae_u32 uaerandgetseed()
+{
+ return randseed;
+}
+
+void my_trim(TCHAR *s)
{
int len;
- while (_tcslen (s) > 0 && _tcscspn (s, _T("\t \r\n")) == 0)
- memmove (s, s + 1, (_tcslen (s + 1) + 1) * sizeof (TCHAR));
- len = _tcslen (s);
- while (len > 0 && _tcscspn (s + len - 1, _T("\t \r\n")) == 0)
+ while (_tcslen(s) > 0 && _tcscspn(s, _T("\t \r\n")) == 0)
+ memmove(s, s + 1, (_tcslen(s + 1) + 1) * sizeof(TCHAR));
+ len = _tcslen(s);
+ while (len > 0 && _tcscspn(s + len - 1, _T("\t \r\n")) == 0)
s[--len] = '\0';
}
-TCHAR *my_strdup_trim (const TCHAR *s)
+TCHAR *my_strdup_trim(const TCHAR *s)
{
TCHAR *out;
int len;
- if (s[0] == 0)
- return my_strdup(s);
- while (_tcscspn (s, _T("\t \r\n")) == 0)
+ while (_tcscspn(s, _T("\t \r\n")) == 0)
s++;
- len = _tcslen (s);
- while (len > 0 && _tcscspn (s + len - 1, _T("\t \r\n")) == 0)
+ len = _tcslen(s);
+ while (len > 0 && _tcscspn(s + len - 1, _T("\t \r\n")) == 0)
len--;
- out = xmalloc (TCHAR, len + 1);
- memcpy (out, s, len * sizeof (TCHAR));
+ out = xmalloc(TCHAR, len + 1);
+ memcpy(out, s, len * sizeof(TCHAR));
out[len] = 0;
return out;
}
-void discard_prefs (struct uae_prefs *p, int type)
+void discard_prefs(struct uae_prefs *p, int type)
{
- struct strlist **ps = &p->all_lines;
- while (*ps) {
- struct strlist *s = *ps;
- *ps = s->next;
- xfree (s->value);
- xfree (s->option);
- xfree (s);
- }
- p->all_lines = NULL;
- currprefs.all_lines = changed_prefs.all_lines = NULL;
+ struct strlist **ps = &p->all_lines;
+ while (*ps) {
+ struct strlist *s = *ps;
+ *ps = s->next;
+ xfree(s->value);
+ xfree(s->option);
+ xfree(s);
+ }
#ifdef FILESYS
- filesys_cleanup ();
+ filesys_cleanup();
#endif
}
-static void fixup_prefs_dim2 (struct wh *wh)
+static void fixup_prefs_dim2(struct wh *wh)
{
- if (wh->width < 320) {
- error_log (_T("Width (%d) must be at least 320."), wh->width);
- wh->width = 320;
+ if (wh->special)
+ return;
+ if (wh->width < 160) {
+ error_log(_T("Width (%d) must be at least 128."), wh->width);
+ wh->width = 160;
}
- if (wh->height < 200) {
- error_log (_T("Height (%d) must be at least 200."), wh->height);
- wh->height = 200;
+ if (wh->height < 128) {
+ error_log(_T("Height (%d) must be at least 128."), wh->height);
+ wh->height = 128;
}
if (wh->width > max_uae_width) {
- error_log (_T("Width (%d) max is %d."), wh->width, max_uae_width);
+ error_log(_T("Width (%d) max is %d."), wh->width, max_uae_width);
wh->width = max_uae_width;
- }
+ }
if (wh->height > max_uae_height) {
- error_log (_T("Height (%d) max is %d."), wh->height, max_uae_height);
+ error_log(_T("Height (%d) max is %d."), wh->height, max_uae_height);
wh->height = max_uae_height;
}
}
-void fixup_prefs_dimensions (struct uae_prefs *prefs)
+void fixup_prefs_dimensions(struct uae_prefs *prefs)
{
- fixup_prefs_dim2(&prefs->gfx_size);
+ fixup_prefs_dim2(&prefs->gfx_size_fs);
+ fixup_prefs_dim2(&prefs->gfx_size_win);
+ if (prefs->gfx_apmode[1].gfx_vsync)
+ prefs->gfx_apmode[1].gfx_vsyncmode = 1;
for (int i = 0; i < 2; i++) {
struct apmode *ap = &prefs->gfx_apmode[i];
ap->gfx_vflip = 0;
- if (ap->gfx_vsync > 0) {
- // legacy vsync: always wait for flip
- ap->gfx_vflip = -1;
- }
- }
+ ap->gfx_strobo = false;
+ if (ap->gfx_vsync) {
+ if (ap->gfx_vsyncmode) {
+ // low latency vsync: no flip only if no-buffer
+ if (ap->gfx_backbuffers >= 1)
+ ap->gfx_vflip = 1;
+ if (!i && ap->gfx_backbuffers == 2)
+ ap->gfx_vflip = 1;
+ ap->gfx_strobo = prefs->lightboost_strobo;
+ }
+ else {
+ // legacy vsync: always wait for flip
+ ap->gfx_vflip = -1;
+ if (prefs->gfx_api && ap->gfx_backbuffers < 1)
+ ap->gfx_backbuffers = 1;
+ if (ap->gfx_vflip)
+ ap->gfx_strobo = prefs->lightboost_strobo;;
+ }
+ }
+ else {
+ // no vsync: wait if triple bufferirng
+ if (ap->gfx_backbuffers >= 2)
+ ap->gfx_vflip = -1;
+ }
+ if (prefs->gf[i].gfx_filter == 0 && ((prefs->gf[i].gfx_filter_autoscale && !prefs->gfx_api) || (prefs->gfx_apmode[APMODE_NATIVE].gfx_vsyncmode))) {
+ prefs->gf[i].gfx_filter = 1;
+ }
+ if (i == 0 && prefs->gf[i].gfx_filter == 0 && prefs->monitoremu) {
+ error_log(_T("A2024 and Graffiti require at least null filter enabled."));
+ prefs->gf[i].gfx_filter = 1;
+ }
+ }
}
void fixup_cpu(struct uae_prefs *p)
{
- if (p->cpu_model >= 68040 && p->address_space_24) {
- error_log (_T("24-bit address space is not supported with 68040/060 configurations."));
- p->address_space_24 = 0;
+ if (p->cpu_frequency == 1000000)
+ p->cpu_frequency = 0;
+
+ if (p->cpu_model >= 68030 && p->address_space_24) {
+ error_log(_T("24-bit address space is not supported in 68030/040/060 configurations."));
+ p->address_space_24 = false;
}
- if (p->cpu_model < 68020 && p->fpu_model && p->cpu_compatible) {
- error_log (_T("FPU is not supported with 68000/010 configurations."));
+ if (p->cpu_model < 68020 && p->fpu_model && (p->cpu_compatible || p->cpu_cycle_exact)) {
+ error_log(_T("FPU is not supported in 68000/010 configurations."));
p->fpu_model = 0;
}
- if (p->cpu_model > 68010 && p->cpu_compatible) {
- error_log(_T("CPU Compatible is only supported with 68000/010 configurations."));
- p->cpu_compatible = 0;
- }
- switch(p->cpu_model)
- {
- case 68000:
- break;
- case 68010:
- break;
- case 68020:
- break;
- case 68030:
- break;
- case 68040:
- if (p->fpu_model)
- p->fpu_model = 68040;
- break;
- }
-
- if (p->cpu_model >= 68020 && p->cachesize && p->cpu_compatible)
- p->cpu_compatible = false;
-
- if (p->cachesize && (p->fpu_no_unimplemented)) {
- error_log (_T("JIT is not compatible with unimplemented FPU instruction emulation."));
- p->fpu_no_unimplemented = false;
+ switch (p->cpu_model)
+ {
+ case 68000:
+ p->address_space_24 = true;
+ break;
+ case 68010:
+ p->address_space_24 = true;
+ break;
+ case 68020:
+ break;
+ case 68030:
+ break;
+ case 68040:
+ if (p->fpu_model)
+ p->fpu_model = 68040;
+ break;
+ case 68060:
+ if (p->fpu_model)
+ p->fpu_model = 68060;
+ break;
}
+ if (p->cpu_model < 68020 && p->cachesize) {
+ p->cachesize = 0;
+ error_log(_T("JIT requires 68020 or better CPU."));
+ }
+
+ if (p->cpu_model >= 68040 && p->cachesize && p->cpu_compatible)
+ p->cpu_compatible = false;
+
+ if (p->cpu_model >= 68040 && p->cpu_cycle_exact) {
+ p->cpu_cycle_exact = false;
+ error_log(_T("68040/060 cycle-exact is not supported."));
+ }
+
+ if ((p->cpu_model < 68030 || p->cachesize) && p->mmu_model) {
+ error_log(_T("MMU emulation requires 68030/040/060 and it is not JIT compatible."));
+ p->mmu_model = 0;
+ }
+
+ if (p->cachesize && p->cpu_cycle_exact) {
+ error_log(_T("JIT and cycle-exact can't be enabled simultaneously."));
+ p->cachesize = 0;
+ }
+ if (p->cachesize && (p->fpu_no_unimplemented || p->int_no_unimplemented)) {
+ error_log(_T("JIT is not compatible with unimplemented CPU/FPU instruction emulation."));
+ p->fpu_no_unimplemented = p->int_no_unimplemented = false;
+ }
+
+ if (p->cpu_cycle_exact && p->m68k_speed < 0)
+ p->m68k_speed = 0;
+
+ if (p->immediate_blits && p->blitter_cycle_exact) {
+ error_log(_T("Cycle-exact and immediate blitter can't be enabled simultaneously.\n"));
+ p->immediate_blits = false;
+ }
if (p->immediate_blits && p->waiting_blits) {
- error_log (_T("Immediate blitter and waiting blits can't be enabled simultaneously.\n"));
+ error_log(_T("Immediate blitter and waiting blits can't be enabled simultaneously.\n"));
p->waiting_blits = 0;
- }
+ }
+ if (p->cpu_cycle_exact)
+ p->cpu_compatible = true;
}
-void fixup_prefs (struct uae_prefs *p, bool userconfig)
-{
- int err = 0;
- built_in_chipset_prefs (p);
- fixup_cpu(p);
+void fixup_prefs(struct uae_prefs *p, bool userconfig)
+{
+ int err = 0;
+
+ built_in_chipset_prefs(p);
+ fixup_cpu(p);
cfgfile_compatibility_rtg(p);
cfgfile_compatibility_romtype(p);
read_kickstart_version(p);
- if (((p->chipmem_size & (p->chipmem_size - 1)) != 0 && p->chipmem_size != 0x180000)
- || p->chipmem_size < 0x20000
- || p->chipmem_size > 0x800000)
- {
- error_log (_T("Unsupported chipmem size %d (0x%x)."), p->chipmem_size, p->chipmem_size);
- p->chipmem_size = 0x200000;
- err = 1;
- }
+ //if (p->cpuboard_type && p->cpuboardmem1_size > cpuboard_maxmemory(p)) {
+ // error_log(_T("Unsupported accelerator board memory size %d (0x%x).\n"), p->cpuboardmem1_size, p->cpuboardmem1_size);
+ // p->cpuboardmem1_size = cpuboard_maxmemory(p);
+ //}
+ //if (cpuboard_memorytype(p) == BOARD_MEMORY_HIGHMEM) {
+ // p->mbresmem_high_size = p->cpuboardmem1_size;
+ //}
+ //else if (cpuboard_memorytype(p) == BOARD_MEMORY_Z2) {
+ // p->fastmem[0].size = p->cpuboardmem1_size;
+ //}
+ //else if (cpuboard_memorytype(p) == BOARD_MEMORY_25BITMEM) {
+ // p->mem25bit_size = p->cpuboardmem1_size;
+ //}
- for (int i = 0; i < MAX_RAM_BOARDS; i++) {
- if ((p->fastmem[i].size & (p->fastmem[i].size - 1)) != 0
- || (p->fastmem[i].size != 0 && (p->fastmem[i].size < 0x10000 || p->fastmem[i].size > 0x800000)))
- {
- error_log (_T("Unsupported fastmem size %d (0x%x)."), p->fastmem[i].size, p->fastmem[i].size);
- p->fastmem[i].size = 0;
- err = 1;
- }
- }
-
- for (int i = 0; i < MAX_RTG_BOARDS; i++) {
- struct rtgboardconfig *rbc = &p->rtgboards[i];
- if (rbc->rtgmem_size > 0x1000000 && rbc->rtgmem_type == GFXBOARD_UAE_Z3) {
- error_log (_T("Graphics card memory size %d (0x%x) larger than maximum reserved %d (0x%x)."), rbc->rtgmem_size, rbc->rtgmem_size, 0x1000000, 0x1000000);
- rbc->rtgmem_size = 0x1000000;
- err = 1;
- }
-
- if ((rbc->rtgmem_size & (rbc->rtgmem_size - 1)) != 0 || (rbc->rtgmem_size != 0 && (rbc->rtgmem_size < 0x100000))) {
- error_log (_T("Unsupported graphics card memory size %d (0x%x)."), rbc->rtgmem_size, rbc->rtgmem_size);
- if (rbc->rtgmem_size > 0x1000000)
- rbc->rtgmem_size = 0x1000000;
- else
- rbc->rtgmem_size = 0;
- err = 1;
- }
- }
-
- for (int i = 0; i < MAX_RAM_BOARDS; i++) {
- if ((p->z3fastmem[i].size & (p->z3fastmem[i].size - 1)) != 0 || (p->z3fastmem[i].size != 0 && p->z3fastmem[i].size < 0x100000))
- {
- error_log (_T("Unsupported Zorro III fastmem size %d (0x%x)."), p->z3fastmem[i].size, p->z3fastmem[i].size);
- p->z3fastmem[i].size = 0;
- err = 1;
- }
- }
-
- p->z3autoconfig_start &= ~0xffff;
- if (p->z3autoconfig_start != 0 && p->z3autoconfig_start < 0x1000000)
- p->z3autoconfig_start = 0x1000000;
-
- if (p->address_space_24 && (p->z3fastmem[0].size != 0)) {
- p->z3fastmem[0].size = 0;
- error_log (_T("Can't use 32-bit memory when using a 24 bit address space."));
- }
-
- if (p->bogomem_size != 0 && p->bogomem_size != 0x80000 && p->bogomem_size != 0x100000 && p->bogomem_size != 0x180000 && p->bogomem_size != 0x1c0000) {
- error_log (_T("Unsupported bogomem size %d (0x%x)"), p->bogomem_size, p->bogomem_size);
- p->bogomem_size = 0;
- err = 1;
- }
-
- if (p->bogomem_size > 0x180000 && (p->cs_fatgaryrev >= 0 || p->cs_ide || p->cs_ramseyrev >= 0)) {
- p->bogomem_size = 0x180000;
- error_log (_T("Possible Gayle bogomem conflict fixed."));
- }
- if (p->chipmem_size > 0x200000 && p->fastmem[0].size > 262144) {
- error_log (_T("You can't use fastmem and more than 2MB chip at the same time."));
+ if (((p->chipmem_size & (p->chipmem_size - 1)) != 0 && p->chipmem_size != 0x180000)
+ || p->chipmem_size < 0x20000
+ || p->chipmem_size > 0x800000)
+ {
+ error_log(_T("Unsupported chipmem size %d (0x%x)."), p->chipmem_size, p->chipmem_size);
p->chipmem_size = 0x200000;
- err = 1;
- }
- if (p->mbresmem_low_size > 0x01000000 || (p->mbresmem_low_size & 0xfffff)) {
- p->mbresmem_low_size = 0;
- error_log (_T("Unsupported Mainboard RAM size"));
- }
- if (p->mbresmem_high_size > 0x02000000 || (p->mbresmem_high_size & 0xfffff)) {
- p->mbresmem_high_size = 0;
- error_log (_T("Unsupported CPU Board RAM size."));
+ err = 1;
}
- for (int i = 0; i < MAX_RTG_BOARDS; i++) {
- struct rtgboardconfig *rbc = &p->rtgboards[i];
- if (p->chipmem_size > 0x200000 && rbc->rtgmem_size && gfxboard_get_configtype(rbc) == 2) {
- error_log(_T("You can't use Zorro II RTG and more than 2MB chip at the same time."));
- p->chipmem_size = 0x200000;
+ for (int i = 0; i < MAX_RAM_BOARDS; i++) {
+ if ((p->fastmem[i].size & (p->fastmem[i].size - 1)) != 0
+ || (p->fastmem[i].size != 0 && (p->fastmem[i].size < 0x10000 || p->fastmem[i].size > 0x800000)))
+ {
+ error_log(_T("Unsupported fastmem size %d (0x%x)."), p->fastmem[i].size, p->fastmem[i].size);
+ p->fastmem[i].size = 0;
err = 1;
}
- if (p->address_space_24 && rbc->rtgmem_size && rbc->rtgmem_type == GFXBOARD_UAE_Z3) {
- error_log (_T("Z3 RTG and 24bit address space are not compatible."));
- rbc->rtgmem_type = GFXBOARD_UAE_Z2;
- rbc->rtgmem_size = 0;
- }
}
+ for (int i = 0; i < MAX_RTG_BOARDS; i++) {
+ struct rtgboardconfig *rbc = &p->rtgboards[i];
+ if (rbc->rtgmem_size > max_z3fastmem && rbc->rtgmem_type == GFXBOARD_UAE_Z3) {
+ error_log(_T("Graphics card memory size %d (0x%x) larger than maximum reserved %d (0x%x)."), rbc->rtgmem_size, rbc->rtgmem_size, max_z3fastmem, max_z3fastmem);
+ rbc->rtgmem_size = max_z3fastmem;
+ err = 1;
+ }
+
+ if ((rbc->rtgmem_size & (rbc->rtgmem_size - 1)) != 0 || (rbc->rtgmem_size != 0 && (rbc->rtgmem_size < 0x100000))) {
+ error_log(_T("Unsupported graphics card memory size %d (0x%x)."), rbc->rtgmem_size, rbc->rtgmem_size);
+ if (rbc->rtgmem_size > max_z3fastmem)
+ rbc->rtgmem_size = max_z3fastmem;
+ else
+ rbc->rtgmem_size = 0;
+ err = 1;
+ }
+ }
+
+ for (int i = 0; i < MAX_RAM_BOARDS; i++) {
+ if ((p->z3fastmem[i].size & (p->z3fastmem[i].size - 1)) != 0 || (p->z3fastmem[i].size != 0 && p->z3fastmem[i].size < 0x100000))
+ {
+ error_log(_T("Unsupported Zorro III fastmem size %d (0x%x)."), p->z3fastmem[i].size, p->z3fastmem[i].size);
+ p->z3fastmem[i].size = 0;
+ err = 1;
+ }
+ }
+
+ p->z3autoconfig_start &= ~0xffff;
+ if (p->z3autoconfig_start < 0x1000000)
+ p->z3autoconfig_start = 0x1000000;
+
+ if (p->z3chipmem_size > max_z3fastmem) {
+ error_log(_T("Zorro III fake chipmem size %d (0x%x) larger than max reserved %d (0x%x)."), p->z3chipmem_size, p->z3chipmem_size, max_z3fastmem, max_z3fastmem);
+ p->z3chipmem_size = max_z3fastmem;
+ err = 1;
+ }
+ if (((p->z3chipmem_size & (p->z3chipmem_size - 1)) != 0 && p->z3chipmem_size != 0x18000000 && p->z3chipmem_size != 0x30000000) || (p->z3chipmem_size != 0 && p->z3chipmem_size < 0x100000))
+ {
+ error_log(_T("Unsupported 32-bit chipmem size %d (0x%x)."), p->z3chipmem_size, p->z3chipmem_size);
+ p->z3chipmem_size = 0;
+ err = 1;
+ }
+
+ if (p->address_space_24 && (p->z3fastmem[0].size != 0 || p->z3fastmem[1].size != 0 || p->z3fastmem[2].size != 0 || p->z3fastmem[3].size != 0 || p->z3chipmem_size != 0)) {
+ p->z3fastmem[0].size = p->z3fastmem[1].size = p->z3fastmem[2].size = p->z3fastmem[3].size = 0;
+ p->z3chipmem_size = 0;
+ error_log(_T("Can't use a Z3 graphics card or 32-bit memory when using a 24 bit address space."));
+ }
+
+ if (p->bogomem_size != 0 && p->bogomem_size != 0x80000 && p->bogomem_size != 0x100000 && p->bogomem_size != 0x180000 && p->bogomem_size != 0x1c0000) {
+ error_log(_T("Unsupported bogomem size %d (0x%x)"), p->bogomem_size, p->bogomem_size);
+ p->bogomem_size = 0;
+ err = 1;
+ }
+
+ if (p->bogomem_size > 0x180000 && (p->cs_fatgaryrev >= 0 || p->cs_ide || p->cs_ramseyrev >= 0)) {
+ p->bogomem_size = 0x180000;
+ error_log(_T("Possible Gayle bogomem conflict fixed."));
+ }
+ if (p->chipmem_size > 0x200000 && (p->fastmem[0].size > 262144 || p->fastmem[1].size > 262144)) {
+ error_log(_T("You can't use fastmem and more than 2MB chip at the same time."));
+ p->chipmem_size = 0x200000;
+ err = 1;
+ }
+ if (p->mem25bit_size > 128 * 1024 * 1024 || (p->mem25bit_size & 0xfffff)) {
+ p->mem25bit_size = 0;
+ error_log(_T("Unsupported 25bit RAM size"));
+ }
+ if (p->mbresmem_low_size > 0x04000000 || (p->mbresmem_low_size & 0xfffff)) {
+ p->mbresmem_low_size = 0;
+ error_log(_T("Unsupported Mainboard RAM size"));
+ }
+ if (p->mbresmem_high_size > 0x08000000 || (p->mbresmem_high_size & 0xfffff)) {
+ p->mbresmem_high_size = 0;
+ error_log(_T("Unsupported CPU Board RAM size."));
+ }
+
+ //for (int i = 0; i < MAX_RTG_BOARDS; i++) {
+ // struct rtgboardconfig *rbc = &p->rtgboards[i];
+ // if (p->chipmem_size > 0x200000 && rbc->rtgmem_size && gfxboard_get_configtype(rbc) == 2) {
+ // error_log(_T("You can't use Zorro II RTG and more than 2MB chip at the same time."));
+ // p->chipmem_size = 0x200000;
+ // err = 1;
+ // }
+ // if (rbc->rtgmem_type >= GFXBOARD_HARDWARE) {
+ // if (gfxboard_get_vram_min(rbc) > 0 && rbc->rtgmem_size < gfxboard_get_vram_min(rbc)) {
+ // error_log(_T("Graphics card memory size %d (0x%x) smaller than minimum hardware supported %d (0x%x)."),
+ // rbc->rtgmem_size, rbc->rtgmem_size, gfxboard_get_vram_min(rbc), gfxboard_get_vram_min(rbc));
+ // rbc->rtgmem_size = gfxboard_get_vram_min(rbc);
+ // }
+ // if (p->address_space_24 && gfxboard_get_configtype(rbc) == 3) {
+ // rbc->rtgmem_type = GFXBOARD_UAE_Z2;
+ // rbc->rtgmem_size = 0;
+ // error_log(_T("Z3 RTG and 24-bit address space are not compatible."));
+ // }
+ // if (gfxboard_get_vram_max(rbc) > 0 && rbc->rtgmem_size > gfxboard_get_vram_max(rbc)) {
+ // error_log(_T("Graphics card memory size %d (0x%x) larger than maximum hardware supported %d (0x%x)."),
+ // rbc->rtgmem_size, rbc->rtgmem_size, gfxboard_get_vram_max(rbc), gfxboard_get_vram_max(rbc));
+ // rbc->rtgmem_size = gfxboard_get_vram_max(rbc);
+ // }
+ // }
+ // if (p->address_space_24 && rbc->rtgmem_size && rbc->rtgmem_type == GFXBOARD_UAE_Z3) {
+ // error_log(_T("Z3 RTG and 24bit address space are not compatible."));
+ // rbc->rtgmem_type = GFXBOARD_UAE_Z2;
+ // rbc->rtgmem_size = 0;
+ // }
+ //}
+
if (p->cs_z3autoconfig && p->address_space_24) {
p->cs_z3autoconfig = false;
- error_log (_T("Z3 autoconfig and 24bit address space are not compatible."));
+ error_log(_T("Z3 autoconfig and 24bit address space are not compatible."));
}
- if (p->produce_sound < 0 || p->produce_sound > 3) {
- error_log (_T("Bad value for -S parameter: enable value must be within 0..3."));
- p->produce_sound = 0;
- err = 1;
- }
- if (p->cachesize < 0 || p->cachesize > 16384) {
- error_log (_T("Bad value for cachesize parameter: value must be within 0..16384."));
- p->cachesize = 0;
- err = 1;
- }
- if ((p->z3fastmem[0].size) && p->address_space_24) {
- error_log (_T("Z3 fast memory can't be used if address space is 24-bit."));
- p->z3fastmem[0].size = 0;
- err = 1;
- }
- for (int i = 0; i < MAX_RTG_BOARDS; i++) {
- if ((p->rtgboards[i].rtgmem_size > 0 && p->rtgboards[i].rtgmem_type == GFXBOARD_UAE_Z3) && p->address_space_24) {
- error_log (_T("UAEGFX Z3 RTG can't be used if address space is 24-bit."));
- p->rtgboards[i].rtgmem_size = 0;
- err = 1;
- }
- }
-
-#if !defined (BSDSOCKET)
- if (p->socket_emu) {
- write_log (_T("Compile-time option of BSDSOCKET_SUPPORTED was not enabled. You can't use bsd-socket emulation.\n"));
- p->socket_emu = 0;
+#if 0
+ if (p->m68k_speed < -1 || p->m68k_speed > 20) {
+ write_log(_T("Bad value for -w parameter: must be -1, 0, or within 1..20.\n"));
+ p->m68k_speed = 4;
err = 1;
}
#endif
- if (p->nr_floppies < 0 || p->nr_floppies > 4) {
- error_log (_T("Invalid number of floppies. Using 2."));
+ if (p->produce_sound < 0 || p->produce_sound > 3) {
+ error_log(_T("Bad value for -S parameter: enable value must be within 0..3."));
+ p->produce_sound = 0;
+ err = 1;
+ }
+ if (p->comptrustbyte < 0 || p->comptrustbyte > 3) {
+ error_log(_T("Bad value for comptrustbyte parameter: value must be within 0..2."));
+ p->comptrustbyte = 1;
+ err = 1;
+ }
+ if (p->comptrustword < 0 || p->comptrustword > 3) {
+ error_log(_T("Bad value for comptrustword parameter: value must be within 0..2."));
+ p->comptrustword = 1;
+ err = 1;
+ }
+ if (p->comptrustlong < 0 || p->comptrustlong > 3) {
+ error_log(_T("Bad value for comptrustlong parameter: value must be within 0..2."));
+ p->comptrustlong = 1;
+ err = 1;
+ }
+ if (p->comptrustnaddr < 0 || p->comptrustnaddr > 3) {
+ error_log(_T("Bad value for comptrustnaddr parameter: value must be within 0..2."));
+ p->comptrustnaddr = 1;
+ err = 1;
+ }
+ if (p->cachesize < 0 || p->cachesize > 16384) {
+ error_log(_T("Bad value for cachesize parameter: value must be within 0..16384."));
+ p->cachesize = 0;
+ err = 1;
+ }
+ if ((p->z3fastmem[0].size || p->z3fastmem[1].size || p->z3fastmem[2].size || p->z3fastmem[3].size || p->z3chipmem_size) && p->address_space_24) {
+ error_log(_T("Z3 fast memory can't be used if address space is 24-bit."));
+ p->z3fastmem[0].size = 0;
+ p->z3fastmem[1].size = 0;
+ p->z3fastmem[2].size = 0;
+ p->z3fastmem[3].size = 0;
+ p->z3chipmem_size = 0;
+ err = 1;
+ }
+ for (int i = 0; i < MAX_RTG_BOARDS; i++) {
+ if ((p->rtgboards[i].rtgmem_size > 0 && p->rtgboards[i].rtgmem_type == GFXBOARD_UAE_Z3) && p->address_space_24) {
+ error_log(_T("UAEGFX Z3 RTG can't be used if address space is 24-bit."));
+ p->rtgboards[i].rtgmem_size = 0;
+ err = 1;
+ }
+ }
+
+#if !defined (BSDSOCKET)
+ if (p->socket_emu) {
+ write_log(_T("Compile-time option of BSDSOCKET_SUPPORTED was not enabled. You can't use bsd-socket emulation.\n"));
+ p->socket_emu = 0;
+ err = 1;
+ }
+#endif
+ if (p->socket_emu && p->uaeboard >= 3) {
+ write_log(_T("bsdsocket.library is not compatible with indirect UAE Boot ROM.\n"));
+ p->socket_emu = 0;
+ }
+
+ if (p->nr_floppies < 0 || p->nr_floppies > 4) {
+ error_log(_T("Invalid number of floppies. Using 2."));
p->nr_floppies = 2;
- p->floppyslots[0].dfxtype = 0;
- p->floppyslots[1].dfxtype = 0;
+ p->floppyslots[0].dfxtype = 0;
+ p->floppyslots[1].dfxtype = 0;
p->floppyslots[2].dfxtype = -1;
p->floppyslots[3].dfxtype = -1;
- err = 1;
- }
-
- if (p->floppy_speed > 0 && p->floppy_speed < 10) {
- error_log (_T("Invalid floppy speed."));
- p->floppy_speed = 100;
- }
- if (p->collision_level < 0 || p->collision_level > 3) {
- error_log (_T("Invalid collision support level. Using 1."));
- p->collision_level = 1;
- err = 1;
- }
+ err = 1;
+ }
+ if (p->floppy_speed > 0 && p->floppy_speed < 10) {
+ error_log(_T("Invalid floppy speed."));
+ p->floppy_speed = 100;
+ }
+ if (p->input_mouse_speed < 1 || p->input_mouse_speed > 1000) {
+ error_log(_T("Invalid mouse speed."));
+ p->input_mouse_speed = 100;
+ }
+ if (p->collision_level < 0 || p->collision_level > 3) {
+ error_log(_T("Invalid collision support level. Using 1."));
+ p->collision_level = 1;
+ err = 1;
+ }
+ if (p->parallel_postscript_emulation)
+ p->parallel_postscript_detection = 1;
if (p->cs_compatible == CP_GENERIC) {
- p->cs_fatgaryrev = p->cs_ramseyrev = -1;
+ p->cs_fatgaryrev = p->cs_ramseyrev = p->cs_mbdmac = -1;
p->cs_ide = 0;
if (p->cpu_model >= 68020) {
p->cs_fatgaryrev = 0;
p->cs_ide = -1;
p->cs_ramseyrev = 0x0f;
- }
- } else if (p->cs_compatible == 0) {
+ p->cs_mbdmac = 0;
+ }
+}
+ else if (p->cs_compatible == 0) {
if (p->cs_ide == IDE_A4000) {
if (p->cs_fatgaryrev < 0)
p->cs_fatgaryrev = 0;
if (p->cs_ramseyrev < 0)
p->cs_ramseyrev = 0x0f;
- }
- }
+ }
+ }
+ if (p->chipmem_size >= 0x100000)
+ p->cs_1mchipjumper = true;
- fixup_prefs_dimensions (p);
+ /* Can't fit genlock and A2024 or Graffiti at the same time,
+ * also Graffiti uses genlock audio bit as an enable signal
+ */
+ if (p->genlock && p->monitoremu) {
+ error_log(_T("Genlock and A2024 or Graffiti can't be active simultaneously."));
+ p->genlock = false;
+ }
+ if (p->cs_hacks) {
+ error_log(_T("chipset_hacks is nonzero (0x%04x)."), p->cs_hacks);
+ }
+
+ fixup_prefs_dimensions(p);
#if !defined (JIT)
p->cachesize = 0;
@@ -370,22 +571,78 @@ void fixup_prefs (struct uae_prefs *p, bool userconfig)
p->cpu_model = 68000;
p->fpu_model = 0;
#endif
+#ifndef CPUEMU_0
+ p->cpu_compatible = 1;
+ p->address_space_24 = 1;
+#endif
+#if !defined (CPUEMU_11) && !defined (CPUEMU_13)
+ p->cpu_compatible = 0;
+ p->address_space_24 = 0;
+#endif
+#if !defined (CPUEMU_13)
+ p->cpu_cycle_exact = p->blitter_cycle_exact = 0;
+#endif
#ifndef AGA
p->chipset_mask &= ~CSMASK_AGA;
#endif
#ifndef AUTOCONFIG
- p->z3fastmem[0].size = 0;
- p->fastmem[0].size = 0;
- p->rtgboards[0].rtgmem_size = 0;
+ p->z3fastmem_size = 0;
+ p->fastmem_size = 0;
+ p->rtgmem_size = 0;
#endif
#if !defined (BSDSOCKET)
p->socket_emu = 0;
#endif
+#if !defined (SCSIEMU)
+ p->scsi = 0;
+//#ifdef _WIN32
+// p->win32_aspi = 0;
+//#endif
+#endif
+#if !defined (SANA2)
+ p->sana2 = 0;
+#endif
+#if !defined (UAESERIAL)
+ p->uaeserial = 0;
+#endif
+#if defined (CPUEMU_13)
+ if (p->cpu_memory_cycle_exact) {
+ if (p->gfx_framerate > 1) {
+ error_log(_T("Cycle-exact requires disabled frameskip."));
+ p->gfx_framerate = 1;
+ }
+ if (p->cachesize) {
+ error_log(_T("Cycle-exact and JIT can't be active simultaneously."));
+ p->cachesize = 0;
+ }
+#if 0
+ if (p->m68k_speed) {
+ error_log(_T("Adjustable CPU speed is not available in cycle-exact mode."));
+ p->m68k_speed = 0;
+ }
+#endif
+ }
+#endif
+ if (p->gfx_framerate < 1)
+ p->gfx_framerate = 1;
+ if (p->maprom && !p->address_space_24) {
+ p->maprom = 0x0f000000;
+ }
+ if (((p->maprom & 0xff000000) && p->address_space_24) || (p->maprom && p->mbresmem_high_size >= 0x08000000)) {
+ p->maprom = 0x00e00000;
+ }
+ if (p->maprom && p->cpuboard_type) {
+ error_log(_T("UAE Maprom and accelerator board emulation are not compatible."));
+ p->maprom = 0;
+ }
- built_in_chipset_prefs (p);
- blkdev_fix_prefs (p);
- inputdevice_fix_prefs(p, userconfig);
- target_fixup_options (p);
+ if (p->tod_hack && p->cs_ciaatod == 0)
+ p->cs_ciaatod = p->ntscmode ? 2 : 1;
+
+ built_in_chipset_prefs(p);
+ blkdev_fix_prefs(p);
+ //inputdevice_fix_prefs(p, userconfig);
+ target_fixup_options(p);
}
int quit_program = 0;
@@ -393,224 +650,261 @@ static int restart_program;
static TCHAR restart_config[MAX_DPATH];
static int default_config;
-void uae_reset (int hardreset, int keyboardreset)
+void uae_reset(int hardreset, int keyboardreset)
{
- if (quit_program == 0) {
+ currprefs.quitstatefile[0] = changed_prefs.quitstatefile[0] = 0;
+
+ if (quit_program == 0) {
quit_program = -UAE_RESET;
if (keyboardreset)
quit_program = -UAE_RESET_KEYBOARD;
- if (hardreset)
+ if (hardreset)
quit_program = -UAE_RESET_HARD;
- }
+ }
}
-void uae_quit (void)
+void uae_quit()
{
- if (quit_program != -UAE_QUIT) {
- quit_program = -UAE_QUIT;
- }
- target_quit ();
+ if (quit_program != -UAE_QUIT) {
+ quit_program = -UAE_QUIT;
+ }
+ target_quit();
}
-void host_shutdown(void)
+void host_shutdown()
{
system("sudo poweroff");
}
/* 0 = normal, 1 = nogui, -1 = disable nogui */
-void uae_restart (int opengui, const TCHAR *cfgfile)
+void uae_restart(int opengui, const TCHAR *cfgfile)
{
- uae_quit ();
- restart_program = opengui > 0 ? 1 : (opengui == 0 ? 2 : 3);
- restart_config[0] = 0;
+ uae_quit();
+ restart_program = opengui > 0 ? 1 : (opengui == 0 ? 2 : 3);
+ restart_config[0] = 0;
default_config = 0;
- if (cfgfile)
- _tcscpy (restart_config, cfgfile);
- target_restart ();
+ if (cfgfile)
+ _tcscpy(restart_config, cfgfile);
+ target_restart();
}
-#ifndef DONT_PARSE_CMDLINE
-
-static void parse_cmdline_2 (int argc, TCHAR **argv)
+void usage()
{
- int i;
-
- cfgfile_addcfgparam (0);
- for (i = 1; i < argc; i++) {
- if (_tcsncmp (argv[i], _T("-cfgparam="), 10) == 0) {
- cfgfile_addcfgparam (argv[i] + 10);
- } else if (_tcscmp (argv[i], _T("-cfgparam")) == 0) {
- if (i + 1 == argc)
- write_log (_T("Missing argument for '-cfgparam' option.\n"));
- else
- cfgfile_addcfgparam (argv[++i]);
- }
- }
}
-static TCHAR *parsetext (const TCHAR *s)
+static void parse_cmdline_2(int argc, TCHAR **argv)
{
- if (*s == '"' || *s == '\'') {
- TCHAR *d;
- TCHAR c = *s++;
- int i;
- d = my_strdup (s);
- for (i = 0; i < _tcslen (d); i++) {
- if (d[i] == c) {
- d[i] = 0;
- break;
- }
- }
- return d;
- } else {
- return my_strdup (s);
- }
+ int i;
+
+ cfgfile_addcfgparam(nullptr);
+ for (i = 1; i < argc; i++) {
+ if (_tcsncmp(argv[i], _T("-cfgparam="), 10) == 0) {
+ cfgfile_addcfgparam(argv[i] + 10);
+ }
+ else if (_tcscmp(argv[i], _T("-cfgparam")) == 0) {
+ if (i + 1 == argc)
+ write_log(_T("Missing argument for '-cfgparam' option.\n"));
+ else
+ cfgfile_addcfgparam(argv[++i]);
+ }
+ }
}
-static TCHAR *parsetextpath (const TCHAR *s)
+
+static int diskswapper_cb(struct zfile *f, void *vrsd)
{
- TCHAR *s2 = parsetext (s);
- TCHAR *s3 = target_expand_environment (s2, NULL, 0);
- xfree (s2);
+ int *num = static_cast(vrsd);
+ if (*num >= MAX_SPARE_DRIVES)
+ return 1;
+ if (zfile_gettype(f) == ZFILE_DISKIMAGE) {
+ _tcsncpy(currprefs.dfxlist[*num], zfile_getname(f), 255);
+ (*num)++;
+ }
+ return 0;
+}
+
+static void parse_diskswapper(const TCHAR *s)
+{
+ TCHAR *tmp = my_strdup(s);
+ TCHAR *delim = _T(",");
+ TCHAR *p1, *p2;
+ int num = 0;
+
+ p1 = tmp;
+ for (;;) {
+ p2 = strtok(p1, delim);
+ if (!p2)
+ break;
+ p1 = nullptr;
+ if (num >= MAX_SPARE_DRIVES)
+ break;
+ if (!zfile_zopen(p2, diskswapper_cb, &num)) {
+ _tcsncpy(currprefs.dfxlist[num], p2, 255);
+ num++;
+ }
+ }
+ free(tmp);
+}
+
+static TCHAR *parsetext(const TCHAR *s)
+{
+ if (*s == '"' || *s == '\'') {
+ TCHAR *d;
+ TCHAR c = *s++;
+ int i;
+ d = my_strdup(s);
+ for (i = 0; i < _tcslen(d); i++) {
+ if (d[i] == c) {
+ d[i] = 0;
+ break;
+ }
+ }
+ return d;
+ }
+ else {
+ return my_strdup(s);
+ }
+}
+static TCHAR *parsetextpath(const TCHAR *s)
+{
+ TCHAR *s2 = parsetext(s);
+ TCHAR *s3 = target_expand_environment(s2);
+ xfree(s2);
return s3;
}
-void print_usage()
+static void parse_cmdline(int argc, TCHAR **argv)
{
- printf("\nUsage:\n");
- printf(" -f Load a configuration file.\n");
- printf(" -config= Load a configuration file.\n");
- printf(" -statefile= Load a save state file.\n");
- printf(" -s = Set the configuration parameter with value.\n");
- printf(" Edit a configuration file in order to know valid parameters and settings.\n");
- printf("\nAdditional options:\n");
- printf(" -0 Set adf for drive 0.\n");
- printf(" -1 Set adf for drive 1.\n");
- printf(" -2 Set adf for drive 2.\n");
- printf(" -3 Set adf for drive 3.\n");
- printf(" -r Set kickstart rom file.\n");
- printf(" -G Start directly into emulation.\n");
- printf(" -c Size of chip memory (in number of 512 KBytes chunks).\n");
- printf(" -F Size of fast memory (in number of 1024 KBytes chunks).\n");
- printf("\nNote:\n");
- printf("Parameters are parsed from the beginning of command line, so in case of ambiguity for parameters, last one will be used.\n");
- printf("File names should be with absolute path.\n");
- printf("\nExample:\n");
- printf("uae4arm -config=conf/A500.uae -statefile=savestates/game.uss -s use_gui=no\n");
- printf("It will load A500.uae configuration with the save state named game.\n");
- printf("It will override use_gui to 'no' so that it enters emulation directly.\n");
- exit(1);
-}
+ int i;
-static void parse_cmdline (int argc, TCHAR **argv)
-{
- int i;
- static bool started;
- bool firstconfig = true;
- bool loaded = false;
-
- // only parse command line when starting for the first time
- if (started)
- return;
- started = true;
-
- for (i = 1; i < argc; i++) {
- if (_tcscmp (argv[i], _T("-cfgparam")) == 0) {
- if (i + 1 < argc)
- i++;
- } else if (_tcsncmp (argv[i], _T("-config="), 8) == 0) {
- TCHAR *txt = parsetextpath (argv[i] + 8);
- currprefs.mountitems = 0;
- target_cfgfile_load (&currprefs, txt, firstconfig ? CONFIG_TYPE_ALL : CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST | CONFIG_TYPE_NORESET, 0);
- xfree (txt);
- firstconfig = false;
- loaded = true;
- } else if (_tcsncmp (argv[i], _T("-statefile="), 11) == 0) {
- TCHAR *txt = parsetextpath (argv[i] + 11);
- savestate_state = STATE_DORESTORE;
- _tcscpy (savestate_fname, txt);
- xfree (txt);
- loaded = true;
- } else if (_tcscmp (argv[i], _T("-f")) == 0) {
- /* Check for new-style "-f xxx" argument, where xxx is config-file */
- if (i + 1 == argc) {
- write_log (_T("Missing argument for '-f' option.\n"));
- } else {
- TCHAR *txt = parsetextpath (argv[++i]);
- currprefs.mountitems = 0;
- target_cfgfile_load (&currprefs, txt, firstconfig ? CONFIG_TYPE_ALL : CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST | CONFIG_TYPE_NORESET, 0);
- xfree (txt);
- firstconfig = false;
- }
- loaded = true;
- } else if (_tcscmp (argv[i], _T("-s")) == 0) {
- if (i + 1 == argc)
- write_log (_T("Missing argument for '-s' option.\n"));
- else
- cfgfile_parse_line (&currprefs, argv[++i], 0);
- } else if (_tcsncmp (argv[i], _T("-cdimage="), 9) == 0) {
- TCHAR *txt = parsetextpath (argv[i] + 9);
+ for (i = 1; i < argc; i++) {
+ if (!_tcsncmp(argv[i], _T("-diskswapper="), 13)) {
+ TCHAR *txt = parsetextpath(argv[i] + 13);
+ parse_diskswapper(txt);
+ xfree(txt);
+ }
+ else if (_tcsncmp(argv[i], _T("-cfgparam="), 10) == 0) {
+ ;
+ }
+ else if (_tcscmp(argv[i], _T("-cfgparam")) == 0) {
+ if (i + 1 < argc)
+ i++;
+ }
+ else if (_tcsncmp(argv[i], _T("-config="), 8) == 0) {
+ TCHAR *txt = parsetextpath(argv[i] + 8);
+ currprefs.mountitems = 0;
+ target_cfgfile_load(&currprefs, txt, -1, 0);
+ xfree(txt);
+ }
+ else if (_tcsncmp(argv[i], _T("-statefile="), 11) == 0) {
+ TCHAR *txt = parsetextpath(argv[i] + 11);
+ savestate_state = STATE_DORESTORE;
+ _tcscpy(savestate_fname, txt);
+ xfree(txt);
+ }
+ else if (_tcscmp(argv[i], _T("-f")) == 0) {
+ /* Check for new-style "-f xxx" argument, where xxx is config-file */
+ if (i + 1 == argc) {
+ write_log(_T("Missing argument for '-f' option.\n"));
+ }
+ else {
+ TCHAR *txt = parsetextpath(argv[++i]);
+ currprefs.mountitems = 0;
+ target_cfgfile_load(&currprefs, txt, -1, 0);
+ xfree(txt);
+ }
+ }
+ else if (_tcscmp(argv[i], _T("-s")) == 0) {
+ if (i + 1 == argc)
+ write_log(_T("Missing argument for '-s' option.\n"));
+ else
+ cfgfile_parse_line(&currprefs, argv[++i], 0);
+ }
+ else if (_tcscmp(argv[i], _T("-h")) == 0 || _tcscmp(argv[i], _T("-help")) == 0) {
+ usage();
+ exit(0);
+ }
+ else if (_tcsncmp(argv[i], _T("-cdimage="), 9) == 0) {
+ TCHAR *txt = parsetextpath(argv[i] + 9);
TCHAR *txt2 = xmalloc(TCHAR, _tcslen(txt) + 2);
_tcscpy(txt2, txt);
if (_tcsrchr(txt2, ',') != NULL)
_tcscat(txt2, _T(","));
- cfgfile_parse_option (&currprefs, _T("cdimage0"), txt2, 0);
+ cfgfile_parse_option(&currprefs, _T("cdimage0"), txt2, 0);
xfree(txt2);
xfree(txt);
- loaded = true;
- } else if (argv[i][0] == '-' && argv[i][1] != '\0') {
- int ret;
- const TCHAR *arg = argv[i] + 2;
- int extra_arg = *arg == '\0';
- if (extra_arg)
- arg = i + 1 < argc ? argv[i + 1] : 0;
- ret = parse_cmdline_option (&currprefs, argv[i][1], arg);
- if (ret == -1)
- print_usage();
- if (ret && extra_arg)
- i++;
- } else if (i == argc - 1) {
- // if last config entry is an orphan and nothing else was loaded:
- // check if it is config file or statefile
- if (!loaded) {
- TCHAR *txt = parsetextpath(argv[i]);
- struct zfile *z = zfile_fopen(txt, _T("rb"), ZFD_NORMAL);
- if (z) {
- int type = zfile_gettype(z);
- zfile_fclose(z);
- if (type == ZFILE_CONFIGURATION) {
- currprefs.mountitems = 0;
- target_cfgfile_load(&currprefs, txt, CONFIG_TYPE_ALL, 0);
- } else if (type == ZFILE_STATEFILE) {
- savestate_state = STATE_DORESTORE;
- _tcscpy(savestate_fname, txt);
- }
- }
- xfree(txt);
+ }
+ else {
+ if (argv[i][0] == '-' && argv[i][1] != '\0') {
+ const TCHAR *arg = argv[i] + 2;
+ int extra_arg = *arg == '\0';
+ if (extra_arg)
+ arg = i + 1 < argc ? argv[i + 1] : 0;
+ if (parse_cmdline_option(&currprefs, argv[i][1], arg) && extra_arg)
+ i++;
}
- else
- {
- printf("Unknown option %s\n", argv[i]);
- print_usage();
- }
- }
- }
+ }
+ }
}
-#endif
-static void parse_cmdline_and_init_file (int argc, TCHAR **argv)
+static void parse_cmdline_and_init_file(int argc, TCHAR **argv)
{
- _tcscpy (optionsfile, _T(""));
+ _tcscpy(optionsfile, _T(""));
- parse_cmdline_2 (argc, argv);
+ parse_cmdline_2(argc, argv);
- _tcscat (optionsfile, restart_config);
+ _tcscat(optionsfile, restart_config);
- if (! target_cfgfile_load (&currprefs, optionsfile, CONFIG_TYPE_DEFAULT, default_config)) {
- write_log (_T("failed to load config '%s'\n"), optionsfile);
- }
- fixup_prefs (&currprefs, false);
+ if (!target_cfgfile_load(&currprefs, optionsfile, 0, default_config)) {
+ write_log(_T("failed to load config '%s'\n"), optionsfile);
+ }
+ fixup_prefs(&currprefs, false);
- parse_cmdline (argc, argv);
+ parse_cmdline(argc, argv);
+}
+
+void reset_all_systems()
+{
+ init_eventtab();
+
+#ifdef PICASSO96
+ picasso_reset();
+#endif
+#ifdef SCSIEMU
+ scsi_reset();
+ scsidev_reset();
+ scsidev_start_threads();
+#endif
+#ifdef A2065
+ a2065_reset();
+#endif
+#ifdef SANA2
+ netdev_reset();
+ netdev_start_threads();
+#endif
+#ifdef FILESYS
+ filesys_prepare_reset();
+ filesys_reset();
+#endif
+ //TODO
+ //init_shm();
+ memory_reset();
+#if defined (BSDSOCKET)
+ bsdlib_reset();
+#endif
+#ifdef FILESYS
+ filesys_start_threads();
+ hardfile_reset();
+#endif
+#ifdef UAESERIAL
+ uaeserialdev_reset();
+ uaeserialdev_start_threads();
+#endif
+#if defined (PARALLEL_PORT)
+ initparallel();
+#endif
+ native2amiga_reset();
+ //dongle_reset();
+ //sampler_init();
}
/* Okay, this stuff looks strange, but it is here to encourage people who
@@ -622,18 +916,75 @@ static void parse_cmdline_and_init_file (int argc, TCHAR **argv)
* of start_program() and leave_program() if you need to do anything special.
* Add #ifdefs around these as appropriate.
*/
-void do_start_program (void)
+void do_start_program()
{
if (quit_program == -UAE_QUIT)
- return;
- /* Do a reset on startup. Whether this is elegant is debatable. */
- inputdevice_updateconfig (&changed_prefs, &currprefs);
- if (quit_program >= 0)
- quit_program = UAE_RESET;
- m68k_go (1);
+ return;
+
+ /* Do a reset on startup. Whether this is elegant is debatable. */
+ inputdevice_updateconfig(&changed_prefs, &currprefs);
+ if (quit_program >= 0)
+ quit_program = UAE_RESET;
+#ifdef WITH_LUA
+ uae_lua_loadall();
+#endif
+ m68k_go(1);
}
-void start_program (void)
+void do_leave_program()
+{
+#ifdef JIT
+ compiler_exit();
+#endif
+ //sampler_free ();
+ graphics_leave();
+ inputdevice_close();
+ DISK_free();
+ close_sound();
+ dump_counts();
+#ifdef SERIAL_PORT
+ serial_exit();
+#endif
+#ifdef CDTV
+ cdtv_free();
+#endif
+#ifdef A2091
+ a2091_free();
+ a3000scsi_free();
+#endif
+#ifdef NCR
+ ncr_free();
+#endif
+ #ifdef CD32
+ akiko_free();
+#endif
+ if (!no_gui)
+ gui_exit();
+#ifdef USE_SDL
+ SDL_Quit();
+#endif
+ hardfile_reset();
+#ifdef AUTOCONFIG
+ expansion_cleanup();
+#endif
+#ifdef FILESYS
+ filesys_cleanup();
+#endif
+#ifdef BSDSOCKET
+ bsdlib_reset();
+#endif
+ device_func_reset();
+#ifdef WITH_LUA
+ uae_lua_free();
+#endif
+ memory_cleanup();
+ //TODO
+ //free_shm();
+ cfgfile_addcfgparam(nullptr);
+ machdep_free();
+}
+
+void start_program()
{
#ifdef CAPSLOCK_DEBIAN_WORKAROUND
char kbd_flags;
@@ -641,16 +992,54 @@ void start_program (void)
ioctl(0, KDGKBLED, &kbd_flags);
if ((kbd_flags & 07) & LED_CAP)
{
- // record capslock pressed
+ // record capslock pressed
inputdevice_do_keyboard(AK_CAPSLOCK, 1);
}
#endif
- do_start_program ();
+ do_start_program();
}
-void leave_program (void)
+void leave_program()
{
- do_leave_program ();
+ do_leave_program();
+}
+
+void virtualdevice_init()
+{
+#ifdef AUTOCONFIG
+ rtarea_setup();
+#endif
+#ifdef FILESYS
+ rtarea_init();
+ uaeres_install();
+ hardfile_install();
+#endif
+#ifdef SCSIEMU
+ scsi_reset();
+ scsidev_install();
+#endif
+#ifdef SANA2
+ netdev_install();
+#endif
+#ifdef UAESERIAL
+ uaeserialdev_install();
+#endif
+#ifdef AUTOCONFIG
+ expansion_init();
+ emulib_install();
+#endif
+#ifdef FILESYS
+ filesys_install();
+#endif
+#if defined (BSDSOCKET)
+ bsdlib_install();
+#endif
+#ifdef WITH_UAENATIVE
+ uaenative_install();
+#endif
+#ifdef WITH_TABLETLIBRARY
+ tabletlib_install();
+#endif
}
// In case of error, print the error code and close the application
@@ -662,8 +1051,10 @@ void check_error_sdl(bool check, const char* message) {
}
}
-static void initialize_sdl2()
+static int real_main2 (int argc, TCHAR **argv)
{
+ printf("Amiberry-SDL2 by Dimitris (MiDWaN) Panokostas\n");
+
if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
{
SDL_Log("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
@@ -671,11 +1062,11 @@ static void initialize_sdl2()
}
sdlWindow = SDL_CreateWindow("Amiberry-SDL2 v2",
- SDL_WINDOWPOS_UNDEFINED,
- SDL_WINDOWPOS_UNDEFINED,
- 0,
- 0,
- SDL_WINDOW_FULLSCREEN_DESKTOP);
+ SDL_WINDOWPOS_UNDEFINED,
+ SDL_WINDOWPOS_UNDEFINED,
+ 0,
+ 0,
+ SDL_WINDOW_FULLSCREEN_DESKTOP);
check_error_sdl(sdlWindow == nullptr, "Unable to create window");
renderer = SDL_CreateRenderer(sdlWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
@@ -690,12 +1081,7 @@ static void initialize_sdl2()
SDL_Log("SDL could not grab the keyboard");
SDL_ShowCursor(SDL_DISABLE);
-}
-static int real_main2 (int argc, TCHAR **argv)
-{
- initialize_sdl2();
- keyboard_settrans();
set_config_changed();
if (restart_config[0]) {
default_prefs(&currprefs, true, 0);
@@ -720,6 +1106,7 @@ static int real_main2 (int argc, TCHAR **argv)
write_log(_T("Sound driver unavailable: Sound output disabled\n"));
currprefs.produce_sound = 0;
}
+
inputdevice_init();
changed_prefs = currprefs;
@@ -737,36 +1124,40 @@ static int real_main2 (int argc, TCHAR **argv)
write_log(_T("Failed to initialize the GUI\n"));
return -1;
}
- if (err == -2) {
+ else if (err == -2) {
return 1;
}
}
- else
- {
-#ifdef PANDORA
- setCpuSpeed();
-#endif
- update_display(&currprefs);
- }
+
memset(&gui_data, 0, sizeof gui_data);
gui_data.cd = -1;
gui_data.hd = -1;
+ gui_data.md = -1;
+#ifdef NATMEM_OFFSET
if (!init_shm()) {
if (currprefs.start_gui)
- uae_restart(-1, nullptr);
+ uae_restart(-1, NULL);
return 0;
- }
+}
+#endif
+#ifdef WITH_LUA
+ uae_lua_init();
+#endif
#ifdef PICASSO96
picasso_reset();
#endif
fixup_prefs(&currprefs, true);
+#ifdef RETROPLATFORM
+ rp_fixup_options(&currprefs);
+#endif
changed_prefs = currprefs;
target_run();
- /* force sound settings change */
+ /* force sound settings change */
currprefs.produce_sound = 0;
+ //savestate_init();
keybuf_init(); /* Must come after init_joystick */
memory_hardreset(2);
@@ -775,9 +1166,14 @@ static int real_main2 (int argc, TCHAR **argv)
#ifdef AUTOCONFIG
native2amiga_install();
#endif
-
custom_init(); /* Must come after memory_init */
+#ifdef SERIAL_PORT
+ serial_init();
+#endif
DISK_init();
+#ifdef WITH_PPC
+ uae_ppc_reset(true);
+#endif
reset_frame_rate_hack();
init_m68k(); /* must come after reset_frame_rate_hack (); */
@@ -801,14 +1197,16 @@ void real_main(int argc, TCHAR **argv)
{
restart_program = 1;
- fetch_configurationpath(restart_config, sizeof restart_config / sizeof(TCHAR));
+ fetch_configurationpath(restart_config, sizeof(restart_config) / sizeof(TCHAR));
_tcscat(restart_config, OPTIONSFILENAME);
- _tcscat(restart_config, ".uae");
default_config = 1;
while (restart_program) {
+ int ret;
changed_prefs = currprefs;
- real_main2(argc, argv);
+ ret = real_main2(argc, argv);
+ if (ret == 0 && quit_to_gui)
+ restart_program = 1;
leave_program();
quit_program = 0;
}
@@ -822,3 +1220,8 @@ int main(int argc, TCHAR **argv)
return 0;
}
#endif
+
+#ifdef SINGLEFILE
+uae_u8 singlefile_config[50000] = { "_CONFIG_STARTS_HERE" };
+uae_u8 singlefile_data[1500000] = { "_DATA_STARTS_HERE" };
+#endif
diff --git a/src/memory.cpp b/src/memory.cpp
index a019f50e..82c7f0ec 100644
--- a/src/memory.cpp
+++ b/src/memory.cpp
@@ -11,113 +11,144 @@
#include "options.h"
#include "uae.h"
-#include "memory.h"
+#include "include/memory.h"
#include "rommgr.h"
+#include "ersatz.h"
#include "zfile.h"
#include "custom.h"
#include "newcpu.h"
#include "autoconf.h"
#include "savestate.h"
-#include "ar.h"
#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"
+#include "jit/compemu.h"
+bool canbang;
+static bool rom_write_enabled;
#ifdef JIT
/* Set by each memory handler that does not simply access real memory. */
int special_mem;
#endif
static int mem_hardreset;
+static bool roms_modified;
-static size_t bootrom_filepos, chip_filepos, bogo_filepos, a3000lmem_filepos, a3000hmem_filepos;
+#define FLASHEMU 0
+
+static bool isdirectjit(void)
+{
+ return currprefs.cachesize && !currprefs.comptrustbyte;
+}
+
+static bool canjit(void)
+{
+ if (currprefs.cpu_model < 68020 || currprefs.address_space_24)
+ return false;
+ return true;
+}
+static bool needmman(void)
+{
+ //if (!jit_direct_compatible_memory)
+ // return false;
+//#ifdef _WIN32
+// return true;
+//#endif
+ if (canjit())
+ return true;
+ return false;
+}
+
+static void nocanbang(void)
+{
+ if (canbang) {
+ write_log(_T("Switching JIT direct off!\n"));
+ }
+ canbang = 0;
+}
+
+uae_u8 ce_banktype[65536];
+uae_u8 ce_cachable[65536];
+
+static size_t bootrom_filepos, chip_filepos, bogo_filepos, a3000lmem_filepos, a3000hmem_filepos, mem25bit_filepos;
/* Set if we notice during initialization that settings changed,
and we must clear all memory to prevent bogus contents from confusing
the Kickstart. */
static bool need_hardreset;
+static int bogomem_aliasing;
/* The address space setting used during the last reset. */
static bool last_address_space_24;
addrbank *mem_banks[MEMORY_BANKS];
+/* This has two functions. It either holds a host address that, when added
+to the 68k address, gives the host address corresponding to that 68k
+address (in which case the value in this array is even), OR it holds the
+same value as mem_banks, for those banks that have baseaddr==0. In that
+case, bit 0 is set (the memory access routines will take care of it). */
+
+uae_u8 *baseaddr[MEMORY_BANKS];
+
+#ifdef NO_INLINE_MEMORY_ACCESS
+__inline__ uae_u32 longget(uaecptr addr)
+{
+ return call_mem_get_func(get_mem_bank(addr).lget, addr);
+}
+__inline__ uae_u32 wordget(uaecptr addr)
+{
+ return call_mem_get_func(get_mem_bank(addr).wget, addr);
+}
+__inline__ uae_u32 byteget(uaecptr addr)
+{
+ return call_mem_get_func(get_mem_bank(addr).bget, addr);
+}
+__inline__ void longput(uaecptr addr, uae_u32 l)
+{
+ call_mem_put_func(get_mem_bank(addr).lput, addr, l);
+}
+__inline__ void wordput(uaecptr addr, uae_u32 w)
+{
+ call_mem_put_func(get_mem_bank(addr).wput, addr, w);
+}
+__inline__ void byteput(uaecptr addr, uae_u32 b)
+{
+ call_mem_put_func(get_mem_bank(addr).bput, addr, b);
+}
+#endif
+
int addr_valid(const TCHAR *txt, uaecptr addr, uae_u32 len)
{
- addrbank *ab = &get_mem_bank(addr);
- if (ab == 0 || !(ab->flags & (ABFLAG_RAM | ABFLAG_ROM)) || addr < 0x100 || len > 16777215 || !valid_address(addr, len)) {
- write_log (_T("corrupt %s pointer %x (%d) detected!\n"), txt, addr, len);
- return 0;
- }
- return 1;
+ addrbank *ab = &get_mem_bank(addr);
+ if (ab == 0 || !(ab->flags & (ABFLAG_RAM | ABFLAG_ROM)) || addr < 0x100 || len > 16777215 || !valid_address(addr, len)) {
+ write_log(_T("corrupt %s pointer %x (%d) detected!\n"), txt, addr, len);
+ return 0;
+ }
+ return 1;
}
+static int illegal_count;
/* A dummy bank that only contains zeros */
-static uae_u32 REGPARAM3 dummy_lget (uaecptr) REGPARAM;
-static uae_u32 REGPARAM3 dummy_wget (uaecptr) REGPARAM;
-static uae_u32 REGPARAM3 dummy_bget (uaecptr) REGPARAM;
-static void REGPARAM3 dummy_lput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 dummy_wput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 dummy_bput (uaecptr, uae_u32) REGPARAM;
-static int REGPARAM3 dummy_check (uaecptr addr, uae_u32 size) REGPARAM;
-
-/* fake UAE ROM */
-
-extern addrbank fakeuaebootrom_bank;
-MEMORY_FUNCTIONS(fakeuaebootrom);
+static uae_u32 REGPARAM3 dummy_lget(uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 dummy_wget(uaecptr) REGPARAM;
+static uae_u32 REGPARAM3 dummy_bget(uaecptr) REGPARAM;
+static void REGPARAM3 dummy_lput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 dummy_wput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 dummy_bput(uaecptr, uae_u32) REGPARAM;
+static int REGPARAM3 dummy_check(uaecptr addr, uae_u32 size) REGPARAM;
#define MAX_ILG 1000
#define NONEXISTINGDATA 0
//#define NONEXISTINGDATA 0xffffffff
-static bool map_uae_boot_rom_direct(void)
+void dummy_put(uaecptr addr, int size, uae_u32 val)
{
- if (!fakeuaebootrom_bank.allocated_size) {
- fakeuaebootrom_bank.start = 0xf00000;
- fakeuaebootrom_bank.reserved_size = 65536;
- fakeuaebootrom_bank.mask = fakeuaebootrom_bank.reserved_size - 1;
- if (!mapped_malloc (&fakeuaebootrom_bank))
- return false;
- // create jump table to real uae boot rom
- for (int i = 0xff00; i < 0xfff8; i += 8) {
- uae_u8 *p = fakeuaebootrom_bank.baseaddr + i;
- p[0] = 0x4e;
- p[1] = 0xf9;
- uaecptr p2 = rtarea_base + i;
- p[2] = p2 >> 24;
- p[3] = p2 >> 16;
- p[4] = p2 >> 8;
- p[5] = p2 >> 0;
- }
- }
- map_banks(&fakeuaebootrom_bank, 0xf0, 1, 1);
- write_log(_T("Mapped fake UAE Boot ROM jump table.\n"));
- return true;
+
}
-static bool gary_nonrange(uaecptr addr)
-{
- if (currprefs.cs_fatgaryrev < 0)
- return false;
- if (addr < 0xb80000)
- return false;
- if (addr >= 0xd00000 && addr < 0xdc0000)
- return true;
- if (addr >= 0xdd0000 && addr < 0xde0000)
- return true;
- if (addr >= 0xdf8000 && addr < 0xe00000)
- return false;
- if (addr >= 0xe80000 && addr < 0xf80000)
- return false;
- return true;
-}
-
-uae_u32 dummy_get_safe(uaecptr addr, int size, bool inst, uae_u32 defvalue)
+uae_u32 dummy_get(uaecptr addr, int size, bool inst, uae_u32 defvalue)
{
uae_u32 v = defvalue;
uae_u32 mask = size == 4 ? 0xffffffff : (1 << (size * 8)) - 1;
@@ -133,74 +164,100 @@ uae_u32 dummy_get_safe(uaecptr addr, int size, bool inst, uae_u32 defvalue)
if (currprefs.cs_cd32cd)
return 0;
if ((currprefs.cpu_model <= 68010) || (currprefs.cpu_model == 68020 && (currprefs.chipset_mask & CSMASK_AGA) && currprefs.address_space_24)) {
- if (size == 4) {
+ if (size == 4) {
v = regs.db & 0xffff;
if (addr & 1)
v = (v << 8) | (v >> 8);
v = (v << 16) | v;
- } else if (size == 2) {
+ }
+ else if (size == 2) {
v = regs.db & 0xffff;
if (addr & 1)
v = (v << 8) | (v >> 8);
- } else {
+ }
+ else {
v = regs.db;
- v = (addr & 1) ? (v & 0xff) : ((v >> 8) & 0xff);
+ v = (addr & 1) ? (v & 0xff) : ((v >> 8) & 0xff);
}
}
return v & mask;
}
-uae_u32 dummy_get (uaecptr addr, int size, bool inst, uae_u32 defvalue)
-{
- uae_u32 v = defvalue;
-
- if (gary_nonrange(addr) || (size > 1 && gary_nonrange(addr + size - 1))) {
- if (gary_toenb)
- exception2 (addr, false, size, (regs.s ? 4 : 0) | (inst ? 0 : 1));
- return v;
- }
-
- return dummy_get_safe(addr, size, inst, defvalue);
-}
-
static uae_u32 REGPARAM2 dummy_lget (uaecptr addr)
{
- return dummy_get (addr, 4, false, NONEXISTINGDATA);
+#ifdef JIT
+ special_mem |= S_READ;
+#endif
+ return dummy_get(addr, 4, false, NONEXISTINGDATA);
}
uae_u32 REGPARAM2 dummy_lgeti (uaecptr addr)
{
- return dummy_get (addr, 4, true, NONEXISTINGDATA);
+#ifdef JIT
+ special_mem |= S_READ;
+#endif
+ return dummy_get(addr, 4, true, NONEXISTINGDATA);
}
static uae_u32 REGPARAM2 dummy_wget (uaecptr addr)
{
- return dummy_get (addr, 2, false, NONEXISTINGDATA);
+#ifdef JIT
+ special_mem |= S_READ;
+#endif
+ return dummy_get(addr, 2, false, NONEXISTINGDATA);
}
uae_u32 REGPARAM2 dummy_wgeti (uaecptr addr)
{
- return dummy_get (addr, 2, true, NONEXISTINGDATA);
+#ifdef JIT
+ special_mem |= S_READ;
+#endif
+ return dummy_get(addr, 2, true, NONEXISTINGDATA);
}
static uae_u32 REGPARAM2 dummy_bget (uaecptr addr)
{
- return dummy_get (addr, 1, false, NONEXISTINGDATA);
+#ifdef JIT
+ special_mem |= S_READ;
+#endif
+ return dummy_get(addr, 1, false, NONEXISTINGDATA);
}
static void REGPARAM2 dummy_lput (uaecptr addr, uae_u32 l)
{
+#ifdef JIT
+ special_mem |= S_WRITE;
+#endif
}
+
static void REGPARAM2 dummy_wput (uaecptr addr, uae_u32 w)
{
+#ifdef JIT
+ special_mem |= S_WRITE;
+#endif
}
+
static void REGPARAM2 dummy_bput (uaecptr addr, uae_u32 b)
{
+#ifdef JIT
+ special_mem |= S_WRITE;
+#endif
}
static int REGPARAM2 dummy_check (uaecptr addr, uae_u32 size)
{
+#ifdef JIT
+ special_mem |= S_READ;
+#endif
return 0;
}
+static void REGPARAM2 none_put(uaecptr addr, uae_u32 v)
+{
+}
+static uae_u32 REGPARAM2 ones_get(uaecptr addr)
+{
+ return 0xffffffff;
+}
+
addrbank *get_sub_bank(uaecptr *paddr)
{
int i;
@@ -223,7 +280,7 @@ addrbank *get_sub_bank(uaecptr *paddr)
*paddr = addr - sb[i - 1].suboffset;
return sb[i - 1].bank;
}
-uae_u32 REGPARAM3 sub_bank_lget (uaecptr addr) REGPARAM
+uae_u32 REGPARAM3 sub_bank_lget(uaecptr addr) REGPARAM
{
addrbank *ab = get_sub_bank(&addr);
return ab->lget(addr);
@@ -274,102 +331,358 @@ uae_u8 *REGPARAM3 sub_bank_xlate(uaecptr addr) REGPARAM
return ab->xlateaddr(addr);
}
-
/* Chip memory */
-uae_u32 chipmem_full_mask;
+static uae_u32 chipmem_full_mask;
+static uae_u32 chipmem_full_size;
-static int REGPARAM3 chipmem_check (uaecptr addr, uae_u32 size) REGPARAM;
-static uae_u8 *REGPARAM3 chipmem_xlate (uaecptr addr) REGPARAM;
+static int REGPARAM3 chipmem_check(uaecptr addr, uae_u32 size) REGPARAM;
+static uae_u8 *REGPARAM3 chipmem_xlate(uaecptr addr) REGPARAM;
-static uae_u32 REGPARAM2 chipmem_lget (uaecptr addr)
+#ifdef AGA
+
+/* AGA ce-chipram access */
+
+static void ce2_timeout(void)
{
- uae_u32 *m;
-
- addr &= chipmem_bank.mask;
- m = (uae_u32 *)(chipmem_bank.baseaddr + addr);
- return do_get_mem_long (m);
+#ifdef CPUEMU_13
+ wait_cpu_cycle_read(0, -1);
+#endif
}
-static uae_u32 REGPARAM2 chipmem_wget (uaecptr addr)
+static uae_u32 REGPARAM2 chipmem_lget_ce2(uaecptr addr)
{
- uae_u16 *m, v;
+ uae_u32 *m;
- addr &= chipmem_bank.mask;
- m = (uae_u16 *)(chipmem_bank.baseaddr + addr);
- v = do_get_mem_word (m);
- return v;
+ addr &= chipmem_bank.mask;
+ m = (uae_u32 *)(chipmem_bank.baseaddr + addr);
+ ce2_timeout();
+ return do_get_mem_long(m);
}
-static uae_u32 REGPARAM2 chipmem_bget (uaecptr addr)
+static uae_u32 REGPARAM2 chipmem_wget_ce2(uaecptr addr)
+{
+ uae_u16 *m, v;
+
+ addr &= chipmem_bank.mask;
+ m = (uae_u16 *)(chipmem_bank.baseaddr + addr);
+ ce2_timeout();
+ v = do_get_mem_word(m);
+ return v;
+}
+
+static uae_u32 REGPARAM2 chipmem_bget_ce2(uaecptr addr)
+{
+ addr &= chipmem_bank.mask;
+ ce2_timeout();
+ return chipmem_bank.baseaddr[addr];
+}
+
+static void REGPARAM2 chipmem_lput_ce2(uaecptr addr, uae_u32 l)
+{
+ uae_u32 *m;
+
+ addr &= chipmem_bank.mask;
+ m = (uae_u32 *)(chipmem_bank.baseaddr + addr);
+ ce2_timeout();
+ do_put_mem_long(m, l);
+}
+
+static void REGPARAM2 chipmem_wput_ce2(uaecptr addr, uae_u32 w)
+{
+ uae_u16 *m;
+
+ addr &= chipmem_bank.mask;
+ m = (uae_u16 *)(chipmem_bank.baseaddr + addr);
+ ce2_timeout();
+ do_put_mem_word(m, w);
+}
+
+static void REGPARAM2 chipmem_bput_ce2(uaecptr addr, uae_u32 b)
+{
+ addr &= chipmem_bank.mask;
+ ce2_timeout();
+ chipmem_bank.baseaddr[addr] = b;
+}
+
+#endif
+
+static uae_u32 REGPARAM2 chipmem_lget(uaecptr addr)
+{
+ uae_u32 *m;
+
+ addr &= chipmem_bank.mask;
+ m = (uae_u32 *)(chipmem_bank.baseaddr + addr);
+ return do_get_mem_long(m);
+}
+
+static uae_u32 REGPARAM2 chipmem_wget(uaecptr addr)
+{
+ uae_u16 *m, v;
+
+ addr &= chipmem_bank.mask;
+ m = (uae_u16 *)(chipmem_bank.baseaddr + addr);
+ v = do_get_mem_word(m);
+ return v;
+}
+
+static uae_u32 REGPARAM2 chipmem_bget(uaecptr addr)
{
uae_u8 v;
- addr &= chipmem_bank.mask;
+ addr &= chipmem_bank.mask;
v = chipmem_bank.baseaddr[addr];
return v;
}
-void REGPARAM2 chipmem_lput (uaecptr addr, uae_u32 l)
+void REGPARAM2 chipmem_lput(uaecptr addr, uae_u32 l)
{
- uae_u32 *m;
+ uae_u32 *m;
- addr &= chipmem_bank.mask;
- m = (uae_u32 *)(chipmem_bank.baseaddr + addr);
- do_put_mem_long(m, l);
+ addr &= chipmem_bank.mask;
+ m = (uae_u32 *)(chipmem_bank.baseaddr + addr);
+ do_put_mem_long(m, l);
}
-void REGPARAM2 chipmem_wput (uaecptr addr, uae_u32 w)
+void REGPARAM2 chipmem_wput(uaecptr addr, uae_u32 w)
{
- uae_u16 *m;
+ uae_u16 *m;
- addr &= chipmem_bank.mask;
- m = (uae_u16 *)(chipmem_bank.baseaddr + addr);
- do_put_mem_word (m, w);
+ addr &= chipmem_bank.mask;
+ m = (uae_u16 *)(chipmem_bank.baseaddr + addr);
+ do_put_mem_word(m, w);
}
-void REGPARAM2 chipmem_bput (uaecptr addr, uae_u32 b)
+void REGPARAM2 chipmem_bput(uaecptr addr, uae_u32 b)
{
- addr &= chipmem_bank.mask;
+ addr &= chipmem_bank.mask;
chipmem_bank.baseaddr[addr] = b;
}
-void REGPARAM2 chipmem_agnus_wput (uaecptr addr, uae_u32 w)
+/* cpu chipmem access inside agnus addressable ram but no ram available */
+static uae_u32 chipmem_dummy(void)
{
- uae_u16 *m;
-
- addr &= chipmem_full_mask;
- m = (uae_u16 *)(chipmem_bank.baseaddr + addr);
- do_put_mem_word (m, w);
+ /* not really right but something random that has more ones than zeros.. */
+ return 0xffff & ~((1 << (uaerand() & 31)) | (1 << (uaerand() & 31)));
}
-static int REGPARAM2 chipmem_check (uaecptr addr, uae_u32 size)
+static void REGPARAM2 chipmem_dummy_bput(uaecptr addr, uae_u32 b)
+{
+}
+static void REGPARAM2 chipmem_dummy_wput(uaecptr addr, uae_u32 b)
+{
+}
+static void REGPARAM2 chipmem_dummy_lput(uaecptr addr, uae_u32 b)
{
- addr &= chipmem_bank.mask;
- return (addr + size) <= chipmem_bank.allocated_size;
}
-static uae_u8 *REGPARAM2 chipmem_xlate (uaecptr addr)
+static uae_u32 REGPARAM2 chipmem_dummy_bget(uaecptr addr)
+{
+ return chipmem_dummy();
+}
+static uae_u32 REGPARAM2 chipmem_dummy_wget(uaecptr addr)
+{
+ return chipmem_dummy();
+}
+static uae_u32 REGPARAM2 chipmem_dummy_lget(uaecptr addr)
+{
+ return (chipmem_dummy() << 16) | chipmem_dummy();
+}
+
+static uae_u32 REGPARAM2 chipmem_agnus_lget(uaecptr addr)
+{
+ uae_u32 *m;
+
+ addr &= chipmem_full_mask;
+ if (addr >= chipmem_full_size - 3)
+ return 0;
+ m = (uae_u32 *)(chipmem_bank.baseaddr + addr);
+ return do_get_mem_long(m);
+}
+
+uae_u32 REGPARAM2 chipmem_agnus_wget(uaecptr addr)
+{
+ uae_u16 *m;
+
+ addr &= chipmem_full_mask;
+ if (addr >= chipmem_full_size - 1)
+ return 0;
+ m = (uae_u16 *)(chipmem_bank.baseaddr + addr);
+ return do_get_mem_word(m);
+}
+
+static uae_u32 REGPARAM2 chipmem_agnus_bget(uaecptr addr)
+{
+ addr &= chipmem_full_mask;
+ if (addr >= chipmem_full_size)
+ return 0;
+ return chipmem_bank.baseaddr[addr];
+}
+
+static void REGPARAM2 chipmem_agnus_lput(uaecptr addr, uae_u32 l)
+{
+ uae_u32 *m;
+
+ addr &= chipmem_full_mask;
+ if (addr >= chipmem_full_size - 3)
+ return;
+ m = (uae_u32 *)(chipmem_bank.baseaddr + addr);
+ do_put_mem_long(m, l);
+}
+
+void REGPARAM2 chipmem_agnus_wput(uaecptr addr, uae_u32 w)
+{
+ uae_u16 *m;
+
+ addr &= chipmem_full_mask;
+ if (addr >= chipmem_full_size - 1)
+ return;
+ m = (uae_u16 *)(chipmem_bank.baseaddr + addr);
+ do_put_mem_word(m, w);
+}
+
+static void REGPARAM2 chipmem_agnus_bput(uaecptr addr, uae_u32 b)
+{
+ addr &= chipmem_full_mask;
+ if (addr >= chipmem_full_size)
+ return;
+ chipmem_bank.baseaddr[addr] = b;
+}
+
+static int REGPARAM2 chipmem_check(uaecptr addr, uae_u32 size)
{
addr &= chipmem_bank.mask;
- return chipmem_bank.baseaddr + addr;
+ return (addr + size) <= chipmem_full_size;
+}
+
+static uae_u8 *REGPARAM2 chipmem_xlate(uaecptr addr)
+{
+ addr &= chipmem_bank.mask;
+ return chipmem_bank.baseaddr + addr;
+}
+
+STATIC_INLINE void REGPARAM2 chipmem_lput_bigmem(uaecptr addr, uae_u32 v)
+{
+ put_long(addr, v);
+}
+STATIC_INLINE void REGPARAM2 chipmem_wput_bigmem(uaecptr addr, uae_u32 v)
+{
+ put_word(addr, v);
+}
+STATIC_INLINE void REGPARAM2 chipmem_bput_bigmem(uaecptr addr, uae_u32 v)
+{
+ put_byte(addr, v);
+}
+STATIC_INLINE uae_u32 REGPARAM2 chipmem_lget_bigmem(uaecptr addr)
+{
+ return get_long(addr);
+}
+STATIC_INLINE uae_u32 REGPARAM2 chipmem_wget_bigmem(uaecptr addr)
+{
+ return get_word(addr);
+}
+STATIC_INLINE uae_u32 REGPARAM2 chipmem_bget_bigmem(uaecptr addr)
+{
+ return get_byte(addr);
+}
+STATIC_INLINE int REGPARAM2 chipmem_check_bigmem(uaecptr addr, uae_u32 size)
+{
+ return valid_address(addr, size);
+}
+STATIC_INLINE uae_u8* REGPARAM2 chipmem_xlate_bigmem(uaecptr addr)
+{
+ return get_real_address(addr);
+}
+
+uae_u32(REGPARAM2 *chipmem_lget_indirect)(uaecptr);
+uae_u32(REGPARAM2 *chipmem_wget_indirect)(uaecptr);
+uae_u32(REGPARAM2 *chipmem_bget_indirect)(uaecptr);
+void (REGPARAM2 *chipmem_lput_indirect)(uaecptr, uae_u32);
+void (REGPARAM2 *chipmem_wput_indirect)(uaecptr, uae_u32);
+void (REGPARAM2 *chipmem_bput_indirect)(uaecptr, uae_u32);
+int (REGPARAM2 *chipmem_check_indirect)(uaecptr, uae_u32);
+uae_u8 *(REGPARAM2 *chipmem_xlate_indirect)(uaecptr);
+
+static void chipmem_setindirect(void)
+{
+ if (currprefs.z3chipmem_size) {
+ chipmem_lget_indirect = chipmem_lget_bigmem;
+ chipmem_wget_indirect = chipmem_wget_bigmem;
+ chipmem_bget_indirect = chipmem_bget_bigmem;
+ chipmem_lput_indirect = chipmem_lput_bigmem;
+ chipmem_wput_indirect = chipmem_wput_bigmem;
+ chipmem_bput_indirect = chipmem_bput_bigmem;
+ chipmem_check_indirect = chipmem_check_bigmem;
+ chipmem_xlate_indirect = chipmem_xlate_bigmem;
+ }
+ else {
+ chipmem_lget_indirect = chipmem_lget;
+ chipmem_wget_indirect = chipmem_agnus_wget;
+ chipmem_bget_indirect = chipmem_agnus_bget;
+ chipmem_lput_indirect = chipmem_lput;
+ chipmem_wput_indirect = chipmem_agnus_wput;
+ chipmem_bput_indirect = chipmem_agnus_bput;
+ chipmem_check_indirect = chipmem_check;
+ chipmem_xlate_indirect = chipmem_xlate;
+ }
}
/* Slow memory */
MEMORY_FUNCTIONS(bogomem);
+/* CDTV expension memory card memory */
+
+MEMORY_FUNCTIONS(cardmem);
+
/* A3000 motherboard fast memory */
MEMORY_FUNCTIONS(a3000lmem);
MEMORY_FUNCTIONS(a3000hmem);
+/* 25bit memory (0x01000000) */
+
+MEMORY_FUNCTIONS(mem25bit);
+
/* Kick memory */
uae_u16 kickstart_version;
-static void REGPARAM3 kickmem_lput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 kickmem_wput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 kickmem_bput (uaecptr, uae_u32) REGPARAM;
+/*
+* A1000 kickstart RAM handling
+*
+* RESET instruction unhides boot ROM and disables write protection
+* write access to boot ROM hides boot ROM and enables write protection
+*
+*/
+static int a1000_kickstart_mode;
+static uae_u8 *a1000_bootrom;
+static void a1000_handle_kickstart(int mode)
+{
+ if (!a1000_bootrom)
+ return;
+ protect_roms(false);
+ if (mode == 0) {
+ a1000_kickstart_mode = 0;
+ memcpy(kickmem_bank.baseaddr, kickmem_bank.baseaddr + ROM_SIZE_256, ROM_SIZE_256);
+ kickstart_version = (kickmem_bank.baseaddr[ROM_SIZE_256 + 12] << 8) | kickmem_bank.baseaddr[ROM_SIZE_256 + 13];
+ }
+ else {
+ a1000_kickstart_mode = 1;
+ memcpy(kickmem_bank.baseaddr, a1000_bootrom, ROM_SIZE_256);
+ kickstart_version = 0;
+ }
+ if (kickstart_version == 0xffff)
+ kickstart_version = 0;
+}
+
+void a1000_reset(void)
+{
+ a1000_handle_kickstart(1);
+}
+
+static void REGPARAM3 kickmem_lput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 kickmem_wput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 kickmem_bput(uaecptr, uae_u32) REGPARAM;
MEMORY_BGET(kickmem);
MEMORY_WGET(kickmem);
@@ -377,16 +690,98 @@ MEMORY_LGET(kickmem);
MEMORY_CHECK(kickmem);
MEMORY_XLATE(kickmem);
-static void REGPARAM2 kickmem_lput (uaecptr addr, uae_u32 b)
+static void REGPARAM2 kickmem_lput(uaecptr addr, uae_u32 b)
{
+ uae_u32 *m;
+ if (currprefs.rom_readwrite && rom_write_enabled) {
+ addr &= kickmem_bank.mask;
+ m = (uae_u32 *)(kickmem_bank.baseaddr + addr);
+ do_put_mem_long(m, b);
+#if 0
+ if (addr == ROM_SIZE_512 - 4) {
+ rom_write_enabled = false;
+ write_log(_T("ROM write disabled\n"));
+ }
+#endif
+ }
+ else if (a1000_kickstart_mode) {
+ if (addr >= 0xfc0000) {
+ addr &= kickmem_bank.mask;
+ m = (uae_u32 *)(kickmem_bank.baseaddr + addr);
+ do_put_mem_long(m, b);
+ return;
+ }
+ else
+ a1000_handle_kickstart(0);
+ }
+ else if (currprefs.illegal_mem) {
+ write_log(_T("Illegal kickmem lput at %08x\n"), addr);
+ }
}
-static void REGPARAM2 kickmem_wput (uaecptr addr, uae_u32 b)
+static void REGPARAM2 kickmem_wput(uaecptr addr, uae_u32 b)
{
+ uae_u16 *m;
+ if (currprefs.rom_readwrite && rom_write_enabled) {
+ addr &= kickmem_bank.mask;
+ m = (uae_u16 *)(kickmem_bank.baseaddr + addr);
+ do_put_mem_word(m, b);
+ }
+ else if (a1000_kickstart_mode) {
+ if (addr >= 0xfc0000) {
+ addr &= kickmem_bank.mask;
+ m = (uae_u16 *)(kickmem_bank.baseaddr + addr);
+ do_put_mem_word(m, b);
+ return;
+ }
+ else
+ a1000_handle_kickstart(0);
+ }
+ else if (currprefs.illegal_mem) {
+ write_log(_T("Illegal kickmem wput at %08x\n"), addr);
+ }
}
-static void REGPARAM2 kickmem_bput (uaecptr addr, uae_u32 b)
+static void REGPARAM2 kickmem_bput(uaecptr addr, uae_u32 b)
{
+ if (currprefs.rom_readwrite && rom_write_enabled) {
+ addr &= kickmem_bank.mask;
+ kickmem_bank.baseaddr[addr] = b;
+ }
+ else if (a1000_kickstart_mode) {
+ if (addr >= 0xfc0000) {
+ addr &= kickmem_bank.mask;
+ kickmem_bank.baseaddr[addr] = b;
+ return;
+ }
+ else
+ a1000_handle_kickstart(0);
+ }
+ else if (currprefs.illegal_mem) {
+ write_log(_T("Illegal kickmem bput at %08x\n"), addr);
+ }
+}
+
+static void REGPARAM2 kickmem2_lput(uaecptr addr, uae_u32 l)
+{
+ uae_u32 *m;
+ addr &= kickmem_bank.mask;
+ m = (uae_u32 *)(kickmem_bank.baseaddr + addr);
+ do_put_mem_long(m, l);
+}
+
+static void REGPARAM2 kickmem2_wput(uaecptr addr, uae_u32 w)
+{
+ uae_u16 *m;
+ addr &= kickmem_bank.mask;
+ m = (uae_u16 *)(kickmem_bank.baseaddr + addr);
+ do_put_mem_word(m, w);
+}
+
+static void REGPARAM2 kickmem2_bput(uaecptr addr, uae_u32 b)
+{
+ addr &= kickmem_bank.mask;
+ kickmem_bank.baseaddr[addr] = b;
}
/* CD32/CDTV extended kick memory */
@@ -396,10 +791,12 @@ static int extendedkickmem_type;
#define EXTENDED_ROM_CD32 1
#define EXTENDED_ROM_CDTV 2
#define EXTENDED_ROM_KS 3
+#define EXTENDED_ROM_ARCADIA 4
+#define EXTENDED_ROM_ALG 5
-static void REGPARAM3 extendedkickmem_lput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 extendedkickmem_wput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 extendedkickmem_bput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 extendedkickmem_lput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 extendedkickmem_wput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 extendedkickmem_bput(uaecptr, uae_u32) REGPARAM;
MEMORY_BGET(extendedkickmem);
MEMORY_WGET(extendedkickmem);
@@ -407,20 +804,26 @@ MEMORY_LGET(extendedkickmem);
MEMORY_CHECK(extendedkickmem);
MEMORY_XLATE(extendedkickmem);
-static void REGPARAM2 extendedkickmem_lput (uaecptr addr, uae_u32 b)
+static void REGPARAM2 extendedkickmem_lput(uaecptr addr, uae_u32 b)
{
+ if (currprefs.illegal_mem)
+ write_log(_T("Illegal extendedkickmem lput at %08x\n"), addr);
}
-static void REGPARAM2 extendedkickmem_wput (uaecptr addr, uae_u32 b)
+static void REGPARAM2 extendedkickmem_wput(uaecptr addr, uae_u32 b)
{
+ if (currprefs.illegal_mem)
+ write_log(_T("Illegal extendedkickmem wput at %08x\n"), addr);
}
-static void REGPARAM2 extendedkickmem_bput (uaecptr addr, uae_u32 b)
+static void REGPARAM2 extendedkickmem_bput(uaecptr addr, uae_u32 b)
{
+ if (currprefs.illegal_mem)
+ write_log(_T("Illegal extendedkickmem lput at %08x\n"), addr);
}
-static void REGPARAM3 extendedkickmem2_lput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 extendedkickmem2_wput (uaecptr, uae_u32) REGPARAM;
-static void REGPARAM3 extendedkickmem2_bput (uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 extendedkickmem2_lput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 extendedkickmem2_wput(uaecptr, uae_u32) REGPARAM;
+static void REGPARAM3 extendedkickmem2_bput(uaecptr, uae_u32) REGPARAM;
MEMORY_BGET(extendedkickmem2);
MEMORY_WGET(extendedkickmem2);
@@ -428,77 +831,136 @@ MEMORY_LGET(extendedkickmem2);
MEMORY_CHECK(extendedkickmem2);
MEMORY_XLATE(extendedkickmem2);
-static void REGPARAM2 extendedkickmem2_lput (uaecptr addr, uae_u32 b)
+static void REGPARAM2 extendedkickmem2_lput(uaecptr addr, uae_u32 b)
{
+ if (currprefs.illegal_mem)
+ write_log(_T("Illegal extendedkickmem2 lput at %08x\n"), addr);
}
-static void REGPARAM2 extendedkickmem2_wput (uaecptr addr, uae_u32 b)
+static void REGPARAM2 extendedkickmem2_wput(uaecptr addr, uae_u32 b)
{
+ if (currprefs.illegal_mem)
+ write_log(_T("Illegal extendedkickmem2 wput at %08x\n"), addr);
}
-static void REGPARAM2 extendedkickmem2_bput (uaecptr addr, uae_u32 b)
+static void REGPARAM2 extendedkickmem2_bput(uaecptr addr, uae_u32 b)
{
+ if (currprefs.illegal_mem)
+ write_log(_T("Illegal extendedkickmem2 lput at %08x\n"), addr);
}
/* Default memory access functions */
-int REGPARAM2 default_check (uaecptr a, uae_u32 b)
+int REGPARAM2 default_check(uaecptr a, uae_u32 b)
{
- return 0;
+ return 0;
}
-static int be_cnt, be_recursive;
+static int be_cnt;
-uae_u8 *REGPARAM2 default_xlate (uaecptr addr)
+uae_u8 *REGPARAM2 default_xlate(uaecptr addr)
{
- if (be_recursive) {
- cpu_halt(CPU_HALT_OPCODE_FETCH_FROM_NON_EXISTING_ADDRESS);
+ static int recursive;
+
+ if (recursive) {
+ cpu_halt(3);
return kickmem_xlate(2);
}
-
- be_recursive++;
+ recursive++;
int size = currprefs.cpu_model >= 68020 ? 4 : 2;
- if (quit_program == 0) {
- /* do this only in 68010+ mode, there are some tricky A500 programs.. */
- if(currprefs.cpu_model > 68000 || !currprefs.cpu_compatible) {
+
+ if (quit_program == 0) {
+ /* do this only in 68010+ mode, there are some tricky A500 programs.. */
+ if (currprefs.cpu_model > 68000 || !currprefs.cpu_compatible) {
if (be_cnt < 3) {
- write_log (_T("Your Amiga program just did something terribly stupid %08X PC=%08X\n"), addr, M68K_GETPC);
- }
- if (gary_toenb && (gary_nonrange(addr) || (size > 1 && gary_nonrange(addr + size - 1)))) {
- exception2 (addr, false, size, regs.s ? 4 : 0);
- } else {
- cpu_halt (CPU_HALT_OPCODE_FETCH_FROM_NON_EXISTING_ADDRESS);
- }
- }
+ int i, j;
+ uaecptr a2 = addr - 32;
+ uaecptr a3 = m68k_getpc() - 32;
+ write_log(_T("Your Amiga program just did something terribly stupid %08X PC=%08X\n"), addr, M68K_GETPC);
+ }
+ be_cnt++;
+ if (regs.s || be_cnt > 1000) {
+ cpu_halt(3);
+ be_cnt = 0;
+ }
+ else {
+ regs.panic = 4;
+ regs.panic_pc = m68k_getpc();
+ regs.panic_addr = addr;
+ set_special(SPCFLAG_BRK);
+ }
+ }
}
- be_recursive--;
- return kickmem_xlate (2); /* So we don't crash. */
+ recursive--;
+ return kickmem_xlate(2); /* So we don't crash. */
}
/* Address banks */
addrbank dummy_bank = {
- dummy_lget, dummy_wget, dummy_bget,
- dummy_lput, dummy_wput, dummy_bput,
- default_xlate, dummy_check, NULL, NULL, NULL,
+ dummy_lget, dummy_wget, dummy_bget,
+ dummy_lput, dummy_wput, dummy_bput,
+ default_xlate, dummy_check, NULL, NULL, NULL,
+ dummy_lgeti, dummy_wgeti,
+ ABFLAG_NONE, S_READ, S_WRITE
+};
+
+addrbank ones_bank = {
+ ones_get, ones_get, ones_get,
+ none_put, none_put, none_put,
+ default_xlate, dummy_check, NULL, NULL, _T("Ones"),
dummy_lgeti, dummy_wgeti,
ABFLAG_NONE, S_READ, S_WRITE
};
addrbank chipmem_bank = {
- chipmem_lget, chipmem_wget, chipmem_bget,
- chipmem_lput, chipmem_wput, chipmem_bput,
+ chipmem_lget, chipmem_wget, chipmem_bget,
+ chipmem_lput, chipmem_wput, chipmem_bput,
chipmem_xlate, chipmem_check, NULL, _T("chip"), _T("Chip memory"),
chipmem_lget, chipmem_wget,
ABFLAG_RAM | ABFLAG_THREADSAFE | ABFLAG_CHIPRAM, 0, 0
};
+addrbank chipmem_dummy_bank = {
+ chipmem_dummy_lget, chipmem_dummy_wget, chipmem_dummy_bget,
+ chipmem_dummy_lput, chipmem_dummy_wput, chipmem_dummy_bput,
+ default_xlate, dummy_check, NULL, NULL, _T("Dummy Chip memory"),
+ dummy_lgeti, dummy_wgeti,
+ ABFLAG_IO | ABFLAG_CHIPRAM, S_READ, S_WRITE
+};
+
+#ifdef AGA
+addrbank chipmem_bank_ce2 = {
+ chipmem_lget_ce2, chipmem_wget_ce2, chipmem_bget_ce2,
+ chipmem_lput_ce2, chipmem_wput_ce2, chipmem_bput_ce2,
+ chipmem_xlate, chipmem_check, NULL, NULL, _T("Chip memory (68020 'ce')"),
+ chipmem_lget_ce2, chipmem_wget_ce2,
+ ABFLAG_RAM | ABFLAG_CHIPRAM, S_READ, S_WRITE
+};
+#endif
+
addrbank bogomem_bank = {
- bogomem_lget, bogomem_wget, bogomem_bget,
- bogomem_lput, bogomem_wput, bogomem_bput,
+ bogomem_lget, bogomem_wget, bogomem_bget,
+ bogomem_lput, bogomem_wput, bogomem_bput,
bogomem_xlate, bogomem_check, NULL, _T("bogo"), _T("Slow memory"),
bogomem_lget, bogomem_wget,
ABFLAG_RAM | ABFLAG_THREADSAFE, 0, 0
};
+addrbank cardmem_bank = {
+ cardmem_lget, cardmem_wget, cardmem_bget,
+ cardmem_lput, cardmem_wput, cardmem_bput,
+ cardmem_xlate, cardmem_check, NULL, _T("rom_e0"), _T("CDTV memory card"),
+ cardmem_lget, cardmem_wget,
+ ABFLAG_RAM, 0, 0
+};
+
+addrbank mem25bit_bank = {
+ mem25bit_lget, mem25bit_wget, mem25bit_bget,
+ mem25bit_lput, mem25bit_wput, mem25bit_bput,
+ mem25bit_xlate, mem25bit_check, NULL, _T("25bitmem"), _T("25bit memory"),
+ mem25bit_lget, mem25bit_wget,
+ ABFLAG_RAM | ABFLAG_THREADSAFE, 0, 0
+};
+
addrbank a3000lmem_bank = {
a3000lmem_lget, a3000lmem_wget, a3000lmem_bget,
a3000lmem_lput, a3000lmem_wput, a3000lmem_bput,
@@ -516,34 +978,35 @@ addrbank a3000hmem_bank = {
};
addrbank kickmem_bank = {
- kickmem_lget, kickmem_wget, kickmem_bget,
- kickmem_lput, kickmem_wput, kickmem_bput,
+ kickmem_lget, kickmem_wget, kickmem_bget,
+ kickmem_lput, kickmem_wput, kickmem_bput,
kickmem_xlate, kickmem_check, NULL, _T("kick"), _T("Kickstart ROM"),
kickmem_lget, kickmem_wget,
ABFLAG_ROM | ABFLAG_THREADSAFE, 0, S_WRITE
};
+addrbank kickram_bank = {
+ kickmem_lget, kickmem_wget, kickmem_bget,
+ kickmem2_lput, kickmem2_wput, kickmem2_bput,
+ kickmem_xlate, kickmem_check, NULL, NULL, _T("Kickstart Shadow RAM"),
+ kickmem_lget, kickmem_wget,
+ ABFLAG_UNK | ABFLAG_SAFE, 0, S_WRITE
+};
+
addrbank extendedkickmem_bank = {
- extendedkickmem_lget, extendedkickmem_wget, extendedkickmem_bget,
- extendedkickmem_lput, extendedkickmem_wput, extendedkickmem_bput,
+ extendedkickmem_lget, extendedkickmem_wget, extendedkickmem_bget,
+ extendedkickmem_lput, extendedkickmem_wput, extendedkickmem_bput,
extendedkickmem_xlate, extendedkickmem_check, NULL, NULL, _T("Extended Kickstart ROM"),
extendedkickmem_lget, extendedkickmem_wget,
ABFLAG_ROM | ABFLAG_THREADSAFE, 0, S_WRITE
};
addrbank extendedkickmem2_bank = {
- extendedkickmem2_lget, extendedkickmem2_wget, extendedkickmem2_bget,
- extendedkickmem2_lput, extendedkickmem2_wput, extendedkickmem2_bput,
+ extendedkickmem2_lget, extendedkickmem2_wget, extendedkickmem2_bget,
+ extendedkickmem2_lput, extendedkickmem2_wput, extendedkickmem2_bput,
extendedkickmem2_xlate, extendedkickmem2_check, NULL, _T("rom_a8"), _T("Extended 2nd Kickstart ROM"),
extendedkickmem2_lget, extendedkickmem2_wget,
ABFLAG_ROM | ABFLAG_THREADSAFE, 0, S_WRITE
};
-addrbank fakeuaebootrom_bank = {
- fakeuaebootrom_lget, fakeuaebootrom_wget, fakeuaebootrom_bget,
- fakeuaebootrom_lput, fakeuaebootrom_wput, fakeuaebootrom_bput,
- fakeuaebootrom_xlate, fakeuaebootrom_check, NULL, _T("*"), _T("fakeuaerom"),
- fakeuaebootrom_lget, fakeuaebootrom_wget,
- ABFLAG_RAM | ABFLAG_THREADSAFE, 0, 0
-};
MEMORY_FUNCTIONS(custmem1);
MEMORY_FUNCTIONS(custmem2);
@@ -563,177 +1026,332 @@ addrbank custmem2_bank = {
ABFLAG_RAM | ABFLAG_THREADSAFE, 0, 0
};
-static const uae_char *kickstring = "exec.library";
-
-static int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksum, int noalias)
+#define fkickmem_size ROM_SIZE_512
+static int a3000_f0;
+void a3000_fakekick(int map)
{
- uae_char buffer[20];
- int i, j, oldpos;
- int cr = 0, kickdisk = 0;
+ static uae_u8 *kickstore;
- if (size < 0) {
- zfile_fseek (f, 0, SEEK_END);
- size = zfile_ftell (f) & ~0x3ff;
- zfile_fseek (f, 0, SEEK_SET);
- }
- oldpos = zfile_ftell (f);
- i = zfile_fread (buffer, 1, 11, f);
- if (!memcmp(buffer, "KICK", 4)) {
- zfile_fseek (f, 512, SEEK_SET);
- kickdisk = 1;
- } else if (memcmp ((uae_char*)buffer, "AMIROMTYPE1", 11) != 0) {
- zfile_fseek (f, oldpos, SEEK_SET);
- } else {
- cloanto_rom = 1;
- cr = 1;
- }
-
- memset (mem, 0, size);
- if (size >= 131072) {
- for (i = 0; i < 8; i++) {
- mem[size - 16 + i * 2 + 1] = 0x18 + i;
+ protect_roms(false);
+ if (map) {
+ uae_u8 *fkickmemory = a3000lmem_bank.baseaddr + a3000lmem_bank.reserved_size - fkickmem_size;
+ if (fkickmemory[2] == 0x4e && fkickmemory[3] == 0xf9 && fkickmemory[4] == 0x00) {
+ if (!kickstore)
+ kickstore = xmalloc(uae_u8, fkickmem_size);
+ memcpy(kickstore, kickmem_bank.baseaddr, fkickmem_size);
+ if (fkickmemory[5] == 0xfc) {
+ memcpy(kickmem_bank.baseaddr, fkickmemory, fkickmem_size / 2);
+ memcpy(kickmem_bank.baseaddr + fkickmem_size / 2, fkickmemory, fkickmem_size / 2);
+ extendedkickmem_bank.reserved_size = 65536;
+ extendedkickmem_bank.label = _T("rom_f0");
+ extendedkickmem_bank.mask = extendedkickmem_bank.reserved_size - 1;
+ mapped_malloc(&extendedkickmem_bank);
+ memcpy(extendedkickmem_bank.baseaddr, fkickmemory + fkickmem_size / 2, 65536);
+ map_banks(&extendedkickmem_bank, 0xf0, 1, 1);
+ a3000_f0 = 1;
+ }
+ else {
+ memcpy(kickmem_bank.baseaddr, fkickmemory, fkickmem_size);
+ }
}
- mem[size - 20] = size >> 24;
- mem[size - 19] = size >> 16;
- mem[size - 18] = size >> 8;
- mem[size - 17] = size >> 0;
+ }
+ else {
+ if (a3000_f0) {
+ map_banks(&dummy_bank, 0xf0, 1, 1);
+ mapped_free(&extendedkickmem_bank);
+ a3000_f0 = 0;
+ }
+ if (kickstore)
+ memcpy(kickmem_bank.baseaddr, kickstore, fkickmem_size);
+ xfree(kickstore);
+ kickstore = NULL;
+ }
+ protect_roms(true);
+}
+
+static bool is_alg_rom(const TCHAR *name)
+{
+ struct romdata *rd = getromdatabypath(name);
+ if (!rd)
+ return false;
+ return (rd->type & ROMTYPE_ALG) != 0;
+}
+
+static void descramble_alg(uae_u8 *data, int size)
+{
+ uae_u8 *tbuf = xmalloc(uae_u8, size);
+ memcpy(tbuf, data, size);
+ for (int mode = 0; mode < 3; mode++) {
+ if ((data[8] == 0x4a && data[9] == 0xfc))
+ break;
+ for (int s = 0; s < size; s++) {
+ int d = s;
+ if (mode == 0) {
+ if (s & 0x2000)
+ d ^= 0x1000;
+ if (s & 0x8000)
+ d ^= 0x4000;
+ }
+ else if (mode == 1) {
+ if (s & 0x2000)
+ d ^= 0x1000;
+ }
+ else {
+ if ((~s) & 0x2000)
+ d ^= 0x1000;
+ if (s & 0x8000)
+ d ^= 0x4000;
+ d ^= 0x20000;
+ }
+ data[d] = tbuf[s];
+ }
+ }
+ xfree(tbuf);
+}
+
+static const char *kickstring = "exec.library";
+
+static int read_kickstart(struct zfile *f, uae_u8 *mem, int size, int dochecksum, int noalias)
+{
+ uae_char buffer[20];
+ int i, j, oldpos;
+ int cr = 0, kickdisk = 0;
+
+ if (size < 0) {
+ zfile_fseek(f, 0, SEEK_END);
+ size = zfile_ftell(f) & ~0x3ff;
+ zfile_fseek(f, 0, SEEK_SET);
+ }
+ oldpos = zfile_ftell(f);
+ i = zfile_fread(buffer, 1, 11, f);
+ if (!memcmp(buffer, "KICK", 4)) {
+ zfile_fseek(f, 512, SEEK_SET);
+ kickdisk = 1;
+ }
+ else if (memcmp(static_cast(buffer), "AMIROMTYPE1", 11) != 0) {
+ zfile_fseek(f, oldpos, SEEK_SET);
+ }
+ else {
+ cloanto_rom = 1;
+ cr = 1;
}
- i = zfile_fread (mem, 1, size, f);
+ memset(mem, 0, size);
+ if (size >= 131072) {
+ for (i = 0; i < 8; i++) {
+ mem[size - 16 + i * 2 + 1] = 0x18 + i;
+ }
+ mem[size - 20] = size >> 24;
+ mem[size - 19] = size >> 16;
+ mem[size - 18] = size >> 8;
+ mem[size - 17] = size >> 0;
+ }
- if (kickdisk && i > ROM_SIZE_256)
- i = ROM_SIZE_256;
- if (i < size - 20)
- kickstart_fix_checksum (mem, size);
- j = 1;
- while (j < i)
- j <<= 1;
- i = j;
+ i = zfile_fread(mem, 1, size, f);
- if (!noalias && i == size / 2)
- memcpy (mem + size / 2, mem, size / 2);
+ if (kickdisk && i > ROM_SIZE_256)
+ i = ROM_SIZE_256;
- if (cr) {
- if(!decode_rom (mem, size, cr, i))
- return 0;
- }
+ if (i < size - 20)
+ kickstart_fix_checksum(mem, size);
+ j = 1;
+ while (j < i)
+ j <<= 1;
+ i = j;
+
+ if (!noalias && i == size / 2)
+ memcpy(mem + size / 2, mem, size / 2);
+
+ if (cr) {
+ if (!decode_rom(mem, size, cr, i))
+ return 0;
+ }
if (size <= 256)
return size;
- for (j = 0; j < 256 && i >= ROM_SIZE_256; j++) {
- if (!memcmp (mem + j, kickstring, strlen (kickstring) + 1))
- break;
- }
+ if (currprefs.cs_a1000ram && i < ROM_SIZE_256) {
+ int off = 0;
+ if (!a1000_bootrom)
+ a1000_bootrom = xcalloc(uae_u8, ROM_SIZE_256);
+ while (off + i < ROM_SIZE_256) {
+ memcpy(a1000_bootrom + off, kickmem_bank.baseaddr, i);
+ off += i;
+ }
+ memset(kickmem_bank.baseaddr, 0, kickmem_bank.allocated_size);
+ a1000_handle_kickstart(1);
+ dochecksum = 0;
+ i = ROM_SIZE_512;
+ }
- if (j == 256 || i < ROM_SIZE_256)
- dochecksum = 0;
- if (dochecksum)
- kickstart_checksum (mem, size);
- return i;
+ for (j = 0; j < 256 && i >= ROM_SIZE_256; j++) {
+ if (!memcmp(mem + j, kickstring, strlen(kickstring) + 1))
+ break;
+ }
+
+ if (j == 256 || i < ROM_SIZE_256)
+ dochecksum = 0;
+ if (dochecksum)
+ kickstart_checksum(mem, size);
+ return i;
}
-static bool load_extendedkickstart (const TCHAR *romextfile, int type)
+static bool load_extendedkickstart(const TCHAR *romextfile, int type)
{
- struct zfile *f;
- int size, off;
+ struct zfile *f;
+ int size, off;
bool ret = false;
- if (_tcslen (romextfile) == 0)
- return false;
- f = read_rom_name (romextfile);
- if (!f) {
- notify_user (NUMSG_NOEXTROM);
- return false;
- }
- zfile_fseek (f, 0, SEEK_END);
- size = zfile_ftell (f);
+ if (_tcslen(romextfile) == 0)
+ return false;
+ //if (is_arcadia_rom(romextfile) == ARCADIA_BIOS) {
+ // extendedkickmem_type = EXTENDED_ROM_ARCADIA;
+ // return false;
+ //}
+ if (is_alg_rom(romextfile)) {
+ type = EXTENDED_ROM_ALG;
+
+ }
+ f = read_rom_name(romextfile);
+ if (!f) {
+ notify_user(NUMSG_NOEXTROM);
+ return false;
+ }
+ zfile_fseek(f, 0, SEEK_END);
+ size = zfile_ftell(f);
extendedkickmem_bank.reserved_size = ROM_SIZE_512;
- off = 0;
+ off = 0;
if (type == 0) {
if (currprefs.cs_cd32cd) {
extendedkickmem_type = EXTENDED_ROM_CD32;
- } else if (size > 300000) {
- extendedkickmem_type = EXTENDED_ROM_CD32;
- }
- } else {
+ }
+ else if (currprefs.cs_cdtvcd || currprefs.cs_cdtvram) {
+ extendedkickmem_type = EXTENDED_ROM_CDTV;
+ }
+ else if (size > 300000) {
+ extendedkickmem_type = EXTENDED_ROM_CD32;
+ }
+ else if (need_uae_boot_rom(&currprefs) != 0xf00000) {
+ extendedkickmem_type = EXTENDED_ROM_CDTV;
+ }
+ }
+ else {
extendedkickmem_type = type;
}
if (extendedkickmem_type) {
- zfile_fseek (f, off, SEEK_SET);
- switch (extendedkickmem_type) {
- case EXTENDED_ROM_CD32:
+ zfile_fseek(f, off, SEEK_SET);
+ switch (extendedkickmem_type) {
+ case EXTENDED_ROM_CDTV:
+ extendedkickmem_bank.label = _T("rom_f0");
+ mapped_malloc(&extendedkickmem_bank);
+ extendedkickmem_bank.start = 0xf00000;
+ break;
+ case EXTENDED_ROM_CD32:
extendedkickmem_bank.label = _T("rom_e0");
- mapped_malloc (&extendedkickmem_bank);
- extendedkickmem_bank.start = 0xe00000;
- break;
- }
+ mapped_malloc(&extendedkickmem_bank);
+ extendedkickmem_bank.start = 0xe00000;
+ break;
+ case EXTENDED_ROM_ALG:
+ extendedkickmem_bank.label = _T("rom_f0");
+ mapped_malloc(&extendedkickmem_bank);
+ extendedkickmem_bank.start = 0xf00000;
+ break;
+ }
if (extendedkickmem_bank.baseaddr) {
- read_kickstart (f, extendedkickmem_bank.baseaddr, extendedkickmem_bank.allocated_size, 0, 1);
- extendedkickmem_bank.mask = extendedkickmem_bank.allocated_size - 1;
+ read_kickstart(f, extendedkickmem_bank.baseaddr, extendedkickmem_bank.allocated_size, 0, 1);
+ if (extendedkickmem_type == EXTENDED_ROM_ALG)
+ descramble_alg(extendedkickmem_bank.baseaddr, 262144);
+ extendedkickmem_bank.mask = extendedkickmem_bank.allocated_size - 1;
ret = true;
}
}
- zfile_fclose (f);
- return ret;
+ zfile_fclose(f);
+ return ret;
+}
+
+static int patch_shapeshifter(uae_u8 *kickmemory)
+{
+ /* Patch Kickstart ROM for ShapeShifter - from Christian Bauer.
+ * Changes 'lea $400,a0' and 'lea $1000,a0' to 'lea $3000,a0' for
+ * ShapeShifter compatability.
+ */
+ int i, patched = 0;
+ uae_u8 kickshift1[] = { 0x41, 0xf8, 0x04, 0x00 };
+ uae_u8 kickshift2[] = { 0x41, 0xf8, 0x10, 0x00 };
+ uae_u8 kickshift3[] = { 0x43, 0xf8, 0x04, 0x00 };
+
+ for (i = 0x200; i < 0x300; i++) {
+ if (!memcmp(kickmemory + i, kickshift1, sizeof(kickshift1)) ||
+ !memcmp(kickmemory + i, kickshift2, sizeof(kickshift2)) ||
+ !memcmp(kickmemory + i, kickshift3, sizeof(kickshift3))) {
+ kickmemory[i + 2] = 0x30;
+ write_log(_T("Kickstart KickShifted @%04X\n"), i);
+ patched++;
+ }
+ }
+ return patched;
}
/* disable incompatible drivers */
-static int patch_residents (uae_u8 *kickmemory, int size)
+static int patch_residents(uae_u8 *kickmemory, int size)
{
- int i, j, patched = 0;
- const uae_char *residents[] = { "NCR scsi.device", NULL };
- // "scsi.device", "carddisk.device", "card.resource" };
- uaecptr base = size == ROM_SIZE_512 ? 0xf80000 : 0xfc0000;
+ int i, j, patched = 0;
+ const uae_char *residents[] = { "NCR scsi.device", NULL };
+ // "scsi.device", "carddisk.device", "card.resource" };
+ uaecptr base = size == ROM_SIZE_512 ? 0xf80000 : 0xfc0000;
- for (i = 0; i < size - 100; i++) {
- if (kickmemory[i] == 0x4a && kickmemory[i + 1] == 0xfc) {
- uaecptr addr;
- addr = (kickmemory[i + 2] << 24) | (kickmemory[i + 3] << 16) | (kickmemory[i + 4] << 8) | (kickmemory[i + 5] << 0);
- if (addr != i + base)
- continue;
- addr = (kickmemory[i + 14] << 24) | (kickmemory[i + 15] << 16) | (kickmemory[i + 16] << 8) | (kickmemory[i + 17] << 0);
- if (addr >= base && addr < base + size) {
- j = 0;
- while (residents[j]) {
- if (!memcmp (residents[j], kickmemory + addr - base, strlen (residents[j]) + 1)) {
- TCHAR *s = au (residents[j]);
- write_log (_T("KSPatcher: '%s' at %08X disabled\n"), s, i + base);
- xfree (s);
- kickmemory[i] = 0x4b; /* destroy RTC_MATCHWORD */
- patched++;
- break;
- }
- j++;
- }
- }
- }
- }
- return patched;
+ if (is_device_rom(&currprefs, ROMTYPE_SCSI_A4000T, 0) < 0) {
+ for (i = 0; i < size - 100; i++) {
+ if (kickmemory[i] == 0x4a && kickmemory[i + 1] == 0xfc) {
+ uaecptr addr;
+ addr = (kickmemory[i + 2] << 24) | (kickmemory[i + 3] << 16) | (kickmemory[i + 4] << 8) | (kickmemory[i + 5] << 0);
+ if (addr != i + base)
+ continue;
+ addr = (kickmemory[i + 14] << 24) | (kickmemory[i + 15] << 16) | (kickmemory[i + 16] << 8) | (kickmemory[i + 17] << 0);
+ if (addr >= base && addr < base + size) {
+ j = 0;
+ while (residents[j]) {
+ if (!memcmp(residents[j], kickmemory + addr - base, strlen(residents[j]) + 1)) {
+ TCHAR *s = au(residents[j]);
+ write_log(_T("KSPatcher: '%s' at %08X disabled\n"), s, i + base);
+ xfree(s);
+ kickmemory[i] = 0x4b; /* destroy RTC_MATCHWORD */
+ patched++;
+ break;
+ }
+ j++;
+ }
+ }
+ }
+ }
+ }
+ return patched;
}
static void patch_kick(void)
{
- int patched = 0;
- patched += patch_residents (kickmem_bank.baseaddr, kickmem_bank.allocated_size);
- if (extendedkickmem_bank.baseaddr) {
- patched += patch_residents (extendedkickmem_bank.baseaddr, extendedkickmem_bank.allocated_size);
- if (patched)
- kickstart_fix_checksum (extendedkickmem_bank.baseaddr, extendedkickmem_bank.allocated_size);
- }
- if (patched)
- kickstart_fix_checksum (kickmem_bank.baseaddr, kickmem_bank.allocated_size);
+ int patched = 0;
+ if (kickmem_bank.allocated_size >= ROM_SIZE_512 && currprefs.kickshifter)
+ patched += patch_shapeshifter(kickmem_bank.baseaddr);
+ patched += patch_residents(kickmem_bank.baseaddr, kickmem_bank.allocated_size);
+ if (extendedkickmem_bank.baseaddr) {
+ patched += patch_residents(extendedkickmem_bank.baseaddr, extendedkickmem_bank.allocated_size);
+ if (patched)
+ kickstart_fix_checksum(extendedkickmem_bank.baseaddr, extendedkickmem_bank.allocated_size);
+ }
+ if (patched)
+ kickstart_fix_checksum(kickmem_bank.baseaddr, kickmem_bank.allocated_size);
}
extern unsigned char arosrom[];
extern unsigned int arosrom_len;
-static bool load_kickstart_replacement (void)
+static bool load_kickstart_replacement(void)
{
struct zfile *f;
- f = zfile_fopen_data (_T("aros.gz"), arosrom_len, arosrom);
+ f = zfile_fopen_data(_T("aros.gz"), arosrom_len, arosrom);
if (!f)
return false;
- f = zfile_gunzip (f);
+ f = zfile_gunzip(f);
if (!f)
return false;
@@ -741,14 +1359,17 @@ static bool load_kickstart_replacement (void)
extendedkickmem_bank.mask = ROM_SIZE_512 - 1;
extendedkickmem_bank.label = _T("rom_e0");
extendedkickmem_type = EXTENDED_ROM_KS;
- mapped_malloc (&extendedkickmem_bank);
- read_kickstart (f, extendedkickmem_bank.baseaddr, ROM_SIZE_512, 0, 1);
+ mapped_malloc(&extendedkickmem_bank);
+ read_kickstart(f, extendedkickmem_bank.baseaddr, ROM_SIZE_512, 0, 1);
+
kickmem_bank.reserved_size = ROM_SIZE_512;
kickmem_bank.mask = ROM_SIZE_512 - 1;
- read_kickstart (f, kickmem_bank.baseaddr, ROM_SIZE_512, 1, 0);
+ read_kickstart(f, kickmem_bank.baseaddr, ROM_SIZE_512, 1, 0);
- zfile_fclose (f);
+ zfile_fclose(f);
+
+ //seriallog = -1;
// if 68000-68020 config without any other fast ram with m68k aros: enable special extra RAM.
if (currprefs.cpu_model <= 68020 &&
@@ -756,7 +1377,8 @@ static bool load_kickstart_replacement (void)
currprefs.fastmem[0].size == 0 &&
currprefs.z3fastmem[0].size == 0 &&
currprefs.mbresmem_high_size == 0 &&
- currprefs.mbresmem_low_size == 0) {
+ currprefs.mbresmem_low_size == 0 &&
+ currprefs.cpuboardmem1_size == 0) {
changed_prefs.custom_memory_addrs[0] = currprefs.custom_memory_addrs[0] = 0xa80000;
changed_prefs.custom_memory_sizes[0] = currprefs.custom_memory_sizes[0] = 512 * 1024;
@@ -764,6 +1386,7 @@ static bool load_kickstart_replacement (void)
changed_prefs.custom_memory_addrs[1] = currprefs.custom_memory_addrs[1] = 0xb00000;
changed_prefs.custom_memory_sizes[1] = currprefs.custom_memory_sizes[1] = 512 * 1024;
changed_prefs.custom_memory_mask[1] = currprefs.custom_memory_mask[1] = 0;
+
}
return true;
@@ -771,358 +1394,843 @@ static bool load_kickstart_replacement (void)
static struct zfile *get_kickstart_filehandle(struct uae_prefs *p)
{
- struct zfile *f;
- TCHAR tmprom[MAX_DPATH], tmprom2[MAX_DPATH];
+ struct zfile *f;
+ TCHAR tmprom[MAX_DPATH], tmprom2[MAX_DPATH];
- f = read_rom_name (p->romfile);
- _tcscpy (tmprom, p->romfile);
- if (f == NULL) {
- _stprintf (tmprom2, _T("%s%s"), start_path_data, p->romfile);
- f = rom_fopen (tmprom2, _T("rb"), ZFD_NORMAL);
- if (f == NULL) {
- _stprintf (p->romfile, _T("%sroms/kick.rom"), start_path_data);
- f = rom_fopen (p->romfile, _T("rb"), ZFD_NORMAL);
- if (f == NULL) {
- _stprintf (p->romfile, _T("%skick.rom"), start_path_data);
- f = rom_fopen(p->romfile, _T("rb"), ZFD_NORMAL);
- if (f == NULL)
- f = read_rom_name_guess (tmprom);
- }
- } else {
- _tcscpy (p->romfile, tmprom2);
- }
- }
+ f = read_rom_name(p->romfile);
+ _tcscpy(tmprom, p->romfile);
+ if (f == NULL) {
+ _stprintf(tmprom2, _T("%s%s"), start_path_data, p->romfile);
+ f = rom_fopen(tmprom2, _T("rb"), ZFD_NORMAL);
+ if (f == NULL) {
+ _stprintf(p->romfile, _T("%sroms/kick.rom"), start_path_data);
+ f = rom_fopen(p->romfile, _T("rb"), ZFD_NORMAL);
+ if (f == NULL) {
+ _stprintf(p->romfile, _T("%skick.rom"), start_path_data);
+ f = rom_fopen(p->romfile, _T("rb"), ZFD_NORMAL);
+ if (f == NULL) {
+ _stprintf(p->romfile, _T("%s../shared/rom/kick.rom"), start_path_data);
+ f = rom_fopen(p->romfile, _T("rb"), ZFD_NORMAL);
+ if (f == NULL) {
+ _stprintf(p->romfile, _T("%s../System/rom/kick.rom"), start_path_data);
+ f = rom_fopen(p->romfile, _T("rb"), ZFD_NORMAL);
+ if (f == NULL)
+ f = read_rom_name_guess(tmprom);
+ }
+ }
+ }
+ }
+ else {
+ _tcscpy(p->romfile, tmprom2);
+ }
+ }
return f;
}
-static int load_kickstart (void)
+static int load_kickstart(void)
{
TCHAR tmprom[MAX_DPATH];
- cloanto_rom = 0;
- if (!_tcscmp (currprefs.romfile, _T(":AROS"))) {
- return load_kickstart_replacement ();
- }
+ cloanto_rom = 0;
+ if (!_tcscmp(currprefs.romfile, _T(":AROS"))) {
+ return load_kickstart_replacement();
+ }
_tcscpy(tmprom, currprefs.romfile);
struct zfile *f = get_kickstart_filehandle(&currprefs);
- addkeydir (currprefs.romfile);
+ addkeydir(currprefs.romfile);
if (f == NULL) /* still no luck */
- goto err;
+ goto err;
- if (f != NULL) {
- int filesize, size, maxsize;
- int kspos = ROM_SIZE_512;
- int extpos = 0;
+ if (f != NULL) {
+ int filesize, size, maxsize;
+ int kspos = ROM_SIZE_512;
+ int extpos = 0;
- maxsize = ROM_SIZE_512;
- zfile_fseek (f, 0, SEEK_END);
- filesize = zfile_ftell (f);
- zfile_fseek (f, 0, SEEK_SET);
- if (filesize == 1760 * 512) {
- filesize = ROM_SIZE_256;
- maxsize = ROM_SIZE_256;
- }
- if (filesize == ROM_SIZE_512 + 8) {
- /* GVP 0xf0 kickstart */
- zfile_fseek (f, 8, SEEK_SET);
- }
- if (filesize >= ROM_SIZE_512 * 2) {
- struct romdata *rd = getromdatabyzfile(f);
- zfile_fseek (f, kspos, SEEK_SET);
- }
- if (filesize >= ROM_SIZE_512 * 4) {
- kspos = ROM_SIZE_512 * 3;
- extpos = 0;
- zfile_fseek (f, kspos, SEEK_SET);
- }
- size = read_kickstart (f, kickmem_bank.baseaddr, maxsize, 1, 0);
- if (size == 0)
- goto err;
- kickmem_bank.mask = size - 1;
- kickmem_bank.reserved_size = size;
- if (filesize >= ROM_SIZE_512 * 2 && !extendedkickmem_type) {
- extendedkickmem_bank.reserved_size = ROM_SIZE_512;
- extendedkickmem_type = EXTENDED_ROM_KS;
- extendedkickmem_bank.label = _T("rom_e0");
- extendedkickmem_bank.start = 0xe00000;
- mapped_malloc (&extendedkickmem_bank);
- zfile_fseek (f, extpos, SEEK_SET);
- read_kickstart (f, extendedkickmem_bank.baseaddr, extendedkickmem_bank.allocated_size, 0, 1);
- extendedkickmem_bank.mask = extendedkickmem_bank.allocated_size - 1;
- }
- if (filesize > ROM_SIZE_512 * 2) {
- extendedkickmem2_bank.reserved_size = ROM_SIZE_512 * 2;
- mapped_malloc (&extendedkickmem2_bank);
- zfile_fseek (f, extpos + ROM_SIZE_512, SEEK_SET);
- read_kickstart (f, extendedkickmem2_bank.baseaddr, ROM_SIZE_512, 0, 1);
- zfile_fseek (f, extpos + ROM_SIZE_512 * 2, SEEK_SET);
- read_kickstart (f, extendedkickmem2_bank.baseaddr + ROM_SIZE_512, ROM_SIZE_512, 0, 1);
- extendedkickmem2_bank.mask = extendedkickmem2_bank.allocated_size - 1;
+ maxsize = ROM_SIZE_512;
+ zfile_fseek(f, 0, SEEK_END);
+ filesize = zfile_ftell(f);
+ zfile_fseek(f, 0, SEEK_SET);
+ if (filesize == 1760 * 512) {
+ filesize = ROM_SIZE_256;
+ maxsize = ROM_SIZE_256;
+ }
+ if (filesize == ROM_SIZE_512 + 8) {
+ /* GVP 0xf0 kickstart */
+ zfile_fseek(f, 8, SEEK_SET);
+ }
+ if (filesize >= ROM_SIZE_512 * 2) {
+ struct romdata *rd = getromdatabyzfile(f);
+ zfile_fseek(f, kspos, SEEK_SET);
+ }
+ if (filesize >= ROM_SIZE_512 * 4) {
+ kspos = ROM_SIZE_512 * 3;
+ extpos = 0;
+ zfile_fseek(f, kspos, SEEK_SET);
+ }
+ size = read_kickstart(f, kickmem_bank.baseaddr, maxsize, 1, 0);
+ if (size == 0)
+ goto err;
+ kickmem_bank.mask = size - 1;
+ kickmem_bank.reserved_size = size;
+ if (filesize >= ROM_SIZE_512 * 2 && !extendedkickmem_type) {
+ extendedkickmem_bank.reserved_size = ROM_SIZE_512;
+ if (currprefs.cs_cdtvcd || currprefs.cs_cdtvram) {
+ extendedkickmem_type = EXTENDED_ROM_CDTV;
+ extendedkickmem_bank.reserved_size *= 2;
+ extendedkickmem_bank.label = _T("rom_f0");
+ extendedkickmem_bank.start = 0xf00000;
+ }
+ else {
+ extendedkickmem_type = EXTENDED_ROM_KS;
+ extendedkickmem_bank.label = _T("rom_e0");
+ extendedkickmem_bank.start = 0xe00000;
+ }
+ mapped_malloc(&extendedkickmem_bank);
+ zfile_fseek(f, extpos, SEEK_SET);
+ read_kickstart(f, extendedkickmem_bank.baseaddr, extendedkickmem_bank.allocated_size, 0, 1);
+ extendedkickmem_bank.mask = extendedkickmem_bank.allocated_size - 1;
+ }
+ if (filesize > ROM_SIZE_512 * 2) {
+ extendedkickmem2_bank.reserved_size = ROM_SIZE_512 * 2;
+ mapped_malloc(&extendedkickmem2_bank);
+ zfile_fseek(f, extpos + ROM_SIZE_512, SEEK_SET);
+ read_kickstart(f, extendedkickmem2_bank.baseaddr, ROM_SIZE_512, 0, 1);
+ zfile_fseek(f, extpos + ROM_SIZE_512 * 2, SEEK_SET);
+ read_kickstart(f, extendedkickmem2_bank.baseaddr + ROM_SIZE_512, ROM_SIZE_512, 0, 1);
+ extendedkickmem2_bank.mask = extendedkickmem2_bank.allocated_size - 1;
extendedkickmem2_bank.start = 0xa80000;
- }
- }
-
- kickstart_version = (kickmem_bank.baseaddr[12] << 8) | kickmem_bank.baseaddr[13];
- if (kickstart_version == 0xffff) {
- // 1.0-1.1 and older
- kickstart_version = (kickmem_bank.baseaddr[16] << 8) | kickmem_bank.baseaddr[17];
- if (kickstart_version > 33)
- kickstart_version = 0;
+ }
}
- zfile_fclose (f);
- return 1;
-err:
- _tcscpy (currprefs.romfile, tmprom);
- zfile_fclose (f);
- return 0;
+
+#if defined(AMIGA)
+ chk_sum:
+#endif
+
+ kickstart_version = (kickmem_bank.baseaddr[12] << 8) | kickmem_bank.baseaddr[13];
+ if (kickstart_version == 0xffff) {
+ // 1.0-1.1 and older
+ kickstart_version = (kickmem_bank.baseaddr[16] << 8) | kickmem_bank.baseaddr[17];
+ if (kickstart_version > 33)
+ kickstart_version = 0;
+ }
+ zfile_fclose(f);
+ return 1;
+ err:
+ _tcscpy(currprefs.romfile, tmprom);
+ zfile_fclose(f);
+ return 0;
}
+#ifndef NATMEM_OFFSET
-void init_mem_banks (void)
+bool mapped_malloc(addrbank *ab)
+{
+ ab->startmask = ab->start;
+ ab->baseaddr = xcalloc(uae_u8, ab->reserved_size + 4);
+ ab->allocated_size = ab->baseaddr != NULL ? ab->reserved_size : 0;
+ return ab->baseaddr != NULL;
+}
+
+void mapped_free(addrbank *ab)
+{
+ xfree(ab->baseaddr);
+ ab->allocated_size = 0;
+ ab->baseaddr = NULL;
+}
+
+#else
+
+#include
+
+shmpiece *shm_start;
+
+static void dumplist(void)
+{
+ shmpiece *x = shm_start;
+ write_log(_T("Start Dump:\n"));
+ while (x) {
+ write_log(_T("this=%p,Native %p,id %d,prev=%p,next=%p,size=0x%08x\n"),
+ x, x->native_address, x->id, x->prev, x->next, x->size);
+ x = x->next;
+ }
+ write_log(_T("End Dump:\n"));
+}
+
+static shmpiece *find_shmpiece(uae_u8 *base, bool safe)
+{
+ shmpiece *x = shm_start;
+
+ while (x && x->native_address != base)
+ x = x->next;
+ if (!x) {
+ if (safe || bogomem_aliasing)
+ return 0;
+ write_log(_T("NATMEM: Failure to find mapping at %08lx, %p\n"), base - NATMEM_OFFSET, base);
+ nocanbang();
+ return 0;
+ }
+ return x;
+}
+
+static void delete_shmmaps(uae_u32 start, uae_u32 size)
+{
+ if (!needmman())
+ return;
+
+ while (size) {
+ uae_u8 *base = mem_banks[bankindex(start)]->baseaddr;
+ if (base) {
+ shmpiece *x;
+ //base = ((uae_u8*)NATMEM_OFFSET)+start;
+
+ x = find_shmpiece(base, true);
+ if (!x)
+ return;
+
+ if (x->size > size) {
+ if (isdirectjit())
+ write_log(_T("NATMEM WARNING: size mismatch mapping at %08x (size %08x, delsize %08x)\n"), start, x->size, size);
+ size = x->size;
+ }
+
+ uae_shmdt(x->native_address);
+ size -= x->size;
+ start += x->size;
+ if (x->next)
+ x->next->prev = x->prev; /* remove this one from the list */
+ if (x->prev)
+ x->prev->next = x->next;
+ else
+ shm_start = x->next;
+ xfree(x);
+ }
+ else {
+ size -= 0x10000;
+ start += 0x10000;
+ }
+ }
+}
+
+static void add_shmmaps(uae_u32 start, Addrbank *what)
+{
+ shmpiece *x = shm_start;
+ shmpiece *y;
+ uae_u8 *base = what->baseaddr;
+
+ if (!needmman())
+ return;
+
+ if (!base)
+ return;
+
+ if (what->jit_read_flag && what->jit_write_flag)
+ return;
+
+ x = find_shmpiece(base, false);
+ if (!x)
+ return;
+
+ y = xmalloc(shmpiece, 1);
+ *y = *x;
+ base = ((uae_u8 *)NATMEM_OFFSET) + start;
+ y->native_address = (uae_u8*)uae_shmat(what, y->id, base, 0);
+ if (y->native_address == (void *)-1) {
+ write_log(_T("NATMEM: Failure to map existing at %08x (%p)\n"), start, base);
+ dumplist();
+ nocanbang();
+ return;
+ }
+ y->next = shm_start;
+ y->prev = NULL;
+ if (y->next)
+ y->next->prev = y;
+ shm_start = y;
+}
+
+#define MAPPED_MALLOC_DEBUG 0
+
+bool mapped_malloc(Addrbank *ab)
+{
+ int id;
+ void *answer;
+ shmpiece *x;
+ bool rtgmem = (ab->flags & ABFLAG_RTG) != 0;
+ static int recurse;
+
+ if (ab->allocated_size) {
+ write_log(_T("mapped_malloc with memory bank '%s' already allocated!?\n"), ab->name);
+ }
+ ab->allocated_size = 0;
+
+ if (ab->label && ab->label[0] == '*') {
+ if (ab->start == 0 || ab->start == 0xffffffff) {
+ write_log(_T("mapped_malloc(*) without start address!\n"));
+ return false;
+ }
+ }
+
+ struct uae_mman_data md = { 0 };
+ uaecptr start = ab->start;
+ if (uae_mman_info(ab, &md)) {
+ start = md.start;
+ }
+ ab->startmask = start;
+ if (!md.directsupport || (ab->flags & ABFLAG_ALLOCINDIRECT)) {
+ if (!(ab->flags & ABFLAG_ALLOCINDIRECT)) {
+ if (canbang) {
+ write_log(_T("JIT direct switched off: %s\n"), ab->name);
+ }
+ nocanbang();
+ }
+ ab->flags &= ~ABFLAG_DIRECTMAP;
+ if (ab->flags & ABFLAG_NOALLOC) {
+ ab->allocated_size = ab->reserved_size;
+#if MAPPED_MALLOC_DEBUG
+ write_log(_T("mapped_malloc noalloc %s\n"), ab->name);
+#endif
+ return true;
+ }
+ ab->baseaddr = xcalloc(uae_u8, ab->reserved_size + 4);
+ if (ab->baseaddr) {
+ // fill end of ram with ILLEGAL to catch direct PC falling out of RAM.
+ put_long_host(ab->baseaddr + ab->reserved_size, 0x4afc4afc);
+ ab->allocated_size = ab->reserved_size;
+ }
+#if MAPPED_MALLOC_DEBUG
+ write_log(_T("mapped_malloc nodirect %s %p\n"), ab->name, ab->baseaddr);
+#endif
+ return ab->baseaddr != NULL;
+ }
+
+ id = uae_shmget(UAE_IPC_PRIVATE, ab, 0x1ff);
+ if (id == -1) {
+ nocanbang();
+ if (recurse)
+ return NULL;
+ recurse++;
+ mapped_malloc(ab);
+ recurse--;
+ return ab->baseaddr != NULL;
+ }
+ if (!(ab->flags & ABFLAG_NOALLOC)) {
+ answer = uae_shmat(ab, id, 0, 0);
+ uae_shmctl(id, UAE_IPC_RMID, NULL);
+ }
+ else {
+ write_log(_T("MMAN: mapped_malloc using existing baseaddr %p\n"), ab->baseaddr);
+ answer = ab->baseaddr;
+ }
+ if (answer != (void *)-1) {
+ x = xmalloc(shmpiece, 1);
+ x->native_address = (uae_u8*)answer;
+ x->id = id;
+ x->size = ab->reserved_size;
+ x->name = ab->label;
+ x->next = shm_start;
+ x->prev = NULL;
+ if (x->next)
+ x->next->prev = x;
+ shm_start = x;
+ ab->baseaddr = x->native_address;
+ if (ab->baseaddr) {
+ if (md.hasbarrier) {
+ // fill end of ram with ILLEGAL to catch direct PC falling out of RAM.
+ put_long_host(ab->baseaddr + ab->reserved_size, 0x4afc4afc);
+ }
+ ab->allocated_size = ab->reserved_size;
+ }
+ ab->flags |= ABFLAG_DIRECTMAP;
+#if MAPPED_MALLOC_DEBUG
+ write_log(_T("mapped_malloc direct %s %p\n"), ab->name, ab->baseaddr);
+#endif
+ return ab->baseaddr != NULL;
+ }
+ if (recurse)
+ return NULL;
+ nocanbang();
+ recurse++;
+ mapped_malloc(ab);
+ recurse--;
+#if MAPPED_MALLOC_DEBUG
+ write_log(_T("mapped_malloc indirect %s %p\n"), ab->name, ab->baseaddr);
+#endif
+ return ab->baseaddr != NULL;
+}
+
+#endif
+
+static void init_mem_banks(void)
{
// unsigned so i << 16 won't overflow to negative when i >= 32768
- for (unsigned int i = 0; i < MEMORY_BANKS; i++)
- mem_banks[i] = &dummy_bank;
+ for (unsigned int i = 0; i < MEMORY_BANKS; i++)
+ put_mem_bank(i << 16, &dummy_bank, 0);
+#ifdef NATMEM_OFFSET
+ delete_shmmaps(0, 0xFFFF0000);
+#endif
}
-static bool singlebit (uae_u32 v)
+static bool singlebit(uae_u32 v)
{
while (v && !(v & 1))
v >>= 1;
return (v & ~1) == 0;
}
-static void allocate_memory (void)
+static void allocate_memory(void)
{
- mapped_free(&fakeuaebootrom_bank);
+ bogomem_aliasing = 0;
- if (chipmem_bank.reserved_size != currprefs.chipmem_size) {
- int memsize;
- mapped_free (&chipmem_bank);
- chipmem_bank.flags &= ~ABFLAG_NOALLOC;
- if (currprefs.chipmem_size > 2 * 1024 * 1024) {
- free_fastmemory (0);
+ bool bogoreset = (bogomem_bank.flags & ABFLAG_NOALLOC) != 0 &&
+ (chipmem_bank.reserved_size != currprefs.chipmem_size || bogomem_bank.reserved_size != currprefs.bogomem_size);
+
+ if (bogoreset) {
+ mapped_free(&chipmem_bank);
+ mapped_free(&bogomem_bank);
+ }
+
+ /* emulate 0.5M+0.5M with 1M Agnus chip ram aliasing */
+ if (currprefs.chipmem_size == 0x80000 && currprefs.bogomem_size >= 0x80000 &&
+ (currprefs.chipset_mask & CSMASK_ECS_AGNUS) && !(currprefs.chipset_mask & CSMASK_AGA) && currprefs.cpu_model < 68020) {
+ if ((chipmem_bank.reserved_size != currprefs.chipmem_size || bogomem_bank.reserved_size != currprefs.bogomem_size)) {
+ int memsize1, memsize2;
+ mapped_free(&chipmem_bank);
+ mapped_free(&bogomem_bank);
+ bogomem_bank.reserved_size = 0;
+ memsize1 = chipmem_bank.reserved_size = currprefs.chipmem_size;
+ memsize2 = bogomem_bank.reserved_size = currprefs.bogomem_size;
+ chipmem_bank.mask = chipmem_bank.reserved_size - 1;
+ chipmem_bank.start = chipmem_start_addr;
+ chipmem_full_mask = bogomem_bank.reserved_size * 2 - 1;
+ chipmem_full_size = 0x80000 * 2;
+ chipmem_bank.reserved_size = memsize1 + memsize2;
+ mapped_malloc(&chipmem_bank);
+ chipmem_bank.reserved_size = currprefs.chipmem_size;
+ chipmem_bank.allocated_size = currprefs.chipmem_size;
+ bogomem_bank.baseaddr = chipmem_bank.baseaddr + memsize1;
+ bogomem_bank.mask = bogomem_bank.reserved_size - 1;
+ bogomem_bank.start = bogomem_start_addr;
+ bogomem_bank.flags |= ABFLAG_NOALLOC;
+ bogomem_bank.allocated_size = bogomem_bank.reserved_size;
+ if (chipmem_bank.baseaddr == 0) {
+ write_log(_T("Fatal error: out of memory for chipmem.\n"));
+ chipmem_bank.reserved_size = 0;
+ }
+ else {
+ need_hardreset = true;
+ }
}
+ bogomem_aliasing = 1;
+ }
+ else if (currprefs.chipmem_size == 0x80000 && currprefs.bogomem_size >= 0x80000 &&
+ !(currprefs.chipset_mask & CSMASK_ECS_AGNUS) && currprefs.cs_1mchipjumper && currprefs.cpu_model < 68020) {
+ if ((chipmem_bank.reserved_size != currprefs.chipmem_size || bogomem_bank.reserved_size != currprefs.bogomem_size)) {
+ int memsize1, memsize2;
+ mapped_free(&chipmem_bank);
+ mapped_free(&bogomem_bank);
+ bogomem_bank.reserved_size = 0;
+ memsize1 = chipmem_bank.reserved_size = currprefs.chipmem_size;
+ memsize2 = bogomem_bank.reserved_size = currprefs.bogomem_size;
+ chipmem_bank.mask = chipmem_bank.reserved_size - 1;
+ chipmem_bank.start = chipmem_start_addr;
+ chipmem_full_mask = chipmem_bank.reserved_size - 1;
+ chipmem_full_size = chipmem_bank.reserved_size;
+ chipmem_bank.reserved_size = memsize1 + memsize2;
+ mapped_malloc(&chipmem_bank);
+ chipmem_bank.reserved_size = currprefs.chipmem_size;
+ chipmem_bank.allocated_size = currprefs.chipmem_size;
+ bogomem_bank.baseaddr = chipmem_bank.baseaddr + memsize1;
+ bogomem_bank.mask = bogomem_bank.reserved_size - 1;
+ bogomem_bank.start = chipmem_bank.start + currprefs.chipmem_size;
+ bogomem_bank.flags |= ABFLAG_NOALLOC;
+ if (chipmem_bank.baseaddr == 0) {
+ write_log(_T("Fatal error: out of memory for chipmem.\n"));
+ chipmem_bank.reserved_size = 0;
+ }
+ else {
+ need_hardreset = true;
+ }
+ }
+ bogomem_aliasing = 2;
+ }
- memsize = chipmem_bank.reserved_size = currprefs.chipmem_size;
- chipmem_full_mask = chipmem_bank.mask = chipmem_bank.reserved_size - 1;
+ if (chipmem_bank.reserved_size != currprefs.chipmem_size || bogoreset) {
+ int memsize;
+ mapped_free(&chipmem_bank);
+ chipmem_bank.flags &= ~ABFLAG_NOALLOC;
+
+ memsize = chipmem_bank.reserved_size = chipmem_full_size = currprefs.chipmem_size;
+ chipmem_full_mask = chipmem_bank.mask = chipmem_bank.reserved_size - 1;
chipmem_bank.start = chipmem_start_addr;
if (!currprefs.cachesize && memsize < 0x100000)
memsize = 0x100000;
- if (memsize > 0x100000 && memsize < 0x200000)
- memsize = 0x200000;
+ if (memsize > 0x100000 && memsize < 0x200000)
+ memsize = 0x200000;
chipmem_bank.reserved_size = memsize;
- mapped_malloc (&chipmem_bank);
+ mapped_malloc(&chipmem_bank);
chipmem_bank.reserved_size = currprefs.chipmem_size;
chipmem_bank.allocated_size = currprefs.chipmem_size;
if (chipmem_bank.baseaddr == 0) {
- write_log (_T("Fatal error: out of memory for chipmem.\n"));
+ write_log(_T("Fatal error: out of memory for chipmem.\n"));
chipmem_bank.reserved_size = 0;
- } else {
- need_hardreset = true;
- if (memsize > chipmem_bank.allocated_size)
- memset (chipmem_bank.baseaddr + chipmem_bank.allocated_size, 0xff, memsize - chipmem_bank.allocated_size);
- }
- currprefs.chipset_mask = changed_prefs.chipset_mask;
- chipmem_full_mask = chipmem_bank.allocated_size - 1;
- if (!currprefs.cachesize) {
- if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
- if (chipmem_bank.allocated_size < 0x100000)
- chipmem_full_mask = 0x100000 - 1;
- if (chipmem_bank.allocated_size > 0x100000 && chipmem_bank.allocated_size < 0x200000)
- chipmem_full_mask = chipmem_bank.mask = 0x200000 - 1;
- }
- }
- }
-
- if (bogomem_bank.reserved_size != currprefs.bogomem_size) {
- mapped_free (&bogomem_bank);
- bogomem_bank.reserved_size = 0;
-
- if(currprefs.bogomem_size > 0x1c0000)
- currprefs.bogomem_size = 0x1c0000;
- if (currprefs.bogomem_size > 0x180000 && ((changed_prefs.chipset_mask & CSMASK_AGA) || (currprefs.cpu_model >= 68020)))
- currprefs.bogomem_size = 0x180000;
-
- bogomem_bank.reserved_size = currprefs.bogomem_size;
- if (bogomem_bank.reserved_size >= 0x180000)
- bogomem_bank.reserved_size = 0x200000;
- bogomem_bank.mask = bogomem_bank.reserved_size - 1;
- bogomem_bank.start = bogomem_start_addr;
-
- if (bogomem_bank.reserved_size) {
- if (!mapped_malloc (&bogomem_bank)) {
- write_log (_T("Out of memory for bogomem.\n"));
- bogomem_bank.reserved_size = 0;
- }
}
- need_hardreset = true;
+ else {
+ need_hardreset = true;
+ if (memsize > chipmem_bank.allocated_size)
+ memset(chipmem_bank.baseaddr + chipmem_bank.allocated_size, 0xff, memsize - chipmem_bank.allocated_size);
+ }
+ currprefs.chipset_mask = changed_prefs.chipset_mask;
+ chipmem_full_mask = chipmem_bank.allocated_size - 1;
+ if (!currprefs.cachesize) {
+ if (currprefs.chipset_mask & CSMASK_ECS_AGNUS) {
+ if (chipmem_bank.allocated_size < 0x100000)
+ chipmem_full_mask = 0x100000 - 1;
+ if (chipmem_bank.allocated_size > 0x100000 && chipmem_bank.allocated_size < 0x200000)
+ chipmem_full_mask = chipmem_bank.mask = 0x200000 - 1;
+ }
+ else if (currprefs.cs_1mchipjumper) {
+ chipmem_full_mask = 0x80000 - 1;
+ }
+ }
+ }
+
+ if (bogomem_bank.reserved_size != currprefs.bogomem_size || bogoreset) {
+ if (!(bogomem_bank.reserved_size == 0x200000 && currprefs.bogomem_size == 0x180000)) {
+ mapped_free(&bogomem_bank);
+ bogomem_bank.flags &= ~ABFLAG_NOALLOC;
+ bogomem_bank.reserved_size = 0;
+
+ bogomem_bank.reserved_size = currprefs.bogomem_size;
+ if (bogomem_bank.reserved_size >= 0x180000)
+ bogomem_bank.reserved_size = 0x200000;
+ bogomem_bank.mask = bogomem_bank.reserved_size - 1;
+ bogomem_bank.start = bogomem_start_addr;
+
+ if (bogomem_bank.reserved_size) {
+ if (!mapped_malloc(&bogomem_bank)) {
+ write_log(_T("Out of memory for bogomem.\n"));
+ bogomem_bank.reserved_size = 0;
+ }
+ }
+ need_hardreset = true;
+ }
+ }
+ if (mem25bit_bank.reserved_size != currprefs.mem25bit_size) {
+ mapped_free(&mem25bit_bank);
+
+ mem25bit_bank.reserved_size = currprefs.mem25bit_size;
+ mem25bit_bank.mask = mem25bit_bank.reserved_size - 1;
+ mem25bit_bank.start = 0x01000000;
+ if (mem25bit_bank.reserved_size) {
+ if (!mapped_malloc(&mem25bit_bank)) {
+ write_log(_T("Out of memory for 25 bit memory.\n"));
+ mem25bit_bank.reserved_size = 0;
+ }
+ }
+ need_hardreset = true;
}
if (a3000lmem_bank.reserved_size != currprefs.mbresmem_low_size) {
- mapped_free (&a3000lmem_bank);
+ mapped_free(&a3000lmem_bank);
a3000lmem_bank.reserved_size = currprefs.mbresmem_low_size;
a3000lmem_bank.mask = a3000lmem_bank.reserved_size - 1;
a3000lmem_bank.start = 0x08000000 - a3000lmem_bank.reserved_size;
if (a3000lmem_bank.reserved_size) {
- if (!mapped_malloc (&a3000lmem_bank)) {
- write_log (_T("Out of memory for a3000lowmem.\n"));
+ if (!mapped_malloc(&a3000lmem_bank)) {
+ write_log(_T("Out of memory for a3000lowmem.\n"));
a3000lmem_bank.reserved_size = 0;
}
}
need_hardreset = true;
}
if (a3000hmem_bank.reserved_size != currprefs.mbresmem_high_size) {
- mapped_free (&a3000hmem_bank);
+ mapped_free(&a3000hmem_bank);
a3000hmem_bank.reserved_size = currprefs.mbresmem_high_size;
a3000hmem_bank.mask = a3000hmem_bank.reserved_size - 1;
a3000hmem_bank.start = 0x08000000;
if (a3000hmem_bank.reserved_size) {
- if (!mapped_malloc (&a3000hmem_bank)) {
- write_log (_T("Out of memory for a3000highmem.\n"));
+ if (!mapped_malloc(&a3000hmem_bank)) {
+ write_log(_T("Out of memory for a3000highmem.\n"));
a3000hmem_bank.reserved_size = 0;
}
}
need_hardreset = true;
}
+#ifdef CDTV
+ if (cardmem_bank.reserved_size != currprefs.cs_cdtvcard * 1024) {
+ mapped_free(&cardmem_bank);
+ cardmem_bank.baseaddr = NULL;
+
+ cardmem_bank.reserved_size = currprefs.cs_cdtvcard * 1024;
+ cardmem_bank.mask = cardmem_bank.reserved_size - 1;
+ cardmem_bank.start = 0xe00000;
+ if (cardmem_bank.reserved_size) {
+ if (!mapped_malloc(&cardmem_bank)) {
+ write_log(_T("Out of memory for cardmem.\n"));
+ cardmem_bank.reserved_size = 0;
+ }
+ }
+ cdtv_loadcardmem(cardmem_bank.baseaddr, cardmem_bank.reserved_size);
+ }
+#endif
if (custmem1_bank.reserved_size != currprefs.custom_memory_sizes[0]) {
- mapped_free (&custmem1_bank);
+ mapped_free(&custmem1_bank);
custmem1_bank.reserved_size = currprefs.custom_memory_sizes[0];
// custmem1 and 2 can have non-power of 2 size so only set correct mask if size is power of 2.
- custmem1_bank.mask = singlebit (custmem1_bank.reserved_size) ? custmem1_bank.reserved_size - 1 : -1;
+ custmem1_bank.mask = singlebit(custmem1_bank.reserved_size) ? custmem1_bank.reserved_size - 1 : -1;
custmem1_bank.start = currprefs.custom_memory_addrs[0];
if (custmem1_bank.reserved_size) {
- if (!mapped_malloc (&custmem1_bank))
+ if (!mapped_malloc(&custmem1_bank))
custmem1_bank.reserved_size = 0;
}
}
if (custmem2_bank.reserved_size != currprefs.custom_memory_sizes[1]) {
- mapped_free (&custmem2_bank);
+ mapped_free(&custmem2_bank);
custmem2_bank.reserved_size = currprefs.custom_memory_sizes[1];
- custmem2_bank.mask = singlebit (custmem2_bank.reserved_size) ? custmem2_bank.reserved_size - 1 : -1;
+ custmem2_bank.mask = singlebit(custmem2_bank.reserved_size) ? custmem2_bank.reserved_size - 1 : -1;
custmem2_bank.start = currprefs.custom_memory_addrs[1];
if (custmem2_bank.reserved_size) {
- if (!mapped_malloc (&custmem2_bank))
+ if (!mapped_malloc(&custmem2_bank))
custmem2_bank.reserved_size = 0;
}
}
- if (savestate_state == STATE_RESTORE) {
- if (bootrom_filepos) {
- protect_roms (false);
- restore_ram (bootrom_filepos, rtarea_bank.baseaddr);
- protect_roms (true);
- }
- restore_ram (chip_filepos, chipmem_bank.baseaddr);
- if (bogomem_bank.allocated_size > 0)
- restore_ram (bogo_filepos, bogomem_bank.baseaddr);
+ if (savestate_state == STATE_RESTORE) {
+ if (bootrom_filepos) {
+ protect_roms(false);
+ restore_ram(bootrom_filepos, rtarea_bank.baseaddr);
+ protect_roms(true);
+ }
+ restore_ram(chip_filepos, chipmem_bank.baseaddr);
+ if (bogomem_bank.allocated_size > 0)
+ restore_ram(bogo_filepos, bogomem_bank.baseaddr);
+ if (mem25bit_bank.allocated_size > 0)
+ restore_ram(mem25bit_filepos, mem25bit_bank.baseaddr);
if (a3000lmem_bank.allocated_size > 0)
- restore_ram (a3000lmem_filepos, a3000lmem_bank.baseaddr);
+ restore_ram(a3000lmem_filepos, a3000lmem_bank.baseaddr);
if (a3000hmem_bank.allocated_size > 0)
- restore_ram (a3000hmem_filepos, a3000hmem_bank.baseaddr);
- }
- bootrom_filepos = 0;
- chip_filepos = 0;
- bogo_filepos = 0;
+ restore_ram(a3000hmem_filepos, a3000hmem_bank.baseaddr);
+ }
+#ifdef AGA
+ chipmem_bank_ce2.baseaddr = chipmem_bank.baseaddr;
+#endif
+ bootrom_filepos = 0;
+ chip_filepos = 0;
+ bogo_filepos = 0;
a3000lmem_filepos = 0;
a3000hmem_filepos = 0;
+ //cpuboard_init();
}
-void map_overlay (int chip)
+static void fill_ce_banks(void)
{
- int size;
- addrbank *cb;
-
- int currPC = m68k_getpc();
+ int i;
- size = chipmem_bank.allocated_size >= 0x180000 ? (chipmem_bank.allocated_size >> 16) : 32;
- cb = &chipmem_bank;
- if (chip) {
- map_banks (&dummy_bank, 0, size, 0);
- map_banks (cb, 0, size, chipmem_bank.allocated_size);
- } else {
- addrbank *rb = NULL;
- if (size < 32)
- size = 32;
- cb = &get_mem_bank (0xf00000);
- if (!rb && cb && (cb->flags & ABFLAG_ROM) && get_word (0xf00000) == 0x1114)
- rb = cb;
- cb = &get_mem_bank (0xe00000);
- if (!rb && cb && (cb->flags & ABFLAG_ROM) && get_word (0xe00000) == 0x1114)
- rb = cb;
- if (!rb)
- rb = &kickmem_bank;
- map_banks (rb, 0, size, 0x80000);
- }
- if (!isrestore () && valid_address (regs.pc, 4))
- m68k_setpc_normal (currPC);
+ if (currprefs.cpu_model <= 68010) {
+ memset(ce_banktype, CE_MEMBANK_FAST16, sizeof ce_banktype);
+ }
+ else {
+ memset(ce_banktype, CE_MEMBANK_FAST32, sizeof ce_banktype);
+ }
+ // data cachable regions (2 = burst supported)
+ memset(ce_cachable, 0, sizeof ce_cachable);
+ memset(ce_cachable + (0x00c00000 >> 16), 1, currprefs.bogomem_size >> 16);
+ for (int i = 0; i < MAX_RAM_BOARDS; i++) {
+ if (fastmem_bank[i].start != 0xffffffff)
+ memset(ce_cachable + (fastmem_bank[i].start >> 16), 1 | 2, currprefs.fastmem[i].size >> 16);
+ if (z3fastmem_bank[i].start != 0xffffffff)
+ memset(ce_cachable + (z3fastmem_bank[i].start >> 16), 1 | 2, currprefs.z3fastmem[i].size >> 16);
+ }
+ memset(ce_cachable + (a3000hmem_bank.start >> 16), 1 | 2, currprefs.mbresmem_high_size >> 16);
+ memset(ce_cachable + (a3000lmem_bank.start >> 16), 1 | 2, currprefs.mbresmem_low_size >> 16);
+ memset(ce_cachable + (mem25bit_bank.start >> 16), 1 | 2, currprefs.mem25bit_size >> 16);
+
+ addrbank *ab = &get_mem_bank(0);
+ if (ab && (ab->flags & ABFLAG_CHIPRAM)) {
+ for (i = 0; i < (0x200000 >> 16); i++) {
+ ce_banktype[i] = (currprefs.cs_mbdmac || (currprefs.chipset_mask & CSMASK_AGA)) ? CE_MEMBANK_CHIP32 : CE_MEMBANK_CHIP16;
+ }
+ }
+ if (!currprefs.cs_slowmemisfast) {
+ for (i = (0xc00000 >> 16); i < (0xe00000 >> 16); i++)
+ ce_banktype[i] = ce_banktype[0];
+ for (i = (bogomem_bank.start >> 16); i < ((bogomem_bank.start + bogomem_bank.allocated_size) >> 16); i++)
+ ce_banktype[i] = ce_banktype[0];
+ }
+ for (i = (0xd00000 >> 16); i < (0xe00000 >> 16); i++)
+ ce_banktype[i] = CE_MEMBANK_CHIP16;
+ for (i = (0xa00000 >> 16); i < (0xc00000 >> 16); i++) {
+ addrbank *b;
+ ce_banktype[i] = CE_MEMBANK_CIA;
+ b = &get_mem_bank(i << 16);
+ if (b && !(b->flags & ABFLAG_CIA)) {
+ ce_banktype[i] = CE_MEMBANK_FAST32;
+ ce_cachable[i] = 1;
+ }
+ }
+ // CD32 ROM is 16-bit
+ if (currprefs.cs_cd32cd) {
+ for (i = (0xe00000 >> 16); i < (0xe80000 >> 16); i++)
+ ce_banktype[i] = CE_MEMBANK_FAST16;
+ for (i = (0xf80000 >> 16); i <= (0xff0000 >> 16); i++)
+ ce_banktype[i] = CE_MEMBANK_FAST16;
+ }
+
+ // A4000T NCR is 32-bit
+ if (is_device_rom(&currprefs, ROMTYPE_SCSI_A4000T, 0) >= 0) {
+ ce_banktype[0xdd0000 >> 16] = CE_MEMBANK_FAST32;
+ }
+
+ if (currprefs.address_space_24) {
+ for (i = 1; i < 256; i++)
+ memcpy(&ce_banktype[i * 256], &ce_banktype[0], 256);
+ }
+}
+
+void map_overlay(int chip)
+{
+ int size;
+ addrbank *cb;
+
+ size = chipmem_bank.allocated_size >= 0x180000 ? (chipmem_bank.allocated_size >> 16) : 32;
+ if (bogomem_aliasing)
+ size = 8;
+ cb = &chipmem_bank;
+#ifdef AGA
+#if 0
+ if (currprefs.cpu_cycle_exact && currprefs.cpu_model >= 68020)
+ cb = &chipmem_bank_ce2;
+#endif
+#endif
+ if (chip) {
+ map_banks(&dummy_bank, 0, size, 0);
+ if (!isdirectjit()) {
+ if ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) && bogomem_bank.allocated_size == 0) {
+ map_banks(cb, 0, size, chipmem_bank.allocated_size);
+ int start = chipmem_bank.allocated_size >> 16;
+ if (chipmem_bank.allocated_size < 0x100000) {
+ if (currprefs.cs_1mchipjumper) {
+ int dummy = (0x100000 - chipmem_bank.allocated_size) >> 16;
+ map_banks(&chipmem_dummy_bank, start, dummy, 0);
+ map_banks(&chipmem_dummy_bank, start + 16, dummy, 0);
+ }
+ }
+ else if (chipmem_bank.allocated_size < 0x200000 && chipmem_bank.allocated_size > 0x100000) {
+ int dummy = (0x200000 - chipmem_bank.allocated_size) >> 16;
+ map_banks(&chipmem_dummy_bank, start, dummy, 0);
+ }
+ }
+ else {
+ int mapsize = 32;
+ if ((chipmem_bank.allocated_size >> 16) > mapsize)
+ mapsize = chipmem_bank.allocated_size >> 16;
+ map_banks(cb, 0, mapsize, chipmem_bank.allocated_size);
+ }
+ }
+ else {
+ map_banks(cb, 0, chipmem_bank.allocated_size >> 16, 0);
+ }
+ }
+ else {
+ addrbank *rb = NULL;
+ if (size < 32 && bogomem_aliasing == 0)
+ size = 32;
+ cb = &get_mem_bank(0xf00000);
+ if (!rb && cb && (cb->flags & ABFLAG_ROM) && get_word(0xf00000) == 0x1114)
+ rb = cb;
+ cb = &get_mem_bank(0xe00000);
+ if (!rb && cb && (cb->flags & ABFLAG_ROM) && get_word(0xe00000) == 0x1114)
+ rb = cb;
+ if (!rb)
+ rb = &kickmem_bank;
+ map_banks(rb, 0, size, 0x80000);
+ }
+ fill_ce_banks();
+ //cpuboard_overlay_override();
+ if (!isrestore() && valid_address(regs.pc, 4))
+ m68k_setpc_normal(m68k_getpc());
}
static void map_banks_set(addrbank *bank, int start, int size, int realsize)
{
+ bank->startmask = start << 16;
map_banks(bank, start, size, realsize);
}
-void memory_clear (void)
+void memory_clear(void)
{
mem_hardreset = 0;
if (savestate_state == STATE_RESTORE)
return;
if (chipmem_bank.baseaddr)
- memset (chipmem_bank.baseaddr, 0, chipmem_bank.allocated_size);
+ memset(chipmem_bank.baseaddr, 0, chipmem_bank.allocated_size);
if (bogomem_bank.baseaddr)
- memset (bogomem_bank.baseaddr, 0, bogomem_bank.allocated_size);
+ memset(bogomem_bank.baseaddr, 0, bogomem_bank.allocated_size);
+ if (mem25bit_bank.baseaddr)
+ memset(mem25bit_bank.baseaddr, 0, mem25bit_bank.allocated_size);
if (a3000lmem_bank.baseaddr)
memset(a3000lmem_bank.baseaddr, 0, a3000lmem_bank.allocated_size);
if (a3000hmem_bank.baseaddr)
memset(a3000hmem_bank.baseaddr, 0, a3000hmem_bank.allocated_size);
- expansion_clear ();
+ expansion_clear();
+ //cpuboard_clear();
}
static void restore_roms(void)
{
- protect_roms (false);
- write_log (_T("ROM loader.. (%s)\n"), currprefs.romfile);
- kickstart_rom = 1;
+ roms_modified = false;
+ protect_roms(false);
+ write_log(_T("ROM loader.. (%s)\n"), currprefs.romfile);
+ kickstart_rom = 1;
+ a1000_handle_kickstart(0);
+ xfree(a1000_bootrom);
+ a1000_bootrom = 0;
+ a1000_kickstart_mode = 0;
- memcpy (currprefs.romfile, changed_prefs.romfile, sizeof currprefs.romfile);
- memcpy (currprefs.romextfile, changed_prefs.romextfile, sizeof currprefs.romextfile);
+ memcpy(currprefs.romfile, changed_prefs.romfile, sizeof currprefs.romfile);
+ memcpy(currprefs.romextfile, changed_prefs.romextfile, sizeof currprefs.romextfile);
need_hardreset = true;
- mapped_free (&extendedkickmem_bank);
- mapped_free (&extendedkickmem2_bank);
- extendedkickmem_bank.reserved_size = 0;
+ mapped_free(&extendedkickmem_bank);
+ mapped_free(&extendedkickmem2_bank);
+ extendedkickmem_bank.reserved_size = 0;
extendedkickmem2_bank.reserved_size = 0;
extendedkickmem_type = 0;
- load_extendedkickstart (currprefs.romextfile, 0);
+ load_extendedkickstart(currprefs.romextfile, 0);
+ load_extendedkickstart(currprefs.romextfile2, EXTENDED_ROM_CDTV);
kickmem_bank.mask = ROM_SIZE_512 - 1;
- if (!load_kickstart ()) {
- if (_tcslen (currprefs.romfile) > 0) {
- error_log (_T("Failed to open '%s'\n"), currprefs.romfile);
- notify_user (NUMSG_NOROM);
- }
- load_kickstart_replacement ();
- } else {
- struct romdata *rd = getromdatabydata (kickmem_bank.baseaddr, kickmem_bank.reserved_size);
- if (rd) {
- write_log (_T("Known ROM '%s' loaded\n"), rd->name);
+ if (!load_kickstart()) {
+ if (_tcslen(currprefs.romfile) > 0) {
+ error_log(_T("Failed to open '%s'\n"), currprefs.romfile);
+ notify_user(NUMSG_NOROM);
+ }
+ load_kickstart_replacement();
+ }
+ else {
+ struct romdata *rd = getromdatabydata(kickmem_bank.baseaddr, kickmem_bank.reserved_size);
+ if (rd) {
+ write_log(_T("Known ROM '%s' loaded\n"), rd->name);
+#if 1
if ((rd->cpu & 8) && changed_prefs.cpu_model < 68030) {
- notify_user (NUMSG_KS68030PLUS);
- uae_restart (-1, NULL);
- } else if ((rd->cpu & 3) == 3 && changed_prefs.cpu_model != 68030) {
- notify_user (NUMSG_KS68030);
- uae_restart (-1, NULL);
- } else if ((rd->cpu & 3) == 1 && changed_prefs.cpu_model < 68020) {
- notify_user (NUMSG_KS68EC020);
- uae_restart (-1, NULL);
- } else if ((rd->cpu & 3) == 2 && (changed_prefs.cpu_model < 68020 || changed_prefs.address_space_24)) {
- notify_user (NUMSG_KS68020);
- uae_restart (-1, NULL);
- }
- if (rd->cloanto)
- cloanto_rom = 1;
- kickstart_rom = 0;
+ notify_user(NUMSG_KS68030PLUS);
+ uae_restart(-1, NULL);
+ }
+ else if ((rd->cpu & 3) == 3 && changed_prefs.cpu_model != 68030) {
+ notify_user(NUMSG_KS68030);
+ uae_restart(-1, NULL);
+ }
+ else if ((rd->cpu & 3) == 1 && changed_prefs.cpu_model < 68020) {
+ notify_user(NUMSG_KS68EC020);
+ uae_restart(-1, NULL);
+ }
+ else if ((rd->cpu & 3) == 2 && (changed_prefs.cpu_model < 68020 || changed_prefs.address_space_24)) {
+ notify_user(NUMSG_KS68020);
+ uae_restart(-1, NULL);
+ }
+#endif
+ if (rd->cloanto)
+ cloanto_rom = 1;
+ kickstart_rom = 0;
if ((rd->type & (ROMTYPE_SPECIALKICK | ROMTYPE_KICK)) == ROMTYPE_KICK)
- kickstart_rom = 1;
+ kickstart_rom = 1;
if ((rd->cpu & 4) && currprefs.cs_compatible) {
/* A4000 ROM = need ramsey, gary and ide */
if (currprefs.cs_ramseyrev < 0)
@@ -1130,14 +2238,15 @@ static void restore_roms(void)
changed_prefs.cs_fatgaryrev = currprefs.cs_fatgaryrev = 0;
if (currprefs.cs_ide != IDE_A4000)
changed_prefs.cs_ide = currprefs.cs_ide = -1;
- }
- } else {
- write_log (_T("Unknown ROM '%s' loaded\n"), currprefs.romfile);
- }
- }
- patch_kick ();
- write_log (_T("ROM loader end\n"));
- protect_roms (true);
+ }
+ }
+ else {
+ write_log(_T("Unknown ROM '%s' loaded\n"), currprefs.romfile);
+ }
+ }
+ patch_kick();
+ write_log(_T("ROM loader end\n"));
+ protect_roms(true);
}
bool read_kickstart_version(struct uae_prefs *p)
@@ -1161,170 +2270,244 @@ bool read_kickstart_version(struct uae_prefs *p)
return true;
}
-void memory_reset (void)
+void reload_roms(void)
{
- int bnk, bnk_end;
+ if (roms_modified)
+ restore_roms();
+}
+
+void memory_restore(void)
+{
+ last_address_space_24 = currprefs.address_space_24;
+ //cpuboard_map();
+ map_banks_set(&kickmem_bank, 0xF8, 8, 0);
+}
+
+void memory_reset(void)
+{
+ int bnk, bnk_end;
bool gayleorfatgary;
-
+ //alg_flag = 0;
need_hardreset = false;
+ rom_write_enabled = true;
/* Use changed_prefs, as m68k_reset is called later. */
if (last_address_space_24 != changed_prefs.address_space_24)
need_hardreset = true;
last_address_space_24 = changed_prefs.address_space_24;
if (mem_hardreset > 2)
- memory_init ();
+ memory_init();
- be_cnt = be_recursive = 0;
- currprefs.chipmem_size = changed_prefs.chipmem_size;
- currprefs.bogomem_size = changed_prefs.bogomem_size;
+ be_cnt = 0;
+ currprefs.chipmem_size = changed_prefs.chipmem_size;
+ currprefs.bogomem_size = changed_prefs.bogomem_size;
currprefs.mbresmem_low_size = changed_prefs.mbresmem_low_size;
currprefs.mbresmem_high_size = changed_prefs.mbresmem_high_size;
currprefs.cs_ksmirror_e0 = changed_prefs.cs_ksmirror_e0;
currprefs.cs_ksmirror_a8 = changed_prefs.cs_ksmirror_a8;
currprefs.cs_ciaoverlay = changed_prefs.cs_ciaoverlay;
+ currprefs.cs_cdtvram = changed_prefs.cs_cdtvram;
+ currprefs.cs_cdtvcard = changed_prefs.cs_cdtvcard;
+ currprefs.cs_a1000ram = changed_prefs.cs_a1000ram;
currprefs.cs_ide = changed_prefs.cs_ide;
currprefs.cs_fatgaryrev = changed_prefs.cs_fatgaryrev;
currprefs.cs_ramseyrev = changed_prefs.cs_ramseyrev;
+ //cpuboard_reset();
- gayleorfatgary = ((currprefs.chipset_mask & CSMASK_AGA) || currprefs.cs_pcmcia || currprefs.cs_ide > 0) && !currprefs.cs_cd32cd;
+ gayleorfatgary = ((currprefs.chipset_mask & CSMASK_AGA) || currprefs.cs_pcmcia || currprefs.cs_ide > 0 || currprefs.cs_mbdmac) && !currprefs.cs_cd32cd;
- init_mem_banks ();
- allocate_memory ();
+ init_mem_banks();
+ allocate_memory();
+ chipmem_setindirect();
- if (mem_hardreset > 1
- || _tcscmp (currprefs.romfile, changed_prefs.romfile) != 0
- || _tcscmp (currprefs.romextfile, changed_prefs.romextfile) != 0)
- {
+ if (mem_hardreset > 1 || ((roms_modified || a1000_bootrom)) //&& is_hardreset())
+ || _tcscmp(currprefs.romfile, changed_prefs.romfile) != 0
+ || _tcscmp(currprefs.romextfile, changed_prefs.romextfile) != 0)
+ {
restore_roms();
- }
+ }
- map_banks (&custom_bank, 0xC0, 0xE0 - 0xC0, 0);
- map_banks (&cia_bank, 0xA0, 32, 0);
- if (currprefs.cs_rtc != 3)
- /* D80000 - DDFFFF not mapped (A1000 or A2000 = custom chips) */
- map_banks (&dummy_bank, 0xD8, 6, 0);
+ if ((cloanto_rom || extendedkickmem_bank.allocated_size) && currprefs.maprom && currprefs.maprom < 0x01000000) {
+ currprefs.maprom = changed_prefs.maprom = 0x00a80000;
+ if (extendedkickmem2_bank.allocated_size) // can't do if 2M ROM
+ currprefs.maprom = changed_prefs.maprom = 0;
+ }
- /* map "nothing" to 0x200000 - 0x9FFFFF (0xBEFFFF if Gayle or Fat Gary) */
- bnk = chipmem_bank.allocated_size >> 16;
- if (bnk < 0x20 + (currprefs.fastmem[0].size >> 16))
- bnk = 0x20 + (currprefs.fastmem[0].size >> 16);
+ map_banks(&custom_bank, 0xC0, 0xE0 - 0xC0, 0);
+ map_banks(&cia_bank, 0xA0, 32, 0);
+ if (!currprefs.cs_a1000ram && currprefs.cs_rtc != 3)
+ /* D80000 - DDFFFF not mapped (A1000 or A2000 = custom chips) */
+ map_banks(&dummy_bank, 0xD8, 6, 0);
+
+ /* map "nothing" to 0x200000 - 0x9FFFFF (0xBEFFFF if Gayle or Fat Gary) */
+ bnk = chipmem_bank.allocated_size >> 16;
+ if (bnk < 0x20 + (currprefs.fastmem[0].size >> 16))
+ bnk = 0x20 + (currprefs.fastmem[0].size >> 16);
bnk_end = currprefs.cs_cd32cd ? 0xBE : (gayleorfatgary ? 0xBF : 0xA0);
- map_banks (&dummy_bank, bnk, bnk_end - bnk, 0);
- if (gayleorfatgary) {
- // a3000 or a4000 = custom chips from 0xc0 to 0xd0
- if (currprefs.cs_ide == IDE_A4000)
- map_banks (&dummy_bank, 0xd0, 8, 0);
+ map_banks(&dummy_bank, bnk, bnk_end - bnk, 0);
+ if (gayleorfatgary) {
+ // a3000 or a4000 = custom chips from 0xc0 to 0xd0
+ if (currprefs.cs_ide == IDE_A4000 || currprefs.cs_mbdmac)
+ map_banks(&dummy_bank, 0xd0, 8, 0);
else
- map_banks (&dummy_bank, 0xc0, 0xd8 - 0xc0, 0);
- } else if (currprefs.cs_cd32cd) {
+ map_banks(&dummy_bank, 0xc0, 0xd8 - 0xc0, 0);
+ }
+ else if (currprefs.cs_cd32cd) {
// CD32: 0xc0 to 0xd0
map_banks(&dummy_bank, 0xd0, 8, 0);
// strange 64k custom mirror
map_banks(&custom_bank, 0xb9, 1, 0);
- }
-
- if (bogomem_bank.baseaddr) {
- int t = currprefs.bogomem_size >> 16;
- if (t > 0x1C)
- t = 0x1C;
- if (t > 0x18 && ((currprefs.chipset_mask & CSMASK_AGA) || (currprefs.cpu_model >= 68020 && !currprefs.address_space_24)))
- t = 0x18;
- map_banks (&bogomem_bank, 0xC0, t, 0);
- }
- if (currprefs.cs_ide || currprefs.cs_pcmcia) {
- if (currprefs.cs_ide == IDE_A600A1200 || currprefs.cs_pcmcia) {
- map_banks (&gayle_bank, 0xD8, 6, 0);
- map_banks (&gayle2_bank, 0xDD, 2, 0);
- }
- gayle_map_pcmcia ();
- if (currprefs.cs_ide == IDE_A4000)
- map_banks (&gayle_bank, 0xDD, 1, 0);
- if (currprefs.cs_ide < 0 && !currprefs.cs_pcmcia)
- map_banks (&gayle_bank, 0xD8, 6, 0);
- if (currprefs.cs_ide < 0)
- map_banks (&gayle_bank, 0xDD, 1, 0);
- }
- if (currprefs.cs_rtc == 3) // A2000 clock
- map_banks (&clock_bank, 0xD8, 4, 0);
- if (currprefs.cs_rtc == 1 || currprefs.cs_rtc == 2)
- map_banks (&clock_bank, 0xDC, 1, 0);
- else if (currprefs.cs_ksmirror_a8 || currprefs.cs_ide > 0 || currprefs.cs_pcmcia)
- map_banks (&clock_bank, 0xDC, 1, 0); /* none clock */
- if (currprefs.cs_fatgaryrev >= 0 || currprefs.cs_ramseyrev >= 0)
- map_banks (&mbres_bank, 0xDE, 1, 0);
-#ifdef CD32
- if (currprefs.cs_cd32c2p || currprefs.cs_cd32cd || currprefs.cs_cd32nvram) {
- map_banks (&akiko_bank, AKIKO_BASE >> 16, 1, 0);
- map_banks (&gayle2_bank, 0xDD, 2, 0);
}
-#endif
+ if (bogomem_bank.baseaddr) {
+ int t = currprefs.bogomem_size >> 16;
+ if (t > 0x1C)
+ t = 0x1C;
+ if (t > 0x18 && ((currprefs.chipset_mask & CSMASK_AGA) || (currprefs.cpu_model >= 68020 && !currprefs.address_space_24)))
+ t = 0x18;
+ if (bogomem_aliasing == 2)
+ map_banks(&bogomem_bank, 0x08, t, 0);
+ else
+ map_banks(&bogomem_bank, 0xC0, t, 0);
+ }
+ //if (currprefs.cs_ide || currprefs.cs_pcmcia) {
+ // if (currprefs.cs_ide == IDE_A600A1200 || currprefs.cs_pcmcia) {
+ // map_banks(&gayle_bank, 0xD8, 6, 0);
+ // map_banks(&gayle2_bank, 0xDD, 2, 0);
+ // }
+ // //gayle_map_pcmcia();
+ // if (currprefs.cs_ide == IDE_A4000 || is_device_rom(&currprefs, ROMTYPE_SCSI_A4000T, 0))
+ // map_banks(&gayle_bank, 0xDD, 1, 0);
+ // if (currprefs.cs_ide < 0 && !currprefs.cs_pcmcia)
+ // map_banks(&gayle_bank, 0xD8, 6, 0);
+ // if (currprefs.cs_ide < 0)
+ // map_banks(&gayle_bank, 0xDD, 1, 0);
+ //}
+ if (currprefs.cs_rtc == 3) // A2000 clock
+ map_banks(&clock_bank, 0xD8, 4, 0);
+ if (currprefs.cs_rtc == 1 || currprefs.cs_rtc == 2 || currprefs.cs_cdtvram)
+ map_banks(&clock_bank, 0xDC, 1, 0);
+ else if (currprefs.cs_ksmirror_a8 || currprefs.cs_ide > 0 || currprefs.cs_pcmcia)
+ map_banks(&clock_bank, 0xDC, 1, 0); /* none clock */
+ //if (currprefs.cs_fatgaryrev >= 0 || currprefs.cs_ramseyrev >= 0)
+ // map_banks(&mbres_bank, 0xDE, 1, 0);
+#ifdef CD32
+ //if (currprefs.cs_cd32c2p || currprefs.cs_cd32cd || currprefs.cs_cd32nvram) {
+ // map_banks(&akiko_bank, AKIKO_BASE >> 16, 1, 0);
+ // map_banks(&gayle2_bank, 0xDD, 2, 0);
+ //}
+#endif
+ if (mem25bit_bank.baseaddr)
+ map_banks(&mem25bit_bank, mem25bit_bank.start >> 16, mem25bit_bank.allocated_size >> 16, 0);
if (a3000lmem_bank.baseaddr)
map_banks(&a3000lmem_bank, a3000lmem_bank.start >> 16, a3000lmem_bank.allocated_size >> 16, 0);
if (a3000hmem_bank.baseaddr)
map_banks(&a3000hmem_bank, a3000hmem_bank.start >> 16, a3000hmem_bank.allocated_size >> 16, 0);
- map_banks_set(&kickmem_bank, 0xF8, 8, 0);
- /* map beta Kickstarts at 0x200000/0xC00000/0xF00000 */
- if (kickmem_bank.baseaddr[0] == 0x11 && kickmem_bank.baseaddr[2] == 0x4e && kickmem_bank.baseaddr[3] == 0xf9 && kickmem_bank.baseaddr[4] == 0x00) {
- uae_u32 addr = kickmem_bank.baseaddr[5];
+#ifdef CDTV
+ if (cardmem_bank.baseaddr)
+ map_banks(&cardmem_bank, cardmem_bank.start >> 16, cardmem_bank.allocated_size >> 16, 0);
+#endif
+ //cpuboard_map();
+ map_banks_set(&kickmem_bank, 0xF8, 8, 0);
+ if (currprefs.maprom) {
+ //if (!cpuboard_maprom())
+ map_banks_set(&kickram_bank, currprefs.maprom >> 16, extendedkickmem2_bank.allocated_size ? 32 : (extendedkickmem_bank.allocated_size ? 16 : 8), 0);
+ }
+ /* map beta Kickstarts at 0x200000/0xC00000/0xF00000 */
+ if (kickmem_bank.baseaddr[0] == 0x11 && kickmem_bank.baseaddr[2] == 0x4e && kickmem_bank.baseaddr[3] == 0xf9 && kickmem_bank.baseaddr[4] == 0x00) {
+ uae_u32 addr = kickmem_bank.baseaddr[5];
if (addr == 0x20 && currprefs.chipmem_size <= 0x200000 && currprefs.fastmem[0].size == 0)
- map_banks_set(&kickmem_bank, addr, 8, 0);
+ map_banks_set(&kickmem_bank, addr, 8, 0);
if (addr == 0xC0 && currprefs.bogomem_size == 0)
- map_banks_set(&kickmem_bank, addr, 8, 0);
- if (addr == 0xF0)
- map_banks_set(&kickmem_bank, addr, 8, 0);
- }
+ map_banks_set(&kickmem_bank, addr, 8, 0);
+ if (addr == 0xF0)
+ map_banks_set(&kickmem_bank, addr, 8, 0);
+ }
+
+ if (a1000_bootrom)
+ a1000_handle_kickstart(1);
#ifdef AUTOCONFIG
expansion_map();
#endif
- /* Map the chipmem into all of the lower 8MB */
- map_overlay (1);
+ if (a3000_f0)
+ map_banks_set(&extendedkickmem_bank, 0xf0, 1, 0);
- switch (extendedkickmem_type) {
- case EXTENDED_ROM_KS:
- map_banks_set(&extendedkickmem_bank, 0xE0, 8, 0);
- break;
-#ifdef CD32
- case EXTENDED_ROM_CD32:
- map_banks_set(&extendedkickmem_bank, 0xE0, 8, 0);
- break;
+ /* Map the chipmem into all of the lower 8MB */
+ map_overlay(1);
+
+ switch (extendedkickmem_type) {
+ case EXTENDED_ROM_KS:
+ map_banks_set(&extendedkickmem_bank, 0xE0, 8, 0);
+ break;
+#ifdef CDTV
+ case EXTENDED_ROM_CDTV:
+ map_banks_set(&extendedkickmem_bank, 0xF0, extendedkickmem_bank.allocated_size == 2 * ROM_SIZE_512 ? 16 : 8, 0);
+ break;
#endif
- }
+#ifdef CD32
+ case EXTENDED_ROM_CD32:
+ map_banks_set(&extendedkickmem_bank, 0xE0, 8, 0);
+ break;
+#endif
+ case EXTENDED_ROM_ALG:
+ map_banks_set(&extendedkickmem_bank, 0xF0, 4, 0);
+ //alg_map_banks();
+ break;
+ }
#ifdef AUTOCONFIG
- if (need_uae_boot_rom (&currprefs))
- map_banks_set(&rtarea_bank, rtarea_base >> 16, 1, 0);
+ if (need_uae_boot_rom(&currprefs) && currprefs.uaeboard < 2)
+ map_banks_set(&rtarea_bank, rtarea_base >> 16, 1, 0);
#endif
- if ((cloanto_rom || currprefs.cs_ksmirror_e0) && !extendedkickmem_type) {
- map_banks (&kickmem_bank, 0xE0, 8, 0);
- }
+ if ((cloanto_rom || currprefs.cs_ksmirror_e0) && (currprefs.maprom != 0xe00000) && !extendedkickmem_type) {
+ map_banks(&kickmem_bank, 0xE0, 8, 0);
+ }
if (currprefs.cs_ksmirror_a8) {
if (extendedkickmem2_bank.allocated_size) {
map_banks_set(&extendedkickmem2_bank, 0xa8, 16, 0);
- } else {
- struct romdata *rd = getromdatabypath (currprefs.cartfile);
- if (!rd || rd->id != 63) {
- if (extendedkickmem_type == EXTENDED_ROM_CD32 || extendedkickmem_type == EXTENDED_ROM_KS)
- map_banks (&extendedkickmem_bank, 0xb0, 8, 0);
- else
- map_banks (&kickmem_bank, 0xb0, 8, 0);
- map_banks (&kickmem_bank, 0xa8, 8, 0);
- }
- }
- }
+ }
+ else {
+ struct romdata *rd = getromdatabypath(currprefs.cartfile);
+ if (!rd || rd->id != 63) {
+ if (extendedkickmem_type == EXTENDED_ROM_CD32 || extendedkickmem_type == EXTENDED_ROM_KS)
+ map_banks(&extendedkickmem_bank, 0xb0, 8, 0);
+ else
+ map_banks(&kickmem_bank, 0xb0, 8, 0);
+ map_banks(&kickmem_bank, 0xa8, 8, 0);
+ }
+ }
+ }
+
+#ifdef ARCADIA
+ if (is_arcadia_rom(currprefs.romextfile) == ARCADIA_BIOS) {
+ if (_tcscmp(currprefs.romextfile, changed_prefs.romextfile) != 0)
+ memcpy(currprefs.romextfile, changed_prefs.romextfile, sizeof currprefs.romextfile);
+ if (_tcscmp(currprefs.cartfile, changed_prefs.cartfile) != 0)
+ memcpy(currprefs.cartfile, changed_prefs.cartfile, sizeof currprefs.cartfile);
+ arcadia_unmap();
+ is_arcadia_rom(currprefs.romextfile);
+ is_arcadia_rom(currprefs.cartfile);
+ arcadia_map_banks();
+ }
+#endif
#ifdef ACTION_REPLAY
- action_replay_memory_reset ();
+#ifdef ARCADIA
+ if (!arcadia_bios) {
+#endif
+ action_replay_memory_reset();
+#ifdef ARCADIA
+ }
+#endif
#endif
for (int i = 0; i < 2; i++) {
if (currprefs.custom_memory_sizes[i]) {
- map_banks (i == 0 ? &custmem1_bank : &custmem2_bank,
+ map_banks(i == 0 ? &custmem1_bank : &custmem2_bank,
currprefs.custom_memory_addrs[i] >> 16,
currprefs.custom_memory_sizes[i] >> 16, 0);
if (currprefs.custom_memory_mask[i]) {
@@ -1336,79 +2519,102 @@ void memory_reset (void)
}
if (mem_hardreset) {
- memory_clear ();
+ memory_clear();
}
- write_log (_T("memory init end\n"));
+ write_log(_T("memory init end\n"));
}
-void memory_init (void)
+void memory_init(void)
{
- init_mem_banks ();
- virtualdevice_init ();
+ init_mem_banks();
+ virtualdevice_init();
- chipmem_bank.reserved_size = 0;
- bogomem_bank.reserved_size = 0;
- kickmem_bank.baseaddr = NULL;
- extendedkickmem_bank.baseaddr = NULL;
- extendedkickmem_bank.reserved_size = 0;
- extendedkickmem2_bank.baseaddr = NULL;
- extendedkickmem2_bank.reserved_size = 0;
- extendedkickmem_type = 0;
- chipmem_bank.baseaddr = 0;
+ chipmem_bank.reserved_size = 0;
+ bogomem_bank.reserved_size = 0;
+ kickmem_bank.baseaddr = NULL;
+ extendedkickmem_bank.baseaddr = NULL;
+ extendedkickmem_bank.reserved_size = 0;
+ extendedkickmem2_bank.baseaddr = NULL;
+ extendedkickmem2_bank.reserved_size = 0;
+ extendedkickmem_type = 0;
+ chipmem_bank.baseaddr = 0;
+ mem25bit_bank.reserved_size = mem25bit_bank.reserved_size = 0;
a3000lmem_bank.reserved_size = a3000hmem_bank.reserved_size = 0;
a3000lmem_bank.baseaddr = a3000hmem_bank.baseaddr = NULL;
- bogomem_bank.baseaddr = NULL;
+ bogomem_bank.baseaddr = NULL;
+ cardmem_bank.baseaddr = NULL;
custmem1_bank.reserved_size = custmem2_bank.reserved_size = 0;
custmem1_bank.baseaddr = NULL;
custmem2_bank.baseaddr = NULL;
kickmem_bank.reserved_size = ROM_SIZE_512;
- mapped_malloc (&kickmem_bank);
- memset (kickmem_bank.baseaddr, 0, ROM_SIZE_512);
- _tcscpy (currprefs.romfile, _T(""));
- currprefs.romextfile[0] = 0;
+ mapped_malloc(&kickmem_bank);
+ memset(kickmem_bank.baseaddr, 0, ROM_SIZE_512);
+ _tcscpy(currprefs.romfile, _T(""));
+ currprefs.romextfile[0] = 0;
+ //cpuboard_reset();
#ifdef ACTION_REPLAY
- action_replay_unload (0);
- action_replay_load ();
- action_replay_init (1);
+ action_replay_unload(0);
+ action_replay_load();
+ action_replay_init(1);
#ifdef ACTION_REPLAY_HRTMON
- hrtmon_load ();
+ hrtmon_load();
#endif
#endif
}
-void memory_cleanup (void)
+void memory_cleanup(void)
{
+ mapped_free(&mem25bit_bank);
mapped_free(&a3000lmem_bank);
mapped_free(&a3000hmem_bank);
- mapped_free (&bogomem_bank);
- mapped_free (&kickmem_bank);
- mapped_free (&chipmem_bank);
- mapped_free (&custmem1_bank);
- mapped_free (&custmem2_bank);
- mapped_free(&fakeuaebootrom_bank);
-
- bogomem_bank.baseaddr = NULL;
- kickmem_bank.baseaddr = NULL;
+ mapped_free(&bogomem_bank);
+ mapped_free(&kickmem_bank);
+ xfree(a1000_bootrom);
+ mapped_free(&chipmem_bank);
+#ifdef CDTV
+ if (cardmem_bank.baseaddr) {
+ cdtv_savecardmem(cardmem_bank.baseaddr, cardmem_bank.allocated_size);
+ mapped_free(&cardmem_bank);
+ }
+#endif
+ mapped_free(&custmem1_bank);
+ mapped_free(&custmem2_bank);
+
+ bogomem_bank.baseaddr = NULL;
+ kickmem_bank.baseaddr = NULL;
+ mem25bit_bank.baseaddr = NULL;
a3000lmem_bank.baseaddr = a3000hmem_bank.baseaddr = NULL;
- chipmem_bank.baseaddr = NULL;
+ a1000_bootrom = NULL;
+ a1000_kickstart_mode = 0;
+ chipmem_bank.baseaddr = NULL;
+ cardmem_bank.baseaddr = NULL;
custmem1_bank.baseaddr = NULL;
custmem2_bank.baseaddr = NULL;
-
+
+ //cpuboard_cleanup();
#ifdef ACTION_REPLAY
action_replay_cleanup();
#endif
+#ifdef ARCADIA
+ arcadia_unmap();
+#endif
}
-void memory_hardreset (int mode)
+void set_roms_modified(void)
+{
+ roms_modified = true;
+}
+
+void memory_hardreset(int mode)
{
if (mode + 1 > mem_hardreset)
mem_hardreset = mode + 1;
}
// do not map if it conflicts with custom banks
-void map_banks_cond (addrbank *bank, int start, int size, int realsize)
+void map_banks_cond(addrbank *bank, int start, int size, int realsize)
{
for (int i = 0; i < MAX_CUSTOM_MEMORY_ADDRS; i++) {
int cstart = currprefs.custom_memory_addrs[i] >> 16;
@@ -1422,61 +2628,221 @@ void map_banks_cond (addrbank *bank, int start, int size, int realsize)
if (cstart <= start && (cstart + size >= start || start + size > cstart))
return;
}
- map_banks (bank, start, size, realsize);
+ map_banks(bank, start, size, realsize);
}
-static void map_banks2 (addrbank *bank, int start, int size, int realsize, int quick)
+#ifdef WITH_THREADED_CPU
+
+struct addrbank_thread {
+ Addrbank *orig;
+ Addrbank ab;
+};
+
+#define MAX_THREAD_BANKS 200
+static addrbank_thread *thread_banks[MAX_THREAD_BANKS];
+static Addrbank *thread_mem_banks[MEMORY_BANKS];
+static int thread_banks_used;
+
+static void REGPARAM2 threadcpu_lput(uaecptr addr, uae_u32 l)
{
- int bnr;
- unsigned long int hioffs = 0, endhioffs = 0x100;
- uae_u32 realstart = start;
+ cpu_semaphore_get();
+ thread_mem_banks[bankindex(addr)]->lput(addr, l);
+ cpu_semaphore_release();
+}
- flush_icache_hard (3); /* Sure don't want to keep any old mappings around! */
+static void REGPARAM2 threadcpu_wput(uaecptr addr, uae_u32 w)
+{
+ cpu_semaphore_get();
+ thread_mem_banks[bankindex(addr)]->wput(addr, w);
+ cpu_semaphore_release();
+}
- if (!realsize)
- realsize = size << 16;
+static void REGPARAM2 threadcpu_bput(uaecptr addr, uae_u32 b)
+{
+ cpu_semaphore_get();
+ thread_mem_banks[bankindex(addr)]->bput(addr, b);
+ cpu_semaphore_release();
+}
+static uae_u32 REGPARAM2 threadcpu_lget(uaecptr addr)
+{
+ cpu_semaphore_get();
+ uae_u32 v = thread_mem_banks[bankindex(addr)]->lget(addr);
+ cpu_semaphore_release();
+ return v;
+}
+static uae_u32 REGPARAM2 threadcpu_wget(uaecptr addr)
+{
+ cpu_semaphore_get();
+ uae_u32 v = thread_mem_banks[bankindex(addr)]->wget(addr);
+ cpu_semaphore_release();
+ return v;
+}
+uae_u32 REGPARAM2 threadcpu_bget(uaecptr addr)
+{
+ cpu_semaphore_get();
+ uae_u32 v = thread_mem_banks[bankindex(addr)]->bget(addr);
+ cpu_semaphore_release();
+ return v;
+}
- if ((size << 16) < realsize) {
- write_log (_T("Broken mapping, size=%x, realsize=%x\nStart is %x\n"),
- size, realsize, start);
- }
+static Addrbank *get_bank_cpu_thread(Addrbank *bank)
+{
+ if (bank->flags & ABFLAG_THREADSAFE)
+ return bank;
+ if (bank == &dummy_bank)
+ return bank;
+
+ for (int i = 0; i < thread_banks_used; i++) {
+ if (thread_banks[i]->orig == bank) {
+ return &thread_banks[i]->ab;
+ }
+ }
+ struct addrbank_thread *at = thread_banks[thread_banks_used];
+ if (!at)
+ at = xcalloc(addrbank_thread, 1);
+ thread_banks[thread_banks_used++] = at;
+ at->orig = bank;
+ memcpy(&at->ab, bank, sizeof Addrbank);
+ Addrbank *tb = &at->ab;
+ tb->lget = threadcpu_lget;
+ tb->wget = threadcpu_wget;
+ tb->bget = threadcpu_bget;
+ tb->lput = threadcpu_lput;
+ tb->wput = threadcpu_wput;
+ tb->bput = threadcpu_bput;
+ // wgeti/lgeti should always point to real RAM
+ return tb;
+}
+#endif
+
+static void map_banks2(addrbank *bank, int start, int size, int realsize, int quick)
+{
+ int bnr, old;
+ unsigned long int hioffs = 0, endhioffs = 0x100;
+ uae_u32 realstart = start;
+ addrbank *orig_bank = NULL;
+
+#ifdef WITH_THREADED_CPU
+ if (currprefs.cpu_thread) {
+ Addrbank *b = bank;
+ bank = get_bank_cpu_thread(bank);
+ if (b != bank)
+ orig_bank = b;
+ }
+#endif
+
+ //if (quick <= 0)
+ // old = debug_bankchange(-1);
+ flush_icache_hard(0, 3); /* Sure don't want to keep any old mappings around! */
+#ifdef NATMEM_OFFSET
+ if (!quick)
+ delete_shmmaps(start << 16, size << 16);
+#endif
+
+ if (!realsize)
+ realsize = size << 16;
+
+ if ((size << 16) < realsize) {
+ write_log(_T("Broken mapping, size=%x, realsize=%x\nStart is %x\n"),
+ size, realsize, start);
+ }
#ifndef ADDRESS_SPACE_24BIT
- if (start >= 0x100) {
- for (bnr = start; bnr < start + size; bnr++) {
- mem_banks[bnr] = bank;
- }
- return;
- }
+ if (start >= 0x100) {
+ int real_left = 0;
+ for (bnr = start; bnr < start + size; bnr++) {
+ if (!real_left) {
+ realstart = bnr;
+ real_left = realsize >> 16;
+#ifdef NATMEM_OFFSET
+ if (!quick)
+ add_shmmaps(realstart << 16, bank);
#endif
- if (last_address_space_24)
- endhioffs = 0x10000;
+ }
+ put_mem_bank(bnr << 16, bank, realstart << 16);
+#ifdef WITH_THREADED_CPU
+ if (currprefs.cpu_thread) {
+ if (orig_bank)
+ put_mem_bank(bnr << 16, orig_bank, realstart << 16);
+ thread_mem_banks[bnr] = orig_bank;
+ }
+#endif
+ real_left--;
+ }
+ //if (quick <= 0)
+ // debug_bankchange(old);
+ return;
+ }
+#endif
+ if (last_address_space_24)
+ endhioffs = 0x10000;
#ifdef ADDRESS_SPACE_24BIT
- endhioffs = 0x100;
+ endhioffs = 0x100;
#endif
- for (hioffs = 0; hioffs < endhioffs; hioffs += 0x100) {
- for (bnr = start; bnr < start + size; bnr++) {
- mem_banks[bnr + hioffs] = bank;
- }
- }
+ for (hioffs = 0; hioffs < endhioffs; hioffs += 0x100) {
+ int real_left = 0;
+ for (bnr = start; bnr < start + size; bnr++) {
+ if (!real_left) {
+ realstart = bnr + hioffs;
+ real_left = realsize >> 16;
+#ifdef NATMEM_OFFSET
+ if (!quick)
+ add_shmmaps(realstart << 16, bank);
+#endif
+ }
+ put_mem_bank((bnr + hioffs) << 16, bank, realstart << 16);
+#ifdef WITH_THREADED_CPU
+ if (currprefs.cpu_thread) {
+ if (orig_bank)
+ put_mem_bank((bnr + hioffs) << 16, bank, realstart << 16);
+ thread_mem_banks[bnr + hioffs] = orig_bank;
+ }
+#endif
+ real_left--;
+ }
+ }
+ //if (quick <= 0)
+ // debug_bankchange(old);
+ fill_ce_banks();
}
-void map_banks (addrbank *bank, int start, int size, int realsize)
+static addrbank *highram_temp_bank[65536 - 0x100];
+
+void restore_banks(void)
+{
+ for (int bnr = 0x100; bnr < 65536; bnr++) {
+ if (highram_temp_bank[bnr - 0x100]) {
+ map_banks(highram_temp_bank[bnr - 0x100], bnr, 1, 0);
+ }
+ else {
+ map_banks(&dummy_bank, bnr, 1, 0);
+ }
+ }
+}
+
+void map_banks(addrbank *bank, int start, int size, int realsize)
{
if (start == 0xffffffff)
return;
if (start >= 0x100) {
+ int real_left = 0;
+ for (int bnr = start; bnr < start + size; bnr++) {
+ highram_temp_bank[bnr - 0x100] = bank;
+ }
if (currprefs.address_space_24)
return;
}
- map_banks2 (bank, start, size, realsize, 0);
+ map_banks2(bank, start, size, realsize, 0);
+#ifdef WITH_PPC
+ ppc_generate_map_banks(bank, start, size);
+#endif
}
bool validate_banks_z3(addrbank *bank, int start, int size)
{
if (start < 0x1000 || size <= 0) {
error_log(_T("Z3 invalid map_banks(%s) start=%08x size=%08x\n"), bank->name, start << 16, size << 16);
- cpu_halt(CPU_HALT_AUTOCONFIG_CONFLICT);
+ cpu_halt(7);
return false;
}
if (size > 0x4000 || start + size > 0xf000) {
@@ -1504,25 +2870,26 @@ bool validate_banks_z2(addrbank *bank, int start, int size)
{
if (start < 0x20 || (start >= 0xa0 && start < 0xe9) || start >= 0xf0) {
error_log(_T("Z2 map_banks(%s) with invalid start address %08X\n"), bank->name, start << 16);
- cpu_halt(CPU_HALT_AUTOCONFIG_CONFLICT);
+ cpu_halt(7);
return false;
}
if (start >= 0xe9) {
if (start + size > 0xf0) {
error_log(_T("Z2 map_banks(%s) with invalid region %08x - %08X\n"), bank->name, start << 16, (start + size) << 16);
- cpu_halt(CPU_HALT_AUTOCONFIG_CONFLICT);
+ cpu_halt(7);
return false;
}
- } else {
+ }
+ else {
if (start + size > 0xa0) {
error_log(_T("Z2 map_banks(%s) with invalid region %08x - %08X\n"), bank->name, start << 16, (start + size) << 16);
- cpu_halt(CPU_HALT_AUTOCONFIG_CONFLICT);
+ cpu_halt(7);
return false;
}
}
if (size <= 0 || size > 0x80) {
error_log(_T("Z2 map_banks(%s) with invalid size %08x\n"), bank->name, size);
- cpu_halt(CPU_HALT_AUTOCONFIG_CONFLICT);
+ cpu_halt(7);
return false;
}
for (int i = start; i < start + size; i++) {
@@ -1536,16 +2903,37 @@ bool validate_banks_z2(addrbank *bank, int start, int size)
}
-void map_banks_z2 (addrbank *bank, int start, int size)
+void map_banks_z2(addrbank *bank, int start, int size)
{
if (!validate_banks_z2(bank, start, size))
return;
- map_banks (bank, start, size, 0);
+ map_banks(bank, start, size, 0);
}
-void map_banks_quick (addrbank *bank, int start, int size, int realsize)
+uae_u32 map_banks_z2_autosize(addrbank *bank, int start)
{
- map_banks2 (bank, start, size, realsize, 1);
+ uae_u32 size = expansion_board_size(bank);
+ if (!size) {
+ error_log(_T("Z2 map_banks(%s) %08x, invalid size!\n"), bank->name, start << 16);
+ return 0;
+ }
+ map_banks_z2(bank, start, size >> 16);
+ return size;
+}
+
+void map_banks_quick(addrbank *bank, int start, int size, int realsize)
+{
+ map_banks2(bank, start, size, realsize, 1);
+#ifdef WITH_PPC
+ ppc_generate_map_banks(bank, start, size);
+#endif
+}
+void map_banks_nojitdirect(addrbank *bank, int start, int size, int realsize)
+{
+ map_banks2(bank, start, size, realsize, -1);
+#ifdef WITH_PPC
+ ppc_generate_map_banks(bank, start, size);
+#endif
}
#ifdef SAVESTATE
@@ -1555,250 +2943,257 @@ void map_banks_quick (addrbank *bank, int start, int size, int realsize)
uae_u8 *save_bootrom(int *len)
{
if (!uae_boot_rom_type)
- return 0;
- *len = uae_boot_rom_size;
+ return 0;
+ *len = uae_boot_rom_size;
return rtarea_bank.baseaddr;
}
-uae_u8 *save_cram (int *len)
+uae_u8 *save_cram(int *len)
{
- *len = chipmem_bank.allocated_size;
- return chipmem_bank.baseaddr;
+ *len = chipmem_bank.allocated_size;
+ return chipmem_bank.baseaddr;
}
-uae_u8 *save_bram (int *len)
+uae_u8 *save_bram(int *len)
{
- *len = bogomem_bank.allocated_size;
- return bogomem_bank.baseaddr;
+ *len = bogomem_bank.allocated_size;
+ return bogomem_bank.baseaddr;
}
-uae_u8 *save_a3000lram (int *len)
+static uae_u8 *save_mem25bitram(int *len)
+{
+ *len = mem25bit_bank.allocated_size;
+ return mem25bit_bank.baseaddr;
+}
+
+uae_u8 *save_a3000lram(int *len)
{
*len = a3000lmem_bank.allocated_size;
return a3000lmem_bank.baseaddr;
}
-uae_u8 *save_a3000hram (int *len)
+uae_u8 *save_a3000hram(int *len)
{
*len = a3000hmem_bank.allocated_size;
return a3000hmem_bank.baseaddr;
}
-void restore_bootrom (int len, size_t filepos)
+void restore_bootrom(int len, size_t filepos)
{
- bootrom_filepos = filepos;
+ bootrom_filepos = filepos;
}
-void restore_cram (int len, size_t filepos)
+void restore_cram(int len, size_t filepos)
{
- chip_filepos = filepos;
- changed_prefs.chipmem_size = len;
+ chip_filepos = filepos;
+ changed_prefs.chipmem_size = len;
}
-void restore_bram (int len, size_t filepos)
+void restore_bram(int len, size_t filepos)
{
- bogo_filepos = filepos;
- changed_prefs.bogomem_size = len;
+ bogo_filepos = filepos;
+ changed_prefs.bogomem_size = len;
}
-void restore_a3000lram (int len, size_t filepos)
+void restore_a3000lram(int len, size_t filepos)
{
a3000lmem_filepos = filepos;
changed_prefs.mbresmem_low_size = len;
}
-void restore_a3000hram (int len, size_t filepos)
+void restore_a3000hram(int len, size_t filepos)
{
a3000hmem_filepos = filepos;
changed_prefs.mbresmem_high_size = len;
}
-uae_u8 *restore_rom (uae_u8 *src)
+uae_u8 *restore_rom(uae_u8 *src)
{
- uae_u32 crc32, mem_start, mem_size, mem_type, version;
- TCHAR *s, *romn;
- int i, crcdet;
- struct romlist *rl = romlist_getit ();
+ uae_u32 crc32, mem_start, mem_size, mem_type, version;
+ TCHAR *s, *romn;
+ int i, crcdet;
+ struct romlist *rl = romlist_getit();
- mem_start = restore_u32 ();
- mem_size = restore_u32 ();
- mem_type = restore_u32 ();
- version = restore_u32 ();
- crc32 = restore_u32 ();
- romn = restore_string ();
- crcdet = 0;
- for (i = 0; i < romlist_count (); i++) {
- if (rl[i].rd->crc32 == crc32 && crc32) {
- if (zfile_exists (rl[i].path)) {
- switch (mem_type)
- {
- case 0:
- _tcsncpy (changed_prefs.romfile, rl[i].path, 255);
- break;
- case 1:
- _tcsncpy (changed_prefs.romextfile, rl[i].path, 255);
- break;
- }
- write_log (_T("ROM '%s' = '%s'\n"), romn, rl[i].path);
- crcdet = 1;
- } else {
- write_log (_T("ROM '%s' = '%s' invalid rom scanner path!"), romn, rl[i].path);
- }
- break;
- }
- }
- s = restore_string ();
- if (!crcdet) {
- if(zfile_exists (s)) {
- switch (mem_type)
- {
- case 0:
- _tcsncpy (changed_prefs.romfile, s, 255);
- break;
- case 1:
- _tcsncpy (changed_prefs.romextfile, s, 255);
- break;
- }
- write_log (_T("ROM detected (path) as '%s'\n"), s);
- crcdet = 1;
- }
- }
- xfree (s);
- if (!crcdet)
- write_log (_T("WARNING: ROM '%s' %d.%d (CRC32=%08x %08x-%08x) not found!\n"),
+ mem_start = restore_u32();
+ mem_size = restore_u32();
+ mem_type = restore_u32();
+ version = restore_u32();
+ crc32 = restore_u32();
+ romn = restore_string();
+ crcdet = 0;
+ for (i = 0; i < romlist_count(); i++) {
+ if (rl[i].rd->crc32 == crc32 && crc32) {
+ if (zfile_exists(rl[i].path)) {
+ switch (mem_type)
+ {
+ case 0:
+ _tcsncpy(changed_prefs.romfile, rl[i].path, 255);
+ break;
+ case 1:
+ _tcsncpy(changed_prefs.romextfile, rl[i].path, 255);
+ break;
+ }
+ write_log(_T("ROM '%s' = '%s'\n"), romn, rl[i].path);
+ crcdet = 1;
+ }
+ else {
+ write_log(_T("ROM '%s' = '%s' invalid rom scanner path!"), romn, rl[i].path);
+ }
+ break;
+ }
+ }
+ s = restore_string();
+ if (!crcdet) {
+ if (zfile_exists(s)) {
+ switch (mem_type)
+ {
+ case 0:
+ _tcsncpy(changed_prefs.romfile, s, 255);
+ break;
+ case 1:
+ _tcsncpy(changed_prefs.romextfile, s, 255);
+ break;
+ }
+ write_log(_T("ROM detected (path) as '%s'\n"), s);
+ crcdet = 1;
+ }
+ }
+ xfree(s);
+ if (!crcdet)
+ write_log(_T("WARNING: ROM '%s' %d.%d (CRC32=%08x %08x-%08x) not found!\n"),
romn, version >> 16, version & 0xffff, crc32, mem_start, mem_start + mem_size - 1);
- xfree (romn);
- return src;
+ xfree(romn);
+ return src;
}
-uae_u8 *save_rom (int first, int *len, uae_u8 *dstptr)
+uae_u8 *save_rom(int first, int *len, uae_u8 *dstptr)
{
- static int count;
- uae_u8 *dst, *dstbak;
- uae_u8 *mem_real_start;
- uae_u32 version;
- TCHAR *path;
- int mem_start, mem_size, mem_type, saverom;
- int i;
- TCHAR tmpname[1000];
+ static int count;
+ uae_u8 *dst, *dstbak;
+ uae_u8 *mem_real_start;
+ uae_u32 version;
+ TCHAR *path;
+ int mem_start, mem_size, mem_type, saverom;
+ int i;
+ TCHAR tmpname[1000];
- version = 0;
- saverom = 0;
- if (first)
- count = 0;
- for (;;) {
- mem_type = count;
- mem_size = 0;
- switch (count) {
- case 0: /* Kickstart ROM */
- mem_start = 0xf80000;
- mem_real_start = kickmem_bank.baseaddr;
- mem_size = kickmem_bank.allocated_size;
- path = currprefs.romfile;
- /* 256KB or 512KB ROM? */
- for (i = 0; i < mem_size / 2 - 4; i++) {
- if (longget (i + mem_start) != longget (i + mem_start + mem_size / 2))
- break;
- }
- if (i == mem_size / 2 - 4) {
- mem_size /= 2;
- mem_start += ROM_SIZE_256;
- }
- version = longget (mem_start + 12); /* version+revision */
- _stprintf (tmpname, _T("Kickstart %d.%d"), wordget (mem_start + 12), wordget (mem_start + 14));
- break;
- case 1: /* Extended ROM */
- if (!extendedkickmem_type)
- break;
- mem_start = extendedkickmem_bank.start;
- mem_real_start = extendedkickmem_bank.baseaddr;
- mem_size = extendedkickmem_bank.allocated_size;
- path = currprefs.romextfile;
- version = longget (mem_start + 12); /* version+revision */
+ version = 0;
+ saverom = 0;
+ if (first)
+ count = 0;
+ for (;;) {
+ mem_type = count;
+ mem_size = 0;
+ switch (count) {
+ case 0: /* Kickstart ROM */
+ mem_start = 0xf80000;
+ mem_real_start = kickmem_bank.baseaddr;
+ mem_size = kickmem_bank.allocated_size;
+ path = currprefs.romfile;
+ /* 256KB or 512KB ROM? */
+ for (i = 0; i < mem_size / 2 - 4; i++) {
+ if (longget(i + mem_start) != longget(i + mem_start + mem_size / 2))
+ break;
+ }
+ if (i == mem_size / 2 - 4) {
+ mem_size /= 2;
+ mem_start += ROM_SIZE_256;
+ }
+ version = longget(mem_start + 12); /* version+revision */
+ _stprintf(tmpname, _T("Kickstart %d.%d"), wordget(mem_start + 12), wordget(mem_start + 14));
+ break;
+ case 1: /* Extended ROM */
+ if (!extendedkickmem_type)
+ break;
+ mem_start = extendedkickmem_bank.start;
+ mem_real_start = extendedkickmem_bank.baseaddr;
+ mem_size = extendedkickmem_bank.allocated_size;
+ path = currprefs.romextfile;
+ version = longget(mem_start + 12); /* version+revision */
if (version == 0xffffffff)
- version = longget (mem_start + 16);
- _stprintf (tmpname, _T("Extended"));
- break;
- default:
- return 0;
- }
- count++;
- if (mem_size)
- break;
- }
- if (dstptr)
- dstbak = dst = dstptr;
- else
- dstbak = dst = xmalloc (uae_u8, 4 + 4 + 4 + 4 + 4 + 256 + 256 + mem_size);
- save_u32 (mem_start);
- save_u32 (mem_size);
- save_u32 (mem_type);
- save_u32 (version);
- save_u32 (get_crc32 (mem_real_start, mem_size));
- save_string (tmpname);
- save_string (path);
- if (saverom) {
- for (i = 0; i < mem_size; i++)
- *dst++ = byteget (mem_start + i);
- }
- *len = dst - dstbak;
- return dstbak;
+ version = longget(mem_start + 16);
+ _stprintf(tmpname, _T("Extended"));
+ break;
+ default:
+ return 0;
+ }
+ count++;
+ if (mem_size)
+ break;
+ }
+ if (dstptr)
+ dstbak = dst = dstptr;
+ else
+ dstbak = dst = xmalloc(uae_u8, 4 + 4 + 4 + 4 + 4 + 256 + 256 + mem_size);
+ save_u32(mem_start);
+ save_u32(mem_size);
+ save_u32(mem_type);
+ save_u32(version);
+ save_u32(get_crc32(mem_real_start, mem_size));
+ save_string(tmpname);
+ save_string(path);
+ if (saverom) {
+ for (i = 0; i < mem_size; i++)
+ *dst++ = byteget(mem_start + i);
+ }
+ *len = dst - dstbak;
+ return dstbak;
}
#endif /* SAVESTATE */
/* memory helpers */
-void memcpyha_safe (uaecptr dst, const uae_u8 *src, int size)
+void memcpyha_safe(uaecptr dst, const uae_u8 *src, int size)
{
- if (!addr_valid (_T("memcpyha"), dst, size))
- return;
- while (size--)
- put_byte (dst++, *src++);
+ if (!addr_valid(_T("memcpyha"), dst, size))
+ return;
+ while (size--)
+ put_byte(dst++, *src++);
}
-void memcpyha (uaecptr dst, const uae_u8 *src, int size)
+void memcpyha(uaecptr dst, const uae_u8 *src, int size)
{
- while (size--)
- put_byte (dst++, *src++);
+ while (size--)
+ put_byte(dst++, *src++);
}
-void memcpyah_safe (uae_u8 *dst, uaecptr src, int size)
+void memcpyah_safe(uae_u8 *dst, uaecptr src, int size)
{
- if (!addr_valid (_T("memcpyah"), src, size))
- return;
- while (size--)
- *dst++ = get_byte(src++);
+ if (!addr_valid(_T("memcpyah"), src, size))
+ return;
+ while (size--)
+ *dst++ = get_byte(src++);
}
-void memcpyah (uae_u8 *dst, uaecptr src, int size)
+void memcpyah(uae_u8 *dst, uaecptr src, int size)
{
- while (size--)
- *dst++ = get_byte(src++);
+ while (size--)
+ *dst++ = get_byte(src++);
}
-uae_char *strcpyah_safe (uae_char *dst, uaecptr src, int maxsize)
+uae_char *strcpyah_safe(uae_char *dst, uaecptr src, int maxsize)
{
uae_char *res = dst;
- uae_u8 b;
+ uae_u8 b;
dst[0] = 0;
- do {
- if (!addr_valid (_T("_tcscpyah"), src, 1))
- return res;
- b = get_byte(src++);
- *dst++ = b;
+ do {
+ if (!addr_valid(_T("_tcscpyah"), src, 1))
+ return res;
+ b = get_byte(src++);
+ *dst++ = b;
*dst = 0;
- maxsize--;
+ maxsize--;
if (maxsize <= 1)
- break;
- } while (b);
- return res;
+ break;
+ } while (b);
+ return res;
}
-uaecptr strcpyha_safe (uaecptr dst, const uae_char *src)
+uaecptr strcpyha_safe(uaecptr dst, const uae_char *src)
{
- uaecptr res = dst;
- uae_u8 b;
- do {
- if (!addr_valid (_T("_tcscpyha"), dst, 1))
- return res;
- b = *src++;
- put_byte (dst++, b);
- } while (b);
- return res;
+ uaecptr res = dst;
+ uae_u8 b;
+ do {
+ if (!addr_valid(_T("_tcscpyha"), dst, 1))
+ return res;
+ b = *src++;
+ put_byte(dst++, b);
+ } while (b);
+ return res;
}
diff --git a/src/newcpu.cpp b/src/newcpu.cpp
index 868a5168..129df783 100644
--- a/src/newcpu.cpp
+++ b/src/newcpu.cpp
@@ -1,3 +1,28 @@
+/*
+ * newcpu.cpp - CPU emulation
+ *
+ * Copyright (c) 2010 ARAnyM dev team (see AUTHORS)
+ *
+ *
+ * Inspired by Christian Bauer's Basilisk II
+ *
+ * This file is part of the ARAnyM project which builds a new and powerful
+ * TOS/FreeMiNT compatible virtual machine running on almost any hardware.
+ *
+ * ARAnyM 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.
+ *
+ * ARAnyM 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 ARAnyM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
/*
* UAE - The Un*x Amiga Emulator
*
@@ -14,10 +39,10 @@
#include "memory.h"
#include "custom.h"
#include "newcpu.h"
-#include "cpummu.h"
#include "cpu_prefetch.h"
#include "autoconf.h"
#include "traps.h"
+#include "debug.h"
#include "gui.h"
#include "savestate.h"
#include "blitter.h"
@@ -25,16 +50,17 @@
#include "cia.h"
#include "inputdevice.h"
#include "audio.h"
-#include "fpp.h"
-#include "threaddep/thread.h"
-#include "bsdsocket.h"
+#include
#ifdef JIT
#include "jit/compemu.h"
#include
#else
/* Need to have these somewhere */
-bool check_prefs_changed_comp (bool checkonly) { return false; }
+static void build_comp(void) {}
+bool check_prefs_changed_comp (void) { return false; }
#endif
+/* For faster JIT cycles handling */
+uae_s32 pissoff = 0;
/* Opcode of faulting instruction */
static uae_u16 last_op_for_exception_3;
@@ -43,16 +69,11 @@ static uaecptr last_addr_for_exception_3;
/* Address that generated the exception */
static uaecptr last_fault_for_exception_3;
/* read (0) or write (1) access */
-static bool last_writeaccess_for_exception_3;
+static int last_writeaccess_for_exception_3;
/* instruction (1) or data (0) access */
-static bool last_instructionaccess_for_exception_3;
-/* not instruction */
-static bool last_notinstruction_for_exception_3;
-/* set when writing exception stack frame */
-static int exception_in_exception;
-
+static int last_instructionaccess_for_exception_3;
int cpu_cycles;
-int m68k_pc_indirect;
+bool m68k_pc_indirect;
static int cpu_prefs_changed_flag;
const int areg_byteinc[] = { 1,1,1,1,1,1,1,2 };
@@ -64,20 +85,18 @@ int movem_next[256];
cpuop_func *cpufunctbl[65536];
-struct cputbl_data
-{
- uae_s16 length;
- uae_s8 disp020[2];
- uae_u8 branch;
-};
-static struct cputbl_data cpudatatbl[65536];
+extern uae_u32 get_fpsr(void);
#define COUNT_INSTRS 0
+#define MC68060_PCR 0x04300000
+#define MC68EC060_PCR 0x04310000
static uae_u64 fake_srp_030, fake_crp_030;
static uae_u32 fake_tt0_030, fake_tt1_030, fake_tc_030;
static uae_u16 fake_mmusr_030;
+int cpu_last_stop_vpos, cpu_stopped_lines;
+
#if COUNT_INSTRS
static unsigned long int instrcount[65536];
static uae_u16 opcodenums[65536];
@@ -92,7 +111,7 @@ static TCHAR *icountfilename (void)
TCHAR *name = getenv ("INSNCOUNT");
if (name)
return name;
- return (TCHAR *)(COUNT_INSTRS == 2 ? _T("frequent.68k") : _T("insncount"));
+ return COUNT_INSTRS == 2 ? "frequent.68k" : "insncount";
}
void dump_counts (void)
@@ -118,7 +137,7 @@ void dump_counts (void)
dp = table68k + opcodenums[i];
for (lookup = lookuptab;lookup->mnemo != dp->mnemo; lookup++)
;
- fprintf (f, "%04x: %8lu %s\n", opcodenums[i], cnt, lookup->name);
+ fprintf (f, "%04x: %lu %s\n", opcodenums[i], cnt, lookup->name);
}
fclose (f);
}
@@ -136,92 +155,35 @@ STATIC_INLINE void count_instr (unsigned int opcode)
}
#endif
-uae_u32 (*x_get_iword)(int);
-uae_u32 (*x_get_long)(uaecptr);
-uae_u32 (*x_get_word)(uaecptr);
-uae_u32 (*x_get_byte)(uaecptr);
-void (*x_put_long)(uaecptr,uae_u32);
-void (*x_put_word)(uaecptr,uae_u32);
-void (*x_put_byte)(uaecptr,uae_u32);
-
-static void set_x_ifetches(void)
-{
- // direct to memory
- x_get_iword = get_diword;
-}
-
-// indirect memory access functions
-static void set_x_funcs (void)
-{
- if (currprefs.cpu_model < 68020) {
- // 68000/010
- if (currprefs.cpu_compatible) {
- // cpu_compatible only
- x_get_iword = get_iiword;
- x_put_long = put_long;
- x_put_word = put_word;
- x_put_byte = put_byte;
- x_get_long = get_long;
- x_get_word = get_word;
- x_get_byte = get_byte;
- } else {
- x_get_iword = get_diword;
- x_put_long = put_long;
- x_put_word = put_word;
- x_put_byte = put_byte;
- x_get_long = get_long;
- x_get_word = get_word;
- x_get_byte = get_byte;
- }
- } else {
- // 68020+ no ce
- set_x_ifetches();
- if (currprefs.cachesize) {
- x_put_long = put_long_jit;
- x_put_word = put_word_jit;
- x_put_byte = put_byte_jit;
- x_get_long = get_long_jit;
- x_get_word = get_word_jit;
- x_get_byte = get_byte_jit;
- } else {
- x_put_long = put_long;
- x_put_word = put_word;
- x_put_byte = put_byte;
- x_get_long = get_long;
- x_get_word = get_word;
- x_get_byte = get_byte;
- }
- }
-}
-
-static void flush_cpu_caches(bool force)
-{
- if (currprefs.cpu_model == 68020) {
- regs.cacr &= ~0x08;
- regs.cacr &= ~0x04;
- } else if (currprefs.cpu_model == 68030) {
- regs.cacr &= ~0x08;
- regs.cacr &= ~0x04;
- regs.cacr &= ~0x800;
- regs.cacr &= ~0x400;
- }
-}
-
-void set_cpu_caches (bool flush)
+void set_cpu_caches(bool flush)
{
#ifdef JIT
if (currprefs.cachesize) {
- if (currprefs.cpu_model < 68040) {
- set_cache_state (regs.cacr & 1);
- if (regs.cacr & 0x08) {
- flush_icache (3);
- }
- } else {
- set_cache_state ((regs.cacr & 0x8000) ? 1 : 0);
- }
- }
+ if (currprefs.cpu_model < 68040) {
+ set_cache_state(regs.cacr & 1);
+ if (regs.cacr & 0x08) {
+ flush_icache (0, 3);
+ }
+ } else {
+ set_cache_state((regs.cacr & 0x8000) ? 1 : 0);
+ }
+ }
#endif
- flush_cpu_caches(flush);
+ if (currprefs.cpu_model == 68020) {
+ if (regs.cacr & 0x04) { // clear entry in instr cache
+ regs.cacr &= ~0x04;
+ }
+ } else if (currprefs.cpu_model == 68030) {
+ if (regs.cacr & 0x04) { // clear entry in instr cache
+ regs.cacr &= ~0x04;
+ }
+ if ((regs.cacr & 0x800) || flush) { // clear data cache
+ regs.cacr &= ~0x800;
+ }
+ if (regs.cacr & 0x400) { // clear entry in data cache
+ regs.cacr &= ~0x400;
+ }
+ }
}
static uae_u32 REGPARAM2 op_illg_1 (uae_u32 opcode)
@@ -229,46 +191,59 @@ static uae_u32 REGPARAM2 op_illg_1 (uae_u32 opcode)
op_illg (opcode);
return 4;
}
-
-// generic+direct, generic+direct+jit, generic+indirect, more compatible
-static const struct cputbl *cputbls[5][4] =
+static uae_u32 REGPARAM2 op_unimpl_1 (uae_u32 opcode)
{
- // 68000
- { op_smalltbl_5_ff, op_smalltbl_45_ff, NULL, op_smalltbl_12_ff },
- // 68010
- { op_smalltbl_4_ff, op_smalltbl_44_ff, NULL, op_smalltbl_11_ff },
- // 68020
- { op_smalltbl_3_ff, op_smalltbl_43_ff, NULL, NULL },
- // 68030
- { op_smalltbl_2_ff, op_smalltbl_42_ff, NULL, NULL },
- // 68040
- { op_smalltbl_1_ff, op_smalltbl_41_ff, NULL, NULL },
-};
+ op_illg (opcode);
+ return 4;
+}
static void build_cpufunctbl (void)
{
int i;
unsigned long opcode;
const struct cputbl *tbl = 0;
- int lvl, mode;
+ int lvl;
- if (!currprefs.cachesize) {
+ switch (currprefs.cpu_model)
+ {
+#ifdef CPUEMU_0
+#ifndef CPUEMU_68000_ONLY
+ case 68040:
+ lvl = 4;
+ tbl = op_smalltbl_1_ff;
+ break;
+ case 68030:
+ lvl = 3;
+ tbl = op_smalltbl_2_ff;
+ break;
+ case 68020:
+ lvl = 2;
+ tbl = op_smalltbl_3_ff;
+ break;
+ case 68010:
+ lvl = 1;
+ tbl = op_smalltbl_4_ff;
+#ifdef CPUEMU_11
if (currprefs.cpu_compatible)
- mode = 3;
- else
- mode = 0;
- m68k_pc_indirect = mode != 0 ? 1 : 0;
- } else {
- mode = 1;
- m68k_pc_indirect = 0;
- }
- lvl = (currprefs.cpu_model - 68000) / 10;
- if (lvl >= 4)
- lvl = 4;
- tbl = cputbls[lvl][mode];
+ tbl = op_smalltbl_11_ff; /* prefetch */
+#endif
+ break;
+#endif
+#endif
+ default:
+ changed_prefs.cpu_model = currprefs.cpu_model = 68000;
+ case 68000:
+ lvl = 0;
+ tbl = op_smalltbl_5_ff;
+#ifdef CPUEMU_11
+ if (currprefs.cpu_compatible)
+ tbl = op_smalltbl_12_ff; /* prefetch */
+#endif
+ break;
+ }
- if (tbl == NULL) {
- write_log (_T("no CPU emulation cores available CPU=%d!"), currprefs.cpu_model);
+ if (tbl == 0) {
+ write_log (_T("no CPU emulation cores available CPU=%d!\n"), currprefs.cpu_model);
abort ();
}
@@ -277,26 +252,16 @@ static void build_cpufunctbl (void)
for (i = 0; tbl[i].handler != NULL; i++) {
opcode = tbl[i].opcode;
cpufunctbl[opcode] = tbl[i].handler;
- cpudatatbl[opcode].length = tbl[i].length;
- cpudatatbl[opcode].disp020[0] = tbl[i].disp020[0];
- cpudatatbl[opcode].disp020[1] = tbl[i].disp020[1];
- cpudatatbl[opcode].branch = tbl[i].branch;
}
/* hack fpu to 68000/68010 mode */
if (currprefs.fpu_model && currprefs.cpu_model < 68020) {
tbl = op_smalltbl_3_ff;
for (i = 0; tbl[i].handler != NULL; i++) {
- if ((tbl[i].opcode & 0xfe00) == 0xf200) {
+ if ((tbl[i].opcode & 0xfe00) == 0xf200)
cpufunctbl[tbl[i].opcode] = tbl[i].handler;
- cpudatatbl[tbl[i].opcode].length = tbl[i].length;
- cpudatatbl[tbl[i].opcode].disp020[0] = tbl[i].disp020[0];
- cpudatatbl[tbl[i].opcode].disp020[1] = tbl[i].disp020[1];
- cpudatatbl[tbl[i].opcode].branch = tbl[i].branch;
- }
}
}
-
for (opcode = 0; opcode < 65536; opcode++) {
cpuop_func *f;
instr *table = &table68k[opcode];
@@ -324,12 +289,10 @@ static void build_cpufunctbl (void)
if (f == op_illg_1)
abort();
cpufunctbl[opcode] = f;
- memcpy(&cpudatatbl[opcode], &cpudatatbl[idx], sizeof(struct cputbl_data));
}
}
#ifdef JIT
- write_log(_T("JIT: &countdown = %p\n"), &countdown);
- write_log(_T("JIT: &build_comp = %p\n"), &build_comp);
+ compiler_init ();
build_comp ();
#endif
@@ -340,26 +303,25 @@ static void build_cpufunctbl (void)
regs.address_space_mask = 0xffffffff;
if (currprefs.cpu_compatible) {
- if (currprefs.address_space_24 && currprefs.cpu_model >= 68040)
+ if (currprefs.address_space_24 && currprefs.cpu_model >= 68030)
currprefs.address_space_24 = false;
}
-
if (currprefs.cpu_compatible) {
if (currprefs.cpu_model <= 68020) {
write_log (_T(" prefetch"));
+ } else {
+ write_log (_T(" fake prefetch"));
}
}
- if (currprefs.m68k_speed < 0)
- write_log(_T(" fast"));
- if (currprefs.fpu_no_unimplemented && currprefs.fpu_model) {
- write_log(_T(" no unimplemented floating point instructions"));
- }
if (currprefs.address_space_24) {
regs.address_space_mask = 0x00ffffff;
write_log (_T(" 24-bit"));
}
write_log (_T("\n"));
+ m68k_pc_indirect = (currprefs.cpu_compatible) && !currprefs.cachesize;
+ if (tbl == op_smalltbl_1_ff || tbl == op_smalltbl_2_ff || tbl == op_smalltbl_3_ff || tbl == op_smalltbl_4_ff || tbl == op_smalltbl_5_ff)
+ m68k_pc_indirect = false;
set_cpu_caches (true);
}
@@ -370,22 +332,18 @@ static void update_68k_cycles (void)
{
cycles_shift = 0;
cycles_shift_2 = 0;
- if(currprefs.m68k_speed >= 0) {
- if(currprefs.m68k_speed == M68K_SPEED_14MHZ_CYCLES)
- cycles_shift = 1;
- else if(currprefs.m68k_speed == M68K_SPEED_25MHZ_CYCLES)
- {
- cycles_shift = 2;
- cycles_shift_2 = 5;
- }
+ if(currprefs.m68k_speed == M68K_SPEED_14MHZ_CYCLES)
+ cycles_shift = 1;
+ else if(currprefs.m68k_speed == M68K_SPEED_25MHZ_CYCLES)
+ {
+ cycles_shift = 2;
+ cycles_shift_2 = 5;
}
- if(currprefs.m68k_speed < 0 || currprefs.cachesize > 0)
+ if(currprefs.m68k_speed < 0 || currprefs.cachesize > 0)
do_cycles = do_cycles_cpu_fastest;
else
do_cycles = do_cycles_cpu_norm;
-
- set_config_changed ();
}
STATIC_INLINE unsigned long adjust_cycles(unsigned long cycles)
@@ -399,13 +357,15 @@ STATIC_INLINE unsigned long adjust_cycles(unsigned long cycles)
static void prefs_changed_cpu (void)
{
- fixup_cpu (&changed_prefs);
- check_prefs_changed_comp(false);
- currprefs.cpu_model = changed_prefs.cpu_model;
- currprefs.fpu_model = changed_prefs.fpu_model;
- currprefs.cpu_compatible = changed_prefs.cpu_compatible;
- currprefs.address_space_24 = changed_prefs.address_space_24;
+ fixup_cpu(&changed_prefs);
+ currprefs.cpu_model = changed_prefs.cpu_model;
+ currprefs.fpu_model = changed_prefs.fpu_model;
+ currprefs.mmu_model = changed_prefs.mmu_model;
+ currprefs.cpu_compatible = changed_prefs.cpu_compatible;
+ currprefs.cpu_cycle_exact = changed_prefs.cpu_cycle_exact;
+ currprefs.int_no_unimplemented = changed_prefs.int_no_unimplemented;
currprefs.fpu_no_unimplemented = changed_prefs.fpu_no_unimplemented;
+ currprefs.blitter_cycle_exact = changed_prefs.blitter_cycle_exact;
}
static int check_prefs_changed_cpu2(void)
@@ -413,20 +373,25 @@ static int check_prefs_changed_cpu2(void)
int changed = 0;
#ifdef JIT
- changed = check_prefs_changed_comp(true) ? 1 : 0;
+ changed = check_prefs_changed_comp() ? 1 : 0;
#endif
- if (changed
- || currprefs.cpu_model != changed_prefs.cpu_model
- || currprefs.fpu_model != changed_prefs.fpu_model
- || currprefs.fpu_no_unimplemented != changed_prefs.fpu_no_unimplemented
- || currprefs.cpu_compatible != changed_prefs.cpu_compatible
- || currprefs.fpu_softfloat != changed_prefs.fpu_softfloat) {
- cpu_prefs_changed_flag |= 1;
- }
- if (changed
- || currprefs.m68k_speed != changed_prefs.m68k_speed) {
- cpu_prefs_changed_flag |= 2;
- }
+ if (changed
+ || currprefs.cpu_model != changed_prefs.cpu_model
+ || currprefs.fpu_model != changed_prefs.fpu_model
+ || currprefs.mmu_model != changed_prefs.mmu_model
+ || currprefs.int_no_unimplemented != changed_prefs.int_no_unimplemented
+ || currprefs.fpu_no_unimplemented != changed_prefs.fpu_no_unimplemented
+ || currprefs.cpu_compatible != changed_prefs.cpu_compatible
+ || currprefs.cpu_cycle_exact != changed_prefs.cpu_cycle_exact) {
+ cpu_prefs_changed_flag |= 1;
+ }
+ if (changed
+ || currprefs.m68k_speed != changed_prefs.m68k_speed
+ || currprefs.m68k_speed_throttle != changed_prefs.m68k_speed_throttle
+ || currprefs.cpu_clock_multiplier != changed_prefs.cpu_clock_multiplier
+ || currprefs.cpu_frequency != changed_prefs.cpu_frequency) {
+ cpu_prefs_changed_flag |= 2;
+ }
return cpu_prefs_changed_flag;
}
@@ -435,9 +400,38 @@ void check_prefs_changed_cpu(void)
if (!config_changed)
return;
+ if (currprefs.cpu_idle != changed_prefs.cpu_idle) {
+ currprefs.cpu_idle = changed_prefs.cpu_idle;
+ }
if (check_prefs_changed_cpu2()) {
- set_special (SPCFLAG_MODE_CHANGE);
- reset_frame_rate_hack ();
+ set_special(SPCFLAG_MODE_CHANGE);
+ reset_frame_rate_hack();
+ }
+}
+
+#define LAST_SPEEDUP_LINE 30
+#define SPEEDUP_CYCLES_JIT 2800
+#define SPEEDUP_CYCLES_NONJIT 600
+#define SPEEDUP_TIMELIMIT_JIT -1500
+#define SPEEDUP_TIMELIMIT_NONJIT -2000
+//int pissoff_value = SPEEDUP_CYCLES_JIT * CYCLE_UNIT;
+int speedup_timelimit = SPEEDUP_TIMELIMIT_JIT;
+
+void set_speedup_values(void)
+{
+ if (currprefs.m68k_speed < 0) {
+ if (currprefs.cachesize) {
+ pissoff_value = SPEEDUP_CYCLES_JIT * CYCLE_UNIT;
+ speedup_timelimit = SPEEDUP_TIMELIMIT_JIT;
+ }
+ else {
+ pissoff_value = SPEEDUP_CYCLES_NONJIT * CYCLE_UNIT;
+ speedup_timelimit = SPEEDUP_TIMELIMIT_NONJIT;
+ }
+ }
+ else {
+ pissoff_value = 0;
+ speedup_timelimit = 0;
}
}
@@ -464,8 +458,12 @@ void init_m68k (void)
do_merges ();
build_cpufunctbl ();
- set_x_funcs ();
- set_speedup_values();
+
+#ifdef JIT
+ /* We need to check whether NATMEM settings have changed
+ * before starting the CPU */
+ check_prefs_changed_comp ();
+#endif
}
struct regstruct regs;
@@ -480,29 +478,9 @@ STATIC_INLINE int in_rom (uaecptr pc)
return (munge24 (pc) & 0xFFF80000) == 0xF80000;
}
-STATIC_INLINE int in_rtarea (uaecptr pc)
+STATIC_INLINE int in_rtarea(uaecptr pc)
{
- return (munge24 (pc) & 0xFFFF0000) == rtarea_base && uae_boot_rom_type;
-}
-
-STATIC_INLINE void m68k_set_stop(void)
-{
- if (regs.stopped)
- return;
- regs.stopped = 1;
- set_special(SPCFLAG_STOP);
-}
-
-STATIC_INLINE void m68k_unset_stop(void)
-{
- regs.stopped = 0;
- unset_special(SPCFLAG_STOP);
-}
-
-static void activate_trace(void)
-{
- unset_special (SPCFLAG_TRACE);
- set_special (SPCFLAG_DOTRACE);
+ return (munge24(pc) & 0xFFFF0000) == rtarea_base && uae_boot_rom_type;
}
void REGPARAM2 MakeSR (void)
@@ -514,12 +492,10 @@ void REGPARAM2 MakeSR (void)
| GET_CFLG());
}
-STATIC_INLINE void MakeFromSR_x(int t0trace)
+void REGPARAM2 MakeFromSR (void)
{
int oldm = regs.m;
int olds = regs.s;
- int oldt0 = regs.t0;
- int oldt1 = regs.t1;
SET_XFLG ((regs.sr >> 4) & 1);
SET_NFLG ((regs.sr >> 3) & 1);
@@ -572,63 +548,12 @@ STATIC_INLINE void MakeFromSR_x(int t0trace)
}
doint();
- if (regs.t1 || regs.t0) {
+ if (regs.t1 || regs.t0)
set_special (SPCFLAG_TRACE);
- } else {
+ else
/* Keep SPCFLAG_DOTRACE, we still want a trace exception for
SR-modifying instructions (including STOP). */
unset_special (SPCFLAG_TRACE);
- }
- // Stop SR-modification does not generate T0
- // If this SR modification set Tx bit, no trace until next instruction.
- if ((oldt0 && t0trace && currprefs.cpu_model >= 68020) || oldt1) {
- // Always trace if Tx bits were already set, even if this SR modification cleared them.
- activate_trace();
- }
-}
-
-void REGPARAM2 MakeFromSR_T0(void)
-{
- MakeFromSR_x(1);
-}
-void REGPARAM2 MakeFromSR(void)
-{
- MakeFromSR_x(0);
-}
-
-static void exception_check_trace (int nr)
-{
- unset_special (SPCFLAG_TRACE | SPCFLAG_DOTRACE);
- if (regs.t1 && !regs.t0) {
- /* trace stays pending if exception is div by zero, chk,
- * trapv or trap #x
- */
- if (nr == 5 || nr == 6 || nr == 7 || (nr >= 32 && nr <= 47))
- set_special (SPCFLAG_DOTRACE);
- }
- regs.t1 = regs.t0 = 0;
-}
-
-STATIC_INLINE int iack_cycle(int nr)
-{
- int vector;
-
- if (1) {
- // non-autovectored
- vector = x_get_byte(0x00fffff1 | ((nr - 24) << 1));
- } else {
- // autovectored
-
- }
- return vector;
-}
-
-static uae_u32 exception_pc (int nr)
-{
- // bus error, address error, illegal instruction, privilege violation, a-line, f-line
- if (nr == 2 || nr == 3 || nr == 4 || nr == 8 || nr == 10 || nr == 11)
- return regs.instruction_pc;
- return m68k_getpc ();
}
static void add_approximate_exception_cycles(int nr)
@@ -689,83 +614,40 @@ static void add_approximate_exception_cycles(int nr)
}
}
cycles = adjust_cycles(cycles);
- x_do_cycles(cycles);
+ do_cycles(cycles);
}
-static void Exception_build_stack_frame (uae_u32 oldpc, uae_u32 currpc, uae_u32 ssw, int nr, int format)
+static void exception_trace (int nr)
{
- switch (format) {
- case 0x0: // four word stack frame
- case 0x1: // throwaway four word stack frame
- break;
- case 0x2: // six word stack frame
- m68k_areg (regs, 7) -= 4;
- x_put_long (m68k_areg (regs, 7), oldpc);
- break;
- case 0x3: // floating point post-instruction stack frame (68040)
- m68k_areg (regs, 7) -= 4;
- x_put_long (m68k_areg (regs, 7), regs.fp_ea);
- break;
- case 0x4: // floating point unimplemented stack frame (68LC040, 68EC040)
- m68k_areg (regs, 7) -= 4;
- x_put_long (m68k_areg (regs, 7), ssw);
- m68k_areg (regs, 7) -= 4;
- x_put_long (m68k_areg (regs, 7), oldpc);
- break;
- default:
- write_log(_T("Unknown exception stack frame format: %X\n"), format);
- return;
- }
- m68k_areg (regs, 7) -= 2;
- x_put_word (m68k_areg (regs, 7), (format << 12) | (nr * 4));
- m68k_areg (regs, 7) -= 4;
- x_put_long (m68k_areg (regs, 7), currpc);
- m68k_areg (regs, 7) -= 2;
- x_put_word (m68k_areg (regs, 7), regs.sr);
+ unset_special (SPCFLAG_TRACE | SPCFLAG_DOTRACE);
+ if (regs.t1 && !regs.t0) {
+ /* trace stays pending if exception is div by zero, chk,
+ * trapv or trap #x
+ */
+ if (nr == 5 || nr == 6 || nr == 7 || (nr >= 32 && nr <= 47))
+ set_special (SPCFLAG_DOTRACE);
+ }
+ regs.t1 = regs.t0 = regs.m = 0;
}
-static void Exception_build_stack_frame_common (uae_u32 oldpc, uae_u32 currpc, uae_u32 ssw, int nr)
+static uae_u32 exception_pc (int nr)
{
- if (nr == 5 || nr == 6 || nr == 7 || nr == 9) {
- Exception_build_stack_frame(oldpc, currpc, 0, nr, 0x2);
- } else if (nr == 60 || nr == 61) {
- Exception_build_stack_frame(oldpc, regs.instruction_pc, 0, nr, 0x0);
- } else if (nr >= 48 && nr <= 55) {
- if (regs.fpu_exp_pre) {
- Exception_build_stack_frame(oldpc, regs.instruction_pc, 0, nr, 0x0);
- } else { /* post-instruction */
- Exception_build_stack_frame(oldpc, currpc, 0, nr, 0x3);
- }
- } else if (nr == 11 && regs.fp_unimp_ins) {
- regs.fp_unimp_ins = false;
- if ((currprefs.cpu_model == 68040 && currprefs.fpu_model == 0)) {
- Exception_build_stack_frame(regs.fp_ea, currpc, regs.instruction_pc, nr, 0x4);
- } else {
- Exception_build_stack_frame(regs.fp_ea, currpc, 0, nr, 0x2);
- }
- } else {
- Exception_build_stack_frame(oldpc, currpc, 0, nr, 0x0);
- }
+ // zero divide, chk, trapcc/trapv, trace, trap#
+ if (nr == 5 || nr == 6 || nr == 7 || nr == 9 || (nr >= 32 && nr <= 47))
+ return m68k_getpc ();
+ return regs.instruction_pc;
}
void Exception (int nr)
{
- uae_u32 newpc;
- uae_u32 currpc = m68k_getpc();
- uae_u32 nextpc;
+ uae_u32 currpc, newpc;
int sv = regs.s;
- int interrupt;
- int vector_nr = nr;
- interrupt = nr >= 24 && nr < 24 + 8;
-
-#ifdef JIT
- if (currprefs.cachesize)
+ if (currprefs.cachesize && nr != 61)
regs.instruction_pc = m68k_getpc ();
-#endif
- if (interrupt && currprefs.cpu_model <= 68010)
- vector_nr = iack_cycle(nr);
+ if (nr >= 24 && nr < 24 + 8 && currprefs.cpu_model <= 68010)
+ nr = get_byte (0x00fffff1 | (nr << 1));
MakeSR ();
@@ -779,38 +661,14 @@ void Exception (int nr)
regs.s = 1;
}
- if ((m68k_areg(regs, 7) & 1) && currprefs.cpu_model < 68020) {
- if (nr == 2 || nr == 3)
- cpu_halt (CPU_HALT_DOUBLE_FAULT);
- else
- exception3_notinstruction(regs.ir, m68k_areg(regs, 7));
- return;
- }
- if ((nr == 2 || nr == 3) && exception_in_exception < 0) {
- cpu_halt (CPU_HALT_DOUBLE_FAULT);
- return;
- }
-
- if (!currprefs.cpu_compatible) {
- addrbank *ab = &get_mem_bank(m68k_areg(regs, 7) - 4);
- // Not plain RAM check because some CPU type tests that
- // don't need to return set stack to ROM..
- if (!ab || ab == &dummy_bank || (ab->flags & ABFLAG_IO)) {
- cpu_halt(CPU_HALT_SSP_IN_NON_EXISTING_ADDRESS);
- return;
- }
- }
-
- bool used_exception_build_stack_frame = false;
-
add_approximate_exception_cycles(nr);
if (currprefs.cpu_model > 68000) {
- uae_u32 oldpc = regs.instruction_pc;
- nextpc = exception_pc (nr);
+ currpc = exception_pc (nr);
if (nr == 2 || nr == 3) {
int i;
if (currprefs.cpu_model >= 68040) {
if (nr == 2) {
+
// 68040 bus error (not really, some garbage?)
for (i = 0 ; i < 18 ; i++) {
m68k_areg(regs, 7) -= 2;
@@ -829,7 +687,7 @@ void Exception (int nr)
m68k_areg(regs, 7) -= 4;
x_put_long (m68k_areg(regs, 7), last_addr_for_exception_3);
m68k_areg(regs, 7) -= 2;
- x_put_word (m68k_areg (regs, 7), 0x7000 + vector_nr * 4);
+ x_put_word (m68k_areg(regs, 7), 0x7000 + nr * 4);
m68k_areg (regs, 7) -= 4;
x_put_long (m68k_areg (regs, 7), regs.instruction_pc);
m68k_areg (regs, 7) -= 2;
@@ -840,7 +698,7 @@ void Exception (int nr)
m68k_areg(regs, 7) -= 4;
x_put_long (m68k_areg(regs, 7), last_fault_for_exception_3);
m68k_areg(regs, 7) -= 2;
- x_put_word (m68k_areg (regs, 7), 0x2000 + vector_nr * 4);
+ x_put_word (m68k_areg(regs, 7), 0x2000 + nr * 4);
}
} else {
// 68020 address error
@@ -862,11 +720,17 @@ void Exception (int nr)
m68k_areg(regs, 7) -= 2;
x_put_word (m68k_areg(regs, 7), ssw);
m68k_areg(regs, 7) -= 2;
- x_put_word (m68k_areg(regs, 7), 0xb000 + vector_nr * 4);
+ x_put_word (m68k_areg(regs, 7), 0xb000 + nr * 4);
}
- } else if (regs.m && interrupt) { /* M + Interrupt */
+ write_log (_T("Exception %d (%x) at %x -> %x!\n"), nr, regs.instruction_pc, currpc, x_get_long (regs.vbr + 4*nr));
+ } else if (nr ==5 || nr == 6 || nr == 7 || nr == 9) {
+ m68k_areg(regs, 7) -= 4;
+ x_put_long (m68k_areg(regs, 7), regs.instruction_pc);
m68k_areg(regs, 7) -= 2;
- x_put_word (m68k_areg(regs, 7), vector_nr * 4);
+ x_put_word (m68k_areg(regs, 7), 0x2000 + nr * 4);
+ } else if (regs.m && nr >= 24 && nr < 32) { /* M + Interrupt */
+ m68k_areg(regs, 7) -= 2;
+ x_put_word (m68k_areg(regs, 7), nr * 4);
m68k_areg(regs, 7) -= 4;
x_put_long (m68k_areg(regs, 7), currpc);
m68k_areg(regs, 7) -= 2;
@@ -876,44 +740,39 @@ void Exception (int nr)
regs.m = 0;
m68k_areg(regs, 7) = regs.isp;
m68k_areg(regs, 7) -= 2;
- x_put_word (m68k_areg(regs, 7), 0x1000 + vector_nr * 4);
+ x_put_word (m68k_areg(regs, 7), 0x1000 + nr * 4);
} else {
- Exception_build_stack_frame_common(oldpc, currpc, 0, nr);
- used_exception_build_stack_frame = true;
+ m68k_areg(regs, 7) -= 2;
+ x_put_word (m68k_areg(regs, 7), nr * 4);
}
} else {
- nextpc = m68k_getpc ();
+ currpc = m68k_getpc ();
if (nr == 2 || nr == 3) {
// 68000 address error
uae_u16 mode = (sv ? 4 : 0) | (last_instructionaccess_for_exception_3 ? 2 : 1);
mode |= last_writeaccess_for_exception_3 ? 0 : 16;
- mode |= last_notinstruction_for_exception_3 ? 8 : 0;
- // undocumented bits seem to contain opcode
- mode |= last_op_for_exception_3 & ~31;
m68k_areg(regs, 7) -= 14;
- exception_in_exception = -1;
+ /* fixme: bit3=I/N */
x_put_word (m68k_areg(regs, 7) + 0, mode);
x_put_long (m68k_areg(regs, 7) + 2, last_fault_for_exception_3);
x_put_word (m68k_areg(regs, 7) + 6, last_op_for_exception_3);
x_put_word (m68k_areg(regs, 7) + 8, regs.sr);
x_put_long (m68k_areg(regs, 7) + 10, last_addr_for_exception_3);
+ write_log (_T("Exception %d (%x) at %x -> %x!\n"), nr, last_fault_for_exception_3, currpc, x_get_long (regs.vbr + 4*nr));
goto kludge_me_do;
}
}
- if (!used_exception_build_stack_frame) {
- m68k_areg(regs, 7) -= 4;
- x_put_long (m68k_areg (regs, 7), nextpc);
- m68k_areg(regs, 7) -= 2;
- x_put_word (m68k_areg(regs, 7), regs.sr);
- }
+ m68k_areg(regs, 7) -= 4;
+ x_put_long (m68k_areg(regs, 7), currpc);
+ m68k_areg(regs, 7) -= 2;
+ x_put_word (m68k_areg(regs, 7), regs.sr);
kludge_me_do:
- newpc = x_get_long (regs.vbr + 4 * vector_nr);
- exception_in_exception = 0;
+ newpc = x_get_long (regs.vbr + 4 * nr);
if (newpc & 1) {
if (nr == 2 || nr == 3)
- cpu_halt (CPU_HALT_DOUBLE_FAULT);
+ cpu_halt (2);
else
- exception3_notinstruction(regs.ir, newpc);
+ exception3 (regs.ir, newpc);
return;
}
m68k_setpc (newpc);
@@ -921,52 +780,31 @@ kludge_me_do:
set_special(SPCFLAG_END_COMPILE);
#endif
fill_prefetch ();
- exception_check_trace (nr);
-}
-
-void REGPARAM2 Exception_cpu(int nr)
-{
- bool t0 = currprefs.cpu_model >= 68020 && regs.t0;
- Exception (nr);
- // check T0 trace
- if (t0) {
- activate_trace();
- }
-}
-
-static void bus_error(void)
-{
- TRY (prb2) {
- Exception (2);
- } CATCH (prb2) {
- cpu_halt (CPU_HALT_BUS_ERROR_DOUBLE_FAULT);
- } ENDTRY
+ exception_trace (nr);
}
static void do_interrupt (int nr)
{
- m68k_unset_stop();
+ regs.stopped = 0;
+ unset_special (SPCFLAG_STOP);
- for (;;) {
- Exception (nr + 24);
- regs.intmask = nr;
- if (!currprefs.cpu_compatible)
- break;
- nr = intlev();
- if (nr <= 0 || regs.intmask >= nr)
- break;
- }
+ Exception (nr + 24);
+ regs.intmask = nr;
doint();
}
-void NMI (void)
+static void m68k_reset (bool hardreset)
{
- do_interrupt (7);
-}
+ uae_u32 v;
-static void m68k_reset_sr(void)
-{
+ pissoff = 0;
+ cpu_cycles = 0;
+
+ regs.spcflags = 0;
+#ifdef SAVESTATE
+ if (isrestore ()) {
+ m68k_setpc_normal (regs.pc);
SET_XFLG ((regs.sr >> 4) & 1);
SET_NFLG ((regs.sr >> 3) & 1);
SET_ZFLG ((regs.sr >> 2) & 1);
@@ -982,35 +820,13 @@ static void m68k_reset_sr(void)
m68k_areg(regs, 7) = regs.isp;
else
m68k_areg(regs, 7) = regs.usp;
-}
-
-static void m68k_reset (bool hardreset)
-{
- uae_u32 v;
-
- regs.pissoff = 0;
- cpu_cycles = 0;
-
- regs.halted = 0;
- gui_data.cpu_halted = 0;
- gui_led (LED_CPU, 0, -1);
-
- regs.spcflags = 0;
-
-#ifdef SAVESTATE
- if (isrestore ()) {
- m68k_reset_sr();
- m68k_setpc_normal (regs.pc);
return;
- } else {
- set_special(SPCFLAG_CHECK);
- }
+ }
#endif
- regs.s = 1;
v = get_long (4);
m68k_areg (regs, 7) = get_long (0);
-
m68k_setpc_normal(v);
+ regs.s = 1;
regs.m = 0;
regs.stopped = 0;
regs.t1 = 0;
@@ -1044,22 +860,24 @@ static void m68k_reset (bool hardreset)
}
fake_mmusr_030 = 0;
- regs.pcr = 0;
+ regs.halted = 0;
+ gui_data.cpu_halted = false;
+ gui_led (LED_CPU, 0);
+
fill_prefetch ();
}
+void REGPARAM2 op_unimpl (uae_u16 opcode)
+{
+ Exception (61);
+}
+
uae_u32 REGPARAM2 op_illg (uae_u32 opcode)
{
uaecptr pc = m68k_getpc ();
int inrom = in_rom(pc);
int inrt = in_rtarea(pc);
- if ((opcode == 0x4afc || opcode == 0xfc4a) && !valid_address(pc, 4) && valid_address(pc - 4, 4)) {
- // PC fell off the end of RAM
- bus_error();
- return 4;
- }
-
if (cloanto_rom && (opcode & 0xF100) == 0x7100) {
m68k_dreg (regs, (opcode >> 9) & 7) = (uae_s8)(opcode & 0xFF);
m68k_incpc_normal (2);
@@ -1071,8 +889,6 @@ uae_u32 REGPARAM2 op_illg (uae_u32 opcode)
if (get_long (0x10) == 0) {
notify_user (NUMSG_KS68020);
uae_restart (-1, NULL);
- m68k_setstopped();
- return 4;
}
}
@@ -1107,20 +923,19 @@ uae_u32 REGPARAM2 op_illg (uae_u32 opcode)
#ifdef CPUEMU_0
-static bool mmu_op30fake_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra)
+static void mmu_op30fake_pmove(uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra)
{
int mode = (opcode >> 3) & 7;
- int rreg = opcode & 7;
int preg = (next >> 10) & 31;
int rw = (next >> 9) & 1;
int fd = (next >> 8) & 1;
- const TCHAR *reg = NULL;
+ const char *reg = NULL;
int siz;
- // Dn, An, (An)+, -(An), immediate and PC-relative not allowed
- if (mode == 0 || mode == 1 || mode == 3 || mode == 4 || mode == 6 || (mode == 7 && rreg > 1)) {
+ // Dn, An, (An)+, -(An), abs and indirect
+ if (mode == 0 || mode == 1 || mode == 3 || mode == 4 || mode >= 6) {
op_illg (opcode);
- return true;
+ return;
}
switch (preg)
@@ -1138,7 +953,7 @@ static bool mmu_op30fake_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecpt
siz = 8;
if (rw) {
x_put_long (extra, fake_srp_030 >> 32);
- x_put_long (extra + 4, (uae_u32)fake_srp_030);
+ x_put_long (extra + 4, fake_srp_030);
} else {
fake_srp_030 = (uae_u64)x_get_long (extra) << 32;
fake_srp_030 |= x_get_long (extra + 4);
@@ -1149,7 +964,7 @@ static bool mmu_op30fake_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecpt
siz = 8;
if (rw) {
x_put_long (extra, fake_crp_030 >> 32);
- x_put_long (extra + 4, (uae_u32)fake_crp_030);
+ x_put_long (extra + 4, fake_crp_030);
} else {
fake_crp_030 = (uae_u64)x_get_long (extra) << 32;
fake_crp_030 |= x_get_long (extra + 4);
@@ -1183,30 +998,27 @@ static bool mmu_op30fake_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecpt
if (!reg) {
op_illg(opcode);
- return true;
+ return;
}
- return false;
}
-static bool mmu_op30fake_ptest (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra)
+static void mmu_op30fake_ptest(uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra)
{
fake_mmusr_030 = 0;
- return false;
}
-static bool mmu_op30fake_pflush (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra)
+static void mmu_op30fake_pflush(uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra)
{
int mode = (opcode >> 3) & 7;
- int rreg = opcode & 7;
int flushmode = (next >> 10) & 7;
switch (flushmode)
{
case 6:
- // Dn, An, (An)+, -(An), immediate and PC-relative not allowed
- if (mode == 0 || mode == 1 || mode == 3 || mode == 4 || mode == 6 || (mode == 7 && rreg > 1)) {
+ // Dn, An, (An)+, -(An), abs and indirect
+ if (mode == 0 || mode == 1 || mode == 3 || mode == 4 || mode >= 6) {
op_illg (opcode);
- return true;
+ return;
}
break;
case 4:
@@ -1215,13 +1027,12 @@ static bool mmu_op30fake_pflush (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecp
break;
default:
op_illg (opcode);
- return true;
+ return;
}
- return false;
}
// 68030 (68851) MMU instructions only
-bool mmu_op30 (uaecptr pc, uae_u32 opcode, uae_u16 extra, uaecptr extraa)
+void mmu_op30 (uaecptr pc, uae_u32 opcode, uae_u16 extra, uaecptr extraa)
{
int type = extra >> 13;
@@ -1230,60 +1041,20 @@ bool mmu_op30 (uaecptr pc, uae_u32 opcode, uae_u16 extra, uaecptr extraa)
case 0:
case 2:
case 3:
- return mmu_op30fake_pmove (pc, opcode, extra, extraa);
+ mmu_op30fake_pmove (pc, opcode, extra, extraa);
break;
case 1:
- return mmu_op30fake_pflush (pc, opcode, extra, extraa);
+ mmu_op30fake_pflush (pc, opcode, extra, extraa);
break;
case 4:
- return mmu_op30fake_ptest (pc, opcode, extra, extraa);
+ mmu_op30fake_ptest (pc, opcode, extra, extraa);
break;
default:
op_illg (opcode);
- return true;
break;
}
}
-/* check if an address matches a ttr */
-static int fake_mmu_do_match_ttr(uae_u32 ttr, uaecptr addr, bool super)
-{
- if (ttr & MMU_TTR_BIT_ENABLED) { /* TTR enabled */
- uae_u8 msb, mask;
-
- msb = ((addr ^ ttr) & MMU_TTR_LOGICAL_BASE) >> 24;
- mask = (ttr & MMU_TTR_LOGICAL_MASK) >> 16;
-
- if (!(msb & ~mask)) {
-
- if ((ttr & MMU_TTR_BIT_SFIELD_ENABLED) == 0) {
- if (((ttr & MMU_TTR_BIT_SFIELD_SUPER) == 0) != (super == 0)) {
- return TTR_NO_MATCH;
- }
- }
-
- return (ttr & MMU_TTR_BIT_WRITE_PROTECT) ? TTR_NO_WRITE : TTR_OK_MATCH;
- }
- }
- return TTR_NO_MATCH;
-}
-
-static int fake_mmu_match_ttr(uaecptr addr, bool super, bool data)
-{
- int res;
-
- if (data) {
- res = fake_mmu_do_match_ttr(regs.dtt0, addr, super);
- if (res == TTR_NO_MATCH)
- res = fake_mmu_do_match_ttr(regs.dtt1, addr, super);
- } else {
- res = fake_mmu_do_match_ttr(regs.itt0, addr, super);
- if (res == TTR_NO_MATCH)
- res = fake_mmu_do_match_ttr(regs.itt1, addr, super);
- }
- return res;
-}
-
// 68040+ MMU instructions only
void mmu_op(uae_u32 opcode, uae_u32 extra)
{
@@ -1293,18 +1064,9 @@ void mmu_op(uae_u32 opcode, uae_u32 extra)
return;
} else if ((opcode & 0x0FD8) == 0x548) {
/* PTEST */
- int regno = opcode & 7;
- uae_u32 addr = m68k_areg(regs, regno);
- bool write = (opcode & 32) == 0;
- bool super = (regs.dfc & 4) != 0;
- bool data = (regs.dfc & 3) != 2;
-
- regs.mmusr = 0;
- if (fake_mmu_match_ttr(addr, super, data) != TTR_NO_MATCH) {
- regs.mmusr = MMU_MMUSR_T | MMU_MMUSR_R;
- }
- regs.mmusr |= addr & 0xfffff000;
return;
+ } else if ((opcode & 0x0FB8) == 0x588) {
+ /* PLPA */
}
m68k_setpc_normal (m68k_getpc () - 2);
op_illg (opcode);
@@ -1315,55 +1077,34 @@ void mmu_op(uae_u32 opcode, uae_u32 extra)
static void do_trace (void)
{
if (regs.t0 && currprefs.cpu_model >= 68020) {
- // this is obsolete
- return;
+ uae_u16 opcode;
+ /* should also include TRAP, CHK, SR modification FPcc */
+ /* probably never used so why bother */
+ /* We can afford this to be inefficient... */
+ m68k_setpc_normal (m68k_getpc ());
+ fill_prefetch ();
+ opcode = x_get_word (regs.pc);
+ if (opcode == 0x4e73 /* RTE */
+ || opcode == 0x4e74 /* RTD */
+ || opcode == 0x4e75 /* RTS */
+ || opcode == 0x4e77 /* RTR */
+ || opcode == 0x4e76 /* TRAPV */
+ || (opcode & 0xffc0) == 0x4e80 /* JSR */
+ || (opcode & 0xffc0) == 0x4ec0 /* JMP */
+ || (opcode & 0xff00) == 0x6100 /* BSR */
+ || ((opcode & 0xf000) == 0x6000 /* Bcc */
+ && cctrue (regs.ccrflags, (opcode >> 8) & 0xf))
+ || ((opcode & 0xf0f0) == 0x5050 /* DBcc */
+ && !cctrue (regs.ccrflags, (opcode >> 8) & 0xf)
+ && uae_s16(m68k_dreg (regs, opcode & 7)) != 0))
+ {
+ unset_special (SPCFLAG_TRACE);
+ set_special (SPCFLAG_DOTRACE);
+ }
+ } else if (regs.t1) {
+ unset_special (SPCFLAG_TRACE);
+ set_special (SPCFLAG_DOTRACE);
}
- if (regs.t1) {
- activate_trace();
- }
-}
-
-static void check_uae_int_request(void)
-{
- if (uae_int_requested) {
- bool irq = false;
- if (uae_int_requested & 0x00ff) {
- INTREQ_f(0x8000 | 0x0008);
- irq = true;
- }
- if (uae_int_requested & 0xff00) {
- INTREQ_f(0x8000 | 0x2000);
- irq = true;
- }
- if (uae_int_requested & 0xff0000) {
- atomic_and(&uae_int_requested, ~0x010000);
- }
- if (irq)
- doint();
- }
-}
-
-static bool haltloop(void)
-{
- while (regs.halted) {
- static int prevvpos;
- if (vpos == 0 && prevvpos) {
- prevvpos = 0;
- }
- if (vpos)
- prevvpos = 1;
- x_do_cycles(8 * CYCLE_UNIT);
-
- if (regs.spcflags & SPCFLAG_COPPER)
- do_copper();
-
- if (regs.spcflags) {
- if ((regs.spcflags & (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE)))
- return true;
- }
- }
-
- return false;
}
void doint (void)
@@ -1379,47 +1120,7 @@ static int do_specialties (int cycles)
if (regs.spcflags & SPCFLAG_MODE_CHANGE)
return 1;
- if (regs.spcflags & SPCFLAG_CHECK) {
- if (regs.halted) {
- unset_special(SPCFLAG_CHECK);
- if (haltloop())
- return 1;
- }
- unset_special(SPCFLAG_CHECK);
- }
-
-#ifdef ACTION_REPLAY
-#ifdef ACTION_REPLAY_HRTMON
- if ((regs.spcflags & SPCFLAG_ACTION_REPLAY) && hrtmon_flag != ACTION_REPLAY_INACTIVE) {
- int isinhrt = (m68k_getpc () >= hrtmem_start && m68k_getpc () < hrtmem_start + hrtmem_size);
- /* exit from HRTMon? */
- if (hrtmon_flag == ACTION_REPLAY_ACTIVE && !isinhrt)
- hrtmon_hide ();
- /* HRTMon breakpoint? (not via IRQ7) */
- if (hrtmon_flag == ACTION_REPLAY_IDLE && isinhrt)
- hrtmon_breakenter ();
- if (hrtmon_flag == ACTION_REPLAY_ACTIVATE)
- hrtmon_enter ();
- }
-#endif
- if ((regs.spcflags & SPCFLAG_ACTION_REPLAY) && action_replay_flag != ACTION_REPLAY_INACTIVE) {
- /*if (action_replay_flag == ACTION_REPLAY_ACTIVE && !is_ar_pc_in_rom ())*/
- /* write_log (_T("PC:%p\n"), m68k_getpc ());*/
-
- if (action_replay_flag == ACTION_REPLAY_ACTIVATE || action_replay_flag == ACTION_REPLAY_DORESET)
- action_replay_enter ();
- if ((action_replay_flag == ACTION_REPLAY_HIDE || action_replay_flag == ACTION_REPLAY_ACTIVE) && !is_ar_pc_in_rom ()) {
- action_replay_hide ();
- unset_special (SPCFLAG_ACTION_REPLAY);
- }
- if (action_replay_flag == ACTION_REPLAY_WAIT_PC) {
- /*write_log (_T("Waiting for PC: %p, current PC= %p\n"), wait_for_pc, m68k_getpc ());*/
- if (m68k_getpc () == wait_for_pc) {
- action_replay_flag = ACTION_REPLAY_ACTIVATE; /* Activate after next instruction. */
- }
- }
- }
-#endif
+ regs.instruction_pc = m68k_getpc ();
if (regs.spcflags & SPCFLAG_COPPER)
do_copper ();
@@ -1445,18 +1146,20 @@ static int do_specialties (int cycles)
if (regs.spcflags & SPCFLAG_DOTRACE)
Exception (9);
- bool first = true;
- while ((regs.spcflags & SPCFLAG_STOP) && !(regs.spcflags & SPCFLAG_BRK)) {
+ while (regs.spcflags & SPCFLAG_STOP) {
- check_uae_int_request();
+ if (uae_int_requested) {
+ INTREQ_f (0x8008);
+ set_special (SPCFLAG_INT);
+ }
{
+ extern void bsdsock_fake_int_handler (void);
+ extern int volatile bsd_int_requested;
if (bsd_int_requested)
bsdsock_fake_int_handler ();
}
- if (!first)
- x_do_cycles (4 * CYCLE_UNIT);
- first = false;
+ x_do_cycles (4 * CYCLE_UNIT);
if (regs.spcflags & SPCFLAG_COPPER)
do_copper ();
@@ -1501,39 +1204,29 @@ static int do_specialties (int cycles)
static void m68k_run_1 (void)
{
struct regstruct *r = ®s;
- bool exit = false;
- while (!exit) {
- TRY (prb) {
- while (!exit) {
- r->opcode = r->ir;
+ for (;;) {
+ uae_u16 opcode = r->ir;
-#if defined (CPU_arm) && defined(USE_ARMNEON)
- // Well not really since pli is ArmV7...
- /* Load ARM code for next opcode into L2 cache during execute of do_cycles() */
- __asm__ volatile ("pli [%[radr]]\n\t" \
- : : [radr] "r" (cpufunctbl[r->opcode]) : );
+#if defined (CPU_arm) & defined(USE_ARMNEON)
+ // Well not really since pli is ArmV7...
+ /* Load ARM code for next opcode into L2 cache during execute of do_cycles() */
+ __asm__ volatile ("pli [%[radr]]\n\t" \
+ : : [radr] "r" (cpufunctbl[opcode]) : );
#endif
- count_instr (r->opcode);
+ count_instr (opcode);
- do_cycles (cpu_cycles);
- r->instruction_pc = m68k_getpc ();
- cpu_cycles = (*cpufunctbl[r->opcode])(r->opcode);
- cpu_cycles = adjust_cycles(cpu_cycles);
- if (r->spcflags) {
- if (do_specialties (cpu_cycles))
- exit = true;
- }
- if (!currprefs.cpu_compatible)
- exit = true;
+ do_cycles (cpu_cycles);
+ r->instruction_pc = m68k_getpc ();
+ cpu_cycles = (*cpufunctbl[opcode])(opcode);
+ cpu_cycles = adjust_cycles(cpu_cycles);
+ if (r->spcflags) {
+ if (do_specialties (cpu_cycles)) {
+ return;
}
- } CATCH (prb) {
- bus_error();
- if (r->spcflags) {
- if (do_specialties(cpu_cycles))
- exit = true;
- }
- } ENDTRY
+ }
+ if (!currprefs.cpu_compatible)
+ return;
}
}
@@ -1552,13 +1245,12 @@ void exec_nostats(void)
for (;;)
{
- r->opcode = x_get_iword (0);
- cpu_cycles = (*cpufunctbl[r->opcode])(r->opcode);
+ uae_u16 opcode = get_diword (0);
+ cpu_cycles = (*cpufunctbl[opcode])(opcode);
cpu_cycles = adjust_cycles(cpu_cycles);
-
do_cycles (cpu_cycles);
- if (end_block(r->opcode) || r->spcflags || uae_int_requested)
+ if (end_block(opcode) || r->spcflags || uae_int_requested)
return; /* We will deal with the spcflags in the caller */
}
}
@@ -1579,19 +1271,21 @@ void execute_normal(void)
start_pc = r->pc;
for (;;) {
/* Take note: This is the do-it-normal loop */
+ uae_u16 opcode;
+
regs.instruction_pc = m68k_getpc ();
- r->opcode = x_get_iword (0);
+ opcode = get_diword (0);
special_mem = DISTRUST_CONSISTENT_MEM;
pc_hist[blocklen].location = (uae_u16*)r->pc_p;
- cpu_cycles = (*cpufunctbl[r->opcode])(r->opcode);
+ cpu_cycles = (*cpufunctbl[opcode])(opcode);
cpu_cycles = adjust_cycles(cpu_cycles);
do_cycles (cpu_cycles);
total_cycles += cpu_cycles;
pc_hist[blocklen].specmem = special_mem;
blocklen++;
- if (end_block(r->opcode) || blocklen >= MAXRUN || r->spcflags || uae_int_requested) {
+ if (end_block(opcode) || blocklen >= MAXRUN || r->spcflags || uae_int_requested) {
compile_block(pc_hist,blocklen,total_cycles);
return; /* We will deal with the spcflags in the caller */
}
@@ -1605,9 +1299,12 @@ typedef void compiled_handler(void);
static void m68k_run_jit (void)
{
for (;;) {
- ((compiled_handler*)(pushall_call_handler))();
+ ((compiled_handler*)pushall_call_handler)();
/* Whenever we return from that, we should check spcflags */
- check_uae_int_request();
+ if (uae_int_requested) {
+ INTREQ_f (0x8008);
+ set_special (SPCFLAG_INT);
+ }
if (regs.spcflags) {
if (do_specialties (0)) {
return;
@@ -1619,16 +1316,23 @@ static void m68k_run_jit (void)
void cpu_halt (int id)
{
- // id > 0: emulation halted.
if (!regs.halted) {
- write_log (_T("CPU halted: reason = %d PC=%08x\n"), id, M68K_GETPC);
+ write_log (_T("CPU halted: reason = %d\n"), id);
regs.halted = id;
- gui_data.cpu_halted = id;
- gui_led (LED_CPU, 0, -1);
- regs.intmask = 7;
- MakeSR ();
- audio_deactivate ();
- set_special(SPCFLAG_CHECK);
+ gui_data.cpu_halted = true;
+ gui_led (LED_CPU, 0);
+ regs.intmask = 7;
+ MakeSR ();
+ audio_deactivate ();
+ }
+ while (regs.halted) {
+ if (vpos == 0)
+ sleep_millis_main (8);
+ x_do_cycles (100 * CYCLE_UNIT);
+ if (regs.spcflags) {
+ if ((regs.spcflags & (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE)))
+ return;
+ }
}
}
@@ -1636,173 +1340,165 @@ void cpu_halt (int id)
static void m68k_run_2 (void)
{
struct regstruct *r = ®s;
- bool exit = false;
- while (!exit) {
- TRY(prb) {
- while (!exit) {
- r->instruction_pc = m68k_getpc ();
-
- r->opcode = x_get_iword (0);
-#if defined (CPU_arm) && defined(USE_ARMNEON)
- // Well not really since pli is ArmV7...
- /* Load ARM code for next opcode into L2 cache during execute of do_cycles() */
- __asm__ volatile ("pli [%[radr]]\n\t" \
- : : [radr] "r" (cpufunctbl[r->opcode]) : );
+ for (;;) {
+ r->instruction_pc = m68k_getpc ();
+ uae_u16 opcode = get_diword (0);
+
+#if defined (CPU_arm) & defined(USE_ARMNEON)
+ // Well not really since pli is ArmV7...
+ /* Load ARM code for next opcode into L2 cache during execute of do_cycles() */
+ __asm__ volatile ("pli [%[radr]]\n\t" \
+ : : [radr] "r" (cpufunctbl[opcode]) : );
#endif
- count_instr (r->opcode);
-
- do_cycles (cpu_cycles);
-
- cpu_cycles = (*cpufunctbl[r->opcode])(r->opcode);
- cpu_cycles = adjust_cycles(cpu_cycles);
-
- if (r->spcflags) {
- if (do_specialties (cpu_cycles))
- exit = true;
- }
+ count_instr (opcode);
+ do_cycles (cpu_cycles);
+ cpu_cycles = (*cpufunctbl[opcode])(opcode);
+ cpu_cycles = adjust_cycles(cpu_cycles);
+ if (r->spcflags) {
+ if (do_specialties (cpu_cycles)) {
+ break;
}
- } CATCH(prb) {
- bus_error();
- if (r->spcflags) {
- if (do_specialties(cpu_cycles))
- exit = true;
- }
- } ENDTRY
- }
+ }
+ }
}
static int in_m68k_go = 0;
-static bool cpu_hardreset;
-
-bool is_hardreset(void)
+static void exception2_handle (uaecptr addr, uaecptr fault)
{
- return cpu_hardreset;
+ last_addr_for_exception_3 = addr;
+ last_fault_for_exception_3 = fault;
+ last_writeaccess_for_exception_3 = 0;
+ last_instructionaccess_for_exception_3 = 0;
+ Exception (2);
}
-void m68k_go (int may_quit)
+void m68k_go(int may_quit)
{
- int hardboot = 1;
+ int hardboot = 1;
int startup = 1;
- if (in_m68k_go || !may_quit) {
- write_log (_T("Bug! m68k_go is not reentrant.\n"));
- abort ();
- }
+ if (in_m68k_go || !may_quit) {
+ write_log(_T("Bug! m68k_go is not reentrant.\n"));
+ abort();
+ }
- reset_frame_rate_hack ();
- update_68k_cycles ();
+ reset_frame_rate_hack();
+ update_68k_cycles();
+ start_cycles = 0;
cpu_prefs_changed_flag = 0;
- in_m68k_go++;
- for (;;) {
- void (*run_func)(void);
-
- if (quit_program > 0) {
- int restored = 0;
- bool cpu_keyboardreset = quit_program == UAE_RESET_KEYBOARD;
- cpu_hardreset = ((quit_program == UAE_RESET_HARD ? 1 : 0) | hardboot) != 0;
+ in_m68k_go++;
+#ifdef DEBUG
+ ProfilerStart("amiberry-sdl2.prof");
+#endif
+ for (;;) {
+ void(*run_func)(void);
+ if (quit_program > 0) {
+ int hardreset = (quit_program == UAE_RESET_HARD ? 1 : 0) | hardboot;
+ bool kbreset = quit_program == UAE_RESET_KEYBOARD;
if (quit_program == UAE_QUIT)
- break;
+ break;
+ if (quit_program == UAE_RESET_HARD)
+ reinit_amiga();
+ int restored = 0;
hsync_counter = 0;
- quit_program = 0;
- hardboot = 0;
+ vsync_counter = 0;
+ quit_program = 0;
+ hardboot = 0;
#ifdef SAVESTATE
if (savestate_state == STATE_DORESTORE)
savestate_state = STATE_RESTORE;
- if (savestate_state == STATE_RESTORE)
- restore_state (savestate_fname);
+ if (savestate_state == STATE_RESTORE)
+ restore_state(savestate_fname);
#endif
- prefs_changed_cpu();
- build_cpufunctbl ();
- set_x_funcs ();
- set_cycles (0);
- custom_reset (cpu_hardreset != 0, cpu_keyboardreset);
- m68k_reset (cpu_hardreset != 0);
- if (cpu_hardreset) {
- memory_clear ();
- write_log (_T("hardreset, memory cleared\n"));
- }
- cpu_hardreset = false;
+ //prefs_changed_cpu();
+ //build_cpufunctbl();
+ //set_x_funcs(); //TODO
+ set_cycles(start_cycles);
+ custom_reset(hardreset != 0, kbreset);
+ m68k_reset(hardreset != 0);
+ if (hardreset) {
+ memory_clear();
+ write_log(_T("hardreset, memory cleared\n"));
+ }
#ifdef SAVESTATE
- /* We may have been restoring state, but we're done now. */
- if (isrestore ()) {
- savestate_restore_finish ();
+ /* We may have been restoring state, but we're done now. */
+ if (isrestore()) {
+ savestate_restore_finish();
startup = 1;
restored = 1;
- }
+ }
#endif
- if (currprefs.produce_sound == 0)
- eventtab[ev_audio].active = 0;
- m68k_setpc_normal (regs.pc);
- check_prefs_changed_audio ();
+ if (currprefs.produce_sound == 0)
+ eventtab[ev_audio].active = 0;
+ m68k_setpc_normal(regs.pc);
+ check_prefs_changed_audio();
if (!restored || hsync_counter == 0)
- savestate_check ();
- }
+ savestate_check();
+ }
+
+ if (regs.panic) {
+ regs.panic = 0;
+ /* program jumped to non-existing memory and cpu was >= 68020 */
+ get_real_address(regs.isp); /* stack in no one's land? -> halt */
+ if (regs.isp & 1)
+ regs.panic = 5;
+ if (!regs.panic)
+ exception2_handle(regs.panic_pc, regs.panic_addr);
+ if (regs.panic) {
+ int id = regs.panic;
+ /* system is very badly confused */
+ regs.panic = 0;
+ cpu_halt(id);
+ }
+ }
if (regs.spcflags & SPCFLAG_MODE_CHANGE) {
if (cpu_prefs_changed_flag & 1) {
uaecptr pc = m68k_getpc();
prefs_changed_cpu();
- fpu_modechange();
build_cpufunctbl();
m68k_setpc_normal(pc);
fill_prefetch();
- }
+ }
if (cpu_prefs_changed_flag & 2) {
fixup_cpu(&changed_prefs);
currprefs.m68k_speed = changed_prefs.m68k_speed;
update_68k_cycles();
}
cpu_prefs_changed_flag = 0;
- set_speedup_values();
}
- set_x_funcs();
- if (startup) {
- custom_prepare ();
- protect_roms (true);
- }
- startup = 0;
- unset_special(SPCFLAG_MODE_CHANGE);
-
- if (!regs.halted) {
- // check that PC points to something that looks like memory.
- uaecptr pc = m68k_getpc();
- addrbank *ab = &get_mem_bank(pc);
- if (ab == NULL || ab == &dummy_bank || (!currprefs.cpu_compatible && !valid_address(pc, 2)) || (pc & 1)) {
- cpu_halt(CPU_HALT_INVALID_START_ADDRESS);
- }
+ if (startup) {
+ custom_prepare();
+ protect_roms(true);
}
+ startup = 0;
if (regs.halted) {
- cpu_halt (regs.halted);
- if (regs.halted < 0) {
- haltloop();
- continue;
- }
+ cpu_halt(regs.halted);
+ continue;
}
-
- run_func =
- currprefs.cpu_compatible && currprefs.cpu_model <= 68010 ? m68k_run_1 :
+ run_func =
+ currprefs.cpu_compatible && currprefs.cpu_model <= 68010 ? m68k_run_1 :
#ifdef JIT
- currprefs.cpu_model >= 68020 && currprefs.cachesize ? m68k_run_jit :
+ currprefs.cpu_model >= 68020 && currprefs.cachesize ? m68k_run_jit :
#endif
- m68k_run_2;
- run_func ();
- }
- protect_roms (false);
-
- // Prepare for a restart: reset pc
- regs.pc = 0;
- regs.pc_p = NULL;
- regs.pc_oldp = NULL;
-
- in_m68k_go--;
+ m68k_run_2;
+ unset_special(SPCFLAG_MODE_CHANGE);
+ unset_special(SPCFLAG_BRK);
+ run_func();
+ }
+#ifdef DEBUG
+ ProfilerStop();
+#endif
+ protect_roms(false);
+ in_m68k_go--;
}
#ifdef SAVESTATE
@@ -1866,6 +1562,9 @@ uae_u8 *restore_cpu (uae_u8 *src)
regs.srp = restore_u32();
}
if (flags & 0x80000000) {
+ regs.chipset_latch_rw = restore_u32();
+ regs.chipset_latch_read = restore_u32();
+ regs.chipset_latch_write = restore_u32();
int khz = restore_u32();
restore_u32();
if (khz > 0 && khz < 800000)
@@ -1873,8 +1572,6 @@ uae_u8 *restore_cpu (uae_u8 *src)
}
set_cpu_caches(true);
- m68k_reset_sr();
-
write_log (_T("CPU: %d%s%03d, PC=%08X\n"),
model / 1000, flags & 1 ? _T("EC") : _T(""), model % 1000, regs.pc);
@@ -1910,6 +1607,7 @@ uae_u8 *restore_cpu_extra (uae_u8 *src)
uae_u32 flags = restore_u32 ();
currprefs.cpu_compatible = changed_prefs.cpu_compatible = (flags & 2) ? true : false;
+ //currprefs.cachesize = changed_prefs.cachesize = (flags & 8) ? 8192 : 0;
currprefs.m68k_speed = changed_prefs.m68k_speed = 0;
if (flags & 4)
@@ -1953,7 +1651,7 @@ uae_u8 *save_cpu (int *len, uae_u8 *dstptr)
dstbak = dst = xmalloc (uae_u8, 1000);
model = currprefs.cpu_model;
save_u32 (model); /* MODEL */
- save_u32 (0x80000000 | (currprefs.address_space_24 ? 1 : 0)); /* FLAGS */
+ save_u32 (0x80000000 | 0x40000000 | (currprefs.address_space_24 ? 1 : 0)); /* FLAGS */
for(i = 0;i < 15; i++)
save_u32 (regs.regs[i]); /* D0-D7 A0-A6 */
save_u32 (m68k_getpc ()); /* PC */
@@ -1997,6 +1695,9 @@ uae_u8 *save_cpu (int *len, uae_u8 *dstptr)
if (currprefs.cpu_model >= 68020)
khz *= 2;
}
+ save_u32(regs.chipset_latch_rw);
+ save_u32(regs.chipset_latch_read);
+ save_u32(regs.chipset_latch_write);
save_u32 (khz); // clock rate in KHz: -1 = fastest possible
save_u32 (0); // spare
*len = dst - dstbak;
@@ -2005,7 +1706,7 @@ uae_u8 *save_cpu (int *len, uae_u8 *dstptr)
#endif /* SAVESTATE */
-static void exception3f (uae_u32 opcode, uaecptr addr, bool writeaccess, bool instructionaccess, bool notinstruction, uaecptr pc, bool plus2)
+static void exception3f (uae_u32 opcode, uaecptr addr, int writeaccess, int instructionaccess, uaecptr pc)
{
if (currprefs.cpu_model >= 68040)
addr &= ~1;
@@ -2015,9 +1716,7 @@ static void exception3f (uae_u32 opcode, uaecptr addr, bool writeaccess, bool in
else
last_addr_for_exception_3 = pc;
} else if (pc == 0xffffffff) {
- last_addr_for_exception_3 = m68k_getpc ();
- if (plus2)
- last_addr_for_exception_3 += 2;
+ last_addr_for_exception_3 = m68k_getpc () + 2;
} else {
last_addr_for_exception_3 = pc;
}
@@ -2025,40 +1724,40 @@ static void exception3f (uae_u32 opcode, uaecptr addr, bool writeaccess, bool in
last_op_for_exception_3 = opcode;
last_writeaccess_for_exception_3 = writeaccess;
last_instructionaccess_for_exception_3 = instructionaccess;
- last_notinstruction_for_exception_3 = notinstruction;
Exception (3);
}
-void exception3_notinstruction(uae_u32 opcode, uaecptr addr)
+void exception3 (uae_u32 opcode, uaecptr addr)
{
- exception3f (opcode, addr, true, false, true, 0xffffffff, false);
-}
-void exception3_read(uae_u32 opcode, uaecptr addr)
-{
- exception3f (opcode, addr, false, 0, false, 0xffffffff, false);
-}
-void exception3_write(uae_u32 opcode, uaecptr addr)
-{
- exception3f (opcode, addr, true, 0, false, 0xffffffff, false);
+ exception3f (opcode, addr, 0, 0, 0xffffffff);
}
+
void exception3i (uae_u32 opcode, uaecptr addr)
{
- exception3f (opcode, addr, 0, 1, false, 0xffffffff, true);
+ exception3f (opcode, addr, 0, 1, 0xffffffff);
}
void exception3b (uae_u32 opcode, uaecptr addr, bool w, bool i, uaecptr pc)
{
- exception3f (opcode, addr, w, i, false, pc, true);
+ exception3f (opcode, addr, w, i, pc);
}
-void exception2 (uaecptr addr, bool read, int size, uae_u32 fc)
+void exception2 (uaecptr addr)
{
- last_addr_for_exception_3 = m68k_getpc();
- last_fault_for_exception_3 = addr;
- last_writeaccess_for_exception_3 = read == 0;
- last_instructionaccess_for_exception_3 = (fc & 1) == 0;
- last_op_for_exception_3 = regs.opcode;
- last_notinstruction_for_exception_3 = exception_in_exception != 0;
- THROW(2);
+ exception2_handle (addr, addr);
+}
+
+void exception2_fake (uaecptr addr)
+{
+ write_log (_T("delayed exception2!\n"));
+ regs.panic_pc = m68k_getpc ();
+ regs.panic_addr = addr;
+ regs.panic = 6;
+ set_special (SPCFLAG_BRK);
+ m68k_setpc_normal (0xf80000);
+#ifdef JIT
+ set_special (SPCFLAG_END_COMPILE);
+#endif
+ fill_prefetch ();
}
void cpureset (void)
@@ -2069,7 +1768,6 @@ void cpureset (void)
uae_u16 ins;
addrbank *ab;
- set_special(SPCFLAG_CHECK);
if (currprefs.cpu_compatible && currprefs.cpu_model <= 68020) {
custom_reset (false, false);
return;
@@ -2089,7 +1787,7 @@ void cpureset (void)
uae_u32 addr = m68k_areg (regs, reg);
if (addr < 0x80000)
addr += 0xf80000;
- write_log (_T("reset/jmp (ax) combination at %08x emulated -> %x\n"), pc, addr);
+ write_log (_T("reset/jmp (ax) combination emulated -> %x\n"), addr);
m68k_setpc_normal (addr - 2);
return;
}
@@ -2103,37 +1801,32 @@ void cpureset (void)
void m68k_setstopped (void)
{
+ regs.stopped = 1;
/* A traced STOP instruction drops through immediately without
actually stopping. */
if ((regs.spcflags & SPCFLAG_DOTRACE) == 0) {
- m68k_set_stop();
- } else {
- m68k_resumestopped ();
+ set_special(SPCFLAG_STOP);
+ cpu_last_stop_vpos = vpos;
}
+ else
+ m68k_resumestopped ();
}
void m68k_resumestopped (void)
{
if (!regs.stopped)
return;
+ regs.stopped = 0;
fill_prefetch ();
- m68k_unset_stop();
-}
-
-void check_t0_trace(void)
-{
- if (regs.t0 && currprefs.cpu_model >= 68020) {
- unset_special (SPCFLAG_TRACE);
- set_special (SPCFLAG_DOTRACE);
- }
+ unset_special (SPCFLAG_STOP);
+ cpu_stopped_lines += vpos - cpu_last_stop_vpos;
+ cpu_last_stop_vpos = vpos;
}
void fill_prefetch (void)
{
if (currprefs.cachesize)
return;
- if (!currprefs.cpu_compatible)
- return;
if (currprefs.cpu_model <= 68010) {
uaecptr pc = m68k_getpc ();
regs.ir = x_get_word (pc);
diff --git a/src/osdep/amiberry.cpp b/src/osdep/amiberry.cpp
index c2f216db..3cfe7c8c 100644
--- a/src/osdep/amiberry.cpp
+++ b/src/osdep/amiberry.cpp
@@ -6,57 +6,55 @@
*/
#include
-#include
#include
+#include
#include
#include
#include
#include
-#include
-#ifndef ANDROID
-#include
-#endif
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
+#include "autoconf.h"
#include "uae.h"
#include "options.h"
#include "threaddep/thread.h"
#include "gui.h"
#include "include/memory.h"
+#include "newcpu.h"
+#include "custom.h"
+#include "xwin.h"
+#include "drawing.h"
#include "inputdevice.h"
+#include "keybuf.h"
#include "keyboard.h"
#include "disk.h"
#include "savestate.h"
+#include "traps.h"
+#include "bsdsocket.h"
+#include "blkdev.h"
+#include "native2amiga.h"
#include "rtgmodes.h"
+#include "uaeresource.h"
#include "rommgr.h"
-#include "zfile.h"
-#include "gfxboard.h"
-#include
-#include