diff --git a/VisualGDB/Amiberry/Amiberry-Debug.vgdbsettings b/VisualGDB/Amiberry/Amiberry-Debug.vgdbsettings index adb259fd..f291eb86 100644 --- a/VisualGDB/Amiberry/Amiberry-Debug.vgdbsettings +++ b/VisualGDB/Amiberry/Amiberry-Debug.vgdbsettings @@ -69,7 +69,6 @@ Amiberry.vcxproj - 1 diff --git a/VisualGDB/Amiberry/Amiberry-Release.vgdbsettings b/VisualGDB/Amiberry/Amiberry-Release.vgdbsettings index aecb317a..169329a0 100644 --- a/VisualGDB/Amiberry/Amiberry-Release.vgdbsettings +++ b/VisualGDB/Amiberry/Amiberry-Release.vgdbsettings @@ -69,7 +69,6 @@ Amiberry.vcxproj - 1 diff --git a/VisualGDB/Amiberry/Amiberry.vcxproj b/VisualGDB/Amiberry/Amiberry.vcxproj index c6c259d9..a9db3213 100644 --- a/VisualGDB/Amiberry/Amiberry.vcxproj +++ b/VisualGDB/Amiberry/Amiberry.vcxproj @@ -56,7 +56,7 @@ 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) + 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;../../src/archivers;%(ClCompile.AdditionalIncludeDirectories) DEBUG=1;_REENTRANT;CAPSLOCK_DEBIAN_WORKAROUND;ARMV6T2;USE_ARMNEON;ARMV6_ASSEMBLY;AMIBERRY;USE_SDL;CPU_arm;GCCCONSTFUNC="__attribute__((const))";%(ClCompile.PreprocessorDefinitions) -march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=hard -pipe -Wno-write-strings %(AdditionalOptions) @@ -70,7 +70,7 @@ 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) + 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;../../src/archivers;%(ClCompile.AdditionalIncludeDirectories) NDEBUG=1;RELEASE=1;_REENTRANT;CAPSLOCK_DEBIAN_WORKAROUND;ARMV6T2;USE_ARMNEON;ARMV6_ASSEMBLY;AMIBERRY;USE_SDL;CPU_arm;GCCCONSTFUNC="__attribute__((const))";%(ClCompile.PreprocessorDefinitions) -march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=hard -pipe -Wno-write-strings %(AdditionalOptions) true @@ -88,7 +88,7 @@ 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) + 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;../../src/archivers;%(ClCompile.AdditionalIncludeDirectories) NDEBUG=1;RELEASE=1;_REENTRANT;CAPSLOCK_DEBIAN_WORKAROUND;ARMV6T2;USE_ARMNEON;ARMV6_ASSEMBLY;AMIBERRY;USE_SDL;CPU_arm;GCCCONSTFUNC="__attribute__((const))";%(ClCompile.PreprocessorDefinitions) -march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard -pipe -Wno-write-strings %(AdditionalOptions) true @@ -107,7 +107,7 @@ 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) + 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;../../src/archivers;%(ClCompile.AdditionalIncludeDirectories) NDEBUG=1;RELEASE=1;_REENTRANT;CAPSLOCK_DEBIAN_WORKAROUND;ARMV6_ASSEMBLY;AMIBERRY;USE_SDL;CPU_arm;GCCCONSTFUNC="__attribute__((const))";%(ClCompile.PreprocessorDefinitions) -march=armv6zk -mfpu=vfp -mfloat-abi=hard -pipe -Wno-write-strings %(AdditionalOptions) true @@ -285,7 +285,7 @@ - + @@ -488,19 +488,16 @@ - - - @@ -508,8 +505,6 @@ - - @@ -529,15 +524,12 @@ - - - @@ -561,7 +553,6 @@ - diff --git a/VisualGDB/Amiberry/Amiberry.vcxproj.filters b/VisualGDB/Amiberry/Amiberry.vcxproj.filters index 12db2b94..88787e75 100644 --- a/VisualGDB/Amiberry/Amiberry.vcxproj.filters +++ b/VisualGDB/Amiberry/Amiberry.vcxproj.filters @@ -513,9 +513,6 @@ Source files\osdep - - Source files\osdep - Source files\archivers\7z @@ -693,6 +690,9 @@ Source files\archivers\7z + + Source files\osdep + @@ -780,9 +780,6 @@ Header files\include - - Header files\include - Header files\include @@ -798,9 +795,6 @@ Header files\include - - Header files\include - Header files\include @@ -810,9 +804,6 @@ Header files\include - - Header files\include - Header files\include @@ -828,12 +819,6 @@ Header files\include - - Header files\include - - - Header files\include - Header files\include @@ -879,12 +864,6 @@ Header files\include - - Header files\include - - - Header files\include - Header files\include @@ -900,9 +879,6 @@ Header files\include - - Header files\include - Header files\include @@ -1035,9 +1011,6 @@ Header files\machdep - - Header files\machdep - Header files\machdep diff --git a/src/akiko.cpp b/src/akiko.cpp index d19367ad..02f92cc4 100644 --- a/src/akiko.cpp +++ b/src/akiko.cpp @@ -31,10 +31,10 @@ // 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 (!(intreq & 8)) { - INTREQ_0(0x8000 | 0x0008); + INTREQ_0 (0x8000 | 0x0008); } } @@ -55,7 +55,7 @@ static uae_u8 cd32_i2c_direction; static bool cd32_i2c_data_scl, cd32_i2c_data_sda; static struct zfile *flashfile; -static void nvram_read(void) +static void nvram_read (void) { zfile_fclose(flashfile); flashfile = NULL; @@ -68,9 +68,9 @@ static void nvram_read(void) 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); + flashfile = zfile_fopen (currprefs.flashfile, _T("rb+"), ZFD_NORMAL); if (!flashfile) - flashfile = zfile_fopen(currprefs.flashfile, _T("wb"), 0); + 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) @@ -79,7 +79,7 @@ static void nvram_read(void) cd32_eeprom = eeprom_new(cd32_nvram, currprefs.cs_cd32nvram_size, flashfile); } -static void akiko_nvram_write(int offset, uae_u32 v) +static void akiko_nvram_write (int offset, uae_u32 v) { switch (offset) { @@ -101,7 +101,7 @@ static void akiko_nvram_write(int offset, uae_u32 v) } } -static uae_u32 akiko_nvram_read(int offset) +static uae_u32 akiko_nvram_read (int offset) { uae_u32 v = 0; switch (offset) @@ -129,62 +129,62 @@ static uae_u32 akiko_result[8]; /* 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])); } } -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; @@ -192,12 +192,12 @@ static void akiko_c2p_write(int offset, uae_u32 v) akiko_read_offset = -1; } -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_c2p_do (); akiko_read_offset = 0; } akiko_write_offset = 0; @@ -304,63 +304,63 @@ static smp_comm_pipe requests; static volatile int akiko_thread_running; static uae_sem_t akiko_sem = 0, sub_sem = 0; -static void checkint(void) +static void checkint (void) { if (cdrom_intreq & cdrom_intena) { - irq(); + irq (); } } -static void set_status(uae_u32 status) +static void set_status (uae_u32 status) { 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 (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,10 +368,10 @@ 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, int playpos) { if (status == -1) return 0; @@ -381,7 +381,7 @@ static int statusfunc(int status, int playpos) if (status == AUDIO_STATUS_IN_PROGRESS) { cdrom_playing = 1; cdrom_audiotimeout = 1; - } + } if (cdrom_playing && status != AUDIO_STATUS_IN_PROGRESS && status != AUDIO_STATUS_PAUSED && status != AUDIO_STATUS_NOT_SUPPORTED) { cdrom_audiotimeout = -1; } @@ -390,19 +390,19 @@ static int statusfunc(int status, int playpos) 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,13 +418,13 @@ 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("CD32: 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++) { struct cd_toc *s = &cdrom_toc_cd_buffer.toc[i]; @@ -436,17 +436,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("CD32: tried to play data track %d!\n"), s->track); s++; startlsn = s->paddress; s++; @@ -458,22 +458,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 +483,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,43 +508,43 @@ 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)); } } 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); 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) secondtrack = addr; } - cdrom_toc_crc = get_crc32(cdrom_toc_buffer, cdrom_toc_cd_buffer.points * 13); + cdrom_toc_crc = get_crc32 (cdrom_toc_buffer, cdrom_toc_cd_buffer.points * 13); return 0; } static bool is_valid_data_sector(int sector) @@ -562,26 +562,26 @@ static bool is_valid_data_sector(int sector) } /* 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); + 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); /* 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) @@ -591,7 +591,7 @@ static bool cdrom_can_return_data(void) return true; } -static int cdrom_start_return_data(int len) +static int cdrom_start_return_data (int len) { if (!cdrom_can_return_data()) return 0; @@ -609,14 +609,14 @@ static int cdrom_start_return_data(int len) } /* -RX DMA channel writes bytes to memory if DMA enabled, cdcomrxinx != cdcomrxcmp -and there is data available from CDROM firmware code. - -Triggers CDINTERRUPT_RXDMADONE and stops transfer (even if there is -more data available) when cdcomrxinx matches cdcomrxcmp + RX DMA channel writes bytes to memory if DMA enabled, cdcomrxinx != cdcomrxcmp + and there is data available from CDROM firmware code. + + Triggers CDINTERRUPT_RXDMADONE and stops transfer (even if there is + 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; @@ -631,13 +631,13 @@ static void cdrom_return_data(void) while (cdrom_receive_offset < cdrom_receive_length) { cdrom_last_rx = cdrom_result_buffer[cdrom_receive_offset]; - put_byte(cmd_buf + cdcomrxinx, cdrom_last_rx); + put_byte (cmd_buf + cdcomrxinx, cdrom_last_rx); cdcomrxinx++; cdrom_receive_offset++; - if (cdcomrxinx == cdcomrxcmp) { - set_status(CDINTERRUPT_RXDMADONE); + if (cdcomrxinx == cdcomrxcmp) { + set_status (CDINTERRUPT_RXDMADONE); break; - } + } } if (cdrom_receive_offset == cdrom_receive_length) { @@ -648,14 +648,14 @@ static void cdrom_return_data(void) } } -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; @@ -664,28 +664,28 @@ 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 ? 0x01: 0x00; 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; 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; return 20; @@ -693,7 +693,7 @@ static int cdrom_command_status(void) /* 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 (cdrom_toc_cd_buffer.points == 0) { @@ -701,7 +701,7 @@ static int cdrom_return_toc_entry(void) 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); + 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); @@ -711,7 +711,7 @@ static int cdrom_return_toc_entry(void) return 15; } -static int checkerr(void) +static int checkerr (void) { if (!cdrom_disk) { cdrom_result_buffer[1] = CH_ERR_NODISK | cdrom_door; @@ -720,24 +720,24 @@ static int checkerr(void) 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) { 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; if (cdrom_paused) @@ -745,15 +745,15 @@ static int cdrom_command_pause(void) 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) { cdrom_result_buffer[0] = cdrom_command; - if (checkerr()) + if (checkerr ()) return 2; cdrom_result_buffer[1] = (cdrom_playing ? CDS_PLAYING : 0) | cdrom_door; if (!cdrom_paused) @@ -761,18 +761,18 @@ static int cdrom_command_unpause(void) 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(); + cdaudiostop (); cdrom_paused = 0; cdrom_speed = (cdrom_command_buffer[8] & 0x40) ? 2 : 1; cdrom_result_buffer[0] = cdrom_command; @@ -784,37 +784,34 @@ static int cdrom_command_multi(void) if (cdrom_command_buffer[7] & 0x80) { /* data read */ cdrom_data_offset = seekpos; - cdrom_seek_delay = abs(cdrom_current_sector - cdrom_data_offset); + cdrom_seek_delay = abs (cdrom_current_sector - cdrom_data_offset); if (cdrom_seek_delay < 100 || currprefs.cd_speed == 0) { cdrom_seek_delay = 1; - } - else { + } else { cdrom_seek_delay /= 1000; cdrom_seek_delay += 10; if (cdrom_seek_delay > 100) cdrom_seek_delay = 100; } cdrom_result_buffer[1] |= 0x02; - } - else { /* play audio */ - // offset 10, bit 2 set: don't send subchannel data + } else { /* play audio */ + // offset 10, bit 2 set: don't send subchannel data if (seekpos < 0) { cdrom_toc_counter = 0; - } - else { + } 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; - } + cdrom_playing = 1; + if (!cd_play_audio (seekpos, endpos, 0)) { + // play didn't start, report it in next status packet + cdrom_audiotimeout = -3; + } } } return 2; } -static int cdrom_playend_notify(int status) +static int cdrom_playend_notify (int status) { cdrom_result_buffer[0] = 4; if (status < 0) @@ -828,11 +825,11 @@ static int cdrom_playend_notify(int status) } /* 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; } @@ -853,7 +850,7 @@ static bool cdrom_add_command_byte(uae_u8 b) return true; } - if (cmd_len + 1 > cdrom_command_length) + if (cmd_len + 1 > cdrom_command_length) return false; uae_u8 checksum = 0; @@ -870,11 +867,11 @@ static bool cdrom_add_command_byte(uae_u8 b) } /* -TX DMA reads bytes from memory and sends them to -CDROM hardware if TX DMA enabled, CDROM data transfer -DMA not enabled and cdcomtxinx != cdcomtx. + TX DMA reads bytes from memory and sends them to + CDROM hardware if TX DMA enabled, CDROM data transfer + DMA not enabled and cdcomtxinx != cdcomtx. -CDINTERRUPT_TXDMADONE triggered when cdromtxinx matches cdcomtx. + CDINTERRUPT_TXDMADONE triggered when cdromtxinx matches cdcomtx. */ static bool can_send_command(void) @@ -888,12 +885,12 @@ static bool can_send_command(void) return true; } -static void cdrom_run_command(void) +static void cdrom_run_command (void) { if (!(cdrom_flags & CDFLAG_TXD)) return; if (cdrom_flags & CDFLAG_ENABLE) - return; + return; if (cdcomtxinx == cdcomtxcmp) return; if (cdrom_tx_dma_delay > 0) @@ -906,18 +903,18 @@ static void cdrom_run_command(void) cdcomtxinx++; if (cdcomtxinx == cdcomtxcmp) { - set_status(CDINTERRUPT_TXDMADONE); + 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)); + memset (cdrom_result_buffer, 0, sizeof (cdrom_result_buffer)); if (cdrom_checksum_error || cdrom_unknown_command) { cdrom_result_buffer[0] = (cdrom_command & 0xf0) | 5; @@ -926,7 +923,7 @@ static void cdrom_run_command_run(void) else if (cdrom_unknown_command) cdrom_result_buffer[1] |= CH_ERR_BADCOMMAND | cdrom_door; len = 2; - cdrom_start_return_data(len); + cdrom_start_return_data (len); return; } @@ -937,25 +934,25 @@ 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; @@ -965,11 +962,11 @@ static void cdrom_run_command_run(void) set_status(CDINTERRUPT_DRIVEXMIT); 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; @@ -998,17 +995,17 @@ 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); + set_status (CDINTERRUPT_PBX); if ((cdrom_flags & CDFLAG_RAW) || !(cdrom_flags & CDFLAG_CAS)) write_log(_T("CD32: Akiko warning: Flags = %08x!\n"), cdrom_flags); @@ -1030,14 +1027,12 @@ static void cdrom_run_read(void) set_status(CDINTERRUPT_SUBCODE); } - } - else { + } else { inc = 0; } if (sector_buffer_info_1[sec] != 0xff) sector_buffer_info_1[sec]--; - } - else { + } else { inc = 0; } if (inc) @@ -1046,7 +1041,7 @@ 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; @@ -1067,11 +1062,11 @@ static void akiko_handler(bool framesync) if (mediachanged) { if (cdrom_can_return_data()) { - cdrom_start_return_data(cdrom_command_media_status()); + 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; } @@ -1079,51 +1074,50 @@ static void akiko_handler(bool framesync) cdrom_audiotimeout--; if (cdrom_audiotimeout == 1 && cdrom_can_return_data()) { // play start if (!cdrom_playing) - cdrom_playing = 1; + cdrom_playing = 1; if (cdrom_playing == 1) - cdrom_start_return_data(cdrom_playend_notify(0)); + cdrom_start_return_data (cdrom_playend_notify (0)); cdrom_playing = 2; 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)); + cdrom_start_return_data (cdrom_playend_notify (1)); cdrom_audiotimeout = 0; } - // play didn't start notification (illegal address) + // 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)); + 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()); + 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; @@ -1134,9 +1128,8 @@ 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); @@ -1153,7 +1146,7 @@ void AKIKO_hsync_handler(void) 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; @@ -1161,17 +1154,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, 0xffff0000); 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; } @@ -1181,12 +1174,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; @@ -1194,97 +1187,93 @@ 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, -1, false)) { 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); - lastmediastate = cdrom_disk = media; - mediachanged = 1; - cdaudiostop_do(); - } - } + } else { + write_log (_T("CD32: media changed = %d\n"), media); + lastmediastate = cdrom_disk = media; + mediachanged = 1; + 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) && - (sector_buffer_sector_1 < 0 || sector < sector_buffer_sector_1 || sector >= sector_buffer_sector_1 + SECTOR_BUFFER_SIZE * 2 / 3 || i != SECTOR_BUFFER_SIZE)) { + (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); 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 { + } else { blocks = SECTOR_BUFFER_SIZE; } if (blocks) { - int ok = sys_command_cd_rawread(unitnum, sector_buffer_2, sector, blocks, 2352); + 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++; + 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 { + } else { for (int i = 0; i < SECTOR_BUFFER_SIZE; i++) sector_buffer_info_2[i] = i < blocks ? 3 : 0; } @@ -1299,34 +1288,34 @@ static void *akiko_thread(void *null) 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; @@ -1335,9 +1324,9 @@ static uae_u32 akiko_bget2(uaecptr addr, int msg) switch (addr) { /* "C0CACAFE" = Akiko identification. - * Kickstart Akiko C2P support requires $CAFE at $B80002.W - * $B80000 $C0CA is not checked. - */ + * Kickstart Akiko C2P support requires $CAFE at $B80002.W + * $B80000 $C0CA is not checked. + */ case 0x00: return 0xC0; case 0x01: @@ -1351,7 +1340,7 @@ 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 */ @@ -1360,100 +1349,99 @@ static uae_u32 akiko_bget2(uaecptr addr, int msg) 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 */ - case 0x04: - case 0x05: - case 0x06: - case 0x07: - v = akiko_get_long(cdrom_intreq, addr - 0x04); - break; + case 0x04: + case 0x05: + case 0x06: + case 0x07: + v = akiko_get_long (cdrom_intreq, addr - 0x04); + break; - case 0x08: - case 0x09: - case 0x0a: - case 0x0b: - v = akiko_get_long(cdrom_intena, addr - 0x08); - break; + case 0x08: + case 0x09: + case 0x0a: + 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; + 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 0x14: - case 0x1c: - 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 0x18: + case 0x10: + case 0x14: + case 0x1c: + 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; - break; + case 0x13: + case 0x17: + case 0x1f: + v = 0; + break; - case 0x20: - case 0x21: - v = akiko_get_long(cdrom_pbx, addr - 0x20 + 2); - break; + case 0x20: + case 0x21: + 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); - break; + case 0x24: + case 0x25: + case 0x26: + case 0x27: + v = akiko_get_long (cdrom_flags, addr - 0x24); + 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) { + 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; - cdrom_receive_length = 0; - set_status(CDINTERRUPT_DRIVEXMIT); } - } - else { - cdrom_intreq &= ~CDINTERRUPT_DRIVERECV; - } - v = cdrom_last_rx; - break; + 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); return v; } @@ -1465,45 +1453,45 @@ static void check_read_c2p(uaecptr addr) akiko_read_offset &= 7; } -static uae_u32 REGPARAM2 akiko_bget(uaecptr addr) +static uae_u32 REGPARAM2 akiko_bget (uaecptr addr) { uae_u8 v; addr &= 0xffff; if (addr >= 0x8000) return 0; - v = akiko_bget2(addr, 1); + 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; addr &= 0xffff; if (addr >= 0x8000) return 0; - v = akiko_bget2(addr + 1, 0); - v |= akiko_bget2(addr + 0, 0) << 8; + v = akiko_bget2 (addr + 1, 0); + v |= akiko_bget2 (addr + 0, 0) << 8; check_read_c2p(addr); return v; } -static uae_u32 REGPARAM2 akiko_lget(uaecptr addr) +static uae_u32 REGPARAM2 akiko_lget (uaecptr addr) { uae_u32 v; 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; + 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); return v; } -static void akiko_bput2(uaecptr addr, uae_u32 v, int msg) +static void akiko_bput2 (uaecptr addr, uae_u32 v, int msg) { uae_u32 tmp; @@ -1517,7 +1505,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: @@ -1525,103 +1513,103 @@ 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); - } - } - } - break; + 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); + } + } + } + break; - default: - write_log(_T("akiko_bput: unknown address %08X=%02X PC=%08X\n"), addr, v & 0xff, M68K_GETPC); - break; + default: + 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) @@ -1629,32 +1617,32 @@ 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); + 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); + 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 = { @@ -1665,47 +1653,47 @@ 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; - } - } - write_log(_T("CD32: couldn't patch extended rom\n")); - } - } + 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; + } + } + write_log (_T("CD32: 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(); + cdaudiostop_do (); + nvram_read (); eeprom_reset(cd32_eeprom); cdrom_speed = 1; @@ -1726,70 +1714,70 @@ 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); + destroy_comm_pipe(&requests); 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_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); + if(sub_sem != 0) + uae_sem_destroy(&sub_sem); sub_sem = 0; } -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); + 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); + 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 (&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; @@ -1800,101 +1788,101 @@ 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 (cd32_i2c_direction << 8); + 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(); + 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(); + 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) @@ -1903,46 +1891,46 @@ 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; } #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/ar.cpp b/src/ar.cpp index ae9fd529..bc32c4e2 100644 --- a/src/ar.cpp +++ b/src/ar.cpp @@ -206,12 +206,12 @@ #include "options.h" #include "uae.h" -#include "include/memory.h" +#include "memory.h" #include "rommgr.h" #include "custom.h" #include "newcpu.h" #include "zfile.h" -#include "include/ar.h" +#include "ar.h" #include "savestate.h" #include "crc32.h" #include "akiko.h" diff --git a/src/archivers/7z/7zAlloc.cpp b/src/archivers/7z/7zAlloc.cpp new file mode 100644 index 00000000..964b28db --- /dev/null +++ b/src/archivers/7z/7zAlloc.cpp @@ -0,0 +1,76 @@ +/* 7zAlloc.c -- Allocation functions +2010-10-29 : Igor Pavlov : Public domain */ + +#include "7zAlloc.h" + +/* #define _SZ_ALLOC_DEBUG */ +/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ + +#ifdef _SZ_ALLOC_DEBUG + +#ifdef _WIN32 +#include +#endif + +#include +int g_allocCount = 0; +int g_allocCountTemp = 0; + +#endif + +void *SzAlloc(void *p, size_t size) +{ + p = p; + if (size == 0) + return 0; + #ifdef _SZ_ALLOC_DEBUG + fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount); + g_allocCount++; + #endif + return malloc(size); +} + +void SzFree(void *p, void *address) +{ + p = p; + #ifdef _SZ_ALLOC_DEBUG + if (address != 0) + { + g_allocCount--; + fprintf(stderr, "\nFree; count = %10d", g_allocCount); + } + #endif + free(address); +} + +void *SzAllocTemp(void *p, size_t size) +{ + p = p; + if (size == 0) + return 0; + #ifdef _SZ_ALLOC_DEBUG + fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp); + g_allocCountTemp++; + #ifdef _WIN32 + return HeapAlloc(GetProcessHeap(), 0, size); + #endif + #endif + return malloc(size); +} + +void SzFreeTemp(void *p, void *address) +{ + p = p; + #ifdef _SZ_ALLOC_DEBUG + if (address != 0) + { + g_allocCountTemp--; + fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp); + } + #ifdef _WIN32 + HeapFree(GetProcessHeap(), 0, address); + return; + #endif + #endif + free(address); +} diff --git a/src/archivers/7z/7zAlloc.h b/src/archivers/7z/7zAlloc.h new file mode 100644 index 00000000..3344e937 --- /dev/null +++ b/src/archivers/7z/7zAlloc.h @@ -0,0 +1,15 @@ +/* 7zAlloc.h -- Allocation functions +2010-10-29 : Igor Pavlov : Public domain */ + +#ifndef __7Z_ALLOC_H +#define __7Z_ALLOC_H + +#include + +void *SzAlloc(void *p, size_t size); +void SzFree(void *p, void *address); + +void *SzAllocTemp(void *p, size_t size); +void SzFreeTemp(void *p, void *address); + +#endif diff --git a/src/archivers/7z/7zDec.cpp b/src/archivers/7z/7zDec.cpp index 6f321baf..b6d80995 100644 --- a/src/archivers/7z/7zDec.cpp +++ b/src/archivers/7z/7zDec.cpp @@ -142,7 +142,7 @@ static SRes SzDecodeLzma(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inSt size_t lookahead = (1 << 18); if (lookahead > inSize) lookahead = (size_t)inSize; - res = inStream->Look((void *)inStream, (void **)&inBuf, &lookahead); + res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); if (res != SZ_OK) break; @@ -192,7 +192,7 @@ static SRes SzDecodeLzma2(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inS size_t lookahead = (1 << 18); if (lookahead > inSize) lookahead = (size_t)inSize; - res = inStream->Look((void *)inStream, (void **)&inBuf, &lookahead); + res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); if (res != SZ_OK) break; @@ -229,7 +229,7 @@ static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer size_t curSize = (1 << 18); if (curSize > inSize) curSize = (size_t)inSize; - RINOK(inStream->Look((void *)inStream, (void **)&inBuf, &curSize)); + RINOK(inStream->Look((void *)inStream, (const void **)&inBuf, &curSize)); if (curSize == 0) return SZ_ERROR_INPUT_EOF; memcpy(outBuffer, inBuf, curSize); diff --git a/src/archivers/7z/7zStream.cpp b/src/archivers/7z/7zStream.cpp index 32c361a7..f0959fb0 100644 --- a/src/archivers/7z/7zStream.cpp +++ b/src/archivers/7z/7zStream.cpp @@ -39,7 +39,7 @@ SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset) SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size) { - void *lookBuf; + const void *lookBuf; if (*size == 0) return SZ_OK; RINOK(stream->Look(stream, &lookBuf, size)); @@ -66,7 +66,7 @@ SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size) return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); } -static SRes LookToRead_Look_Lookahead(void *pp, void **buf, size_t *size) +static SRes LookToRead_Look_Lookahead(void *pp, const void **buf, size_t *size) { SRes res = SZ_OK; CLookToRead *p = (CLookToRead *)pp; @@ -84,7 +84,7 @@ static SRes LookToRead_Look_Lookahead(void *pp, void **buf, size_t *size) return res; } -static SRes LookToRead_Look_Exact(void *pp, void **buf, size_t *size) +static SRes LookToRead_Look_Exact(void *pp, const void **buf, size_t *size) { SRes res = SZ_OK; CLookToRead *p = (CLookToRead *)pp; diff --git a/src/archivers/7z/Types.h b/src/archivers/7z/Types.h index 2f8542b9..18b0dcb0 100644 --- a/src/archivers/7z/Types.h +++ b/src/archivers/7z/Types.h @@ -168,7 +168,7 @@ typedef struct typedef struct { - SRes (*Look)(void *p, void **buf, size_t *size); + SRes (*Look)(void *p, const void **buf, size_t *size); /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. (output(*size) > input(*size)) is not allowed (output(*size) < input(*size)) is allowed */ diff --git a/src/audio.cpp b/src/audio.cpp index eb9e2bf2..fb5875ee 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -1,16 +1,16 @@ -/* -* UAE - The Un*x Amiga Emulator -* -* Paula audio emulation -* -* Copyright 1995, 1996, 1997 Bernd Schmidt -* Copyright 1996 Marcus Sundberg -* Copyright 1996 Manfred Thole -* Copyright 2006 Toni Wilen -* -* new filter algorithm and anti&sinc interpolators by Antti S. Lankila -* -*/ + /* + * UAE - The Un*x Amiga Emulator + * + * Paula audio emulation + * + * Copyright 1995, 1996, 1997 Bernd Schmidt + * Copyright 1996 Marcus Sundberg + * Copyright 1996 Manfred Thole + * Copyright 2006 Toni Wilen + * + * new filter algorithm and anti&sinc interpolators by Antti S. Lankila + * + */ #include "sysconfig.h" #include "sysdeps.h" @@ -33,17 +33,17 @@ 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; } #define SINC_QUEUE_MAX_AGE 2048 /* Queue length 256 implies minimum emulated period of 8. This should be -* sufficient for all imaginable purposes. This must be power of two. */ + * sufficient for all imaginable purposes. This must be power of two. */ #define SINC_QUEUE_LENGTH 256 #include "sinctable.cpp" @@ -61,23 +61,23 @@ struct audio_channel_data2 int sinc_queue_time; int sinc_queue_head; int vol; - unsigned int adk_mask; + unsigned int adk_mask; }; struct audio_channel_data { - unsigned int evtime; + 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; + uaecptr lc, pt; + int state; + int per; + int len, wlen; + uae_u16 dat, dat2; struct audio_channel_data2 data; /* too fast cpu fixes */ uaecptr ptx; @@ -89,8 +89,8 @@ struct audio_channel_data static struct audio_channel_data audio_channel[AUDIO_CHANNELS_PAULA]; static struct audio_channel_data2 *audio_data[AUDIO_CHANNELS_PAULA]; 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; @@ -102,15 +102,13 @@ static unsigned long next_sample_evtime; typedef uae_s8 sample8_t; #define DO_CHANNEL_1(v, c) do { (v) *= audio_channel[c].data.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) { - data >>= bits - 16; - } - else { + } else if (bits - 16 > 0) { + data >>= bits - 16; + } else { int shift = 16 - bits; data <<= shift; } @@ -125,12 +123,12 @@ static int mixed_on, mixed_stereo_size, mixed_mul1, mixed_mul2; static int led_filter_forced, sound_use_filter, sound_use_filter_sinc, led_filter_on; /* denormals are very small floating point numbers that force FPUs into slow -mode. All lowpass filters using floats are suspectible to denormals unless -a small offset is added to avoid very small floating point numbers. */ + mode. All lowpass filters using floats are suspectible to denormals unless + a small offset is added to avoid very small floating point numbers. */ #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; @@ -138,214 +136,213 @@ 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 -* on A500 and the LED filter. This code emulates both. -* -* The Amiga filtering circuitry depends on Amiga model. Older Amigas seem -* to have a 6 dB/oct RC filter with cutoff frequency such that the -6 dB -* point for filter is reached at 6 kHz, while newer Amigas have no filtering. -* -* The LED filter is complicated, and we are modelling it with a pair of -* RC filters, the other providing a highboost. The LED starts to cut -* into signal somewhere around 5-6 kHz, and there's some kind of highboost -* in effect above 12 kHz. Better measurements are required. -* -* The current filtering should be accurate to 2 dB with the filter on, -* and to 1 dB with the filter off. + * on A500 and the LED filter. This code emulates both. + * + * The Amiga filtering circuitry depends on Amiga model. Older Amigas seem + * to have a 6 dB/oct RC filter with cutoff frequency such that the -6 dB + * point for filter is reached at 6 kHz, while newer Amigas have no filtering. + * + * The LED filter is complicated, and we are modelling it with a pair of + * RC filters, the other providing a highboost. The LED starts to cut + * into signal somewhere around 5-6 kHz, and there's some kind of highboost + * in effect above 12 kHz. Better measurements are required. + * + * The current filtering should be accurate to 2 dB with the filter on, + * and to 1 dB with the filter off. */ 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; + + case FILTER_MODEL_A1200: + normal_output = input; - led_output = fs->rc5; - break; + 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; - case FILTER_MODEL_A1200: - normal_output = input; + led_output = fs->rc4; + break; - 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; + case FILTER_NONE: + default: + return input; - led_output = fs->rc4; - break; + } - case FILTER_NONE: - default: - return input; + if (led_filter_on) + o = led_output; + else + o = normal_output; - } + if (o > 32767) + o = 32767; + else if (o < -32768) + o = -32768; - if (led_filter_on) - o = led_output; - else - o = normal_output; - - 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) { uae_u32 rold, lold, tmp; - lnew = filter(lnew, &sound_filter_state[0]); - rnew = filter(rnew, &sound_filter_state[1]); + lnew = filter (lnew, &sound_filter_state[0]); + rnew = filter (rnew, &sound_filter_state[1]); - left_word_saved[saved_ptr] = lnew; - right_word_saved[saved_ptr] = rnew; + left_word_saved[saved_ptr] = lnew; + right_word_saved[saved_ptr] = rnew; - 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 = (rnew * 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]; + lnew = (lnew * mixed_mul2 + rold * mixed_mul1) / MIXED_STEREO_SCALE; - PUT_SOUND_WORD_STEREO(lnew, tmp); + PUT_SOUND_WORD_STEREO(lnew, 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) { uae_u32 rold, lold, tmp; - left_word_saved[saved_ptr] = lnew; - right_word_saved[saved_ptr] = rnew; + left_word_saved[saved_ptr] = lnew; + right_word_saved[saved_ptr] = rnew; - 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 = (rnew * 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]; + lnew = (lnew * mixed_mul2 + rold * mixed_mul1) / MIXED_STEREO_SCALE; - PUT_SOUND_WORD_STEREO(lnew, tmp); + PUT_SOUND_WORD_STEREO(lnew, 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_data2 *acd; - /* Handle accumulator antialiasiation */ - for (i = 0; i < AUDIO_CHANNELS_PAULA; i++) { + /* 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; - } + 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++) { + 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; - } + } } -static void sinc_prehandler_paula(unsigned long best_evtime) +static void sinc_prehandler_paula (unsigned long best_evtime) { int i, output; - struct audio_channel_data2 *acd; + struct audio_channel_data2 *acd; - for (i = 0; i < AUDIO_CHANNELS_PAULA; i++) { + for (i = 0; i < AUDIO_CHANNELS_PAULA; i++) { acd = audio_data[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 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) { 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) + * functions) with a type of BLEP that matches the filtering configuration. */ +STATIC_INLINE void samplexx_sinc_handler (int *datasp) { - int n, i; - int const *winsinc; + int n, i; + 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; + 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 */ + /* 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; @@ -355,66 +352,66 @@ 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[AUDIO_CHANNELS_PAULA], data1; + + samplexx_sinc_handler (datas); + data1 = datas[0] + datas[3] + datas[1] + datas[2]; + data1 = FINISH_DATA (data1, 18); - 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(); + set_sound_buffers (); + put_sound_word_mono_func (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; + 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; + + data = FINISH_DATA (data, 16); - data = FINISH_DATA(data, 16); - - set_sound_buffers(); - put_sound_word_mono_func(data); - check_sound_buffers(); + set_sound_buffers (); + put_sound_word_mono_func (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) + * voltage and computes the average of Paula's output */ +static void sample16i_anti_handler (void) { - int datas[AUDIO_CHANNELS_PAULA], data1; + int datas[AUDIO_CHANNELS_PAULA], data1; - samplexx_anti_handler(datas); - data1 = datas[0] + datas[3] + datas[1] + datas[2]; - data1 = FINISH_DATA(data1, 16); + 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(); + set_sound_buffers (); + put_sound_word_mono_func (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; @@ -426,14 +423,14 @@ static void sample16i_rh_handler(void) int data3p = audio_channel[3].data.last_sample; int 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; @@ -444,28 +441,28 @@ static void sample16i_rh_handler(void) data3 &= audio_channel[3].data.adk_mask; data3p &= audio_channel[3].data.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); + data = FINISH_DATA (data, 16); - set_sound_buffers(); - put_sound_word_mono_func(data); - check_sound_buffers(); + set_sound_buffers (); + put_sound_word_mono_func (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; @@ -477,14 +474,14 @@ static void sample16i_crux_handler(void) int data3p = audio_channel[3].data.last_sample; int 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; @@ -495,101 +492,101 @@ static void sample16i_crux_handler(void) data3 &= audio_channel[3].data.adk_mask; data3p &= audio_channel[3].data.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); + data = FINISH_DATA (data, 16); - set_sound_buffers(); - put_sound_word_mono_func(data); - check_sound_buffers(); + set_sound_buffers (); + put_sound_word_mono_func (data); + check_sound_buffers (); } #ifdef HAVE_STEREO_SUPPORT /* This interpolator examines sample points when Paula switches the output -* voltage and computes the average of Paula's 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[AUDIO_CHANNELS_PAULA], 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); + 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(); + 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[AUDIO_CHANNELS_PAULA], 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); + 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(); + 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); + 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); - 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; @@ -600,14 +597,14 @@ static void sample16si_crux_handler(void) int data2p = audio_channel[2].data.last_sample; int data3p = audio_channel[3].data.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; @@ -618,51 +615,51 @@ static void sample16si_crux_handler(void) data3 &= audio_channel[3].data.adk_mask; data3p &= audio_channel[3].data.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); + 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(); + 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; @@ -673,14 +670,14 @@ static void sample16si_rh_handler(void) int data2p = audio_channel[2].data.last_sample; int data3p = audio_channel[3].data.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; @@ -691,112 +688,112 @@ static void sample16si_rh_handler(void) data3 &= audio_channel[3].data.adk_mask; data3p &= audio_channel[3].data.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); + /* 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(); + 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 < AUDIO_CHANNELS_PAULA; 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 < AUDIO_CHANNELS_PAULA; 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; + 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; + 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) @@ -809,7 +806,7 @@ STATIC_INLINE void update_volume(int nr, uae_u16 v) 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++) { @@ -823,24 +820,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; -} +} -STATIC_INLINE void setdr(int nr) +STATIC_INLINE void setdr (int nr) { struct audio_channel_data *cdp = audio_channel + nr; cdp->dr = true; @@ -849,7 +846,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); @@ -864,31 +861,29 @@ static void loaddat(int nr, bool modper) cdp[1].per = cdp->dat * CYCLE_UNIT; else cdp[1].per = PERIOD_MIN * CYCLE_UNIT; - } - else if (audav) { + } else if (audav) { update_volume(nr + 1, cdp->dat); } - } - else { + } 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)); @@ -896,27 +891,27 @@ 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); + zerostate (nr); } } @@ -930,40 +925,37 @@ static void audio_state_channel2(int nr, bool perfin) cdp->wlen = cdp->len; cdp->ptx_written = false; /* Some programs first start short empty sample and then later switch to - * real sample, we must not enable the hack in this case - */ + * real sample, we must not enable the hack in this case + */ 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 { + newsample (nr, (cdp->dat2 >> 0) & 0xff); + zerostate (nr); + } else { cdp->pbufldl = true; - audio_state_channel2(nr, false); + audio_state_channel2 (nr, false); } - } - else { - zerostate(nr); + } 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; @@ -971,7 +963,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) @@ -980,397 +972,390 @@ 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(); + update_audio (); for (int nr = 0; nr < AUDIO_CHANNELS_PAULA; 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()) { + 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 = &audio_channel[i]; + memset (cdp, 0, sizeof *audio_channel); + cdp->per = PERIOD_MAX - 1; cdp->data.vol = 0; - cdp->evtime = MAX_EV; - } - } + cdp->evtime = MAX_EV; + } + } - last_cycles = get_cycles(); - next_sample_evtime = scaled_sample_evtime; + last_cycles = get_cycles (); + next_sample_evtime = scaled_sample_evtime; - schedule_audio(); - events_schedule(); + 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 + 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; + || 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. */ + * The a1 term is 1.0 - b0. The center frequency marks the -3 dB point. */ #ifndef M_PI #define M_PI 3.14159265358979323846 #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; + 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; } -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_filter = changed_prefs.sound_filter; + currprefs.sound_filter_type = changed_prefs.sound_filter_type; currprefs.sound_volume_cd = changed_prefs.sound_volume_cd; 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); - } + 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(); + 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) + /* 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; - } + 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 (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.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(); - } - set_config_changed(); + if (currprefs.produce_sound == 0) { + eventtab[ev_audio].active = 0; + events_schedule (); + } else { + audio_activate (); + schedule_audio (); + events_schedule (); + } + set_config_changed (); } -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 < AUDIO_CHANNELS_PAULA; 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 < AUDIO_CHANNELS_PAULA; 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 < AUDIO_CHANNELS_PAULA; i++) { if (audio_channel[i].evtime == 0) { - audio_state_channel(i, true); + audio_state_channel (i, true); } - } + } } 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) { struct audio_channel_data *cdp = audio_channel + nr; int chan_ena = (dmacon & DMA_MASTER) && (dmacon & (1 << nr)); @@ -1382,194 +1367,190 @@ void AUDxDAT(int nr, uae_u16 v) if (cdp->wlen == 1) { cdp->wlen = cdp->len; cdp->intreq2 = true; - } - else { + } 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 audio_dmal_do(int nr, bool reset) +void audio_dmal_do (int nr, bool reset) { struct audio_channel_data *cdp = audio_channel + nr; - uae_u16 dat = chipmem_wget_indirect(cdp->pt); - cdp->pt += 2; + uae_u16 dat = chipmem_wget_indirect (cdp->pt); + cdp->pt += 2; if (reset) cdp->pt = cdp->lc; cdp->ptx_tofetch = false; - AUDxDAT(nr, dat); + AUDxDAT (nr, dat); } -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 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 */ + /* smaller values would cause extremely high cpu usage */ per = PERIOD_MIN * CYCLE_UNIT; } if (per < PERIOD_MIN_NONCE * CYCLE_UNIT && cdp->dmaenstore) { /* DMAL emulation and low period can cause very very high cpu usage on slow performance PCs - * Only do this hack if audio DMA is active. - */ + * Only do this hack if audio DMA is active. + */ 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(); + audio_activate(); + update_audio (); update_volume(nr, 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; - } + 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->data.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->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; } diff --git a/src/autoconf.cpp b/src/autoconf.cpp index eae34a01..7b93dadd 100644 --- a/src/autoconf.cpp +++ b/src/autoconf.cpp @@ -1,18 +1,18 @@ -/* -* 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" #include "options.h" #include "uae.h" -#include "include/memory.h" +#include "memory.h" #include "custom.h" #include "newcpu.h" #include "autoconf.h" @@ -31,30 +31,30 @@ uaecptr rtarea_base = RTAREA_DEFAULT; DECLARE_MEMORY_FUNCTIONS(rtarea); addrbank rtarea_bank = { - rtarea_lget, rtarea_wget, rtarea_bget, - rtarea_lput, rtarea_wput, rtarea_bput, - rtarea_xlate, rtarea_check, nullptr, _T("rtarea"), _T("UAE Boot ROM"), + 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 }; #define RTAREA_WRITEOFFSET 0xfff0 -static uae_u8 *REGPARAM2 rtarea_xlate(uaecptr addr) +static uae_u8 *REGPARAM2 rtarea_xlate (uaecptr addr) { - addr &= 0xFFFF; + 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,9 +62,9 @@ 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; @@ -72,21 +72,19 @@ static uae_u32 REGPARAM2 rtarea_wget(uaecptr addr) 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; + addr &= 0xFFFF; - if (addr == RTAREA_INTREQ + 0) { + 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) { + } else if (addr == RTAREA_INTREQ + 1) { rtarea_bank.baseaddr[addr] = false; - } - else if (addr == RTAREA_INTREQ + 2) { - rtarea_bank.baseaddr[addr] = 0; - } - return rtarea_bank.baseaddr[addr]; + } else if (addr == RTAREA_INTREQ + 2) { + rtarea_bank.baseaddr[addr] = 0; + } + return rtarea_bank.baseaddr[addr]; } static bool rtarea_write(uaecptr addr) @@ -95,10 +93,10 @@ static bool rtarea_write(uaecptr addr) return true; if (addr >= RTAREA_SYSBASE && addr < RTAREA_SYSBASE + 4) return true; - return false; + return false; } -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)) @@ -109,7 +107,7 @@ static void REGPARAM2 rtarea_bput(uaecptr addr, uae_u32 value) } } -static void REGPARAM2 rtarea_wput(uaecptr addr, uae_u32 value) +static void REGPARAM2 rtarea_wput (uaecptr addr, uae_u32 value) { addr &= 0xffff; value &= 0xffff; @@ -123,10 +121,10 @@ static void REGPARAM2 rtarea_wput(uaecptr addr, uae_u32 value) uaecptr addr2 = addr - RTAREA_TRAP_STATUS; rtarea_bank.baseaddr[addr + 0] = value >> 8; - rtarea_bank.baseaddr[addr + 1] = uae_u8(value); + rtarea_bank.baseaddr[addr + 1] = (uae_u8)value; } -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) @@ -149,33 +147,33 @@ void rtarea_reset(void) 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); - } + } } /* 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); + 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; @@ -183,98 +181,102 @@ 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) { - if (!str) - return addr(rt_straddr); - int len = strlen(str) + 1; - rt_straddr -= len; - strcpy(reinterpret_cast(rtarea_bank.baseaddr) + rt_straddr, str); - return addr(rt_straddr); + 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); } -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 = strlen(str) + 2; + int len; + + len = strlen (str) + 2; rt_straddr -= len; while (rt_straddr & 3) rt_straddr--; rtarea_bank.baseaddr[rt_straddr] = len - 2; - strcpy(reinterpret_cast(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 calltrap (uae_u32 n) { - dw(0xA000 + n); + dw (0xA000 + n); } -void org(uae_u32 a) +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; + if ( ((a & 0xffff0000) != 0x00f00000) && ((a & 0xffff0000) != rtarea_base) ) + write_log (_T("ORG: corrupt address! %08X"), a); + rt_addr = a & 0xffff; } -uae_u32 here(void) +uae_u32 here (void) { - return addr(rt_addr); + return addr (rt_addr); } -void align(int b) +void align (int b) { - rt_addr = (rt_addr + b - 1) & ~(b - 1); + 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; + 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)); + trap_get_string(ctx, buf, trap_get_areg(ctx, 0), sizeof (uae_char)); write_log(_T("%s"), buf); - return 0; + return 0; } -void rtarea_init_mem(void) +void rtarea_init_mem (void) { 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, nullptr); - return; - } + 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; + } } void rtarea_free(void) @@ -282,101 +284,102 @@ void rtarea_free(void) mapped_free(&rtarea_bank); } -void rtarea_init(void) +void rtarea_init (void) { - 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(); + init_traps (); - rtarea_init_mem(); - memset(rtarea_bank.baseaddr, 0, RTAREA_SIZE); + rtarea_init_mem (); + memset (rtarea_bank.baseaddr, 0, RTAREA_SIZE); - _stprintf(uaever, _T("uae-%d.%d.%d"), UAEMAJOR, UAEMINOR, UAESUBREV); + _stprintf (uaever, _T("uae-%d.%d.%d"), UAEMAJOR, UAEMINOR, UAESUBREV); - EXPANSION_uaeversion = ds(uaever); - EXPANSION_explibname = ds(_T("expansion.library")); - EXPANSION_doslibname = ds(_T("dos.library")); - EXPANSION_uaedevname = ds(_T("uae.device")); + 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); + dw (0); + dw (0); #ifdef FILESYS - filesys_install_code(); + filesys_install_code (); #endif - deftrap(NULL); /* Generic emulator trap */ + deftrap (NULL); /* Generic emulator trap */ - uae_u32 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, nullptr); - return; + 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; } #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; 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 02c457e2..e3901f89 100644 --- a/src/blitfunc.cpp +++ b/src/blitfunc.cpp @@ -1,1622 +1,1584 @@ #include "sysconfig.h" #include "sysdeps.h" #include "options.h" -#include "memory.h" +#include "include/memory.h" #include "newcpu.h" #include "custom.h" #include "savestate.h" #include "blitter.h" #include "blitfunc.h" -void blitdofast_0(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +void blitdofast_0 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) { - int i, j; - uae_u32 totald = 0; - uae_u32 dstd = 0; - uaecptr dstp = 0; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 dstd=0; +uaecptr dstp = 0; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = (0); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } - } - if (ptd) ptd += b->bltdmod; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = (0); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_0(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) + if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 0) b->blitzero = 0; +} +void blitdofast_desc_0 (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) { - uae_u32 totald = 0; - int i, j; - uae_u32 dstd = 0; - uaecptr dstp = 0; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = (0); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } - } - if (ptd) ptd -= b->bltdmod; +uae_u32 totald = 0; +int i,j; +uae_u32 dstd = 0; +uaecptr dstp = 0; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = (0); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) + if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((~srca & srcc)); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } - } - if (pta) pta += b->bltamod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((~srca & srcc)); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((~srca & srcc)); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } - } - if (pta) pta -= b->bltamod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; +uae_u32 totald = 0; +int i,j; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((~srca & srcc)); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_2a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc & ~(srca & srcb))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc & ~(srca & srcb))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_2a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc & ~(srca & srcb))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc & ~(srca & srcb))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_30(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srca & ~srcb)); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srca & ~srcb)); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_30(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srca & ~srcb)); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srca & ~srcb)); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_3a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcb ^ (srca | (srcb ^ srcc)))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcb ^ (srca | (srcb ^ srcc)))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_3a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcb ^ (srca | (srcb ^ srcc)))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcb ^ (srca | (srcb ^ srcc)))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_3c(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srca ^ srcb)); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srca ^ srcb)); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_3c(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srca ^ srcb)); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srca ^ srcb)); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_4a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc ^ (srca & (srcb | srcc)))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc ^ (srca & (srcb | srcc)))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_4a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc ^ (srca & (srcb | srcc)))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc ^ (srca & (srcb | srcc)))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_6a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc ^ (srca & srcb))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc ^ (srca & srcb))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_6a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc ^ (srca & srcb))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc ^ (srca & srcb))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_8a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc & (~srca | srcb))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc & (~srca | srcb))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_8a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc & (~srca | srcb))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc & (~srca | srcb))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_8c(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcb & (~srca | srcc))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcb & (~srca | srcc))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_8c(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcb & (~srca | srcc))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcb & (~srca | srcc))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_9a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc ^ (srca & ~srcb))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc ^ (srca & ~srcb))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_9a(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc ^ (srca & ~srcb))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc ^ (srca & ~srcb))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_a8(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc & (srca | srcb))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc & (srca | srcb))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_a8(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc & (srca | srcb))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc & (srca | srcb))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_aa(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 0) b->blitzero = 0; +} +void blitdofast_aa (uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) { - int i, j; - uae_u32 totald = 0; - uae_u32 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = (srcc); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } - } - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = (srcc); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_aa(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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; - uaecptr dstp = 0; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = (srcc); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } - } - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; +uae_u32 totald = 0; +int i,j; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = (srcc); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_b1(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = (~(srca ^ (srcc | (srca ^ srcb)))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = (~(srca ^ (srcc | (srca ^ srcb)))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_b1(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = (~(srca ^ (srcc | (srca ^ srcb)))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = (~(srca ^ (srcc | (srca ^ srcb)))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_ca(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc ^ (srca & (srcb ^ srcc)))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc ^ (srca & (srcb ^ srcc)))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_ca(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc ^ (srca & (srcb ^ srcc)))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc ^ (srca & (srcb ^ srcc)))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_cc(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 dstd = 0; - uaecptr dstp = 0; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 dstd=0; +uaecptr dstp = 0; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = (srcb); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (ptb) ptb += b->bltbmod; - if (ptd) ptd += b->bltdmod; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = (srcb); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (ptb) ptb += b->bltbmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_cc(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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; - uaecptr dstp = 0; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = (srcb); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 dstd=0; +uaecptr dstp = 0; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (ptb) ptb -= b->bltbmod; - if (ptd) ptd -= b->bltdmod; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = (srcb); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (ptb) ptb -= b->bltbmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_d8(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srca ^ (srcc & (srca ^ srcb)))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srca ^ (srcc & (srca ^ srcb)))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_d8(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srca ^ (srcc & (srca ^ srcb)))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srca ^ (srcc & (srca ^ srcb)))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_e2(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc ^ (srcb & (srca ^ srcc)))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc ^ (srcb & (srca ^ srcc)))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_e2(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc ^ (srcb & (srca ^ srcc)))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc ^ (srcb & (srca ^ srcc)))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_ea(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc | (srca & srcb))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc | (srca & srcb))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_ea(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srcc | (srca & srcb))); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srcc | (srca & srcb))); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_f0(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = (srca); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } - } - if (pta) pta += b->bltamod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = (srca); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_f0(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = (srca); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } - } - if (pta) pta -= b->bltamod; - if (ptd) ptd -= b->bltdmod; +uae_u32 totald = 0; +int i,j; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = (srca); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_fa(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc += 2; } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srca | srcc)); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } - } - if (pta) pta += b->bltamod; - if (ptc) ptc += b->bltcmod; - if (ptd) ptd += b->bltdmod; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc += 2; } + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srca | srcc)); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptc) ptc += b->bltcmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_fa(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 srcc = b->bltcdat; - uae_u32 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptc) { srcc = do_get_mem_word((uae_u16 *)ptc); ptc -= 2; } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srca | srcc)); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } - } - if (pta) pta -= b->bltamod; - if (ptc) ptc -= b->bltcmod; - if (ptd) ptd -= b->bltdmod; +uae_u32 totald = 0; +int i,j; +uae_u32 srcc = b->bltcdat; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptc) { srcc = do_get_mem_word ((uae_u16 *)ptc); ptc -= 2; } + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srca | srcc)); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltcdat = srcc; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptc) ptc -= b->bltcmod; + if (ptd) ptd -= b->bltdmod; } -void blitdofast_fc(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltcdat = srcc; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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 dstd = 0; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; +int i,j; +uae_u32 totald = 0; +uae_u32 srcb = b->bltbhold; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb += 2; - srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta += 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srca | srcb)); - totald |= dstd; - if (ptd) { dstp = ptd; ptd += 2; } + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb += 2; + srcb = (((uae_u32)b->bltbold << 16) | bltbdat) >> b->blitbshift; + b->bltbold = bltbdat; } - if (pta) pta += b->bltamod; - if (ptb) ptb += b->bltbmod; - if (ptd) ptd += b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta += 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)b->bltaold << 16) | bltadat) >> b->blitashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srca | srcb)); + totald |= dstd; + if (ptd) { dstp = ptd; ptd += 2; } } - b->bltbhold = srcb; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta += b->bltamod; + if (ptb) ptb += b->bltbmod; + if (ptd) ptd += b->bltdmod; } -void blitdofast_desc_fc(uaecptr pta, uaecptr ptb, uaecptr ptc, uaecptr ptd, struct bltinfo *b) +b->bltbhold = srcb; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 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; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; - for (j = b->vblitsize; j--;) { - for (i = b->hblitsize; i--;) { - uae_u32 bltadat, srca; - if (ptb) { - uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word((uae_u16 *)ptb); ptb -= 2; - srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; - b->bltbold = bltbdat; - } - if (pta) { b->bltadat = bltadat = do_get_mem_word((uae_u16 *)pta); pta -= 2; } - else { bltadat = b->bltadat; } - bltadat &= blit_masktable_p[i]; - srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; - b->bltaold = bltadat; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - dstd = ((srca | srcb)); - totald |= dstd; - if (ptd) { dstp = ptd; ptd -= 2; } +uae_u32 totald = 0; +int i,j; +uae_u32 srcb = b->bltbhold; +uae_u32 dstd=0; +uaecptr dstp = 0; +uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - b->hblitsize; +for (j = b->vblitsize; j--;) { + for (i = b->hblitsize; i--;) { + uae_u32 bltadat, srca; + if (ptb) { + uae_u32 bltbdat; b->bltbdat = bltbdat = do_get_mem_word ((uae_u16 *)ptb); ptb -= 2; + srcb = ((bltbdat << 16) | b->bltbold) >> b->blitdownbshift; + b->bltbold = bltbdat; } - if (pta) pta -= b->bltamod; - if (ptb) ptb -= b->bltbmod; - if (ptd) ptd -= b->bltdmod; + if (pta) { b->bltadat = bltadat = do_get_mem_word ((uae_u16 *)pta); pta -= 2; } else { bltadat = b->bltadat; } + bltadat &= blit_masktable_p[i]; + srca = (((uae_u32)bltadat << 16) | b->bltaold) >> b->blitdownashift; + b->bltaold = bltadat; + if (dstp) + chipmem_agnus_wput (dstp, dstd); + dstd = ((srca | srcb)); + totald |= dstd; + if (ptd) { dstp = ptd; ptd -= 2; } } - b->bltbhold = srcb; - if (dstp) - chipmem_agnus_wput(dstp, dstd); - if ((totald << 16) != 0) b->blitzero = 0; + if (pta) pta -= b->bltamod; + if (ptb) ptb -= b->bltbmod; + if (ptd) ptd -= b->bltdmod; +} +b->bltbhold = srcb; +if (dstp) + chipmem_agnus_wput (dstp, dstd); +if ((totald<<16) != 0) b->blitzero = 0; } diff --git a/src/blitops.cpp b/src/blitops.cpp index 3060a08e..eb2142db 100644 --- a/src/blitops.cpp +++ b/src/blitops.cpp @@ -1,263 +1,262 @@ -/* This file generated automatically - do not edit */ + /* This file generated automatically - do not edit */ #include "genblitter.h" -struct blitop blitops[256] = -{ - /* 00 */ { "0", 0 }, - /* 01 */ { "~(srca | srcb | srcc)", 7 }, - /* 02 */ { "(srcc & ~(srca | srcb))", 7 }, - /* 03 */ { "~(srca | srcb)", 3 }, - /* 04 */ { "(srcb & ~(srca | srcc))", 7 }, - /* 05 */ { "~(srca | srcc)", 5 }, - /* 06 */ { "(~srca & (srcb ^ srcc))", 7 }, - /* 07 */ { "~(srca | (srcb & srcc))", 7 }, - /* 08 */ { "(~srca & srcb & srcc)", 7 }, - /* 09 */ { "~(srca | (srcb ^ srcc))", 7 }, - /* 0a */ { "(~srca & srcc)", 5 }, - /* 0b */ { "~(srca | (srcb & ~srcc))", 7 }, - /* 0c */ { "(~srca & srcb)", 3 }, - /* 0d */ { "~(srca | (~srcb & srcc))", 7 }, - /* 0e */ { "(~srca & (srcb | srcc))", 7 }, - /* 0f */ { "~srca", 1 }, - /* 10 */ { "(srca & ~(srcb | srcc))", 7 }, - /* 11 */ { "~(srcb | srcc)", 6 }, - /* 12 */ { "(~srcb & (srca ^ srcc))", 7 }, - /* 13 */ { "~(srcb | (srca & srcc))", 7 }, - /* 14 */ { "(~srcc & (srca ^ srcb))", 7 }, - /* 15 */ { "~(srcc | (srca & srcb))", 7 }, - /* 16 */ { "(srca ^ ((srca & srcb) | (srcb ^ srcc)))", 7 }, - /* 17 */ { "~(srca ^ ((srca ^ srcb) & (srca ^ srcc)))", 7 }, - /* 18 */ { "((srca ^ srcb) & (srca ^ srcc))", 7 }, - /* 19 */ { "(srcb ^ (~srcc | (srca & srcb)))", 7 }, - /* 1a */ { "(srca ^ (srcc | (srca & srcb)))", 7 }, - /* 1b */ { "(srca ^ (srcc | ~(srca ^ srcb)))", 7 }, - /* 1c */ { "(srca ^ (srcb | (srca & srcc)))", 7 }, - /* 1d */ { "(srca ^ (srcb | ~(srca ^ srcc)))", 7 }, - /* 1e */ { "(srca ^ (srcb | srcc))", 7 }, - /* 1f */ { "~(srca & (srcb | srcc))", 7 }, - /* 20 */ { "(srca & ~srcb & srcc)", 7 }, - /* 21 */ { "~(srcb | (srca ^ srcc))", 7 }, - /* 22 */ { "(~srcb & srcc)", 6 }, - /* 23 */ { "~(srcb | (srca & ~srcc))", 7 }, - /* 24 */ { "((srca ^ srcb) & (srcb ^ srcc))", 7 }, - /* 25 */ { "(srca ^ (~srcc | (srca & srcb)))", 7 }, - /* 26 */ { "(srcb ^ (srcc | (srca & srcb)))", 7 }, - /* 27 */ { "~(srca ^ (srcc & (srca ^ srcb)))", 7 }, - /* 28 */ { "(srcc & (srca ^ srcb))", 7 }, - /* 29 */ { "~(srca ^ srcb ^ (srcc | (srca & srcb)))", 7 }, - /* 2a */ { "(srcc & ~(srca & srcb))", 7 }, - /* 2b */ { "~(srca ^ ((srca ^ srcb) & (srcb ^ srcc)))", 7 }, - /* 2c */ { "(srcb ^ (srca & (srcb | srcc)))", 7 }, - /* 2d */ { "(srca ^ (srcb | ~srcc))", 7 }, - /* 2e */ { "(srca ^ (srcb | (srca ^ srcc)))", 7 }, - /* 2f */ { "~(srca & (srcb | ~srcc))", 7 }, - /* 30 */ { "(srca & ~srcb)", 3 }, - /* 31 */ { "~(srcb | (~srca & srcc))", 7 }, - /* 32 */ { "(~srcb & (srca | srcc))", 7 }, - /* 33 */ { "~srcb", 2 }, - /* 34 */ { "(srcb ^ (srca | (srcb & srcc)))", 7 }, - /* 35 */ { "(srcb ^ (srca | ~(srcb ^ srcc)))", 7 }, - /* 36 */ { "(srcb ^ (srca | srcc))", 7 }, - /* 37 */ { "~(srcb & (srca | srcc))", 7 }, - /* 38 */ { "(srca ^ (srcb & (srca | srcc)))", 7 }, - /* 39 */ { "(srcb ^ (srca | ~srcc))", 7 }, - /* 3a */ { "(srcb ^ (srca | (srcb ^ srcc)))", 7 }, - /* 3b */ { "~(srcb & (srca | ~srcc))", 7 }, - /* 3c */ { "(srca ^ srcb)", 3 }, - /* 3d */ { "(srca ^ (srcb | ~(srca | srcc)))", 7 }, - /* 3e */ { "(srca ^ (srcb | (srca ^ (srca | srcc))))", 7 }, - /* 3f */ { "~(srca & srcb)", 3 }, - /* 40 */ { "(srca & srcb & ~srcc)", 7 }, - /* 41 */ { "~(srcc | (srca ^ srcb))", 7 }, - /* 42 */ { "((srca ^ srcc) & (srcb ^ srcc))", 7 }, - /* 43 */ { "(srca ^ (~srcb | (srca & srcc)))", 7 }, - /* 44 */ { "(srcb & ~srcc)", 6 }, - /* 45 */ { "~(srcc | (srca & ~srcb))", 7 }, - /* 46 */ { "(srcc ^ (srcb | (srca & srcc)))", 7 }, - /* 47 */ { "~(srca ^ (srcb & (srca ^ srcc)))", 7 }, - /* 48 */ { "(srcb & (srca ^ srcc))", 7 }, - /* 49 */ { "~(srca ^ srcc ^ (srcb | (srca & srcc)))", 7 }, - /* 4a */ { "(srcc ^ (srca & (srcb | srcc)))", 7 }, - /* 4b */ { "(srca ^ (~srcb | srcc))", 7 }, - /* 4c */ { "(srcb & ~(srca & srcc))", 7 }, - /* 4d */ { "(srca ^ ((srca ^ srcb) | ~(srca ^ srcc)))", 7 }, - /* 4e */ { "(srca ^ (srcc | (srca ^ srcb)))", 7 }, - /* 4f */ { "~(srca & (~srcb | srcc))", 7 }, - /* 50 */ { "(srca & ~srcc)", 5 }, - /* 51 */ { "~(srcc | (~srca & srcb))", 7 }, - /* 52 */ { "(srcc ^ (srca | (srcb & srcc)))", 7 }, - /* 53 */ { "~(srcb ^ (srca & (srcb ^ srcc)))", 7 }, - /* 54 */ { "(~srcc & (srca | srcb))", 7 }, - /* 55 */ { "~srcc", 4 }, - /* 56 */ { "(srcc ^ (srca | srcb))", 7 }, - /* 57 */ { "~(srcc & (srca | srcb))", 7 }, - /* 58 */ { "(srca ^ (srcc & (srca | srcb)))", 7 }, - /* 59 */ { "(srcc ^ (srca | ~srcb))", 7 }, - /* 5a */ { "(srca ^ srcc)", 5 }, - /* 5b */ { "(srca ^ (srcc | ~(srca | srcb)))", 7 }, - /* 5c */ { "(srcc ^ (srca | (srcb ^ srcc)))", 7 }, - /* 5d */ { "~(srcc & (srca | ~srcb))", 7 }, - /* 5e */ { "(srca ^ (srcc | (srca ^ (srca | srcb))))", 7 }, - /* 5f */ { "~(srca & srcc)", 5 }, - /* 60 */ { "(srca & (srcb ^ srcc))", 7 }, - /* 61 */ { "~(srcb ^ srcc ^ (srca | (srcb & srcc)))", 7 }, - /* 62 */ { "(srcc ^ (srcb & (srca | srcc)))", 7 }, - /* 63 */ { "(srcb ^ (~srca | srcc))", 7 }, - /* 64 */ { "(srcb ^ (srcc & (srca | srcb)))", 7 }, - /* 65 */ { "(srcc ^ (~srca | srcb))", 7 }, - /* 66 */ { "(srcb ^ srcc)", 6 }, - /* 67 */ { "(srcb ^ (srcc | ~(srca | srcb)))", 7 }, - /* 68 */ { "((srca & srcb) ^ (srcc & (srca | srcb)))", 7 }, - /* 69 */ { "~(srca ^ srcb ^ srcc)", 7 }, - /* 6a */ { "(srcc ^ (srca & srcb))", 7 }, - /* 6b */ { "~(srca ^ srcb ^ (srcc & (srca | srcb)))", 7 }, - /* 6c */ { "(srcb ^ (srca & srcc))", 7 }, - /* 6d */ { "~(srca ^ srcc ^ (srcb & (srca | srcc)))", 7 }, - /* 6e */ { "((~srca & srcb) | (srcb ^ srcc))", 7 }, - /* 6f */ { "(~srca | (srcb ^ srcc))", 7 }, - /* 70 */ { "(srca & ~(srcb & srcc))", 7 }, - /* 71 */ { "~(srca ^ ((srca ^ srcb) | (srca ^ srcc)))", 7 }, - /* 72 */ { "(srcb ^ (srcc | (srca ^ srcb)))", 7 }, - /* 73 */ { "~(srcb & (~srca | srcc))", 7 }, - /* 74 */ { "(srcc ^ (srcb | (srca ^ srcc)))", 7 }, - /* 75 */ { "~(srcc & (~srca | srcb))", 7 }, - /* 76 */ { "(srcb ^ (srcc | (srca ^ (srca & srcb))))", 7 }, - /* 77 */ { "~(srcb & srcc)", 6 }, - /* 78 */ { "(srca ^ (srcb & srcc))", 7 }, - /* 79 */ { "~(srcb ^ srcc ^ (srca & (srcb | srcc)))", 7 }, - /* 7a */ { "((srca & ~srcb) | (srca ^ srcc))", 7 }, - /* 7b */ { "(~srcb | (srca ^ srcc))", 7 }, - /* 7c */ { "((srca ^ srcb) | (srca & ~srcc))", 7 }, - /* 7d */ { "(~srcc | (srca ^ srcb))", 7 }, - /* 7e */ { "((srca ^ srcb) | (srca ^ srcc))", 7 }, - /* 7f */ { "~(srca & srcb & srcc)", 7 }, - /* 80 */ { "(srca & srcb & srcc)", 7 }, - /* 81 */ { "~((srca ^ srcb) | (srca ^ srcc))", 7 }, - /* 82 */ { "(srcc & ~(srca ^ srcb))", 7 }, - /* 83 */ { "(srca ^ (~srcb | (srca & ~srcc)))", 7 }, - /* 84 */ { "(srcb & ~(srca ^ srcc))", 7 }, - /* 85 */ { "(srca ^ (~srcc | (srca & ~srcb)))", 7 }, - /* 86 */ { "(srcb ^ srcc ^ (srca & (srcb | srcc)))", 7 }, - /* 87 */ { "~(srca ^ (srcb & srcc))", 7 }, - /* 88 */ { "(srcb & srcc)", 6 }, - /* 89 */ { "(srcb ^ (~srcc & (~srca | srcb)))", 7 }, - /* 8a */ { "(srcc & (~srca | srcb))", 7 }, - /* 8b */ { "(srca ^ (~srcb | (srca ^ srcc)))", 7 }, - /* 8c */ { "(srcb & (~srca | srcc))", 7 }, - /* 8d */ { "(srca ^ (~srcc | (srca ^ srcb)))", 7 }, - /* 8e */ { "(srca ^ ((srca ^ srcb) | (srca ^ srcc)))", 7 }, - /* 8f */ { "(~srca | (srcb & srcc))", 7 }, - /* 90 */ { "(srca & ~(srcb ^ srcc))", 7 }, - /* 91 */ { "(srcb ^ (~srcc | (~srca & srcb)))", 7 }, - /* 92 */ { "(srca ^ srcc ^ (srcb & (srca | srcc)))", 7 }, - /* 93 */ { "~(srcb ^ (srca & srcc))", 7 }, - /* 94 */ { "(srca ^ srcb ^ (srcc & (srca | srcb)))", 7 }, - /* 95 */ { "~(srcc ^ (srca & srcb))", 7 }, - /* 96 */ { "(srca ^ srcb ^ srcc)", 7 }, - /* 97 */ { "(srca ^ srcb ^ (srcc | ~(srca | srcb)))", 7 }, - /* 98 */ { "(srcb ^ (~srcc & (srca | srcb)))", 7 }, - /* 99 */ { "~(srcb ^ srcc)", 6 }, - /* 9a */ { "(srcc ^ (srca & ~srcb))", 7 }, - /* 9b */ { "~(srcb ^ (srcc & (srca | srcb)))", 7 }, - /* 9c */ { "(srcb ^ (srca & ~srcc))", 7 }, - /* 9d */ { "~(srcc ^ (srcb & (srca | srcc)))", 7 }, - /* 9e */ { "(srcb ^ srcc ^ (srca | (srcb & srcc)))", 7 }, - /* 9f */ { "~(srca & (srcb ^ srcc))", 7 }, - /* a0 */ { "(srca & srcc)", 5 }, - /* a1 */ { "(srca ^ (~srcc & (srca | ~srcb)))", 7 }, - /* a2 */ { "(srcc & (srca | ~srcb))", 7 }, - /* a3 */ { "(srcb ^ (~srca | (srcb ^ srcc)))", 7 }, - /* a4 */ { "(srca ^ (~srcc & (srca | srcb)))", 7 }, - /* a5 */ { "~(srca ^ srcc)", 5 }, - /* a6 */ { "(srcc ^ (~srca & srcb))", 7 }, - /* a7 */ { "~(srca ^ (srcc & (srca | srcb)))", 7 }, - /* a8 */ { "(srcc & (srca | srcb))", 7 }, - /* a9 */ { "~(srcc ^ (srca | srcb))", 7 }, - /* aa */ { "srcc", 4 }, - /* ab */ { "(srcc | ~(srca | srcb))", 7 }, - /* ac */ { "(srcb ^ (srca & (srcb ^ srcc)))", 7 }, - /* ad */ { "~(srcc ^ (srca | (srcb & srcc)))", 7 }, - /* ae */ { "(srcc | (~srca & srcb))", 7 }, - /* af */ { "(~srca | srcc)", 5 }, - /* b0 */ { "(srca & (~srcb | srcc))", 7 }, - /* b1 */ { "~(srca ^ (srcc | (srca ^ srcb)))", 7 }, - /* b2 */ { "(srca ^ ((srca ^ srcc) & (srcb ^ srcc)))", 7 }, - /* b3 */ { "(~srcb | (srca & srcc))", 7 }, - /* b4 */ { "(srca ^ (srcb & ~srcc))", 7 }, - /* b5 */ { "~(srcc ^ (srca & (srcb | srcc)))", 7 }, - /* b6 */ { "(srca ^ srcc ^ (srcb | (srca & srcc)))", 7 }, - /* b7 */ { "~(srcb & (srca ^ srcc))", 7 }, - /* b8 */ { "(srca ^ (srcb & (srca ^ srcc)))", 7 }, - /* b9 */ { "~(srcc ^ (srcb | (srca & srcc)))", 7 }, - /* ba */ { "(srcc | (srca & ~srcb))", 7 }, - /* bb */ { "(~srcb | srcc)", 6 }, - /* bc */ { "((srca ^ srcb) | (srca & srcc))", 7 }, - /* bd */ { "((srca ^ srcb) | ~(srca ^ srcc))", 7 }, - /* be */ { "(srcc | (srca ^ srcb))", 7 }, - /* bf */ { "(srcc | ~(srca & srcb))", 7 }, - /* c0 */ { "(srca & srcb)", 3 }, - /* c1 */ { "(srca ^ (~srcb & (srca | ~srcc)))", 7 }, - /* c2 */ { "(srca ^ (~srcb & (srca | srcc)))", 7 }, - /* c3 */ { "~(srca ^ srcb)", 3 }, - /* c4 */ { "(srcb & (srca | ~srcc))", 7 }, - /* c5 */ { "~(srcb ^ (srca | (srcb ^ srcc)))", 7 }, - /* c6 */ { "(srcb ^ (~srca & srcc))", 7 }, - /* c7 */ { "~(srca ^ (srcb & (srca | srcc)))", 7 }, - /* c8 */ { "(srcb & (srca | srcc))", 7 }, - /* c9 */ { "~(srcb ^ (srca | srcc))", 7 }, - /* ca */ { "(srcc ^ (srca & (srcb ^ srcc)))", 7 }, - /* cb */ { "~(srcb ^ (srca | (srcb & srcc)))", 7 }, - /* cc */ { "srcb", 2 }, - /* cd */ { "(srcb | ~(srca | srcc))", 7 }, - /* ce */ { "(srcb | (~srca & srcc))", 7 }, - /* cf */ { "(~srca | srcb)", 3 }, - /* d0 */ { "(srca & (srcb | ~srcc))", 7 }, - /* d1 */ { "~(srca ^ (srcb | (srca ^ srcc)))", 7 }, - /* d2 */ { "(srca ^ (~srcb & srcc))", 7 }, - /* d3 */ { "~(srcb ^ (srca & (srcb | srcc)))", 7 }, - /* d4 */ { "(srca ^ ((srca ^ srcb) & (srcb ^ srcc)))", 7 }, - /* d5 */ { "(~srcc | (srca & srcb))", 7 }, - /* d6 */ { "(srca ^ srcb ^ (srcc | (srca & srcb)))", 7 }, - /* d7 */ { "~(srcc & (srca ^ srcb))", 7 }, - /* d8 */ { "(srca ^ (srcc & (srca ^ srcb)))", 7 }, - /* d9 */ { "~(srcb ^ (srcc | (srca & srcb)))", 7 }, - /* da */ { "((srca & srcb) | (srca ^ srcc))", 7 }, - /* db */ { "~((srca ^ srcb) & (srcb ^ srcc))", 7 }, - /* dc */ { "(srcb | (srca & ~srcc))", 7 }, - /* dd */ { "(srcb | ~srcc)", 6 }, - /* de */ { "(srcb | (srca ^ srcc))", 7 }, - /* df */ { "(srcb | ~(srca & srcc))", 7 }, - /* e0 */ { "(srca & (srcb | srcc))", 7 }, - /* e1 */ { "~(srca ^ (srcb | srcc))", 7 }, - /* e2 */ { "(srcc ^ (srcb & (srca ^ srcc)))", 7 }, - /* e3 */ { "~(srca ^ (srcb | (srca & srcc)))", 7 }, - /* e4 */ { "(srcb ^ (srcc & (srca ^ srcb)))", 7 }, - /* e5 */ { "~(srca ^ (srcc | (srca & srcb)))", 7 }, - /* e6 */ { "((srca & srcb) | (srcb ^ srcc))", 7 }, - /* e7 */ { "~((srca ^ srcb) & (srca ^ srcc))", 7 }, - /* e8 */ { "(srca ^ ((srca ^ srcb) & (srca ^ srcc)))", 7 }, - /* e9 */ { "(srca ^ srcb ^ (~srcc | (srca & srcb)))", 7 }, - /* ea */ { "(srcc | (srca & srcb))", 7 }, - /* eb */ { "(srcc | ~(srca ^ srcb))", 7 }, - /* ec */ { "(srcb | (srca & srcc))", 7 }, - /* ed */ { "(srcb | ~(srca ^ srcc))", 7 }, - /* ee */ { "(srcb | srcc)", 6 }, - /* ef */ { "(~srca | srcb | srcc)", 7 }, - /* f0 */ { "srca", 1 }, - /* f1 */ { "(srca | ~(srcb | srcc))", 7 }, - /* f2 */ { "(srca | (~srcb & srcc))", 7 }, - /* f3 */ { "(srca | ~srcb)", 3 }, - /* f4 */ { "(srca | (srcb & ~srcc))", 7 }, - /* f5 */ { "(srca | ~srcc)", 5 }, - /* f6 */ { "(srca | (srcb ^ srcc))", 7 }, - /* f7 */ { "(srca | ~(srcb & srcc))", 7 }, - /* f8 */ { "(srca | (srcb & srcc))", 7 }, - /* f9 */ { "(srca | ~(srcb ^ srcc))", 7 }, - /* fa */ { "(srca | srcc)", 5 }, - /* fb */ { "(srca | ~srcb | srcc)", 7 }, - /* fc */ { "(srca | srcb)", 3 }, - /* fd */ { "(srca | srcb | ~srcc)", 7 }, - /* fe */ { "(srca | srcb | srcc)", 7 }, - /* ff */ { "0xFFFFFFFF", 0 } +struct blitop blitops[256] = { + /* 00 */ { "0", 0 }, + /* 01 */ { "~(srca | srcb | srcc)", 7 }, + /* 02 */ { "(srcc & ~(srca | srcb))", 7 }, + /* 03 */ { "~(srca | srcb)", 3 }, + /* 04 */ { "(srcb & ~(srca | srcc))", 7 }, + /* 05 */ { "~(srca | srcc)", 5 }, + /* 06 */ { "(~srca & (srcb ^ srcc))", 7 }, + /* 07 */ { "~(srca | (srcb & srcc))", 7 }, + /* 08 */ { "(~srca & srcb & srcc)", 7 }, + /* 09 */ { "~(srca | (srcb ^ srcc))", 7 }, + /* 0a */ { "(~srca & srcc)", 5 }, + /* 0b */ { "~(srca | (srcb & ~srcc))", 7 }, + /* 0c */ { "(~srca & srcb)", 3 }, + /* 0d */ { "~(srca | (~srcb & srcc))", 7 }, + /* 0e */ { "(~srca & (srcb | srcc))", 7 }, + /* 0f */ { "~srca", 1 }, + /* 10 */ { "(srca & ~(srcb | srcc))", 7 }, + /* 11 */ { "~(srcb | srcc)", 6 }, + /* 12 */ { "(~srcb & (srca ^ srcc))", 7 }, + /* 13 */ { "~(srcb | (srca & srcc))", 7 }, + /* 14 */ { "(~srcc & (srca ^ srcb))", 7 }, + /* 15 */ { "~(srcc | (srca & srcb))", 7 }, + /* 16 */ { "(srca ^ ((srca & srcb) | (srcb ^ srcc)))", 7 }, + /* 17 */ { "~(srca ^ ((srca ^ srcb) & (srca ^ srcc)))", 7 }, + /* 18 */ { "((srca ^ srcb) & (srca ^ srcc))", 7 }, + /* 19 */ { "(srcb ^ (~srcc | (srca & srcb)))", 7 }, + /* 1a */ { "(srca ^ (srcc | (srca & srcb)))", 7 }, + /* 1b */ { "(srca ^ (srcc | ~(srca ^ srcb)))", 7 }, + /* 1c */ { "(srca ^ (srcb | (srca & srcc)))", 7 }, + /* 1d */ { "(srca ^ (srcb | ~(srca ^ srcc)))", 7 }, + /* 1e */ { "(srca ^ (srcb | srcc))", 7 }, + /* 1f */ { "~(srca & (srcb | srcc))", 7 }, + /* 20 */ { "(srca & ~srcb & srcc)", 7 }, + /* 21 */ { "~(srcb | (srca ^ srcc))", 7 }, + /* 22 */ { "(~srcb & srcc)", 6 }, + /* 23 */ { "~(srcb | (srca & ~srcc))", 7 }, + /* 24 */ { "((srca ^ srcb) & (srcb ^ srcc))", 7 }, + /* 25 */ { "(srca ^ (~srcc | (srca & srcb)))", 7 }, + /* 26 */ { "(srcb ^ (srcc | (srca & srcb)))", 7 }, + /* 27 */ { "~(srca ^ (srcc & (srca ^ srcb)))", 7 }, + /* 28 */ { "(srcc & (srca ^ srcb))", 7 }, + /* 29 */ { "~(srca ^ srcb ^ (srcc | (srca & srcb)))", 7 }, + /* 2a */ { "(srcc & ~(srca & srcb))", 7 }, + /* 2b */ { "~(srca ^ ((srca ^ srcb) & (srcb ^ srcc)))", 7 }, + /* 2c */ { "(srcb ^ (srca & (srcb | srcc)))", 7 }, + /* 2d */ { "(srca ^ (srcb | ~srcc))", 7 }, + /* 2e */ { "(srca ^ (srcb | (srca ^ srcc)))", 7 }, + /* 2f */ { "~(srca & (srcb | ~srcc))", 7 }, + /* 30 */ { "(srca & ~srcb)", 3 }, + /* 31 */ { "~(srcb | (~srca & srcc))", 7 }, + /* 32 */ { "(~srcb & (srca | srcc))", 7 }, + /* 33 */ { "~srcb", 2 }, + /* 34 */ { "(srcb ^ (srca | (srcb & srcc)))", 7 }, + /* 35 */ { "(srcb ^ (srca | ~(srcb ^ srcc)))", 7 }, + /* 36 */ { "(srcb ^ (srca | srcc))", 7 }, + /* 37 */ { "~(srcb & (srca | srcc))", 7 }, + /* 38 */ { "(srca ^ (srcb & (srca | srcc)))", 7 }, + /* 39 */ { "(srcb ^ (srca | ~srcc))", 7 }, + /* 3a */ { "(srcb ^ (srca | (srcb ^ srcc)))", 7 }, + /* 3b */ { "~(srcb & (srca | ~srcc))", 7 }, + /* 3c */ { "(srca ^ srcb)", 3 }, + /* 3d */ { "(srca ^ (srcb | ~(srca | srcc)))", 7 }, + /* 3e */ { "(srca ^ (srcb | (srca ^ (srca | srcc))))", 7 }, + /* 3f */ { "~(srca & srcb)", 3 }, + /* 40 */ { "(srca & srcb & ~srcc)", 7 }, + /* 41 */ { "~(srcc | (srca ^ srcb))", 7 }, + /* 42 */ { "((srca ^ srcc) & (srcb ^ srcc))", 7 }, + /* 43 */ { "(srca ^ (~srcb | (srca & srcc)))", 7 }, + /* 44 */ { "(srcb & ~srcc)", 6 }, + /* 45 */ { "~(srcc | (srca & ~srcb))", 7 }, + /* 46 */ { "(srcc ^ (srcb | (srca & srcc)))", 7 }, + /* 47 */ { "~(srca ^ (srcb & (srca ^ srcc)))", 7 }, + /* 48 */ { "(srcb & (srca ^ srcc))", 7 }, + /* 49 */ { "~(srca ^ srcc ^ (srcb | (srca & srcc)))", 7 }, + /* 4a */ { "(srcc ^ (srca & (srcb | srcc)))", 7 }, + /* 4b */ { "(srca ^ (~srcb | srcc))", 7 }, + /* 4c */ { "(srcb & ~(srca & srcc))", 7 }, + /* 4d */ { "(srca ^ ((srca ^ srcb) | ~(srca ^ srcc)))", 7 }, + /* 4e */ { "(srca ^ (srcc | (srca ^ srcb)))", 7 }, + /* 4f */ { "~(srca & (~srcb | srcc))", 7 }, + /* 50 */ { "(srca & ~srcc)", 5 }, + /* 51 */ { "~(srcc | (~srca & srcb))", 7 }, + /* 52 */ { "(srcc ^ (srca | (srcb & srcc)))", 7 }, + /* 53 */ { "~(srcb ^ (srca & (srcb ^ srcc)))", 7 }, + /* 54 */ { "(~srcc & (srca | srcb))", 7 }, + /* 55 */ { "~srcc", 4 }, + /* 56 */ { "(srcc ^ (srca | srcb))", 7 }, + /* 57 */ { "~(srcc & (srca | srcb))", 7 }, + /* 58 */ { "(srca ^ (srcc & (srca | srcb)))", 7 }, + /* 59 */ { "(srcc ^ (srca | ~srcb))", 7 }, + /* 5a */ { "(srca ^ srcc)", 5 }, + /* 5b */ { "(srca ^ (srcc | ~(srca | srcb)))", 7 }, + /* 5c */ { "(srcc ^ (srca | (srcb ^ srcc)))", 7 }, + /* 5d */ { "~(srcc & (srca | ~srcb))", 7 }, + /* 5e */ { "(srca ^ (srcc | (srca ^ (srca | srcb))))", 7 }, + /* 5f */ { "~(srca & srcc)", 5 }, + /* 60 */ { "(srca & (srcb ^ srcc))", 7 }, + /* 61 */ { "~(srcb ^ srcc ^ (srca | (srcb & srcc)))", 7 }, + /* 62 */ { "(srcc ^ (srcb & (srca | srcc)))", 7 }, + /* 63 */ { "(srcb ^ (~srca | srcc))", 7 }, + /* 64 */ { "(srcb ^ (srcc & (srca | srcb)))", 7 }, + /* 65 */ { "(srcc ^ (~srca | srcb))", 7 }, + /* 66 */ { "(srcb ^ srcc)", 6 }, + /* 67 */ { "(srcb ^ (srcc | ~(srca | srcb)))", 7 }, + /* 68 */ { "((srca & srcb) ^ (srcc & (srca | srcb)))", 7 }, + /* 69 */ { "~(srca ^ srcb ^ srcc)", 7 }, + /* 6a */ { "(srcc ^ (srca & srcb))", 7 }, + /* 6b */ { "~(srca ^ srcb ^ (srcc & (srca | srcb)))", 7 }, + /* 6c */ { "(srcb ^ (srca & srcc))", 7 }, + /* 6d */ { "~(srca ^ srcc ^ (srcb & (srca | srcc)))", 7 }, + /* 6e */ { "((~srca & srcb) | (srcb ^ srcc))", 7 }, + /* 6f */ { "(~srca | (srcb ^ srcc))", 7 }, + /* 70 */ { "(srca & ~(srcb & srcc))", 7 }, + /* 71 */ { "~(srca ^ ((srca ^ srcb) | (srca ^ srcc)))", 7 }, + /* 72 */ { "(srcb ^ (srcc | (srca ^ srcb)))", 7 }, + /* 73 */ { "~(srcb & (~srca | srcc))", 7 }, + /* 74 */ { "(srcc ^ (srcb | (srca ^ srcc)))", 7 }, + /* 75 */ { "~(srcc & (~srca | srcb))", 7 }, + /* 76 */ { "(srcb ^ (srcc | (srca ^ (srca & srcb))))", 7 }, + /* 77 */ { "~(srcb & srcc)", 6 }, + /* 78 */ { "(srca ^ (srcb & srcc))", 7 }, + /* 79 */ { "~(srcb ^ srcc ^ (srca & (srcb | srcc)))", 7 }, + /* 7a */ { "((srca & ~srcb) | (srca ^ srcc))", 7 }, + /* 7b */ { "(~srcb | (srca ^ srcc))", 7 }, + /* 7c */ { "((srca ^ srcb) | (srca & ~srcc))", 7 }, + /* 7d */ { "(~srcc | (srca ^ srcb))", 7 }, + /* 7e */ { "((srca ^ srcb) | (srca ^ srcc))", 7 }, + /* 7f */ { "~(srca & srcb & srcc)", 7 }, + /* 80 */ { "(srca & srcb & srcc)", 7 }, + /* 81 */ { "~((srca ^ srcb) | (srca ^ srcc))", 7 }, + /* 82 */ { "(srcc & ~(srca ^ srcb))", 7 }, + /* 83 */ { "(srca ^ (~srcb | (srca & ~srcc)))", 7 }, + /* 84 */ { "(srcb & ~(srca ^ srcc))", 7 }, + /* 85 */ { "(srca ^ (~srcc | (srca & ~srcb)))", 7 }, + /* 86 */ { "(srcb ^ srcc ^ (srca & (srcb | srcc)))", 7 }, + /* 87 */ { "~(srca ^ (srcb & srcc))", 7 }, + /* 88 */ { "(srcb & srcc)", 6 }, + /* 89 */ { "(srcb ^ (~srcc & (~srca | srcb)))", 7 }, + /* 8a */ { "(srcc & (~srca | srcb))", 7 }, + /* 8b */ { "(srca ^ (~srcb | (srca ^ srcc)))", 7 }, + /* 8c */ { "(srcb & (~srca | srcc))", 7 }, + /* 8d */ { "(srca ^ (~srcc | (srca ^ srcb)))", 7 }, + /* 8e */ { "(srca ^ ((srca ^ srcb) | (srca ^ srcc)))", 7 }, + /* 8f */ { "(~srca | (srcb & srcc))", 7 }, + /* 90 */ { "(srca & ~(srcb ^ srcc))", 7 }, + /* 91 */ { "(srcb ^ (~srcc | (~srca & srcb)))", 7 }, + /* 92 */ { "(srca ^ srcc ^ (srcb & (srca | srcc)))", 7 }, + /* 93 */ { "~(srcb ^ (srca & srcc))", 7 }, + /* 94 */ { "(srca ^ srcb ^ (srcc & (srca | srcb)))", 7 }, + /* 95 */ { "~(srcc ^ (srca & srcb))", 7 }, + /* 96 */ { "(srca ^ srcb ^ srcc)", 7 }, + /* 97 */ { "(srca ^ srcb ^ (srcc | ~(srca | srcb)))", 7 }, + /* 98 */ { "(srcb ^ (~srcc & (srca | srcb)))", 7 }, + /* 99 */ { "~(srcb ^ srcc)", 6 }, + /* 9a */ { "(srcc ^ (srca & ~srcb))", 7 }, + /* 9b */ { "~(srcb ^ (srcc & (srca | srcb)))", 7 }, + /* 9c */ { "(srcb ^ (srca & ~srcc))", 7 }, + /* 9d */ { "~(srcc ^ (srcb & (srca | srcc)))", 7 }, + /* 9e */ { "(srcb ^ srcc ^ (srca | (srcb & srcc)))", 7 }, + /* 9f */ { "~(srca & (srcb ^ srcc))", 7 }, + /* a0 */ { "(srca & srcc)", 5 }, + /* a1 */ { "(srca ^ (~srcc & (srca | ~srcb)))", 7 }, + /* a2 */ { "(srcc & (srca | ~srcb))", 7 }, + /* a3 */ { "(srcb ^ (~srca | (srcb ^ srcc)))", 7 }, + /* a4 */ { "(srca ^ (~srcc & (srca | srcb)))", 7 }, + /* a5 */ { "~(srca ^ srcc)", 5 }, + /* a6 */ { "(srcc ^ (~srca & srcb))", 7 }, + /* a7 */ { "~(srca ^ (srcc & (srca | srcb)))", 7 }, + /* a8 */ { "(srcc & (srca | srcb))", 7 }, + /* a9 */ { "~(srcc ^ (srca | srcb))", 7 }, + /* aa */ { "srcc", 4 }, + /* ab */ { "(srcc | ~(srca | srcb))", 7 }, + /* ac */ { "(srcb ^ (srca & (srcb ^ srcc)))", 7 }, + /* ad */ { "~(srcc ^ (srca | (srcb & srcc)))", 7 }, + /* ae */ { "(srcc | (~srca & srcb))", 7 }, + /* af */ { "(~srca | srcc)", 5 }, + /* b0 */ { "(srca & (~srcb | srcc))", 7 }, + /* b1 */ { "~(srca ^ (srcc | (srca ^ srcb)))", 7 }, + /* b2 */ { "(srca ^ ((srca ^ srcc) & (srcb ^ srcc)))", 7 }, + /* b3 */ { "(~srcb | (srca & srcc))", 7 }, + /* b4 */ { "(srca ^ (srcb & ~srcc))", 7 }, + /* b5 */ { "~(srcc ^ (srca & (srcb | srcc)))", 7 }, + /* b6 */ { "(srca ^ srcc ^ (srcb | (srca & srcc)))", 7 }, + /* b7 */ { "~(srcb & (srca ^ srcc))", 7 }, + /* b8 */ { "(srca ^ (srcb & (srca ^ srcc)))", 7 }, + /* b9 */ { "~(srcc ^ (srcb | (srca & srcc)))", 7 }, + /* ba */ { "(srcc | (srca & ~srcb))", 7 }, + /* bb */ { "(~srcb | srcc)", 6 }, + /* bc */ { "((srca ^ srcb) | (srca & srcc))", 7 }, + /* bd */ { "((srca ^ srcb) | ~(srca ^ srcc))", 7 }, + /* be */ { "(srcc | (srca ^ srcb))", 7 }, + /* bf */ { "(srcc | ~(srca & srcb))", 7 }, + /* c0 */ { "(srca & srcb)", 3 }, + /* c1 */ { "(srca ^ (~srcb & (srca | ~srcc)))", 7 }, + /* c2 */ { "(srca ^ (~srcb & (srca | srcc)))", 7 }, + /* c3 */ { "~(srca ^ srcb)", 3 }, + /* c4 */ { "(srcb & (srca | ~srcc))", 7 }, + /* c5 */ { "~(srcb ^ (srca | (srcb ^ srcc)))", 7 }, + /* c6 */ { "(srcb ^ (~srca & srcc))", 7 }, + /* c7 */ { "~(srca ^ (srcb & (srca | srcc)))", 7 }, + /* c8 */ { "(srcb & (srca | srcc))", 7 }, + /* c9 */ { "~(srcb ^ (srca | srcc))", 7 }, + /* ca */ { "(srcc ^ (srca & (srcb ^ srcc)))", 7 }, + /* cb */ { "~(srcb ^ (srca | (srcb & srcc)))", 7 }, + /* cc */ { "srcb", 2 }, + /* cd */ { "(srcb | ~(srca | srcc))", 7 }, + /* ce */ { "(srcb | (~srca & srcc))", 7 }, + /* cf */ { "(~srca | srcb)", 3 }, + /* d0 */ { "(srca & (srcb | ~srcc))", 7 }, + /* d1 */ { "~(srca ^ (srcb | (srca ^ srcc)))", 7 }, + /* d2 */ { "(srca ^ (~srcb & srcc))", 7 }, + /* d3 */ { "~(srcb ^ (srca & (srcb | srcc)))", 7 }, + /* d4 */ { "(srca ^ ((srca ^ srcb) & (srcb ^ srcc)))", 7 }, + /* d5 */ { "(~srcc | (srca & srcb))", 7 }, + /* d6 */ { "(srca ^ srcb ^ (srcc | (srca & srcb)))", 7 }, + /* d7 */ { "~(srcc & (srca ^ srcb))", 7 }, + /* d8 */ { "(srca ^ (srcc & (srca ^ srcb)))", 7 }, + /* d9 */ { "~(srcb ^ (srcc | (srca & srcb)))", 7 }, + /* da */ { "((srca & srcb) | (srca ^ srcc))", 7 }, + /* db */ { "~((srca ^ srcb) & (srcb ^ srcc))", 7 }, + /* dc */ { "(srcb | (srca & ~srcc))", 7 }, + /* dd */ { "(srcb | ~srcc)", 6 }, + /* de */ { "(srcb | (srca ^ srcc))", 7 }, + /* df */ { "(srcb | ~(srca & srcc))", 7 }, + /* e0 */ { "(srca & (srcb | srcc))", 7 }, + /* e1 */ { "~(srca ^ (srcb | srcc))", 7 }, + /* e2 */ { "(srcc ^ (srcb & (srca ^ srcc)))", 7 }, + /* e3 */ { "~(srca ^ (srcb | (srca & srcc)))", 7 }, + /* e4 */ { "(srcb ^ (srcc & (srca ^ srcb)))", 7 }, + /* e5 */ { "~(srca ^ (srcc | (srca & srcb)))", 7 }, + /* e6 */ { "((srca & srcb) | (srcb ^ srcc))", 7 }, + /* e7 */ { "~((srca ^ srcb) & (srca ^ srcc))", 7 }, + /* e8 */ { "(srca ^ ((srca ^ srcb) & (srca ^ srcc)))", 7 }, + /* e9 */ { "(srca ^ srcb ^ (~srcc | (srca & srcb)))", 7 }, + /* ea */ { "(srcc | (srca & srcb))", 7 }, + /* eb */ { "(srcc | ~(srca ^ srcb))", 7 }, + /* ec */ { "(srcb | (srca & srcc))", 7 }, + /* ed */ { "(srcb | ~(srca ^ srcc))", 7 }, + /* ee */ { "(srcb | srcc)", 6 }, + /* ef */ { "(~srca | srcb | srcc)", 7 }, + /* f0 */ { "srca", 1 }, + /* f1 */ { "(srca | ~(srcb | srcc))", 7 }, + /* f2 */ { "(srca | (~srcb & srcc))", 7 }, + /* f3 */ { "(srca | ~srcb)", 3 }, + /* f4 */ { "(srca | (srcb & ~srcc))", 7 }, + /* f5 */ { "(srca | ~srcc)", 5 }, + /* f6 */ { "(srca | (srcb ^ srcc))", 7 }, + /* f7 */ { "(srca | ~(srcb & srcc))", 7 }, + /* f8 */ { "(srca | (srcb & srcc))", 7 }, + /* f9 */ { "(srca | ~(srcb ^ srcc))", 7 }, + /* fa */ { "(srca | srcc)", 5 }, + /* fb */ { "(srca | ~srcb | srcc)", 7 }, + /* fc */ { "(srca | srcb)", 3 }, + /* fd */ { "(srca | srcb | ~srcc)", 7 }, + /* fe */ { "(srca | srcb | srcc)", 7 }, + /* ff */ { "0xFFFFFFFF", 0 } }; diff --git a/src/blittable.cpp b/src/blittable.cpp index c81e0b69..1c47b0ba 100644 --- a/src/blittable.cpp +++ b/src/blittable.cpp @@ -8,74 +8,72 @@ #include "blitter.h" #include "blitfunc.h" -blitter_func * const blitfunc_dofast[256] = -{ - blitdofast_0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_a, 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, blitdofast_2a, 0, 0, 0, 0, 0, - blitdofast_30, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_3a, 0, blitdofast_3c, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_4a, 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, blitdofast_6a, 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, blitdofast_8a, 0, blitdofast_8c, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_9a, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - blitdofast_a8, 0, blitdofast_aa, 0, 0, 0, 0, 0, - 0, blitdofast_b1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_ca, 0, blitdofast_cc, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - blitdofast_d8, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_e2, 0, 0, 0, 0, 0, - 0, 0, blitdofast_ea, 0, 0, 0, 0, 0, - blitdofast_f0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_fa, 0, blitdofast_fc, 0, 0, 0 +blitter_func * const blitfunc_dofast[256] = { +blitdofast_0, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_a, 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, blitdofast_2a, 0, 0, 0, 0, 0, +blitdofast_30, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_3a, 0, blitdofast_3c, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_4a, 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, blitdofast_6a, 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, blitdofast_8a, 0, blitdofast_8c, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_9a, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, +blitdofast_a8, 0, blitdofast_aa, 0, 0, 0, 0, 0, +0, blitdofast_b1, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_ca, 0, blitdofast_cc, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, +blitdofast_d8, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_e2, 0, 0, 0, 0, 0, +0, 0, blitdofast_ea, 0, 0, 0, 0, 0, +blitdofast_f0, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_fa, 0, blitdofast_fc, 0, 0, 0 }; -blitter_func * const blitfunc_dofast_desc[256] = -{ - blitdofast_desc_0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_desc_a, 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, blitdofast_desc_2a, 0, 0, 0, 0, 0, - blitdofast_desc_30, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_desc_3a, 0, blitdofast_desc_3c, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_desc_4a, 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, blitdofast_desc_6a, 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, blitdofast_desc_8a, 0, blitdofast_desc_8c, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_desc_9a, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - blitdofast_desc_a8, 0, blitdofast_desc_aa, 0, 0, 0, 0, 0, - 0, blitdofast_desc_b1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_desc_ca, 0, blitdofast_desc_cc, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - blitdofast_desc_d8, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_desc_e2, 0, 0, 0, 0, 0, - 0, 0, blitdofast_desc_ea, 0, 0, 0, 0, 0, - blitdofast_desc_f0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, blitdofast_desc_fa, 0, blitdofast_desc_fc, 0, 0, 0 +blitter_func * const blitfunc_dofast_desc[256] = { +blitdofast_desc_0, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_desc_a, 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, blitdofast_desc_2a, 0, 0, 0, 0, 0, +blitdofast_desc_30, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_desc_3a, 0, blitdofast_desc_3c, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_desc_4a, 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, blitdofast_desc_6a, 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, blitdofast_desc_8a, 0, blitdofast_desc_8c, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_desc_9a, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, +blitdofast_desc_a8, 0, blitdofast_desc_aa, 0, 0, 0, 0, 0, +0, blitdofast_desc_b1, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_desc_ca, 0, blitdofast_desc_cc, 0, 0, 0, +0, 0, 0, 0, 0, 0, 0, 0, +blitdofast_desc_d8, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_desc_e2, 0, 0, 0, 0, 0, +0, 0, blitdofast_desc_ea, 0, 0, 0, 0, 0, +blitdofast_desc_f0, 0, 0, 0, 0, 0, 0, 0, +0, 0, blitdofast_desc_fa, 0, blitdofast_desc_fc, 0, 0, 0 }; diff --git a/src/blitter.cpp b/src/blitter.cpp index 0bcf51d3..6557d9b3 100644 --- a/src/blitter.cpp +++ b/src/blitter.cpp @@ -1,11 +1,11 @@ -/* -* UAE - The Un*x Amiga Emulator -* -* Custom chip emulation -* -* (c) 1995 Bernd Schmidt, Alessandro Bissacco -* (c) 2002 - 2005 Toni Wilen -*/ + /* + * UAE - The Un*x Amiga Emulator + * + * Custom chip emulation + * + * (c) 1995 Bernd Schmidt, Alessandro Bissacco + * (c) 2002 - 2005 Toni Wilen + */ #include "sysconfig.h" #include "sysdeps.h" @@ -157,7 +157,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]) @@ -174,7 +174,7 @@ static int get_cycle_diagram_type(const int *diag) 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]; @@ -189,7 +189,7 @@ static const int *set_cycle_diagram_type(uae_u8 diag) return NULL; } -void build_blitfilltable(void) +void build_blitfilltable (void) { unsigned int d, fillmask; int i; @@ -217,7 +217,7 @@ void build_blitfilltable(void) } } -STATIC_INLINE int channel_state(int cycles) +STATIC_INLINE int channel_state (int cycles) { if (cycles < blit_diag[0]) return blit_diag[1 + cycles]; @@ -235,225 +235,221 @@ 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 (void) { if (blit_interrupt) return; blit_interrupt = 1; - send_interrupt(6); + send_interrupt (6); } -static void blitter_done(void) +static void blitter_done (void) { ddat1use = 0; bltstate = BLT_done; - blitter_interrupt(); - blitter_done_notify(); - event_remevent(ev_blitter); - unset_special(SPCFLAG_BLTNASTY); + blitter_interrupt (); + blitter_done_notify (); + event_remevent(ev_blitter); + unset_special (SPCFLAG_BLTNASTY); } -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); + chipmem_wput_indirect (addr, w); } 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[BLITTER_MAX_WORDS - 1] = blt_info.bltafwm; - blit_masktable[BLITTER_MAX_WORDS - blt_info.hblitsize] &= blt_info.bltalwm; + blit_masktable[BLITTER_MAX_WORDS - 1] = blt_info.bltafwm; + blit_masktable[BLITTER_MAX_WORDS - blt_info.hblitsize] &= blt_info.bltalwm; - if (bltcon0 & 0x800) { - bltadatptr = (uaecptr)get_real_address(bltapt); - bltapt += (blt_info.hblitsize * 2 + blt_info.bltamod) * blt_info.vblitsize; - } - if (bltcon0 & 0x400) { - bltbdatptr = (uaecptr)get_real_address(bltbpt); - bltbpt += (blt_info.hblitsize * 2 + blt_info.bltbmod) * blt_info.vblitsize; - } - if (bltcon0 & 0x200) { - bltcdatptr = (uaecptr)get_real_address(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 (bltcon0 & 0x800) { + bltadatptr = (uaecptr)get_real_address(bltapt); + bltapt += (blt_info.hblitsize * 2 + blt_info.bltamod) * blt_info.vblitsize; + } + if (bltcon0 & 0x400) { + bltbdatptr = (uaecptr)get_real_address(bltbpt); + bltbpt += (blt_info.hblitsize * 2 + blt_info.bltbmod) * blt_info.vblitsize; + } + if (bltcon0 & 0x200) { + bltcdatptr = (uaecptr)get_real_address(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; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - blt_info.hblitsize; + if (blitfunc_dofast[mt] && !blitfill) { + (*blitfunc_dofast[mt])(bltadatptr, bltbdatptr, bltcdatptr, bltddatptr, &blt_info); + } else { + uae_u32 blitbhold = blt_info.bltbhold; + uaecptr dstp = 0; + uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - blt_info.hblitsize; - for (j = blt_info.vblitsize; j--;) { - blitfc = !!(bltcon1 & 0x4); - for (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_p[i]; + for (j = blt_info.vblitsize; j--;) { + blitfc = !!(bltcon1 & 0x4); + for (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_p[i]; blitahold = (((uae_u32)blt_info.bltaold << 16) | bltadat) >> blt_info.blitashift; blt_info.bltaold = bltadat; - if (bltbdatptr) { - uae_u16 bltbdat; - blt_info.bltbdat = bltbdat = do_get_mem_word((uae_u16 *)bltbdatptr); - bltbdatptr += 2; + if (bltbdatptr) { + uae_u16 bltbdat; + blt_info.bltbdat = 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; - } - 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[BLITTER_MAX_WORDS - 1] = 0xFFFF; - blit_masktable[BLITTER_MAX_WORDS - blt_info.hblitsize] = 0xFFFF; + } + 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[BLITTER_MAX_WORDS - 1] = 0xFFFF; + blit_masktable[BLITTER_MAX_WORDS - blt_info.hblitsize] = 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; + int i,j; + uaecptr bltadatptr = 0, bltbdatptr = 0, bltcdatptr = 0, bltddatptr = 0; + uae_u8 mt = bltcon0 & 0xFF; - blit_masktable[BLITTER_MAX_WORDS - 1] = blt_info.bltafwm; - blit_masktable[BLITTER_MAX_WORDS - blt_info.hblitsize] &= blt_info.bltalwm; + blit_masktable[BLITTER_MAX_WORDS - 1] = blt_info.bltafwm; + blit_masktable[BLITTER_MAX_WORDS - blt_info.hblitsize] &= blt_info.bltalwm; - if (bltcon0 & 0x800) { - bltadatptr = (uaecptr)get_real_address(bltapt); - bltapt -= (blt_info.hblitsize * 2 + blt_info.bltamod) * blt_info.vblitsize; - } - if (bltcon0 & 0x400) { - bltbdatptr = (uaecptr)get_real_address(bltbpt); - bltbpt -= (blt_info.hblitsize * 2 + blt_info.bltbmod) * blt_info.vblitsize; - } - if (bltcon0 & 0x200) { - bltcdatptr = (uaecptr)get_real_address(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_desc[mt] && !blitfill) { + if (bltcon0 & 0x800) { + bltadatptr = (uaecptr)get_real_address(bltapt); + bltapt -= (blt_info.hblitsize * 2 + blt_info.bltamod) * blt_info.vblitsize; + } + if (bltcon0 & 0x400) { + bltbdatptr = (uaecptr)get_real_address(bltbpt); + bltbpt -= (blt_info.hblitsize * 2 + blt_info.bltbmod) * blt_info.vblitsize; + } + if (bltcon0 & 0x200) { + bltcdatptr = (uaecptr)get_real_address(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_desc[mt] && !blitfill) { (*blitfunc_dofast_desc[mt])(bltadatptr, bltbdatptr, bltcdatptr, bltddatptr, &blt_info); - } - else { - uae_u32 blitbhold = blt_info.bltbhold; - uaecptr dstp = 0; - uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - blt_info.hblitsize; + } else { + uae_u32 blitbhold = blt_info.bltbhold; + uaecptr dstp = 0; + uae_u32 *blit_masktable_p = blit_masktable + BLITTER_MAX_WORDS - blt_info.hblitsize; - for (j = blt_info.vblitsize; j--;) { + for (j = blt_info.vblitsize; j--;) { blitfc = !!(bltcon1 & 0x4); - for (i = blt_info.hblitsize; i--;) { + for (i = blt_info.hblitsize; i--;) { uae_u32 bltadat, blitahold; if (bltadatptr) { - bltadat = blt_info.bltadat = do_get_mem_word((uae_u16 *)bltadatptr); + bltadat = blt_info.bltadat = do_get_mem_word ((uae_u16 *)bltadatptr); bltadatptr -= 2; - } - else + } else bltadat = blt_info.bltadat; bltadat &= blit_masktable_p[i]; blitahold = (((uae_u32)bltadat << 16) | blt_info.bltaold) >> blt_info.blitdownashift; blt_info.bltaold = bltadat; if (bltbdatptr) { - uae_u16 bltbdat; - blt_info.bltbdat = bltbdat = do_get_mem_word((uae_u16 *)bltbdatptr); - bltbdatptr -= 2; + uae_u16 bltbdat; + blt_info.bltbdat = 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; - } + } - 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 = 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); blt_info.bltbhold = blitbhold; } - blit_masktable[BLITTER_MAX_WORDS - 1] = 0xFFFF; - blit_masktable[BLITTER_MAX_WORDS - blt_info.hblitsize] = 0xFFFF; + blit_masktable[BLITTER_MAX_WORDS - 1] = 0xFFFF; + blit_masktable[BLITTER_MAX_WORDS - blt_info.hblitsize] = 0xFFFF; - bltstate = BLT_done; + bltstate = BLT_done; } STATIC_INLINE void blitter_read(void) { if (bltcon0 & 0x200) { - blt_info.bltcdat = chipmem_wget_indirect(bltcpt); + blt_info.bltcdat = chipmem_wget_indirect(bltcpt); } } @@ -463,36 +459,36 @@ 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); + chipmem_wput_indirect (bltdpt, blt_info.bltddat); } } 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) @@ -501,7 +497,7 @@ static int blitter_line(void) blt_info.bltbhold = (blineb & 1) ? 0xFFFF : 0; int blitlinepixel = !blitsing || (blitsing && !blitonedot); - blt_info.bltddat = blit_func(blitahold, blt_info.bltbhold, blt_info.bltcdat, bltcon0 & 0xFF); + blt_info.bltddat = blit_func (blitahold, blt_info.bltbhold, blt_info.bltcdat, bltcon0 & 0xFF); blitonedot++; if (bltcon0 & 0x800) { @@ -514,28 +510,26 @@ static int blitter_line(void) 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; @@ -550,86 +544,85 @@ STATIC_INLINE void blitter_nxline(void) 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(); + if (blitter_line ()) { + blitter_write (); } - blitter_nxline(); + blitter_nxline (); if (blt_info.vblitsize == 0) bltstate = BLT_done; } while (bltstate != BLT_done); - bltdpt = bltcpt; + bltdpt = bltcpt; last_custom_value1 = blt_info.bltcdat; - } - else { + } 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 (); return; } - actually_do_blit(); - blitter_done(); + actually_do_blit (); + blitter_done (); } void blitter_handler(void) { static int blitter_stuck; - if (!dmaen(DMA_BLITTER)) { - event_newevent(ev_blitter, 10); + if (!dmaen (DMA_BLITTER)) { + event_newevent (ev_blitter, 10); 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 + */ } blitter_stuck = 0; if (blit_slowdown > 0 && !immediate_blits) { - event_newevent(ev_blitter, blit_slowdown); + event_newevent (ev_blitter, blit_slowdown); blit_slowdown = -1; return; } - blitter_doit(); + blitter_doit (); } -static void blitter_force_finish(void) +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; - actually_do_blit(); - blitter_done(); - dmacon = odmacon; - } + 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; + } } -static bool invstate(void) +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; @@ -638,12 +631,12 @@ static void blit_bltset(int con) 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); - return; - } - if (bltstate != BLT_done) { + write_log (_T("BLITTER: linedraw enabled after starting normal blit! %08x\n"), M68K_GETPC); return; } + if (bltstate != BLT_done) { + return; + } } if (con & 1) { @@ -660,13 +653,12 @@ 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 (blitline) { blit_diag = blit_cycle_diagram_line; - } - else { + } else { if (con & 2) { blitfc = !!(bltcon1 & 0x4); blitife = !!(bltcon1 & 0x8); @@ -679,7 +671,7 @@ static void blit_bltset(int con) // 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 ()) { if (blit_ch == 13 && original_ch == 1) { blit_faulty = 1; } @@ -706,48 +698,48 @@ static void blit_bltset(int con) } } -void reset_blit(int bltcon) +void reset_blit (int bltcon) { - if (bltstate == BLT_done) - return; - blit_bltset(bltcon); + if (bltstate == BLT_done) + return; + blit_bltset (bltcon); } -static bool waitingblits(void) +static bool waitingblits (void) { bool waited = false; - while (bltstate != BLT_done && dmaen(DMA_BLITTER)) { + while (bltstate != BLT_done && dmaen (DMA_BLITTER)) { waited = true; - x_do_cycles(8 * CYCLE_UNIT); + x_do_cycles (8 * CYCLE_UNIT); } if (bltstate == BLT_done) return true; return false; } -static void blitter_start_init(void) +static void blitter_start_init (void) { blt_info.blitzero = 1; blitline_started = bltcon1 & 1; - blit_bltset(1 | 2); + blit_bltset (1 | 2); ddat1use = 0; blit_interrupt = 0; - blt_info.bltaold = 0; - blt_info.bltbold = 0; + blt_info.bltaold = 0; + blt_info.bltbold = 0; if (blitline) { - blinea_shift = bltcon0 >> 12; + blinea_shift = bltcon0 >> 12; blinea = blt_info.bltadat; blineb = (blt_info.bltbdat >> blt_info.blitbshift) | (blt_info.bltbdat << (16 - blt_info.blitbshift)); blitonedot = 0; blitsing = bltcon1 & 0x2; - blitsign = bltcon1 & 0x40; + blitsign = bltcon1 & 0x40; } } -void do_blitter() +void do_blitter () { int cycles; int cleanstart; @@ -761,16 +753,15 @@ void do_blitter() bltstate = BLT_done; immediate_blits = currprefs.immediate_blits; - blit_firstline_cycles = blit_first_cycle = get_cycles(); + blit_firstline_cycles = blit_first_cycle = get_cycles (); blit_last_cycle = 0; blit_cyclecounter = 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; } @@ -779,59 +770,58 @@ void do_blitter() original_ch = blit_ch; } - bltstate = BLT_init; + 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)) + blitter_done (); return; } - blit_cyclecounter = cycles * (blit_dmacount2 + (blit_nod ? 0 : 1)); - if (!dmaen(DMA_BLITTER)) - return; + blit_cyclecounter = cycles * (blit_dmacount2 + (blit_nod ? 0 : 1)); + if (!dmaen (DMA_BLITTER)) + return; bltstate = BLT_work; if (immediate_blits) { - blitter_doit(); - return; + blitter_doit (); + return; } - event_newevent(ev_blitter, blit_cyclecounter); + event_newevent(ev_blitter, blit_cyclecounter); - if (dmaen(DMA_BLITTER)) { + if (dmaen (DMA_BLITTER)) { 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(); + blitter_start_init (); bltstate = BLT_work; if (immediate_blits) { - blitter_doit(); - } - else { - event_newevent(ev_blitter, blit_cyclecounter); - } + blitter_doit (); + } else { + event_newevent(ev_blitter, blit_cyclecounter); + } } -void maybe_blit2(int hack) +void maybe_blit2 (int hack) { - if (dmaen(DMA_BLITTER)) { + if (dmaen (DMA_BLITTER)) { bool doit = false; if (currprefs.waiting_blits) { // automatic if (blit_dmacount == blit_diag[0] && (regs.spcflags & SPCFLAG_BLTNASTY)) @@ -840,30 +830,30 @@ void maybe_blit2(int hack) doit = true; } if (doit) { - if (waitingblits()) + if (waitingblits ()) return; } } - if (hack == 1 && (int)get_cycles() - (int)blit_firstline_cycles < 0) - return; + if (hack == 1 && (int)get_cycles() - (int)blit_firstline_cycles < 0) + return; - blitter_handler(); + blitter_handler (); } -int blitnasty(void) +int blitnasty (void) { int cycles, ccnt; if (bltstate == BLT_done) return 0; - if (!dmaen(DMA_BLITTER)) + if (!dmaen (DMA_BLITTER)) return 0; 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++; } @@ -871,122 +861,122 @@ 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; } #ifdef SAVESTATE -uae_u8 *restore_blitter(uae_u8 *src) +uae_u8 *restore_blitter (uae_u8 *src) { - uae_u32 flags = restore_u32(); + uae_u32 flags = restore_u32(); bltstate = BLT_done; if (flags & 4) { - bltstate = (flags & 1) ? BLT_done : BLT_init; - } - return src; + bltstate = (flags & 1) ? BLT_done : BLT_init; + } + return src; } -uae_u8 *save_blitter(int *len, uae_u8 *dstptr) +uae_u8 *save_blitter (int *len, uae_u8 *dstptr) { - uae_u8 *dstbak, *dst; - int forced; + 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(); + 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_firstline_cycles = restore_u32 (); + blit_cyclecounter = restore_u32 (); + blit_slowdown = restore_u32 (); - blit_ch = restore_u8(); - blit_dmacount = restore_u8(); - blit_dmacount2 = restore_u8(); - blit_nod = 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(); + ddat1use = 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(); + 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_faulty = restore_u8(); - original_ch = 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")); bltstate = BLT_done; if (state > 0) - do_blitter(); + do_blitter (); 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; if (bltstate == BLT_done) @@ -995,47 +985,47 @@ uae_u8 *save_blitter_new(int *len, uae_u8 *dstptr) 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")); } - 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_firstline_cycles); + save_u32 (blit_cyclecounter); + save_u32 (blit_slowdown); - save_u8(blit_ch); - save_u8(blit_dmacount); - save_u8(blit_dmacount2); - save_u8(blit_nod); - 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 (ddat1use); - 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 (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_faulty); - save_u8(original_ch); - save_u8(get_cycle_diagram_type(blit_diag)); - - save_u16(0x1234); + save_u16 (0x1234); *len = dst - dstbak; return dstbak; diff --git a/src/blkdev.cpp b/src/blkdev.cpp index cf1796e9..986a297b 100644 --- a/src/blkdev.cpp +++ b/src/blkdev.cpp @@ -48,7 +48,7 @@ struct blkdevstate state[MAX_TOTAL_SCSI_DEVICES]; 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 +56,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,26 +66,26 @@ 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 (int unitnum, struct cd_toc_head *th, int block) { if (th->lastaddress == 0) { if (unitnum < 0) @@ -96,21 +96,21 @@ static struct cd_toc *gettoc(int unitnum, struct cd_toc_head *th, int block) 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 (-1, 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]; @@ -118,13 +118,13 @@ static int cdscsidevicetype[MAX_TOTAL_SCSI_DEVICES]; static struct device_functions *devicetable[] = { NULL, &devicefunc_cdimage, - NULL, - NULL, + NULL, + NULL, }; #define NUM_DEVICE_TABLE_ENTRIES 4 static int driver_installed[NUM_DEVICE_TABLE_ENTRIES]; -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,51 +135,49 @@ 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; - } - } - } - } + // 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; + continue; } 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); + 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); + write_log (_T("Fallback to image mode, unit %d.\n"), i); driver_installed[j] = -1; + } else { + driver_installed[j] = 1; } - else { - driver_installed[j] = 1; - } - write_log(_T("%s driver installed, ok=%d\n"), st->device_func->name, ok); + write_log (_T("%s driver installed, ok=%d\n"), st->device_func->name, ok); break; } } @@ -188,7 +186,7 @@ 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; @@ -199,7 +197,7 @@ void blkdev_default_prefs(struct uae_prefs *p) } } -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; @@ -217,148 +215,145 @@ 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)) + _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]; @@ -369,23 +364,23 @@ 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); } if (st->isopen) { @@ -393,29 +388,29 @@ 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; 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); + 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); } -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]; @@ -429,65 +424,65 @@ void device_func_reset(void) dev_init = false; } -int device_func_init(int flags) +int device_func_init (int flags) { - blkdev_fix_prefs(&currprefs); - install_driver(flags); + blkdev_fix_prefs (&currprefs); + install_driver (flags); dev_init = true; 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; } -static void check_changes(int unitnum) +static void check_changes (int unitnum) { struct blkdevstate *st = &state[unitnum]; bool changed = false; @@ -499,36 +494,36 @@ 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) { 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); if (gotsem) { - freesem(unitnum); + freesem (unitnum); gotsem = false; } } @@ -538,52 +533,51 @@ 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; if (gotsem) { - freesem(unitnum); + freesem (unitnum); gotsem = false; } - set_config_changed(); + 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; @@ -592,70 +586,68 @@ 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,(uae_u8)(paused?0:1),0}; + do_scsi (unitnum, cmd, sizeof cmd); v = as == AUDIO_STATUS_PAUSED; + } else { + v = state[unitnum].device_func->pause (unitnum, paused); } - else { - v = state[unitnum].device_func->pause(unitnum, paused); - } - freesem(unitnum); + 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); + 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); } - else { - state[unitnum].device_func->stop(unitnum); - } - freesem(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); @@ -663,157 +655,150 @@ 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; + v = do_scsi (unitnum, cmd, sizeof cmd) ? 0 : 1; + } else { + v = state[unitnum].device_func->play (unitnum, startlsn, endlsn, scan, NULL, NULL); } - else { - v = state[unitnum].device_func->play(unitnum, startlsn, endlsn, scan, NULL, NULL); - } - freesem(unitnum); + 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 sector, bool all) { 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 { - 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); } - else { - v = state[unitnum].device_func->qcode(unitnum, buf, sector, all); - } - freesem(unitnum); + 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); } - else { - v = state[unitnum].device_func->toc(unitnum, toc); - } - freesem(unitnum); + 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); + v = do_scsi (unitnum, cmd1, sizeof cmd1, data, size * 2048); + } else { + v = state[unitnum].device_func->read (unitnum, data, block, size); } - else { - v = state[unitnum].device_func->read(unitnum, data, block, size); - } - freesem(unitnum); + 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); + v = do_scsi (unitnum, cmd, sizeof cmd, data, size * sectorsize); + } else { + v = state[unitnum].device_func->rawread (unitnum, data, block, size, sectorsize, 0xffffffff); } - else { - v = state[unitnum].device_func->rawread(unitnum, data, block, size, sectorsize, 0xffffffff); - } - freesem(unitnum); + 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); + 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); } - else { - v = state[unitnum].device_func->rawread(unitnum, data, block, size, sectorsize, (sectortype << 16) | (scsicmd9 << 8) | subs); - } - freesem(unitnum); + 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 }; @@ -821,76 +806,73 @@ int sys_command_read(int unitnum, uae_u8 *data, int block, int size) 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); + v = do_scsi (unitnum, cmd, sizeof cmd, data, size * 2048); + } else { + v = state[unitnum].device_func->read (unitnum, data, block, size); } - else { - v = state[unitnum].device_func->read(unitnum, data, block, size); - } - freesem(unitnum); + 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); } - else { - v = state[unitnum].device_func->write(unitnum, data, offset, size); - } - freesem(unitnum); + 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); + v = do_scsi (unitnum, cmd, sizeof cmd); + } else { + v = state[unitnum].device_func->ismedia (unitnum, quick); } - else { - v = state[unitnum].device_func->ismedia(unitnum, quick); - } - freesem(unitnum); + 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); + 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]; @@ -908,7 +890,7 @@ struct device_info *sys_command_info(int unitnum, struct device_info *di, int qu } } } - return dix; + return dix; } #define MODE_SELECT_6 0x15 @@ -916,7 +898,7 @@ struct device_info *sys_command_info(int unitnum, struct device_info *di, int qu #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; @@ -935,9 +917,9 @@ void scsi_atapi_fixup_pre(uae_u8 *scsi_cmd, int *len, uae_u8 **datap, int *datal 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); + p = xmalloc (uae_u8, 8 + datalen + 4); if (datalen > 4) - memcpy(p + 8, data + 4, datalen - 4); + memcpy (p + 8, data + 4, datalen - 4); p[0] = 0; p[1] = data[0]; p[2] = data[1]; @@ -948,21 +930,20 @@ void scsi_atapi_fixup_pre(uae_u8 *scsi_cmd, int *len, uae_u8 **datap, int *datal datalen += 4; *parm = MODE_SELECT_10; *datap = p; - } - else { + } 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); + *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) @@ -974,12 +955,12 @@ void scsi_atapi_fixup_post(uae_u8 *scsi_cmd, int len, uae_u8 *olddata, uae_u8 *d olddata[3] = data[7]; datalen -= 4; if (datalen > 4) - memcpy(olddata + 4, data + 8, 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; @@ -1001,81 +982,81 @@ static void scsi_atapi_fixup_inquiry(struct amigascsi *as) } } -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("%s%02X"), i > 0 ? _T(".") : _T(""), cdb[i]); } - write_log(_T("\n")); + write_log (_T("\n")); if (data) { - write_log(_T("DATAOUT: %d\n"), datalen); + 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]); + write_log (_T("%s%02X"), i > 0 ? _T(".") : _T(""), data[i]); if (datalen > 0) - write_log(_T("\n")); + 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); + 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]); + write_log (_T("%s%02X"), i > 0 ? _T(".") : _T(""), data[i]); if (data && datalen > 0) - write_log(_T("\n")); + write_log (_T("\n")); if (senselen > 0) { - write_log(_T("SENSE: %d,"), senselen); + 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("%s%02X"), i > 0 ? _T(".") : _T(""), sense[i]); } - write_log(_T("\n")); + write_log (_T("\n")); } } -static bool nodisk(struct device_info *di) +static bool nodisk (struct device_info *di) { 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)) + if (!getsem (unitnum)) return 0; - int v = state[unitnum].device_func->read(unitnum, dataptr, offset, len); - freesem(unitnum); + 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; } -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 int rw(uae_u8 *p) +static int rw (uae_u8 *p) { 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; @@ -1086,15 +1067,15 @@ static int addtocentry(uae_u8 **dstp, int *len, int point, int newpoint, int msf return 0; int addr = t->paddress; if (msf) - addr = lsn2msf(addr); + 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; + dst[6] = addr >> 8; + dst[7] = addr >> 0; if (point >= 1 && point <= 99) { if (head[2] == 0) @@ -1110,27 +1091,27 @@ static int addtocentry(uae_u8 **dstp, int *len, int point, int newpoint, int msf return -1; } -static int scsiemudrv(int unitnum, uae_u8 *cmd) +static int scsiemudrv (int unitnum, uae_u8 *cmd) { - if (failunit(unitnum)) + if (failunit (unitnum)) return -1; - if (!getsem(unitnum)) + if (!getsem (unitnum)) return 0; int v = 0; if (state[unitnum].device_func->scsiemu) - v = state[unitnum].device_func->scsiemu(unitnum, cmd); - freesem(unitnum); + v = state[unitnum].device_func->scsiemu (unitnum, cmd); + freesem (unitnum); return v; } -static int scsi_read_cd(int unitnum, uae_u8 *cmd, uae_u8 *data, struct device_info *di) +static int scsi_read_cd (int unitnum, uae_u8 *cmd, uae_u8 *data, struct device_info *di) { 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; + int start = msf ? msf2lsn (rl (cmd + 2) & 0x00ffffff) : rl (cmd + 2); + int len = rl (cmd + 5) & 0x00ffffff; if (msf) { - int end = msf2lsn(len); + int end = msf2lsn (len); len = end - start; if (len < 0) return -1; @@ -1138,13 +1119,13 @@ static int scsi_read_cd(int unitnum, uae_u8 *cmd, uae_u8 *data, struct device_in 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); + 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; } -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_data (int unitnum, uae_u8 *scsi_data, uae_u32 offset, uae_u32 len, struct device_info *di, int *scsi_len, struct cd_toc *t) { struct blkdevstate *st = &state[unitnum]; int end = t[1].paddress; @@ -1154,11 +1135,10 @@ static int scsi_read_cd_data(int unitnum, uae_u8 *scsi_data, uae_u32 offset, uae return -1; *scsi_len = 0; return 0; - } - else { + } else { if (offset >= end) return -1; - int v = cmd_readx(unitnum, scsi_data, offset, len) * di->bytespersector; + int v = cmd_readx (unitnum, scsi_data, offset, len) * di->bytespersector; if (v > 0) { st->current_pos = offset + len; *scsi_len = v; @@ -1168,7 +1148,7 @@ static int scsi_read_cd_data(int unitnum, uae_u8 *scsi_data, uae_u32 offset, uae } } -int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, +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]; @@ -1183,7 +1163,7 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, if (cmdbuf == NULL) { if (st->mediawaschanged) { - st->mediawaschanged = false; + st->mediawaschanged = false; return (0x28 << 8) | (0x00); } return 0; @@ -1194,7 +1174,7 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, if (cmd == 0x03) { return 0; } - + dlen = *data_len; *reply_len = *sense_len = 0; @@ -1205,16 +1185,16 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, 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); + 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)) + if (nodisk (&di)) goto nodisk; scsi_len = 0; break; @@ -1227,8 +1207,8 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, len = 8; scsi_len = len; r[2] = st->current_pos >> 16; - r[3] = st->current_pos >> 8; - r[4] = st->current_pos >> 0; + r[3] = st->current_pos >> 8; + r[4] = st->current_pos >> 0; break; case 0x12: /* INQUIRY */ { @@ -1237,9 +1217,8 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, len = cmdbuf[4]; if (cmdbuf[1] >> 5) { r[0] = 0x7f; - } - else { - r[0] = 5; // CDROM + } else { + r[0] = 5; // CDROM } r[1] |= 0x80; // removable r[2] = 2; /* supports SCSI-2 */ @@ -1251,15 +1230,15 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, 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); + 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; @@ -1268,9 +1247,9 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, break; case 0xbe: // READ CD case 0xb9: // READ CD MSF - if (nodisk(&di)) + if (nodisk (&di)) goto nodisk; - scsi_len = scsi_read_cd(unitnum, cmdbuf, scsi_data, &di); + scsi_len = scsi_read_cd (unitnum, cmdbuf, scsi_data, &di); if (scsi_len == -2) goto notdatatrack; if (scsi_len == -1) @@ -1288,10 +1267,9 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, 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); + sys_command_cd_volume (unitnum, vol_left, vol_right); scsi_len = 0; - } - else { + } else { goto errreq; } } @@ -1324,8 +1302,7 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, p[6] = 0; p[7] = 0; p += 8; - } - else { + } else { totalsize = 4 - 1; maxlen = cmdbuf[4]; p[1] = 0; @@ -1346,28 +1323,26 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, } for (;;) { psize = 0; - if (pcode == 0) { - p[0] = 0; - p[1] = 0; - p[2] = 0x20; - p[3] = 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; + } 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 + } 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 @@ -1386,11 +1361,10 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, p[20] = p[21] = 0; p[22] = p[23] = 0; psize = p[1] + 2; - } - else { + } else { if (!pcodeloop) - goto err; - } + goto err; + } totalsize += psize; p += psize; if (!pcodeloop) @@ -1400,15 +1374,14 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, 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 { + } else { totalsize += bdsize; r[3] = bdsize & 0xff; r[0] = totalsize & 0xff; @@ -1421,70 +1394,69 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, break; case 0x01: /* REZERO UNIT */ scsi_len = 0; - break; + 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; + { + 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; } - wl(r, blocks); - wl(r + 4, di.bytespersector); - scsi_len = lr = 8; - } - break; + 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; - } + { + 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)) + if (nodisk (&di)) goto nodisk; - stopplay(unitnum); + stopplay (unitnum); offset = ((cmdbuf[1] & 31) << 16) | (cmdbuf[2] << 8) | cmdbuf[3]; - struct cd_toc *t = gettoc(unitnum, &di.toc, offset); + 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); + 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 { + } else { goto notdatatrack; } } @@ -1492,37 +1464,36 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, 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; - } + { + 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)) + if (nodisk (&di)) goto nodisk; - stopplay(unitnum); - offset = rl(cmdbuf + 2); - struct cd_toc *t = gettoc(unitnum, &di.toc, offset); + 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); + 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 { + } else { goto notdatatrack; } } @@ -1531,22 +1502,21 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, goto readprot; case 0xa8: /* READ (12) */ { - if (nodisk(&di)) + if (nodisk (&di)) goto nodisk; - stopplay(unitnum); - offset = rl(cmdbuf + 2); - struct cd_toc *t = gettoc(unitnum, &di.toc, offset); + 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); + 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 { + } else { goto notdatatrack; } } @@ -1554,381 +1524,377 @@ int scsi_cd_emulate(int unitnum, uae_u8 *cmdbuf, int scsi_cmd_len, 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) { + { + 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] = 2 + 8; - p[2] = 1; + 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[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; + 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; } - 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) + 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; - start = toc->toc[toc->first_track_offset + start].paddress; + 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; } - 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) { + 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 }; - 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)); + + 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; - sys_command_cd_pause(unitnum, 0); - if (!sys_command_cd_play(unitnum, start, end, 0)) - goto notdatatrack; + if (len > 0) { + sys_command_cd_pause (unitnum, 0); + if (!sys_command_cd_play (unitnum, start, start + len, 0)) + goto notdatatrack; + } + scsi_len = 0; } - 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); + 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; } - else { - start = rl(cmdbuf + 2); - end = start + rl(cmdbuf + 6); + 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; } - 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 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; + 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: + 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: +nodisk: status = 2; /* CHECK CONDITION */ s[0] = 0x70; s[2] = 2; /* NOT READY */ s[12] = 0x3A; /* MEDIUM NOT PRESENT */ ls = 0x12; break; - readerr: +readerr: status = 2; /* CHECK CONDITION */ s[0] = 0x70; s[2] = 2; /* NOT READY */ s[12] = 0x11; /* UNRECOVERED READ ERROR */ ls = 0x12; break; - notdatatrack: +notdatatrack: status = 2; s[0] = 0x70; s[2] = 5; s[12] = 0x64; /* ILLEGAL MODE FOR THIS TRACK */ ls = 0x12; break; - outofbounds: +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: +errreq: lr = -1; status = 2; /* CHECK CONDITION */ s[0] = 0x70; @@ -1949,7 +1915,7 @@ end: return status; } -static int execscsicmd_direct(int unitnum, int type, struct amigascsi *as) +static int execscsicmd_direct (int unitnum, int type, struct amigascsi *as) { int io_error = 0; uae_u8 *scsi_datap, *scsi_datap_org; @@ -1960,7 +1926,7 @@ static int execscsicmd_direct(int unitnum, int type, struct amigascsi *as) int senselen = as->sense_len; int replylen = 0; - memcpy(cmd, as->cmd, as->cmd_len); + 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; @@ -1970,21 +1936,20 @@ static int execscsicmd_direct(int unitnum, int type, struct amigascsi *as) 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; - } + 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 { + } else { int i; if (replylen > 0) { for (int i = 0; i < replylen; i++) { @@ -1997,8 +1962,7 @@ static int execscsicmd_direct(int unitnum, int type, struct amigascsi *as) if (datalen < 0) { io_error = IOERR_NotSpecified; as->actual = 0; /* scsi_Actual */ - } - else { + } else { as->len = datalen; io_error = 0; as->actual = as->len; /* scsi_Actual */ @@ -2008,19 +1972,18 @@ static int execscsicmd_direct(int unitnum, int type, struct amigascsi *as) return io_error; } -int sys_command_scsi_direct_native(int unitnum, int type, struct amigascsi *as) +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 { + return execscsicmd_direct (unitnum, type, as); + } else { if (!st->device_func->exec_direct) return -1; } - int ret = st->device_func->exec_direct(unitnum, as); + int ret = st->device_func->exec_direct (unitnum, as); if (!ret && st->device_func->isatapi(unitnum)) - scsi_atapi_fixup_inquiry(as); + scsi_atapi_fixup_inquiry (as); return ret; } @@ -2041,16 +2004,16 @@ int sys_command_scsi_direct(TrapContext *ctx, int unitnum, int type, uaecptr acm ap = get_long_host(scsicmd + 0); as.len = get_long_host(scsicmd + 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); - 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); @@ -2083,7 +2046,7 @@ void restore_blkdev_start(void) } } -uae_u8 *save_cd(int num, int *len) +uae_u8 *save_cd (int num, int *len) { struct blkdevstate *st = &state[num]; uae_u8 *dstbak, *dst; @@ -2093,21 +2056,21 @@ uae_u8 *save_cd(int num, int *len) 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); + 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); + save_u8 (st->play_qcode[i]); + save_u32 (st->play_end_pos); *len = dst - dstbak; return dstbak; } -uae_u8 *restore_cd(int num, uae_u8 *src) +uae_u8 *restore_cd (int num, uae_u8 *src) { struct blkdevstate *st = &state[num]; uae_u32 flags; @@ -2115,23 +2078,23 @@ uae_u8 *restore_cd(int num, uae_u8 *src) if (num >= MAX_TOTAL_SCSI_DEVICES) return NULL; - flags = restore_u32(); - s = restore_path(SAVESTATE_PATH_CD); - int type = restore_u32(); - restore_u32(); + 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); + 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(); + restore_u32 (); for (int i = 0; i < SUBQ_SIZE; i++) - st->play_qcode[i] = restore_u8(); - st->play_end_pos = restore_u32(); + st->play_qcode[i] = restore_u8 (); + st->play_end_pos = restore_u32 (); } return src; } diff --git a/src/blkdev_cdimage.cpp b/src/blkdev_cdimage.cpp index c28a1ee6..28324b8d 100644 --- a/src/blkdev_cdimage.cpp +++ b/src/blkdev_cdimage.cpp @@ -96,7 +96,7 @@ static int bus_open; static volatile int cdimage_unpack_thread, cdimage_unpack_active; static smp_comm_pipe unpack_pipe; -static struct cdunit *unitisopen(int unitnum) +static struct cdunit *unitisopen (int unitnum) { struct cdunit *cdu = &cdunits[unitnum]; if (cdu->open) @@ -105,7 +105,7 @@ static struct cdunit *unitisopen(int unitnum) } -static struct cdtoc *findtoc(struct cdunit *cdu, int *sectorp, bool data) +static struct cdtoc *findtoc (struct cdunit *cdu, int *sectorp, bool data) { int i; int sector; @@ -131,31 +131,31 @@ static struct cdtoc *findtoc(struct cdunit *cdu, int *sectorp, bool data) return NULL; } -static int do_read(struct cdunit *cdu, struct cdtoc *t, uae_u8 *data, int sector, int offset, int size, bool audio) +static int do_read (struct cdunit *cdu, struct cdtoc *t, uae_u8 *data, int sector, int offset, int size, bool audio) { if (t->handle) { int ssize = t->size + t->skipsize; - zfile_fseek(t->handle, t->offset + (uae_u64)sector * ssize + offset, SEEK_SET); - return zfile_fread(data, 1, size, t->handle) == size; + zfile_fseek (t->handle, t->offset + (uae_u64)sector * ssize + offset, SEEK_SET); + return zfile_fread (data, 1, size, t->handle) == size; } return 0; } // WOHOO, library that supports virtual file access functions. Perfect! -static void flac_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) +static void flac_metadata_callback (const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) { struct cdtoc *t = (struct cdtoc*)client_data; if (t->data) return; - if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { + if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { t->filesize = metadata->data.stream_info.total_samples * (metadata->data.stream_info.bits_per_sample / 8) * metadata->data.stream_info.channels; } } -static void flac_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) +static void flac_error_callback (const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) { return; } -static FLAC__StreamDecoderWriteStatus flac_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) +static FLAC__StreamDecoderWriteStatus flac_write_callback (const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) { struct cdtoc *t = (struct cdtoc*)client_data; uae_u16 *p = (uae_u16*)(t->data + t->writeoffset); @@ -166,71 +166,71 @@ static FLAC__StreamDecoderWriteStatus flac_write_callback(const FLAC__StreamDeco } return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; } -static FLAC__StreamDecoderReadStatus file_read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) +static FLAC__StreamDecoderReadStatus file_read_callback (const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) { struct cdtoc *t = (struct cdtoc*)client_data; - if (zfile_ftell(t->handle) >= zfile_size(t->handle)) + if (zfile_ftell (t->handle) >= zfile_size (t->handle)) return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - return zfile_fread(buffer, *bytes, 1, t->handle) ? FLAC__STREAM_DECODER_READ_STATUS_CONTINUE : FLAC__STREAM_DECODER_READ_STATUS_ABORT; + return zfile_fread (buffer, *bytes, 1, t->handle) ? FLAC__STREAM_DECODER_READ_STATUS_CONTINUE : FLAC__STREAM_DECODER_READ_STATUS_ABORT; } -static FLAC__StreamDecoderSeekStatus file_seek_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) +static FLAC__StreamDecoderSeekStatus file_seek_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) { struct cdtoc *t = (struct cdtoc*)client_data; - zfile_fseek(t->handle, absolute_byte_offset, SEEK_SET); + zfile_fseek (t->handle, absolute_byte_offset, SEEK_SET); return FLAC__STREAM_DECODER_SEEK_STATUS_OK; } -static FLAC__StreamDecoderTellStatus file_tell_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) +static FLAC__StreamDecoderTellStatus file_tell_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) { struct cdtoc *t = (struct cdtoc*)client_data; - *absolute_byte_offset = zfile_ftell(t->handle); + *absolute_byte_offset = zfile_ftell (t->handle); return FLAC__STREAM_DECODER_TELL_STATUS_OK; } -static FLAC__StreamDecoderLengthStatus file_len_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) +static FLAC__StreamDecoderLengthStatus file_len_callback (const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) { struct cdtoc *t = (struct cdtoc*)client_data; - *stream_length = zfile_size(t->handle); + *stream_length = zfile_size (t->handle); return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; } -static FLAC__bool file_eof_callback(const FLAC__StreamDecoder *decoder, void *client_data) +static FLAC__bool file_eof_callback (const FLAC__StreamDecoder *decoder, void *client_data) { struct cdtoc *t = (struct cdtoc*)client_data; - return zfile_ftell(t->handle) >= zfile_size(t->handle); + return zfile_ftell (t->handle) >= zfile_size (t->handle); } -static void flac_get_size(struct cdtoc *t) +static void flac_get_size (struct cdtoc *t) { - FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new(); + FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new (); if (decoder) { - FLAC__stream_decoder_set_md5_checking(decoder, false); - int init_status = FLAC__stream_decoder_init_stream(decoder, + FLAC__stream_decoder_set_md5_checking (decoder, false); + int init_status = FLAC__stream_decoder_init_stream (decoder, &file_read_callback, &file_seek_callback, &file_tell_callback, &file_len_callback, &file_eof_callback, &flac_write_callback, &flac_metadata_callback, &flac_error_callback, t); - FLAC__stream_decoder_process_until_end_of_metadata(decoder); - FLAC__stream_decoder_delete(decoder); + FLAC__stream_decoder_process_until_end_of_metadata (decoder); + FLAC__stream_decoder_delete (decoder); } } -static uae_u8 *flac_get_data(struct cdtoc *t) +static uae_u8 *flac_get_data (struct cdtoc *t) { - write_log(_T("FLAC: unpacking '%s'..\n"), zfile_getname(t->handle)); + write_log (_T("FLAC: unpacking '%s'..\n"), zfile_getname (t->handle)); t->writeoffset = 0; - FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new(); + FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new (); if (decoder) { - FLAC__stream_decoder_set_md5_checking(decoder, false); - int init_status = FLAC__stream_decoder_init_stream(decoder, + FLAC__stream_decoder_set_md5_checking (decoder, false); + int init_status = FLAC__stream_decoder_init_stream (decoder, &file_read_callback, &file_seek_callback, &file_tell_callback, &file_len_callback, &file_eof_callback, &flac_write_callback, &flac_metadata_callback, &flac_error_callback, t); - FLAC__stream_decoder_process_until_end_of_stream(decoder); - FLAC__stream_decoder_delete(decoder); - write_log(_T("FLAC: %s unpacked\n"), zfile_getname(t->handle)); + FLAC__stream_decoder_process_until_end_of_stream (decoder); + FLAC__stream_decoder_delete (decoder); + write_log (_T("FLAC: %s unpacked\n"), zfile_getname (t->handle)); } return t->data; } -void sub_to_interleaved(const uae_u8 *s, uae_u8 *d) +void sub_to_interleaved (const uae_u8 *s, uae_u8 *d) { - for (int i = 0; i < 8 * SUB_ENTRY_SIZE; i++) { + for (int i = 0; i < 8 * SUB_ENTRY_SIZE; i ++) { int dmask = 0x80; int smask = 1 << (7 - (i & 7)); (*d) = 0; @@ -241,9 +241,9 @@ void sub_to_interleaved(const uae_u8 *s, uae_u8 *d) d++; } } -void sub_to_deinterleaved(const uae_u8 *s, uae_u8 *d) +void sub_to_deinterleaved (const uae_u8 *s, uae_u8 *d) { - for (int i = 0; i < 8 * SUB_ENTRY_SIZE; i++) { + for (int i = 0; i < 8 * SUB_ENTRY_SIZE; i ++) { int dmask = 0x80; int smask = 1 << (7 - (i / SUB_ENTRY_SIZE)); (*d) = 0; @@ -255,10 +255,10 @@ void sub_to_deinterleaved(const uae_u8 *s, uae_u8 *d) } } -static int getsub_deinterleaved(uae_u8 *dst, struct cdunit *cdu, struct cdtoc *t, int sector) +static int getsub_deinterleaved (uae_u8 *dst, struct cdunit *cdu, struct cdtoc *t, int sector) { int ret = 0; - uae_sem_wait(&cdu->sub_sem); + uae_sem_wait (&cdu->sub_sem); if (t->subcode) { if (t->subhandle) { int offset = 0; @@ -267,40 +267,39 @@ static int getsub_deinterleaved(uae_u8 *dst, struct cdunit *cdu, struct cdtoc *t totalsize += t->size; offset = t->size; } - zfile_fseek(t->subhandle, (uae_u64)sector * totalsize + t->suboffset + offset, SEEK_SET); - if (zfile_fread(dst, SUB_CHANNEL_SIZE, 1, t->subhandle) > 0) + zfile_fseek (t->subhandle, (uae_u64)sector * totalsize + t->suboffset + offset, SEEK_SET); + if (zfile_fread (dst, SUB_CHANNEL_SIZE, 1, t->subhandle) > 0) ret = t->subcode; - } - else { - memcpy(dst, t->subdata + sector * SUB_CHANNEL_SIZE + t->suboffset, SUB_CHANNEL_SIZE); + } else { + memcpy (dst, t->subdata + sector * SUB_CHANNEL_SIZE + t->suboffset, SUB_CHANNEL_SIZE); ret = t->subcode; } } if (!ret) { - memset(dst, 0, SUB_CHANNEL_SIZE); + memset (dst, 0, SUB_CHANNEL_SIZE); // regenerate Q-subchannel uae_u8 *s = dst + SUB_ENTRY_SIZE; s[0] = (t->ctrl << 4) | (t->adr << 0); - s[1] = tobcd(t - &cdu->toc[0] + 1); - s[2] = tobcd(1); - int msf = lsn2msf(sector); - tolongbcd(s + 7, msf); - msf = lsn2msf(sector - t->address - 150); - tolongbcd(s + 3, msf); + s[1] = tobcd (t - &cdu->toc[0] + 1); + s[2] = tobcd (1); + int msf = lsn2msf (sector); + tolongbcd (s + 7, msf); + msf = lsn2msf (sector - t->address - 150); + tolongbcd (s + 3, msf); ret = 2; } if (ret == 1) { uae_u8 tmp[SUB_CHANNEL_SIZE]; - memcpy(tmp, dst, SUB_CHANNEL_SIZE); - sub_to_deinterleaved(tmp, dst); + memcpy (tmp, dst, SUB_CHANNEL_SIZE); + sub_to_deinterleaved (tmp, dst); ret = 2; } - uae_sem_post(&cdu->sub_sem); + uae_sem_post (&cdu->sub_sem); return ret; } -static void dosub(struct cdunit *cdu, uae_u8 *subbuf) +static void dosub (struct cdunit *cdu, uae_u8 *subbuf) { uae_u8 subbuf2[SUB_CHANNEL_SIZE]; @@ -308,57 +307,55 @@ static void dosub(struct cdunit *cdu, uae_u8 *subbuf) return; if (!subbuf) { - memset(subbuf2, 0, sizeof subbuf2); - cdu->cdda_subfunc(subbuf2, 1); + memset (subbuf2, 0, sizeof subbuf2); + cdu->cdda_subfunc (subbuf2, 1); return; } - sub_to_interleaved(subbuf, subbuf2); - cdu->cdda_subfunc(subbuf2, 1); + sub_to_interleaved (subbuf, subbuf2); + cdu->cdda_subfunc (subbuf2, 1); } -static int setstate(struct cdunit *cdu, int state, int playpos) +static int setstate (struct cdunit *cdu, int state, int playpos) { cdu->cdda_play_state = state; if (cdu->cdda_statusfunc) - return cdu->cdda_statusfunc(cdu->cdda_play_state, playpos); + return cdu->cdda_statusfunc (cdu->cdda_play_state, playpos); return 0; } -static void *cdda_unpack_func(void *v) +static void *cdda_unpack_func (void *v) { cdimage_unpack_thread = 1; mp3decoder *mp3dec = NULL; for (;;) { - uae_u32 cduidx = read_comm_pipe_u32_blocking(&unpack_pipe); + uae_u32 cduidx = read_comm_pipe_u32_blocking (&unpack_pipe); if (cdimage_unpack_thread == 0) break; - uae_u32 tocidx = read_comm_pipe_u32_blocking(&unpack_pipe); + uae_u32 tocidx = read_comm_pipe_u32_blocking (&unpack_pipe); struct cdunit *cdu = &cdunits[cduidx]; struct cdtoc *t = &cdu->toc[tocidx]; if (t->handle) { // force unpack if handle points to delayed zipped file - uae_s64 pos = zfile_ftell(t->handle); - zfile_fseek(t->handle, -1, SEEK_END); + uae_s64 pos = zfile_ftell (t->handle); + zfile_fseek (t->handle, -1, SEEK_END); uae_u8 b; - zfile_fread(&b, 1, 1, t->handle); - zfile_fseek(t->handle, pos, SEEK_SET); + zfile_fread (&b, 1, 1, t->handle); + zfile_fseek (t->handle, pos, SEEK_SET); if (!t->data && (t->enctype == AUDENC_MP3 || t->enctype == AUDENC_FLAC)) { - t->data = xcalloc(uae_u8, t->filesize + 2352); + t->data = xcalloc (uae_u8, t->filesize + 2352); cdimage_unpack_active = 1; if (t->data) { if (t->enctype == AUDENC_MP3) { if (!mp3dec) { try { mp3dec = new mp3decoder(); - } - catch (exception) {}; + } catch (exception) { }; } if (mp3dec) - t->data = mp3dec->get(t->handle, t->data, t->filesize); - } - else if (t->enctype == AUDENC_FLAC) { - flac_get_data(t); + t->data = mp3dec->get (t->handle, t->data, t->filesize); + } else if (t->enctype == AUDENC_FLAC) { + flac_get_data (t); } } } @@ -370,15 +367,15 @@ static void *cdda_unpack_func(void *v) return 0; } -static void audio_unpack(struct cdunit *cdu, struct cdtoc *t) +static void audio_unpack (struct cdunit *cdu, struct cdtoc *t) { // do this even if audio is not compressed, t->handle also could be // compressed and we want to unpack it in background too while (cdimage_unpack_active == 1) sleep_millis(10); cdimage_unpack_active = 0; - write_comm_pipe_u32(&unpack_pipe, cdu - &cdunits[0], 0); - write_comm_pipe_u32(&unpack_pipe, t - &cdu->toc[0], 1); + write_comm_pipe_u32 (&unpack_pipe, cdu - &cdunits[0], 0); + write_comm_pipe_u32 (&unpack_pipe, t - &cdu->toc[0], 1); while (cdimage_unpack_active == 0) sleep_millis(10); } @@ -386,7 +383,7 @@ static void audio_unpack(struct cdunit *cdu, struct cdtoc *t) static volatile int cda_bufon[2]; static cda_audio *cda; -static void *cdda_play_func(void *v) +static void *cdda_play_func (void *v) { int cdda_pos; int bufnum; @@ -406,7 +403,7 @@ static void *cdda_play_func(void *v) cda_bufon[0] = cda_bufon[1] = 0; bufnum = 0; - cda = new cda_audio(CDDA_BUFFERS, 2352, 44100); + cda = new cda_audio (CDDA_BUFFERS, 2352, 44100); while (cdu->cdda_play > 0) { @@ -422,27 +419,25 @@ static void *cdda_play_func(void *v) idleframes = 0; silentframes = 0; foundsub = false; - _ftime(&tb1); + _ftime (&tb1); cdda_pos = cdu->cdda_start; oldplay = cdu->cdda_play; sector = cdu->cd_last_pos = cdda_pos; - t = findtoc(cdu, §or, false); + t = findtoc (cdu, §or, false); if (!t) { sector = cdu->cd_last_pos = cdda_pos + 2 * 75; - t = findtoc(cdu, §or, false); + t = findtoc (cdu, §or, false); if (!t) { - write_log(_T("IMAGE CDDA: illegal sector number %d\n"), cdu->cdda_start); - setstate(cdu, AUDIO_STATUS_PLAY_ERROR, -1); + write_log (_T("IMAGE CDDA: illegal sector number %d\n"), cdu->cdda_start); + setstate (cdu, AUDIO_STATUS_PLAY_ERROR, -1); + } else { + audio_unpack (cdu, t); } - else { - audio_unpack(cdu, t); - } - } - else { - write_log(_T("IMAGE CDDA: playing from %d to %d, track %d ('%s', offset %lld, secoffset %d (%d))\n"), + } else { + write_log (_T("IMAGE CDDA: playing from %d to %d, track %d ('%s', offset %lld, secoffset %d (%d))\n"), cdu->cdda_start, cdu->cdda_end, t->track, t->fname, t->offset, sector, t->index1); oldtrack = t->track; - audio_unpack(cdu, t); + audio_unpack (cdu, t); } idleframes = cdu->cdda_delay_frames; while (cdu->cdda_paused && cdu->cdda_play > 0) { @@ -456,22 +451,21 @@ static void *cdda_play_func(void *v) bool seenindex = false; for (sector = cdda_pos - 200; sector < cdda_pos; sector++) { int sec = sector; - t = findtoc(cdu, &sec, false); + t = findtoc (cdu, &sec, false); if (t) { uae_u8 subbuf[SUB_CHANNEL_SIZE]; - getsub_deinterleaved(subbuf, cdu, t, sector); + getsub_deinterleaved (subbuf, cdu, t, sector); if (seenindex) { for (int i = 2 * SUB_ENTRY_SIZE; i < SUB_CHANNEL_SIZE; i++) { if (subbuf[i]) { // non-zero R-W subchannels int diff = cdda_pos - sector + 2; - write_log(_T("-> CD+G start pos fudge -> %d (%d)\n"), sector, -diff); + write_log (_T("-> CD+G start pos fudge -> %d (%d)\n"), sector, -diff); idleframes -= diff; cdda_pos = sector; break; } } - } - else if (subbuf[0] == 0xff) { // P == 1? + } else if (subbuf[0] == 0xff) { // P == 1? seenindex = true; } } @@ -479,21 +473,21 @@ static void *cdda_play_func(void *v) } cdda_pos -= idleframes; - _ftime(&tb2); + _ftime (&tb2); diff = (tb2.time * (uae_s64)1000 + tb2.millitm) - (tb1.time * (uae_s64)1000 + tb1.millitm); diff -= cdu->cdda_delay; if (idleframes >= 0 && diff < 0 && cdu->cdda_play > 0) sleep_millis(-diff); - setstate(cdu, AUDIO_STATUS_IN_PROGRESS, cdda_pos); + setstate (cdu, AUDIO_STATUS_IN_PROGRESS, cdda_pos); sector = cdda_pos; - struct cdtoc *t1 = findtoc(cdu, §or, false); + struct cdtoc *t1 = findtoc (cdu, §or, false); int tsector = cdda_pos + 2 * 75; - struct cdtoc *t2 = findtoc(cdu, &tsector, false); + struct cdtoc *t2 = findtoc (cdu, &tsector, false); if (t1 != t2) { for (sector = cdda_pos; sector < cdda_pos + 2 * 75; sector++) { int sec = sector; - t = findtoc(cdu, &sec, false); + t = findtoc (cdu, &sec, false); if (t == t2) break; silentframes++; @@ -501,15 +495,15 @@ static void *cdda_play_func(void *v) } } - cda->wait(bufnum); + cda->wait(bufnum); cda_bufon[bufnum] = 0; if (cdu->cdda_play <= 0) goto end; - if (idleframes <= 0 && cdda_pos >= cdu->cdda_start && !isaudiotrack(&cdu->di.toc, cdda_pos)) { - setstate(cdu, AUDIO_STATUS_PLAY_ERROR, -1); - write_log(_T("IMAGE CDDA: attempted to play data track %d\n"), cdda_pos); + if (idleframes <= 0 && cdda_pos >= cdu->cdda_start && !isaudiotrack (&cdu->di.toc, cdda_pos)) { + setstate (cdu, AUDIO_STATUS_PLAY_ERROR, -1); + write_log (_T("IMAGE CDDA: attempted to play data track %d\n"), cdda_pos); goto end; // data track? } @@ -518,69 +512,67 @@ static void *cdda_play_func(void *v) int sector, cnt; int dofinish = 0; - gui_flicker_led(LED_CD, cdu->di.unitnum - 1, LED_CD_AUDIO); + gui_flicker_led (LED_CD, cdu->di.unitnum - 1, LED_CD_AUDIO); setstate(cdu, AUDIO_STATUS_IN_PROGRESS, cdda_pos); - memset(cda->buffers[bufnum], 0, CDDA_BUFFERS * 2352); + memset (cda->buffers[bufnum], 0, CDDA_BUFFERS * 2352); for (cnt = 0; cnt < CDDA_BUFFERS && cdu->cdda_play > 0; cnt++) { uae_u8 *dst = cda->buffers[bufnum] + cnt * 2352; uae_u8 subbuf[SUB_CHANNEL_SIZE]; sector = cdda_pos; - memset(subbuf, 0, SUB_CHANNEL_SIZE); + memset (subbuf, 0, SUB_CHANNEL_SIZE); - t = findtoc(cdu, §or, false); + t = findtoc (cdu, §or, false); if (t) { if (t->track != oldtrack) { oldtrack = t->track; - write_log(_T("IMAGE CDDA: track %d ('%s', offset %lld, secoffset %d (%d))\n"), + write_log (_T("IMAGE CDDA: track %d ('%s', offset %lld, secoffset %d (%d))\n"), t->track, t->fname, t->offset, sector, t->index1); - audio_unpack(cdu, t); + audio_unpack (cdu, t); } if (!(t->ctrl & 4)) { if (t->handle) { - int totalsize = t->size + t->skipsize; + int totalsize = t->size + t->skipsize; int offset = t->offset; if (offset >= 0) { - if ((t->enctype == AUDENC_MP3 || t->enctype == AUDENC_FLAC) && t->data) { + if ((t->enctype == AUDENC_MP3 || t->enctype == AUDENC_FLAC) && t->data) { if (t->filesize >= sector * totalsize + offset + t->size) - memcpy(dst, t->data + sector * totalsize + offset, t->size); - } - else if (t->enctype == AUDENC_PCM) { + memcpy (dst, t->data + sector * totalsize + offset, t->size); + } else if (t->enctype == AUDENC_PCM) { if (sector * totalsize + offset + totalsize < t->filesize) { - zfile_fseek(t->handle, (uae_u64)sector * totalsize + offset, SEEK_SET); - zfile_fread(dst, t->size, 1, t->handle); + zfile_fseek (t->handle, (uae_u64)sector * totalsize + offset, SEEK_SET); + zfile_fread (dst, t->size, 1, t->handle); } - } - } - } + } + } + } } - getsub_deinterleaved(subbuf, cdu, t, cdda_pos); + getsub_deinterleaved (subbuf, cdu, t, cdda_pos); } if (idleframes > 0 || silentframes > 0) { - if (idleframes > 0) { - idleframes--; - memset(subbuf, 0, SUB_CHANNEL_SIZE); + if (idleframes > 0) { + idleframes--; + memset (subbuf, 0, SUB_CHANNEL_SIZE); } if (silentframes > 0) silentframes--; - memset(dst, 0, 2352); + memset (dst, 0, 2352); } if (cdda_pos < cdu->cdda_start && cdu->cdda_scan == 0) - memset(dst, 0, 2352); + memset (dst, 0, 2352); - dosub(cdu, subbuf); + dosub (cdu, subbuf); if (cdu->cdda_scan) { cdda_pos += cdu->cdda_scan; if (cdda_pos < 0) cdda_pos = 0; - } - else { + } else { cdda_pos++; } @@ -588,22 +580,22 @@ static void *cdda_play_func(void *v) dofinish = 1; } - + if (idleframes <= 0) cdu->cd_last_pos = cdda_pos; - cda_bufon[bufnum] = 1; - cda->setvolume(cdu->cdda_volume[0], cdu->cdda_volume[1]); - if (!cda->play(bufnum)) { - if (cdu->cdda_play > 0) - setstate(cdu, AUDIO_STATUS_PLAY_ERROR, -1); - goto end; - } + cda_bufon[bufnum] = 1; + cda->setvolume (cdu->cdda_volume[0], cdu->cdda_volume[1]); + if (!cda->play (bufnum)) { + if (cdu->cdda_play > 0) + setstate (cdu, AUDIO_STATUS_PLAY_ERROR, -1); + goto end; + } if (dofinish) { cdda_pos = cdu->cdda_end + 1; if (cdu->cdda_play >= 0) - setstate(cdu, AUDIO_STATUS_PLAY_COMPLETE, cdda_pos); + setstate (cdu, AUDIO_STATUS_PLAY_COMPLETE, cdda_pos); cdu->cdda_play = -1; } @@ -618,8 +610,8 @@ static void *cdda_play_func(void *v) } end: - cda->wait(0); - cda->wait(1); + cda->wait (0); + cda->wait (1); while (cdimage_unpack_active == 1) sleep_millis(10); @@ -627,13 +619,13 @@ end: delete cda; cdu->cdda_play = 0; - write_log(_T("IMAGE CDDA: thread killed\n")); + write_log (_T("IMAGE CDDA: thread killed\n")); cdu->thread_active = false; return NULL; } -static void cdda_stop(struct cdunit *cdu) +static void cdda_stop (struct cdunit *cdu) { if (cdu->cdda_play != 0) { cdu->cdda_play = -1; @@ -647,35 +639,35 @@ static void cdda_stop(struct cdunit *cdu) } -static int command_pause(int unitnum, int paused) +static int command_pause (int unitnum, int paused) { - struct cdunit *cdu = unitisopen(unitnum); + struct cdunit *cdu = unitisopen (unitnum); if (!cdu) return -1; int old = cdu->cdda_paused; if ((paused && cdu->cdda_play) || !paused) - cdu->cdda_paused = paused; + cdu->cdda_paused = paused; return old; } -static int command_stop(int unitnum) +static int command_stop (int unitnum) { - struct cdunit *cdu = unitisopen(unitnum); + struct cdunit *cdu = unitisopen (unitnum); if (!cdu) return 0; - cdda_stop(cdu); + cdda_stop (cdu); return 1; } -static int command_play(int unitnum, int startlsn, int endlsn, int scan, play_status_callback statusfunc, play_subchannel_callback subfunc) +static int command_play (int unitnum, int startlsn, int endlsn, int scan, play_status_callback statusfunc, play_subchannel_callback subfunc) { - struct cdunit *cdu = unitisopen(unitnum); + struct cdunit *cdu = unitisopen (unitnum); if (!cdu) return 0; if (cdu->cdda_play) { cdu->cdda_play = -1; while (cdu->thread_active) - Sleep(10); + Sleep (10); cdu->cdda_play = 0; } cdu->cd_last_pos = startlsn; @@ -684,25 +676,25 @@ static int command_play(int unitnum, int startlsn, int endlsn, int scan, play_st cdu->cdda_subfunc = subfunc; cdu->cdda_statusfunc = statusfunc; cdu->cdda_scan = scan > 0 ? 10 : (scan < 0 ? 10 : 0); - cdu->cdda_delay = setstate(cdu, -1, -1); - cdu->cdda_delay_frames = setstate(cdu, -2, -1); - setstate(cdu, cdu->cdda_delay > 0 || cdu->cdda_delay_frames ? AUDIO_STATUS_NOT_SUPPORTED : AUDIO_STATUS_IN_PROGRESS, -1); - if (!isaudiotrack(&cdu->di.toc, startlsn)) { - setstate(cdu, AUDIO_STATUS_PLAY_ERROR, -1); + cdu->cdda_delay = setstate (cdu, -1, -1); + cdu->cdda_delay_frames = setstate (cdu, -2, -1); + setstate (cdu, cdu->cdda_delay > 0 || cdu->cdda_delay_frames ? AUDIO_STATUS_NOT_SUPPORTED : AUDIO_STATUS_IN_PROGRESS, -1); + if (!isaudiotrack (&cdu->di.toc, startlsn)) { + setstate (cdu, AUDIO_STATUS_PLAY_ERROR, -1); return 0; } if (!cdu->thread_active) { - uae_start_thread(_T("cdimage_cdda_play"), cdda_play_func, cdu, NULL); + uae_start_thread (_T("cdimage_cdda_play"), cdda_play_func, cdu, NULL); while (!cdu->thread_active) - Sleep(10); + Sleep (10); } cdu->cdda_play++; return 1; } -static int command_qcode(int unitnum, uae_u8 *buf, int sector, bool all) +static int command_qcode (int unitnum, uae_u8 *buf, int sector, bool all) { - struct cdunit *cdu = unitisopen(unitnum); + struct cdunit *cdu = unitisopen (unitnum); if (!cdu) return 0; @@ -712,7 +704,7 @@ static int command_qcode(int unitnum, uae_u8 *buf, int sector, bool all) int pos; int status; - memset(buf, 0, SUBQ_SIZE); + memset (buf, 0, SUBQ_SIZE); p = buf; status = cdu->cdda_play_state; @@ -742,12 +734,11 @@ static int command_qcode(int unitnum, uae_u8 *buf, int sector, bool all) } if (!td) return 0; - getsub_deinterleaved(subbuf, cdu, td, pos); - if (all) { + getsub_deinterleaved (subbuf, cdu, td, pos); + if (all) { memcpy(buf, subbuf, SUB_CHANNEL_SIZE); - } - else { - memcpy(p, subbuf + 12, 12); + } else { + memcpy (p, subbuf + 12, 12); } if (cdu->cdda_play_state == AUDIO_STATUS_PLAY_COMPLETE || cdu->cdda_play_state == AUDIO_STATUS_PLAY_ERROR) @@ -756,9 +747,9 @@ static int command_qcode(int unitnum, uae_u8 *buf, int sector, bool all) return 1; } -static uae_u32 command_volume(int unitnum, uae_u16 volume_left, uae_u16 volume_right) +static uae_u32 command_volume (int unitnum, uae_u16 volume_left, uae_u16 volume_right) { - struct cdunit *cdu = unitisopen(unitnum); + struct cdunit *cdu = unitisopen (unitnum); if (!cdu) return -1; uae_u32 old = (cdu->cdda_volume[1] << 16) | (cdu->cdda_volume[0] << 0); @@ -767,23 +758,23 @@ static uae_u32 command_volume(int unitnum, uae_u16 volume_left, uae_u16 volume_r return old; } -extern void encode_l2(uae_u8 *p, int address); +extern void encode_l2 (uae_u8 *p, int address); -static int command_rawread(int unitnum, uae_u8 *data, int sector, int size, int sectorsize, uae_u32 extra) +static int command_rawread (int unitnum, uae_u8 *data, int sector, int size, int sectorsize, uae_u32 extra) { int ret = 0; - struct cdunit *cdu = unitisopen(unitnum); + struct cdunit *cdu = unitisopen (unitnum); if (!cdu) return 0; int asector = sector; - struct cdtoc *t = findtoc(cdu, §or, true); + struct cdtoc *t = findtoc (cdu, §or, true); int ssize; if (!t) goto end; ssize = t->size + t->skipsize; - cdda_stop(cdu); + cdda_stop (cdu); if (sectorsize > 0) { if (sectorsize == 2352 && t->size == 2336) { // 2336 -> 2352 @@ -801,49 +792,45 @@ static int command_rawread(int unitnum, uae_u8 *data, int sector, int size, int data += sectorsize; ret += sectorsize; } - } - else if (sectorsize == 2352 && t->size == 2048) { + } else if (sectorsize == 2352 && t->size == 2048) { // 2048 -> 2352 while (size-- > 0) { - memset(data, 0, 16); - do_read(cdu, t, data + 16, sector, 0, 2048, false); - encode_l2(data, sector + 150); + memset (data, 0, 16); + do_read (cdu, t, data + 16, sector, 0, 2048, false); + encode_l2 (data, sector + 150); sector++; asector++; data += sectorsize; ret += sectorsize; } - } - else if (sectorsize == 2048 && t->size == 2352) { + } else if (sectorsize == 2048 && t->size == 2352) { // 2352 -> 2048 while (size-- > 0) { uae_u8 b = 0; - do_read(cdu, t, &b, sector, 15, 1, false); - do_read(cdu, t, data, sector, b == 2 ? 24 : 16, sectorsize, false); + do_read (cdu, t, &b, sector, 15, 1, false); + do_read (cdu, t, data, sector, b == 2 ? 24 : 16, sectorsize, false); sector++; asector++; data += sectorsize; ret += sectorsize; } - } - else if (sectorsize == 2336 && t->size == 2352) { + } else if (sectorsize == 2336 && t->size == 2352) { // 2352 -> 2336 while (size-- > 0) { uae_u8 b = 0; - do_read(cdu, t, &b, sector, 15, 1, false); + do_read (cdu, t, &b, sector, 15, 1, false); if (b != 2 && b != 0) // MODE0 or MODE2 only allowed - return 0; - do_read(cdu, t, data, sector, 16, sectorsize, false); + return 0; + do_read (cdu, t, data, sector, 16, sectorsize, false); sector++; asector++; data += sectorsize; ret += sectorsize; } - } - else if (sectorsize == t->size) { + } else if (sectorsize == t->size) { // no change - while (size-- > 0) { - do_read(cdu, t, data, sector, 0, sectorsize, false); + while (size -- > 0) { + do_read (cdu, t, data, sector, 0, sectorsize, false); sector++; asector++; data += sectorsize; @@ -852,8 +839,7 @@ static int command_rawread(int unitnum, uae_u8 *data, int sector, int size, int } cdu->cd_last_pos = asector; - } - else { + } else { uae_u8 sectortype = extra >> 16; uae_u8 cmd9 = extra >> 8; @@ -877,21 +863,19 @@ static int command_rawread(int unitnum, uae_u8 *data, int sector, int size, int goto end; } for (int i = 0; i < size; i++) { - do_read(cdu, t, data, sector, 0, t->size, true); + do_read (cdu, t, data, sector, 0, t->size, true); uae_u8 *p = data + t->size; if (subs) { uae_u8 subdata[SUB_CHANNEL_SIZE]; - getsub_deinterleaved(subdata, cdu, t, sector); + getsub_deinterleaved (subdata, cdu, t, sector); if (subs == 4) { // all, de-interleaved - memcpy(p, subdata, SUB_CHANNEL_SIZE); + memcpy (p, subdata, SUB_CHANNEL_SIZE); p += SUB_CHANNEL_SIZE; - } - else if (subs == 2) { // q-only - memcpy(p, subdata + SUB_ENTRY_SIZE, SUB_ENTRY_SIZE); + } else if (subs == 2) { // q-only + memcpy (p, subdata + SUB_ENTRY_SIZE, SUB_ENTRY_SIZE); p += SUB_ENTRY_SIZE; - } - else if (subs == 1) { // all, interleaved - sub_to_interleaved(subdata, p); + } else if (subs == 1) { // all, interleaved + sub_to_interleaved (subdata, p); p += SUB_CHANNEL_SIZE; } } @@ -905,33 +889,31 @@ end: } // return standard 2048 byte sectors only -static int command_read(int unitnum, uae_u8 *data, int sector, int numsectors) +static int command_read (int unitnum, uae_u8 *data, int sector, int numsectors) { - struct cdunit *cdu = unitisopen(unitnum); + struct cdunit *cdu = unitisopen (unitnum); if (!cdu) return 0; - struct cdtoc *t = findtoc(cdu, §or, true); + struct cdtoc *t = findtoc (cdu, §or, true); if (!t) return 0; - cdda_stop(cdu); + cdda_stop (cdu); if (t->size == 2048) { while (numsectors-- > 0) { - do_read(cdu, t, data, sector, 0, 2048, false); + do_read (cdu, t, data, sector, 0, 2048, false); data += 2048; sector++; } - } - else { + } else { while (numsectors-- > 0) { if (t->size == 2352) { uae_u8 b = 0; - do_read(cdu, t, &b, sector, 15, 1, false); + do_read (cdu, t, &b, sector, 15, 1, false); // 2 = MODE2 - do_read(cdu, t, data, sector, b == 2 ? 24 : 16, 2048, false); - } - else { + do_read (cdu, t, data, sector, b == 2 ? 24 : 16, 2048, false); + } else { // 2336 - do_read(cdu, t, data, sector, 8, 2048, false); + do_read (cdu, t, data, sector, 8, 2048, false); } data += 2048; sector++; @@ -941,19 +923,19 @@ static int command_read(int unitnum, uae_u8 *data, int sector, int numsectors) return 1; } -static int command_toc(int unitnum, struct cd_toc_head *th) +static int command_toc (int unitnum, struct cd_toc_head *th) { - struct cdunit *cdu = unitisopen(unitnum); + struct cdunit *cdu = unitisopen (unitnum); if (!cdu) return 0; int i; - memset(&cdu->di.toc, 0, sizeof(struct cd_toc_head)); + memset (&cdu->di.toc, 0, sizeof (struct cd_toc_head)); if (!cdu->tracks) return 0; - memset(th, 0, sizeof(struct cd_toc_head)); + memset (th, 0, sizeof (struct cd_toc_head)); struct cd_toc *toc = &th->toc[0]; th->first_track = 1; th->last_track = cdu->tracks; @@ -998,27 +980,27 @@ static int command_toc(int unitnum, struct cd_toc_head *th) toc->paddress = th->lastaddress; toc++; - memcpy(&cdu->di.toc, th, sizeof(struct cd_toc_head)); + memcpy (&cdu->di.toc, th, sizeof (struct cd_toc_head)); return 1; } -static void skipspace(TCHAR **s) +static void skipspace (TCHAR **s) { - while (_istspace(**s)) + while (_istspace (**s)) (*s)++; } -static void skipnspace(TCHAR **s) +static void skipnspace (TCHAR **s) { - while (!_istspace(**s)) + while (!_istspace (**s)) (*s)++; } -static TCHAR *nextstring(TCHAR **sp) +static TCHAR *nextstring (TCHAR **sp) { TCHAR *s; TCHAR *out = NULL; - skipspace(sp); + skipspace (sp); s = *sp; if (*s == '\"') { s++; @@ -1026,23 +1008,22 @@ static TCHAR *nextstring(TCHAR **sp) while (*s && *s != '\"') s++; *s++ = 0; - } - else if (*s) { + } else if (*s) { out = s; - skipnspace(&s); + skipnspace (&s); *s++ = 0; } *sp = s; return out; } -static int readval(const TCHAR *s) +static int readval (const TCHAR *s) { int base = 10; TCHAR *endptr; - if (s[0] == '0' && _totupper(s[1]) == 'X') + if (s[0] == '0' && _totupper (s[1]) == 'X') s += 2, base = 16; - return _tcstol(s, &endptr, base); + return _tcstol (s, &endptr, base); } #define MEDIA_DESCRIPTOR "MEDIA DESCRIPTOR" @@ -1054,7 +1035,7 @@ static int readval(const TCHAR *s) #define MDS_MEDIUM_CD_RW 0x02 /* CD-RW */ #define MDS_MEDIUM_DVD 0x10 /* DVD-ROM */ #define MDS_MEDIUM_DVD_MINUS_R 0x12 /* DVD-R */ - + #define MDS_TRACKMODE_UNKNOWN 0x00 #define MDS_TRACKMODE_AUDIO 0xA9 /* sector size = 2352 */ #define MDS_TRACKMODE_MODE1 0xAA /* sector size = 2048 */ @@ -1072,98 +1053,98 @@ static int readval(const TCHAR *s) #pragma pack(1) typedef struct { - uae_u8 signature[16]; /* "MEDIA DESCRIPTOR" */ - uae_u8 version[2]; /* Version ? */ - uae_u16 medium_type; /* Medium type */ - uae_u16 num_sessions; /* Number of sessions */ - uae_u16 __dummy1__[2]; /* Wish I knew... */ - uae_u16 bca_len; /* Length of BCA data (DVD-ROM) */ - uae_u32 __dummy2__[2]; - uae_u32 bca_data_offset; /* Offset to BCA data (DVD-ROM) */ - uae_u32 __dummy3__[6]; /* Probably more offsets */ - uae_u32 disc_structures_offset; /* Offset to disc structures */ - uae_u32 __dummy4__[3]; /* Probably more offsets */ - uae_u32 sessions_blocks_offset; /* Offset to session blocks */ - uae_u32 dpm_blocks_offset; /* offset to DPM data blocks */ + uae_u8 signature[16]; /* "MEDIA DESCRIPTOR" */ + uae_u8 version[2]; /* Version ? */ + uae_u16 medium_type; /* Medium type */ + uae_u16 num_sessions; /* Number of sessions */ + uae_u16 __dummy1__[2]; /* Wish I knew... */ + uae_u16 bca_len; /* Length of BCA data (DVD-ROM) */ + uae_u32 __dummy2__[2]; + uae_u32 bca_data_offset; /* Offset to BCA data (DVD-ROM) */ + uae_u32 __dummy3__[6]; /* Probably more offsets */ + uae_u32 disc_structures_offset; /* Offset to disc structures */ + uae_u32 __dummy4__[3]; /* Probably more offsets */ + uae_u32 sessions_blocks_offset; /* Offset to session blocks */ + uae_u32 dpm_blocks_offset; /* offset to DPM data blocks */ } MDS_Header; /* length: 88 bytes */ typedef struct { - uae_s32 session_start; /* Session's start address */ - uae_s32 session_end; /* Session's end address */ - uae_u16 session_number; /* (Unknown) */ - uae_u8 num_all_blocks; /* Number of all data blocks. */ - uae_u8 num_nontrack_blocks; /* Number of lead-in data blocks */ - uae_u16 first_track; /* Total number of sessions in image? */ - uae_u16 last_track; /* Number of regular track data blocks. */ - uae_u32 __dummy2__; /* (unknown) */ - uae_u32 tracks_blocks_offset; /* Offset of lead-in+regular track data blocks. */ + uae_s32 session_start; /* Session's start address */ + uae_s32 session_end; /* Session's end address */ + uae_u16 session_number; /* (Unknown) */ + uae_u8 num_all_blocks; /* Number of all data blocks. */ + uae_u8 num_nontrack_blocks; /* Number of lead-in data blocks */ + uae_u16 first_track; /* Total number of sessions in image? */ + uae_u16 last_track; /* Number of regular track data blocks. */ + uae_u32 __dummy2__; /* (unknown) */ + uae_u32 tracks_blocks_offset; /* Offset of lead-in+regular track data blocks. */ } MDS_SessionBlock; /* length: 24 bytes */ typedef struct { - uae_u8 mode; /* Track mode */ - uae_u8 subchannel; /* Subchannel mode */ - uae_u8 adr_ctl; /* Adr/Ctl */ - uae_u8 __dummy2__; /* Track flags? */ - uae_u8 point; /* Track number. (>0x99 is lead-in track) */ - - uae_u32 __dummy3__; - uae_u8 min; /* Min */ - uae_u8 sec; /* Sec */ - uae_u8 frame; /* Frame */ - uae_u32 extra_offset; /* Start offset of this track's extra block. */ - uae_u16 sector_size; /* Sector size. */ - - uae_u8 __dummy4__[18]; - uae_u32 start_sector; /* Track start sector (PLBA). */ - uae_u64 start_offset; /* Track start offset. */ - uae_u8 session; /* Session or index? */ - uae_u8 __dummy5__[3]; - uae_u32 footer_offset; /* Start offset of footer. */ - uae_u8 __dummy6__[24]; + uae_u8 mode; /* Track mode */ + uae_u8 subchannel; /* Subchannel mode */ + uae_u8 adr_ctl; /* Adr/Ctl */ + uae_u8 __dummy2__; /* Track flags? */ + uae_u8 point; /* Track number. (>0x99 is lead-in track) */ + + uae_u32 __dummy3__; + uae_u8 min; /* Min */ + uae_u8 sec; /* Sec */ + uae_u8 frame; /* Frame */ + uae_u32 extra_offset; /* Start offset of this track's extra block. */ + uae_u16 sector_size; /* Sector size. */ + + uae_u8 __dummy4__[18]; + uae_u32 start_sector; /* Track start sector (PLBA). */ + uae_u64 start_offset; /* Track start offset. */ + uae_u8 session; /* Session or index? */ + uae_u8 __dummy5__[3]; + uae_u32 footer_offset; /* Start offset of footer. */ + uae_u8 __dummy6__[24]; } MDS_TrackBlock; /* length: 80 bytes */ typedef struct { - uae_u32 pregap; /* Number of sectors in pregap. */ - uae_u32 length; /* Number of sectors in track. */ + uae_u32 pregap; /* Number of sectors in pregap. */ + uae_u32 length; /* Number of sectors in track. */ } MDS_TrackExtraBlock; /* length: 8 bytes */ typedef struct { - uae_u32 filename_offset; /* Start offset of image filename. */ - uae_u32 widechar_filename; /* Seems to be set to 1 if widechar filename is used */ - uae_u32 __dummy1__; - uae_u32 __dummy2__; + uae_u32 filename_offset; /* Start offset of image filename. */ + uae_u32 widechar_filename; /* Seems to be set to 1 if widechar filename is used */ + uae_u32 __dummy1__; + uae_u32 __dummy2__; } MDS_Footer; /* length: 16 bytes */ #pragma pack() -static int parsemds(struct cdunit *cdu, struct zfile *zmds, const TCHAR *img) +static int parsemds (struct cdunit *cdu, struct zfile *zmds, const TCHAR *img) { MDS_Header *head; struct cdtoc *t; uae_u8 *mds = NULL; uae_u64 size; MDS_SessionBlock *sb; - - write_log(_T("MDS TOC: '%s'\n"), img); - size = zfile_size(zmds); - mds = xmalloc(uae_u8, size); + + write_log (_T("MDS TOC: '%s'\n"), img); + size = zfile_size (zmds); + mds = xmalloc (uae_u8, size); if (!mds) goto end; - if (zfile_fread(mds, size, 1, zmds) != 1) + if (zfile_fread (mds, size, 1, zmds) != 1) goto end; head = (MDS_Header*)mds; - if (!memcmp(&head, MEDIA_DESCRIPTOR, strlen(MEDIA_DESCRIPTOR))) + if (!memcmp (&head, MEDIA_DESCRIPTOR, strlen (MEDIA_DESCRIPTOR))) goto end; if (head->version[0] != 1) { - write_log(_T("unsupported MDS version %d, only v.1 supported\n"), head->version[0]); + write_log (_T("unsupported MDS version %d, only v.1 supported\n"), head->version[0]); goto end; } sb = (MDS_SessionBlock*)(mds + head->sessions_blocks_offset); cdu->tracks = sb->last_track - sb->first_track + 1; for (int i = 0; i < sb->num_all_blocks; i++) { - MDS_TrackBlock *tb = (MDS_TrackBlock*)(mds + sb->tracks_blocks_offset + i * sizeof(MDS_TrackBlock)); + MDS_TrackBlock *tb = (MDS_TrackBlock*)(mds + sb->tracks_blocks_offset + i * sizeof (MDS_TrackBlock)); int point = tb->point; int tracknum = -1; if (point == 0xa2) @@ -1190,29 +1171,29 @@ static int parsemds(struct cdunit *cdu, struct zfile *zmds, const TCHAR *img) if (footer) { TCHAR *fname = NULL; if (footer->widechar_filename == 0) - fname = au((char*)(mds + footer->filename_offset)); + fname = au ((char*)(mds + footer->filename_offset)); else - fname = my_strdup((TCHAR*)(mds + footer->filename_offset)); + fname = my_strdup ((TCHAR*)(mds + footer->filename_offset)); if (fname[0] == '*' && fname[1] == '.') { TCHAR newname[MAX_DPATH]; - _tcscpy(newname, img); - TCHAR *ext = _tcsrchr(newname, '.'); + _tcscpy (newname, img); + TCHAR *ext = _tcsrchr (newname, '.'); if (ext) - _tcscpy(ext, fname + 1); - xfree(fname); - fname = my_strdup(newname); + _tcscpy (ext, fname + 1); + xfree (fname); + fname = my_strdup (newname); } - t->handle = zfile_fopen(fname, _T("rb"), ZFD_NORMAL); - t->fname = my_strdup(fname); + t->handle = zfile_fopen (fname, _T("rb"), ZFD_NORMAL); + t->fname = my_strdup (fname); if (t->handle) - t->filesize = zfile_size(t->handle); + t->filesize = zfile_size (t->handle); } if (tb->subchannel && t->handle) { t->suboffset = t->size; t->subcode = 1; // interleaved - t->subhandle = zfile_dup(t->handle); + t->subhandle = zfile_dup (t->handle); t->skipsize = SUB_CHANNEL_SIZE; t->size -= SUB_CHANNEL_SIZE; } @@ -1222,12 +1203,12 @@ static int parsemds(struct cdunit *cdu, struct zfile *zmds, const TCHAR *img) } end: - xfree(mds); + xfree (mds); return cdu->tracks; } -static int parseccd(struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) +static int parseccd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) { int mode; int num, tracknum, trackmode; @@ -1236,49 +1217,47 @@ static int parseccd(struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) struct cdtoc *t; struct zfile *zimg, *zsub; TCHAR fname[MAX_DPATH]; - - write_log(_T("CCD TOC: '%s'\n"), img); - _tcscpy(fname, zfile_getname(zcue)); - TCHAR *ext = _tcsrchr(fname, '.'); + + write_log (_T("CCD TOC: '%s'\n"), img); + _tcscpy (fname, zfile_getname(zcue)); + TCHAR *ext = _tcsrchr (fname, '.'); if (ext) *ext = 0; - _tcscat(fname, _T(".img")); - zimg = zfile_fopen(fname, _T("rb"), ZFD_NORMAL); + _tcscat (fname, _T(".img")); + zimg = zfile_fopen (fname, _T("rb"), ZFD_NORMAL); if (!zimg) { - write_log(_T("CCD: can't open '%s'\n"), fname); + write_log (_T("CCD: can't open '%s'\n"), fname); return 0; } - ext = _tcsrchr(fname, '.'); + ext = _tcsrchr (fname, '.'); if (ext) *ext = 0; - _tcscat(fname, _T(".sub")); - zsub = zfile_fopen(fname, _T("rb"), ZFD_NORMAL); + _tcscat (fname, _T(".sub")); + zsub = zfile_fopen (fname, _T("rb"), ZFD_NORMAL); if (zsub) - write_log(_T("CCD: '%s' detected\n"), fname); + write_log (_T("CCD: '%s' detected\n"), fname); num = -1; mode = -1; for (;;) { TCHAR buf[MAX_DPATH], *p; - if (!zfile_fgets(buf, sizeof buf / sizeof(TCHAR), zcue)) + if (!zfile_fgets (buf, sizeof buf / sizeof (TCHAR), zcue)) break; p = buf; - skipspace(&p); - if (!_tcsnicmp(p, _T("[DISC]"), 6)) { + skipspace (&p); + if (!_tcsnicmp (p, _T("[DISC]"), 6)) { mode = 1; - } - else if (!_tcsnicmp(p, _T("[ENTRY "), 7)) { + } else if (!_tcsnicmp (p, _T("[ENTRY "), 7)) { t = NULL; mode = 2; - num = readval(p + 7); + num = readval (p + 7); if (num < 0) break; adr = control = -1; gotlba = false; - } - else if (!_tcsnicmp(p, _T("[TRACK "), 7)) { + } else if (!_tcsnicmp (p, _T("[TRACK "), 7)) { mode = 3; - tracknum = readval(p + 7); + tracknum = readval (p + 7); trackmode = -1; if (tracknum <= 0 || tracknum > 99) break; @@ -1287,8 +1266,8 @@ static int parseccd(struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) if (mode < 0) continue; if (mode == 1) { - if (!_tcsnicmp(p, _T("TocEntries="), 11)) { - cdu->tracks = readval(p + 11) - 3; + if (!_tcsnicmp (p, _T("TocEntries="), 11)) { + cdu->tracks = readval (p + 11) - 3; if (cdu->tracks <= 0 || cdu->tracks > 99) break; } @@ -1296,16 +1275,15 @@ static int parseccd(struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) } if (cdu->tracks <= 0) break; - + if (mode == 2) { - if (!_tcsnicmp(p, _T("SESSION="), 8)) { - if (readval(p + 8) != 1) + if (!_tcsnicmp (p, _T("SESSION="), 8)) { + if (readval (p + 8) != 1) mode = -1; continue; - } - else if (!_tcsnicmp(p, _T("POINT="), 6)) { - tracknum = readval(p + 6); + } else if (!_tcsnicmp (p, _T("POINT="), 6)) { + tracknum = readval (p + 6); if (tracknum <= 0) break; if (tracknum >= 0xa0 && tracknum != 0xa2) { @@ -1317,12 +1295,12 @@ static int parseccd(struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) t = &cdu->toc[tracknum - 1]; continue; } - if (!_tcsnicmp(p, _T("ADR="), 4)) - adr = readval(p + 4); - if (!_tcsnicmp(p, _T("CONTROL="), 8)) - control = readval(p + 8); - if (!_tcsnicmp(p, _T("PLBA="), 5)) { - lba = readval(p + 5); + if (!_tcsnicmp (p, _T("ADR="), 4)) + adr = readval (p + 4); + if (!_tcsnicmp (p, _T("CONTROL="), 8)) + control = readval (p + 8); + if (!_tcsnicmp (p, _T("PLBA="), 5)) { + lba = readval (p + 5); gotlba = true; } if (gotlba && adr >= 0 && control >= 0) { @@ -1336,33 +1314,32 @@ static int parseccd(struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) t->enctype = AUDENC_PCM; if (zsub) { t->subcode = 2; - t->subhandle = zfile_dup(zsub); + t->subhandle = zfile_dup (zsub); t->suboffset = 0; } if (zimg) { - t->handle = zfile_dup(zimg); - t->fname = my_strdup(zfile_getname(zimg)); + t->handle = zfile_dup (zimg); + t->fname = my_strdup (zfile_getname (zimg)); } mode = -1; } - } - else if (mode == 3) { + } else if (mode == 3) { - if (!_tcsnicmp(p, _T("MODE="), 5)) - trackmode = _tstol(p + 5); + if (!_tcsnicmp (p, _T("MODE="), 5)) + trackmode = _tstol (p + 5); if (trackmode < 0 || trackmode > 2) continue; - + } } - zfile_fclose(zimg); - zfile_fclose(zsub); + zfile_fclose (zimg); + zfile_fclose (zsub); return cdu->tracks; } -static int parsecue(struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) +static int parsecue (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) { int tracknum, pregap, postgap, lastpregap, lastpostgap; int newfile, secoffset; @@ -1387,77 +1364,74 @@ static int parsecue(struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) lastpostgap = 0; fnametypeid = AUDENC_NONE; - write_log(_T("CUE TOC: '%s'\n"), img); + write_log (_T("CUE TOC: '%s'\n"), img); for (;;) { TCHAR buf[MAX_DPATH], *p; - if (!zfile_fgets(buf, sizeof buf / sizeof(TCHAR), zcue)) + if (!zfile_fgets (buf, sizeof buf / sizeof (TCHAR), zcue)) break; p = buf; - skipspace(&p); + skipspace (&p); - if (!_tcsnicmp(p, _T("FILE"), 4)) { + if (!_tcsnicmp (p, _T("FILE"), 4)) { p += 4; - xfree(fname); - fname = my_strdup(nextstring(&p)); - fnametype = nextstring(&p); + xfree (fname); + fname = my_strdup (nextstring (&p)); + fnametype = nextstring (&p); fnametypeid = AUDENC_NONE; if (!fnametype) break; - if (_tcsicmp(fnametype, _T("BINARY")) && _tcsicmp(fnametype, _T("WAVE")) && _tcsicmp(fnametype, _T("MP3")) && _tcsicmp(fnametype, _T("FLAC"))) { - write_log(_T("CUE: unknown file type '%s' ('%s')\n"), fnametype, fname); + if (_tcsicmp (fnametype, _T("BINARY")) && _tcsicmp (fnametype, _T("WAVE")) && _tcsicmp (fnametype, _T("MP3")) && _tcsicmp (fnametype, _T("FLAC"))) { + write_log (_T("CUE: unknown file type '%s' ('%s')\n"), fnametype, fname); } fnametypeid = AUDENC_PCM; - if (!_tcsicmp(fnametype, _T("MP3"))) + if (!_tcsicmp (fnametype, _T("MP3"))) fnametypeid = AUDENC_MP3; - else if (!_tcsicmp(fnametype, _T("FLAC"))) + else if (!_tcsicmp (fnametype, _T("FLAC"))) fnametypeid = AUDENC_FLAC; fileoffset = 0; newfile = 1; ctrl = 0; - } - else if (!_tcsnicmp(p, _T("FLAGS"), 5)) { + } else if (!_tcsnicmp (p, _T("FLAGS"), 5)) { ctrl &= ~(1 | 2 | 8); for (;;) { - TCHAR *f = nextstring(&p); + TCHAR *f = nextstring (&p); if (!f) break; - if (!_tcsicmp(f, _T("PRE"))) + if (!_tcsicmp (f, _T("PRE"))) ctrl |= 1; - if (!_tcsicmp(f, _T("DCP"))) + if (!_tcsicmp (f, _T("DCP"))) ctrl |= 2; - if (!_tcsicmp(f, _T("4CH"))) + if (!_tcsicmp (f, _T("4CH"))) ctrl |= 8; } - } - else if (!_tcsnicmp(p, _T("TRACK"), 5)) { + } else if (!_tcsnicmp (p, _T("TRACK"), 5)) { int size; TCHAR *tracktype; - + p += 5; index0 = -1; lastpregap = 0; lastpostgap = 0; - tracknum = _tstoi(nextstring(&p)); - tracktype = nextstring(&p); + tracknum = _tstoi (nextstring (&p)); + tracktype = nextstring (&p); if (!tracktype) break; size = 2352; - if (!_tcsicmp(tracktype, _T("AUDIO"))) { + if (!_tcsicmp (tracktype, _T("AUDIO"))) { ctrl &= ~4; - } - else { + } else { ctrl |= 4; - if (!_tcsicmp(tracktype, _T("MODE1/2048"))) + if (!_tcsicmp (tracktype, _T("MODE1/2048"))) size = 2048; - else if (!_tcsicmp(tracktype, _T("MODE1/2352"))) + else if (!_tcsicmp (tracktype, _T("MODE1/2352"))) size = 2352; - else if (!_tcsicmp(tracktype, _T("MODE2/2336")) || !_tcsicmp(tracktype, _T("CDI/2336"))) + else if (!_tcsicmp (tracktype, _T("MODE2/2336")) || !_tcsicmp (tracktype, _T("CDI/2336"))) size = 2336; - else if (!_tcsicmp(tracktype, _T("MODE2/2352")) || !_tcsicmp(tracktype, _T("CDI/2352"))) + else if (!_tcsicmp (tracktype, _T("MODE2/2352")) || !_tcsicmp (tracktype, _T("CDI/2352"))) size = 2352; else { - write_log(_T("CUE: unknown tracktype '%s' ('%s')\n"), tracktype, fname); + write_log (_T("CUE: unknown tracktype '%s' ('%s')\n"), tracktype, fname); } } if (tracknum >= 1 && tracknum <= 99) { @@ -1471,17 +1445,17 @@ static int parsecue(struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) } newfile = 0; - ztrack = zfile_fopen(fname, _T("rb"), ZFD_ARCHIVE | ZFD_DELAYEDOPEN); + ztrack = zfile_fopen (fname, _T("rb"), ZFD_ARCHIVE | ZFD_DELAYEDOPEN); if (!ztrack) { TCHAR tmp[MAX_DPATH]; - _tcscpy(tmp, fname); - p = tmp + _tcslen(tmp); + _tcscpy (tmp, fname); + p = tmp + _tcslen (tmp); while (p > tmp) { if (*p == '/' || *p == '\\') { - ztrack = zfile_fopen(p + 1, _T("rb"), ZFD_ARCHIVE | ZFD_DELAYEDOPEN); + ztrack = zfile_fopen (p + 1, _T("rb"), ZFD_ARCHIVE | ZFD_DELAYEDOPEN); if (ztrack) { - xfree(fname); - fname = my_strdup(p + 1); + xfree (fname); + fname = my_strdup (p + 1); } break; } @@ -1491,15 +1465,15 @@ static int parsecue(struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) if (!ztrack) { TCHAR tmp[MAX_DPATH]; TCHAR *s2; - _tcscpy(tmp, zfile_getname(zcue)); - s2 = _tcsrchr(tmp, '\\'); + _tcscpy (tmp, zfile_getname (zcue)); + s2 = _tcsrchr (tmp, '\\'); if (!s2) - s2 = _tcsrchr(tmp, '/'); + s2 = _tcsrchr (tmp, '/'); if (s2) { s2[0] = 0; - _tcscat(tmp, FSDB_DIR_SEPARATOR_S); - _tcscat(tmp, fname); - ztrack = zfile_fopen(tmp, _T("rb"), ZFD_ARCHIVE | ZFD_DELAYEDOPEN); + _tcscat (tmp, FSDB_DIR_SEPARATOR_S); + _tcscat (tmp, fname); + ztrack = zfile_fopen (tmp, _T("rb"), ZFD_ARCHIVE | ZFD_DELAYEDOPEN); } } t->track = tracknum; @@ -1507,50 +1481,46 @@ static int parsecue(struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) t->adr = 1; t->handle = ztrack; t->size = size; - t->fname = my_strdup(fname); + t->fname = my_strdup (fname); if (tracknum > cdu->tracks) cdu->tracks = tracknum; if (t->handle) - t->filesize = zfile_size(t->handle); + t->filesize = zfile_size (t->handle); } - } - else if (!_tcsnicmp(p, _T("PREGAP"), 6)) { + } else if (!_tcsnicmp (p, _T("PREGAP"), 6)) { TCHAR *tt; int tn; p += 6; - tt = nextstring(&p); - tn = _tstoi(tt) * 60 * 75; - tn += _tstoi(tt + 3) * 75; - tn += _tstoi(tt + 6); + tt = nextstring (&p); + tn = _tstoi (tt) * 60 * 75; + tn += _tstoi (tt + 3) * 75; + tn += _tstoi (tt + 6); pregap += tn; lastpregap = tn; - } - else if (!_tcsnicmp(p, _T("POSTGAP"), 7)) { + } else if (!_tcsnicmp (p, _T("POSTGAP"), 7)) { struct cdtoc *t = &cdu->toc[tracknum - 1]; TCHAR *tt; int tn; p += 7; - tt = nextstring(&p); - tn = _tstoi(tt) * 60 * 75; - tn += _tstoi(tt + 3) * 75; - tn += _tstoi(tt + 6); + tt = nextstring (&p); + tn = _tstoi (tt) * 60 * 75; + tn += _tstoi (tt + 3) * 75; + tn += _tstoi (tt + 6); postgap += tn; lastpostgap = tn; - } - else if (!_tcsnicmp(p, _T("INDEX"), 5)) { + } else if (!_tcsnicmp (p, _T("INDEX"), 5)) { int idxnum; int tn = 0; TCHAR *tt; p += 5; - idxnum = _tstoi(nextstring(&p)); - tt = nextstring(&p); - tn = _tstoi(tt) * 60 * 75; - tn += _tstoi(tt + 3) * 75; - tn += _tstoi(tt + 6); + idxnum = _tstoi (nextstring (&p)); + tt = nextstring (&p); + tn = _tstoi (tt) * 60 * 75; + tn += _tstoi (tt + 3) * 75; + tn += _tstoi (tt + 6); if (idxnum == 0) { index0 = tn; - } - else if (idxnum == 1 && tracknum >= 1 && tracknum <= 99) { + } else if (idxnum == 1 && tracknum >= 1 && tracknum <= 99) { struct cdtoc *t = &cdu->toc[tracknum - 1]; if (!t->address) { t->address = tn + secoffset; @@ -1575,41 +1545,38 @@ static int parsecue(struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) if (fnametypeid == AUDENC_PCM && t->handle) { struct zfile *zf = t->handle; uae_u8 buf[16] = { 0 }; - zfile_fread(buf, 12, 1, zf); - if (!memcmp(buf, "RIFF", 4) && !memcmp(buf + 8, "WAVE", 4)) { + zfile_fread (buf, 12, 1, zf); + if (!memcmp (buf, "RIFF", 4) && !memcmp (buf + 8, "WAVE", 4)) { int size; for (;;) { - memset(buf, 0, sizeof buf); - if (zfile_fread(buf, 8, 1, zf) != 1) + memset (buf, 0, sizeof buf); + if (zfile_fread (buf, 8, 1, zf) != 1) break; size = (buf[4] << 0) | (buf[5] << 8) | (buf[6] << 16) | (buf[7] << 24); - if (!memcmp(buf, "data", 4)) + if (!memcmp (buf, "data", 4)) break; if (size <= 0) break; - zfile_fseek(zf, size, SEEK_CUR); + zfile_fseek (zf, size, SEEK_CUR); } - t->offset += zfile_ftell(zf); + t->offset += zfile_ftell (zf); t->filesize = size; } t->enctype = fnametypeid; - } - else if (fnametypeid == AUDENC_MP3 && t->handle) { + } else if (fnametypeid == AUDENC_MP3 && t->handle) { if (!mp3dec) { try { mp3dec = new mp3decoder(); - } - catch (exception) {} + } catch (exception) { } } if (mp3dec) { t->offset = 0; - t->filesize = mp3dec->getsize(t->handle); + t->filesize = mp3dec->getsize (t->handle); if (t->filesize) t->enctype = fnametypeid; } - } - else if (fnametypeid == AUDENC_FLAC && t->handle) { - flac_get_size(t); + } else if (fnametypeid == AUDENC_FLAC && t->handle) { + flac_get_size (t); if (t->filesize) t->enctype = fnametypeid; } @@ -1627,7 +1594,7 @@ static int parsecue(struct cdunit *cdu, struct zfile *zcue, const TCHAR *img) size /= t->size; cdu->toc[cdu->tracks].address = t->address + (int)size; - xfree(fname); + xfree (fname); delete mp3dec; @@ -1650,11 +1617,9 @@ static int parsenrg(struct cdunit *cdu, struct zfile *znrg, const TCHAR *img) if (!memcmp(buf, "NER5", 4)) { offset = get_quad_host(buf + 4); ner5 = true; - } - else if (!memcmp(buf + 4, "NERO", 4)) { + } else if (!memcmp(buf + 4, "NERO", 4)) { offset = get_long_host(buf + 8); - } - else { + } else { return 0; } if (offset < 0 || offset >= size - 12) @@ -1686,8 +1651,7 @@ static int parsenrg(struct cdunit *cdu, struct zfile *znrg, const TCHAR *img) if (type == 7) { t->size = 2352; t->enctype = AUDENC_PCM; - } - else if (type == 0 || type == 3) { + } else if (type == 0 || type == 3) { t->size = 2048; t->ctrl |= 4; } @@ -1699,8 +1663,7 @@ static int parsenrg(struct cdunit *cdu, struct zfile *znrg, const TCHAR *img) size -= blocksize; } gotsession = true; - } - else if (!memcmp(buf, "SINF", 4)) { + } else if (!memcmp(buf, "SINF", 4)) { if (zfile_fread(buf, 4, 1, znrg) != 1) return 0; if (!cdu->tracks) { @@ -1708,8 +1671,7 @@ static int parsenrg(struct cdunit *cdu, struct zfile *znrg, const TCHAR *img) cdtoc *t = &cdu->toc[cdu->tracks]; t->address = lastlba; } - } - else if (!memcmp(buf, "CUEX", 4) || !memcmp(buf, "CUES", 4)) { + } else if (!memcmp(buf, "CUEX", 4) || !memcmp(buf, "CUES", 4)) { while (size >= 8) { if (zfile_fread(buf, 8, 1, znrg) != 1) return 0; @@ -1718,8 +1680,7 @@ static int parsenrg(struct cdunit *cdu, struct zfile *znrg, const TCHAR *img) if (trk == 0xaa) { lastlba = get_long_host(buf + 4); } - } - else { + } else { tracknum = frombcd(trk); int index = frombcd(buf[2]); if (index == 0 && tracknum >= 1 && tracknum <= 99) { @@ -1732,8 +1693,7 @@ static int parsenrg(struct cdunit *cdu, struct zfile *znrg, const TCHAR *img) } size -= 8; } - } - else if (!memcmp(buf, "DAOX", 4) || !memcmp(buf, "DAOI", 4)) { + } else if (!memcmp(buf, "DAOX", 4) || !memcmp(buf, "DAOI", 4)) { bool newformat = memcmp(buf, "DAOX", 4) == 0; int first_track, last_track; int blocksize; @@ -1743,8 +1703,7 @@ static int parsenrg(struct cdunit *cdu, struct zfile *znrg, const TCHAR *img) last_track = frombcd(buf[4 + 14 + 2 + 1]); size -= 22; blocksize = 42; - } - else { + } else { zfile_fread(buf, 24, 1, znrg); first_track = frombcd(buf[4 + 14 + 4]); last_track = frombcd(buf[4 + 14 + 4 + 1]); @@ -1770,8 +1729,7 @@ static int parsenrg(struct cdunit *cdu, struct zfile *znrg, const TCHAR *img) index0 = get_quad_host(buf + 18); index1 = get_quad_host(buf + 26); end = get_quad_host(buf + 34); - } - else { + } else { sectorsize = get_long_host(buf + 12); type = get_long_host(buf + 16); index0 = get_long_host(buf + 20); @@ -1803,8 +1761,7 @@ static int parsenrg(struct cdunit *cdu, struct zfile *znrg, const TCHAR *img) tracknum++; size -= blocksize; } - } - else if (!memcmp(buf, "END!", 4)) { + } else if (!memcmp(buf, "END!", 4)) { break; } zfile_fseek(znrg, offset, SEEK_SET); @@ -1813,7 +1770,7 @@ static int parsenrg(struct cdunit *cdu, struct zfile *znrg, const TCHAR *img) } -static int parse_image(struct cdunit *cdu, const TCHAR *img) +static int parse_image (struct cdunit *cdu, const TCHAR *img) { struct zfile *zcue; int i; @@ -1824,19 +1781,19 @@ static int parse_image(struct cdunit *cdu, const TCHAR *img) cdu->tracks = 0; if (!img) return 0; - zcue = zfile_fopen(img, _T("rb"), ZFD_ARCHIVE | ZFD_CD | ZFD_DELAYEDOPEN); + zcue = zfile_fopen (img, _T("rb"), ZFD_ARCHIVE | ZFD_CD | ZFD_DELAYEDOPEN); if (!zcue) return 0; - ext = _tcsrchr(zfile_getname(zcue), '.'); + ext = _tcsrchr (zfile_getname (zcue), '.'); if (ext) { TCHAR curdir[MAX_DPATH]; TCHAR oldcurdir[MAX_DPATH], *p; ext++; oldcurdir[0] = 0; - _tcscpy(curdir, img); - p = curdir + _tcslen(curdir); + _tcscpy (curdir, img); + p = curdir + _tcslen (curdir); while (p > curdir) { if (*p == '/' || *p == '\\') break; @@ -1844,90 +1801,87 @@ static int parse_image(struct cdunit *cdu, const TCHAR *img) } *p = 0; if (p > curdir) - my_setcurrentdir(curdir, oldcurdir); + my_setcurrentdir (curdir, oldcurdir); - if (!_tcsicmp(ext, _T("cue"))) { - parsecue(cdu, zcue, img); - } - else if (!_tcsicmp(ext, _T("ccd"))) { - parseccd(cdu, zcue, img); - } - else if (!_tcsicmp(ext, _T("mds"))) { - parsemds(cdu, zcue, img); - } - else if (!_tcsicmp(ext, _T("nrg"))) { + if (!_tcsicmp (ext, _T("cue"))) { + parsecue (cdu, zcue, img); + } else if (!_tcsicmp (ext, _T("ccd"))) { + parseccd (cdu, zcue, img); + } else if (!_tcsicmp (ext, _T("mds"))) { + parsemds (cdu, zcue, img); + } else if (!_tcsicmp(ext, _T("nrg"))) { parsenrg(cdu, zcue, img); } if (oldcurdir[0]) - my_setcurrentdir(oldcurdir, NULL); + my_setcurrentdir (oldcurdir, NULL); } if (!cdu->tracks) { - uae_u64 siz = zfile_size(zcue); + uae_u64 siz = zfile_size (zcue); if (siz >= 16384 && ((siz % 2048) == 0 || (siz % 2352) == 0)) { struct cdtoc *t = &cdu->toc[0]; cdu->tracks = 1; t->ctrl = 4; t->adr = 1; - t->fname = my_strdup(img); + t->fname = my_strdup (img); t->handle = zcue; t->size = (siz % 2048) == 0 ? 2048 : 2352; t->filesize = siz; t->track = 1; - write_log(_T("CD: plain CD image mounted!\n")); + write_log (_T("CD: plain CD image mounted!\n")); cdu->toc[1].address = t->address + (int)(t->filesize / t->size); zcue = NULL; } } if (!cdu->tracks) - write_log(_T("CD: couldn't mount '%s'!\n"), img); + write_log (_T("CD: couldn't mount '%s'!\n"), img); for (i = 0; i <= cdu->tracks; i++) { struct cdtoc *t = &cdu->toc[i]; uae_u32 msf; if (t->pregap) { - msf = lsn2msf(t->pregap - 150); - write_log(_T(" PREGAP : %02d:%02d:%02d\n"), (msf >> 16) & 0x7fff, (msf >> 8) & 0xff, (msf >> 0) & 0xff); + msf = lsn2msf (t->pregap - 150); + write_log (_T(" PREGAP : %02d:%02d:%02d\n"), (msf >> 16) & 0x7fff, (msf >> 8) & 0xff, (msf >> 0) & 0xff); } if (t->index1) { - msf = lsn2msf(t->index1 - 150); - write_log(_T(" INDEX1 : %02d:%02d:%02d\n"), (msf >> 16) & 0x7fff, (msf >> 8) & 0xff, (msf >> 0) & 0xff); + msf = lsn2msf (t->index1 - 150); + write_log (_T(" INDEX1 : %02d:%02d:%02d\n"), (msf >> 16) & 0x7fff, (msf >> 8) & 0xff, (msf >> 0) & 0xff); } if (i < cdu->tracks) - write_log(_T("%2d: "), i + 1); + write_log (_T("%2d: "), i + 1); else - write_log(_T(" ")); - msf = lsn2msf(t->address); - write_log(_T("%7d %02d:%02d:%02d"), + write_log (_T(" ")); + msf = lsn2msf (t->address); + write_log (_T("%7d %02d:%02d:%02d"), t->address, (msf >> 16) & 0x7fff, (msf >> 8) & 0xff, (msf >> 0) & 0xff); if (i < cdu->tracks) { - write_log(_T(" %s %x %10lld %10lld %s%s"), - (t->ctrl & 4) ? _T("DATA ") : (t->subcode ? _T("CDA+SUB") : _T("CDA ")), - t->ctrl, t->offset, t->filesize, + write_log (_T(" %s %x %10lld %10lld %s%s"), + (t->ctrl & 4) ? _T("DATA ") : (t->subcode ? _T("CDA+SUB") : _T("CDA ")), + t->ctrl, t->offset, t->filesize, t->extrainfo ? t->extrainfo : _T(""), t->handle == NULL ? _T("[FILE ERROR]") : _T("")); - } - write_log(_T("\n")); + } + write_log (_T("\n")); if (i < cdu->tracks) - write_log(_T(" - %s\n"), t->fname); + write_log (_T(" - %s\n"), t->fname); if (t->handle && !t->filesize) - t->filesize = zfile_size(t->handle); + t->filesize = zfile_size (t->handle); if (t->postgap) { - msf = lsn2msf(t->postgap - 150); - write_log(_T(" POSTGAP: %02d:%02d:%02d\n"), (msf >> 16) & 0x7fff, (msf >> 8) & 0xff, (msf >> 0) & 0xff); + msf = lsn2msf (t->postgap - 150); + write_log (_T(" POSTGAP: %02d:%02d:%02d\n"), (msf >> 16) & 0x7fff, (msf >> 8) & 0xff, (msf >> 0) & 0xff); } } cdu->blocksize = 2048; cdu->cdsize = (uae_u64)cdu->toc[cdu->tracks].address * cdu->blocksize; + - - zfile_fclose(zcue); + zfile_fclose (zcue); return 1; } -static int ismedia(int unitnum, int quick) +static int ismedia (int unitnum, int quick) { struct cdunit *cdu = &cdunits[unitnum]; if (!cdu->enabled) @@ -1935,10 +1889,10 @@ static int ismedia(int unitnum, int quick) return cdu->tracks > 0 ? 1 : 0; } -static struct device_info *info_device(int unitnum, struct device_info *di, int quick, int session) +static struct device_info *info_device (int unitnum, struct device_info *di, int quick, int session) { struct cdunit *cdu = &cdunits[unitnum]; - memset(di, 0, sizeof(struct device_info)); + memset (di, 0, sizeof (struct device_info)); if (!cdu->enabled) return NULL; di->open = cdu->open; @@ -1952,122 +1906,121 @@ static struct device_info *info_device(int unitnum, struct device_info *di, int di->cylinders = 1; di->trackspercylinder = 1; di->sectorspertrack = (int)(cdu->cdsize / di->bytespersector); - if (ismedia(unitnum, 1)) { + if (ismedia (unitnum, 1)) { di->media_inserted = 1; - _tcscpy(di->mediapath, cdu->imgname); + _tcscpy (di->mediapath, cdu->imgname); di->audio_playing = cdu->cdda_play > 0; } - memset(&di->toc, 0, sizeof(struct cd_toc_head)); - command_toc(unitnum, &di->toc); + memset (&di->toc, 0, sizeof (struct cd_toc_head)); + command_toc (unitnum, &di->toc); di->write_protected = 1; di->type = INQ_ROMD; di->unitnum = unitnum + 1; if (di->mediapath[0]) { - _tcscpy(di->label, _T("IMG:")); - _tcscat(di->label, di->mediapath); + _tcscpy (di->label, _T("IMG:")); + _tcscat (di->label, di->mediapath); + } else { + _tcscpy (di->label, _T("IMG:")); } - else { - _tcscpy(di->label, _T("IMG:")); - } - _tcscpy(di->vendorid, _T("UAE")); - _stprintf(di->productid, _T("SCSICD%d"), unitnum); - _tcscpy(di->revision, _T("1.0")); + _tcscpy (di->vendorid, _T("UAE")); + _stprintf (di->productid, _T("SCSICD%d"), unitnum); + _tcscpy (di->revision, _T("1.0")); di->backend = _T("IMAGE"); return di; } -static void unload_image(struct cdunit *cdu) +static void unload_image (struct cdunit *cdu) { int i; - for (i = 0; i < sizeof cdu->toc / sizeof(struct cdtoc); i++) { + for (i = 0; i < sizeof cdu->toc / sizeof (struct cdtoc); i++) { struct cdtoc *t = &cdu->toc[i]; - zfile_fclose(t->handle); + zfile_fclose (t->handle); if (t->handle != t->subhandle) - zfile_fclose(t->subhandle); - xfree(t->fname); - xfree(t->data); - xfree(t->subdata); - xfree(t->extrainfo); + zfile_fclose (t->subhandle); + xfree (t->fname); + xfree (t->data); + xfree (t->subdata); + xfree (t->extrainfo); } - memset(cdu->toc, 0, sizeof cdu->toc); + memset (cdu->toc, 0, sizeof cdu->toc); cdu->tracks = 0; cdu->cdsize = 0; } -static int open_device(int unitnum, const TCHAR *ident, int flags) +static int open_device (int unitnum, const TCHAR *ident, int flags) { struct cdunit *cdu = &cdunits[unitnum]; int ret = 0; if (!cdu->open) { - uae_sem_init(&cdu->sub_sem, 0, 1); + uae_sem_init (&cdu->sub_sem, 0, 1); cdu->imgname[0] = 0; if (ident) - _tcscpy(cdu->imgname, ident); - parse_image(cdu, ident); + _tcscpy (cdu->imgname, ident); + parse_image (cdu, ident); cdu->open = true; cdu->enabled = true; cdu->cdda_volume[0] = 0x7fff; cdu->cdda_volume[1] = 0x7fff; if (cdimage_unpack_thread == 0) { - init_comm_pipe(&unpack_pipe, 10, 1); - uae_start_thread(_T("cdimage_unpack"), cdda_unpack_func, NULL, NULL); + init_comm_pipe (&unpack_pipe, 10, 1); + uae_start_thread (_T("cdimage_unpack"), cdda_unpack_func, NULL, NULL); while (cdimage_unpack_thread == 0) - Sleep(10); + Sleep (10); } ret = 1; } - blkdev_cd_change(unitnum, cdu->imgname); + blkdev_cd_change (unitnum, cdu->imgname); return ret; } -static void close_device(int unitnum) +static void close_device (int unitnum) { struct cdunit *cdu = &cdunits[unitnum]; if (cdu->open) { - cdda_stop(cdu); + cdda_stop (cdu); cdu->open = false; if (cdimage_unpack_thread) { cdimage_unpack_thread = 0; - write_comm_pipe_u32(&unpack_pipe, -1, 0); - write_comm_pipe_u32(&unpack_pipe, -1, 1); + write_comm_pipe_u32 (&unpack_pipe, -1, 0); + write_comm_pipe_u32 (&unpack_pipe, -1, 1); while (cdimage_unpack_thread == 0) - Sleep(10); + Sleep (10); cdimage_unpack_thread = 0; - destroy_comm_pipe(&unpack_pipe); + destroy_comm_pipe (&unpack_pipe); } - unload_image(cdu); - uae_sem_destroy(&cdu->sub_sem); + unload_image (cdu); + uae_sem_destroy (&cdu->sub_sem); } - blkdev_cd_change(unitnum, cdu->imgname); + blkdev_cd_change (unitnum, cdu->imgname); } -static void close_bus(void) +static void close_bus (void) { if (!bus_open) { - write_log(_T("IMAGE close_bus() when already closed!\n")); + write_log (_T("IMAGE close_bus() when already closed!\n")); return; } for (int i = 0; i < MAX_TOTAL_SCSI_DEVICES; i++) { struct cdunit *cdu = &cdunits[i]; if (cdu->open) - close_device(i); + close_device (i); cdu->enabled = false; } bus_open = 0; - write_log(_T("IMAGE driver closed.\n")); + write_log (_T("IMAGE driver closed.\n")); } -static int open_bus(int flags) +static int open_bus (int flags) { if (bus_open) { - write_log(_T("IOCTL open_bus() more than once!\n")); + write_log (_T("IOCTL open_bus() more than once!\n")); return 1; } bus_open = 1; - write_log(_T("Image driver open.\n")); + write_log (_T("Image driver open.\n")); return 1; } diff --git a/src/bsdsocket.cpp b/src/bsdsocket.cpp index 7853ba97..12c185a5 100644 --- a/src/bsdsocket.cpp +++ b/src/bsdsocket.cpp @@ -15,7 +15,7 @@ #include #include "options.h" -#include "memory.h" +#include "include/memory.h" #include "custom.h" #include "newcpu.h" #include "autoconf.h" @@ -47,13 +47,13 @@ static struct sockd *sockdata; uae_u32 strncpyha(TrapContext *ctx, uae_u32 dst, const uae_char *src, int size) { uae_u32 res = dst; - if (!addr_valid(_T("strncpyha"), dst, size)) - return res; - while (size--) { - put_byte(dst++, *src); - if (!*src++) - return res; - } + if (!addr_valid (_T("strncpyha"), dst, size)) + return res; + while (size--) { + put_byte (dst++, *src); + if (!*src++) + return res; + } return res; } @@ -61,19 +61,19 @@ uae_u32 addstr(TrapContext *ctx, uae_u32 * dst, const TCHAR *src) { uae_u32 res = *dst; int len; - char *s = ua(src); - len = strlen(s) + 1; - strcpyha_safe(*dst, s); + char *s = ua (src); + len = strlen (s) + 1; + strcpyha_safe (*dst, s); (*dst) += len; - xfree(s); + xfree (s); return res; } uae_u32 addstr_ansi(TrapContext *ctx, uae_u32 * dst, const uae_char *src) { uae_u32 res = *dst; int len; - len = strlen(src) + 1; - strcpyha_safe(*dst, src); + len = strlen (src) + 1; + strcpyha_safe (*dst, src); (*dst) += len; return res; } @@ -84,14 +84,14 @@ uae_u32 addmem(TrapContext *ctx, uae_u32 * dst, const uae_char *src, int len) if (!src) return 0; - memcpyha_safe(*dst, (uae_u8*)src, len); + memcpyha_safe (*dst, (uae_u8*)src, len); (*dst) += len; return res; } /* Get current task */ -static uae_u32 gettask(TrapContext *ctx) +static uae_u32 gettask (TrapContext *ctx) { uae_u32 currtask, a1 = trap_get_areg(ctx, 1); TCHAR *tskname; @@ -105,18 +105,18 @@ static uae_u32 gettask(TrapContext *ctx) uae_char name[256]; trap_get_string(ctx, name, trap_get_long(ctx, currtask + 10), sizeof name); tskname = au(name); - BSDTRACE((_T("[%s] "), tskname)); - xfree(tskname); + BSDTRACE ((_T("[%s] "), tskname)); + xfree (tskname); } return currtask; } /* errno/herrno setting */ -void bsdsocklib_seterrno(TrapContext *ctx, SB, int sb_errno) +void bsdsocklib_seterrno (TrapContext *ctx, SB, int sb_errno) { sb->sb_errno = sb_errno; if (sb->sb_errno >= 1001 && sb->sb_errno <= 1005) - bsdsocklib_setherrno(ctx, sb, sb->sb_errno - 1000); + bsdsocklib_setherrno(ctx, sb,sb->sb_errno-1000); if (sb->errnoptr) { switch (sb->errnosize) { case 1: @@ -127,7 +127,7 @@ void bsdsocklib_seterrno(TrapContext *ctx, SB, int sb_errno) break; case 4: trap_put_long(ctx, sb->errnoptr, sb_errno); - break; + break; } } } @@ -146,12 +146,12 @@ void bsdsocklib_setherrno(TrapContext *ctx, SB, int sb_herrno) break; case 4: trap_put_long(ctx, sb->herrnoptr, sb_herrno); - break; + break; } } } -uae_u32 callfdcallback(TrapContext *ctx, SB, uae_u32 fd, uae_u32 action) +uae_u32 callfdcallback (TrapContext *ctx, SB, uae_u32 fd, uae_u32 action) { uae_u32 v; if (!sb->fdcallback) @@ -171,7 +171,7 @@ bool checksd(TrapContext *ctx, SB, int sd) s = getsock(ctx, sb, sd); if (s != INVALID_SOCKET) { - for (iCounter = 1; iCounter <= sb->dtablesize; iCounter++) { + for (iCounter = 1; iCounter <= sb->dtablesize; iCounter++) { if (iCounter != sd) { if (getsock(ctx, sb, iCounter) == s) { releasesock(ctx, sb, sd); @@ -179,12 +179,12 @@ bool checksd(TrapContext *ctx, SB, int sd) } } } - for (iCounter = 0; iCounter < SOCKPOOLSIZE; iCounter++) { + for (iCounter = 0; iCounter < SOCKPOOLSIZE; iCounter++) { if (s == sockdata->sockpoolsocks[iCounter]) return true; } } - BSDTRACE((_T("checksd FALSE s 0x%x sd %d\n"), s, sd)); + BSDTRACE((_T("checksd FALSE s 0x%x sd %d\n"),s,sd)); return false; } @@ -195,7 +195,7 @@ void setsd(TrapContext *ctx, SB, int sd, SOCKET_TYPE s) } /* Socket descriptor/opaque socket handle management */ -int getsd(TrapContext *ctx, SB, SOCKET_TYPE s) +int getsd (TrapContext *ctx, SB, SOCKET_TYPE s) { int i, fdcb; SOCKET_TYPE *dt = sb->dtable; @@ -218,8 +218,7 @@ int getsd(TrapContext *ctx, SB, SOCKET_TYPE s) dt[i] = s; sb->ftable[i] = SF_BLOCKING; return i + 1; - } - else if (dt[i] == -2) { + } else if (dt[i] == -2) { fdcb = 1; } } @@ -242,10 +241,10 @@ int getsd(TrapContext *ctx, SB, SOCKET_TYPE s) return -1; } -SOCKET_TYPE getsock(TrapContext *ctx, SB, int sd) +SOCKET_TYPE getsock (TrapContext *ctx, SB, int sd) { - if ((unsigned int)(sd - 1) >= (unsigned int)sb->dtablesize) { - BSDTRACE((_T("Invalid Socket Descriptor (%d)\n"), sd)); + if ((unsigned int) (sd - 1) >= (unsigned int) sb->dtablesize) { + BSDTRACE ((_T("Invalid Socket Descriptor (%d)\n"), sd)); bsdsocklib_seterrno(ctx, sb, 38); /* ENOTSOCK */ return -1; } @@ -281,9 +280,9 @@ SOCKET_TYPE getsock(TrapContext *ctx, SB, int sd) return sb->dtable[sd - 1]; } -void releasesock(TrapContext *ctx, SB, int sd) +void releasesock (TrapContext *ctx, SB, int sd) { - if ((unsigned int)(sd - 1) < (unsigned int)sb->dtablesize) { + if ((unsigned int) (sd - 1) < (unsigned int) sb->dtablesize) { sb->dtable[sd - 1] = -1; callfdcallback(ctx, sb, sd - 1, FDCB_FREE); } @@ -296,14 +295,14 @@ struct socketbase *sbsigqueue; volatile int bsd_int_requested; #endif -void addtosigqueue(SB, int events) +void addtosigqueue (SB, int events) { - locksigqueue(); + locksigqueue (); if (events) sb->sigstosend |= sb->eventsigs; else - sb->sigstosend |= ((uae_u32)1) << sb->signal; + sb->sigstosend |= ((uae_u32) 1) << sb->signal; if (!sb->dosignal) { sb->nextsig = sbsigqueue; @@ -313,13 +312,13 @@ void addtosigqueue(SB, int events) bsd_int_requested |= 1; - unlocksigqueue(); + unlocksigqueue (); } void bsdsock_fake_int_handler(void) { - locksigqueue(); + locksigqueue (); bsd_int_requested = 0; @@ -328,7 +327,7 @@ void bsdsock_fake_int_handler(void) for (sb = sbsigqueue; sb; sb = sb->nextsig) { if (sb->dosignal == 1) { - uae_Signal(sb->ownertask, sb->sigstosend); + uae_Signal (sb->ownertask, sb->sigstosend); sb->sigstosend = 0; } sb->dosignal = 0; @@ -337,47 +336,46 @@ void bsdsock_fake_int_handler(void) sbsigqueue = NULL; } - unlocksigqueue(); + unlocksigqueue (); } -void waitsig(TrapContext *ctx, SB) +void waitsig (TrapContext *ctx, SB) { long sigs; - trap_call_add_dreg(ctx, 0, (((uae_u32)1) << sb->signal) | sb->eintrsigs); + trap_call_add_dreg(ctx, 0, (((uae_u32) 1) << sb->signal) | sb->eintrsigs); if ((sigs = trap_call_lib(ctx, sb->sysbase, -0x13e)) & sb->eintrsigs) { /* Wait */ - sockabort(sb); + sockabort (sb); bsdsocklib_seterrno(ctx, sb, 4); /* EINTR */ - // Set signal + // Set signal trap_call_add_dreg(ctx, 0, sigs); trap_call_add_dreg(ctx, 1, sb->eintrsigs); sigs = trap_call_lib(ctx, sb->sysbase, -0x132); /* SetSignal() */ sb->eintr = 1; - } - else + } else sb->eintr = 0; } -void cancelsig(TrapContext *ctx, SB) +void cancelsig (TrapContext *ctx, SB) { - locksigqueue(); + locksigqueue (); if (sb->dosignal) sb->dosignal = 2; - unlocksigqueue(); + unlocksigqueue (); trap_call_add_dreg(ctx, 0, 0); - trap_call_add_dreg(ctx, 1, ((uae_u32)1) << sb->signal); + trap_call_add_dreg(ctx, 1, ((uae_u32) 1) << sb->signal); trap_call_lib(ctx, sb->sysbase, -0x132); /* SetSignal() */ } /* Allocate and initialize per-task state structure */ -static struct socketbase *alloc_socketbase(TrapContext *ctx) +static struct socketbase *alloc_socketbase (TrapContext *ctx) { SB; int i; - if ((sb = xcalloc(struct socketbase, 1)) != NULL) { + if ((sb = xcalloc (struct socketbase, 1)) != NULL) { sb->ownertask = gettask(ctx); sb->sysbase = trap_get_long(ctx, 4); @@ -385,12 +383,12 @@ static struct socketbase *alloc_socketbase(TrapContext *ctx) sb->signal = trap_call_lib(ctx, sb->sysbase, -0x14A); /* AllocSignal */ if (sb->signal == -1) { - write_log(_T("bsdsocket: ERROR: Couldn't allocate signal for task 0x%08x.\n"), sb->ownertask); - free(sb); + write_log (_T("bsdsocket: ERROR: Couldn't allocate signal for task 0x%08x.\n"), sb->ownertask); + free (sb); return NULL; } - // trap_get_dreg(ctx, 0) = SCRATCHBUFSIZE; - // trap_get_dreg(ctx, 1) = 0; +// trap_get_dreg(ctx, 0) = SCRATCHBUFSIZE; +// trap_get_dreg(ctx, 1) = 0; sb->dtablesize = DEFAULT_DTABLE_SIZE; /* @@@ check malloc() result */ @@ -407,7 +405,7 @@ static struct socketbase *alloc_socketbase(TrapContext *ctx) if (!host_sbinit(ctx, sb)) { /* @@@ free everything */ - return NULL; + return NULL; } locksigqueue(); @@ -423,16 +421,16 @@ static struct socketbase *alloc_socketbase(TrapContext *ctx) return NULL; } -STATIC_INLINE struct socketbase *get_socketbase(TrapContext *ctx) +STATIC_INLINE struct socketbase *get_socketbase (TrapContext *ctx) { - return (struct socketbase*)get_pointer(trap_get_areg(ctx, 6) + offsetof(struct UAEBSDBase, sb)); + return (struct socketbase*)get_pointer (trap_get_areg(ctx, 6) + offsetof (struct UAEBSDBase, sb)); } -static void free_socketbase(TrapContext *ctx) +static void free_socketbase (TrapContext *ctx) { struct socketbase *sb, *nsb; - if ((sb = get_socketbase(ctx)) != NULL) { + if ((sb = get_socketbase (ctx)) != NULL) { trap_call_add_dreg(ctx, 0, sb->signal); trap_call_lib(ctx, sb->sysbase, -0x150); /* FreeSignal */ @@ -454,12 +452,12 @@ static void free_socketbase(TrapContext *ctx) trap_call_lib(ctx, sb->sysbase, -0xD2); /* FreeMem */ } - host_sbcleanup(sb); + host_sbcleanup (sb); - free(sb->dtable); - free(sb->ftable); + free (sb->dtable); + free (sb->ftable); - locksigqueue(); + locksigqueue (); if (sb == socketbases) socketbases = sb->next; @@ -485,27 +483,27 @@ static void free_socketbase(TrapContext *ctx) } #endif - unlocksigqueue(); + unlocksigqueue (); - free(sb); + free (sb); } } -static uae_u32 REGPARAM2 bsdsocklib_Expunge(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_Expunge (TrapContext *ctx) { - BSDTRACE((_T("Expunge() -> [ignored]\n"))); + BSDTRACE ((_T("Expunge() -> [ignored]\n"))); return 0; } static uae_u32 functable, datatable, inittable; -static uae_u32 REGPARAM2 bsdsocklib_Open(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_Open (TrapContext *ctx) { uae_u32 result = 0; int opencount; SB; - BSDTRACE((_T("OpenLibrary() -> "))); + BSDTRACE ((_T("OpenLibrary() -> "))); if ((sb = alloc_socketbase(ctx)) != NULL) { trap_put_word(ctx, SockLibBase + 32, opencount = trap_get_word(ctx, SockLibBase + 32) + 1); @@ -513,26 +511,25 @@ static uae_u32 REGPARAM2 bsdsocklib_Open(TrapContext *ctx) trap_call_add_areg(ctx, 0, functable); trap_call_add_areg(ctx, 1, datatable); trap_call_add_areg(ctx, 2, 0); - trap_call_add_dreg(ctx, 0, sizeof(struct UAEBSDBase)); + trap_call_add_dreg(ctx, 0, sizeof (struct UAEBSDBase)); trap_call_add_dreg(ctx, 1, 0); result = trap_call_lib(ctx, sb->sysbase, -0x54); /* MakeLibrary */ - put_pointer(result + offsetof(struct UAEBSDBase, sb), sb); + put_pointer (result + offsetof (struct UAEBSDBase, sb), sb); - BSDTRACE((_T("%0x [%d]\n"), result, opencount)); - } - else - BSDTRACE((_T("failed (out of memory)\n"))); + BSDTRACE ((_T("%0x [%d]\n"), result, opencount)); + } else + BSDTRACE ((_T("failed (out of memory)\n"))); return result; } -static uae_u32 REGPARAM2 bsdsocklib_Close(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_Close (TrapContext *ctx) { int opencount; uae_u32 base = trap_get_areg(ctx, 6); - uae_u32 negsize = get_word(base + 16); + uae_u32 negsize = get_word (base + 16); free_socketbase(ctx); @@ -542,155 +539,155 @@ static uae_u32 REGPARAM2 bsdsocklib_Close(TrapContext *ctx) trap_call_add_dreg(ctx, 0, negsize + trap_get_word(ctx, base + 18)); trap_call_lib(ctx, trap_get_long(ctx, 4), -0xD2); /* FreeMem */ - BSDTRACE((_T("CloseLibrary() -> [%d]\n"), opencount)); + BSDTRACE ((_T("CloseLibrary() -> [%d]\n"), opencount)); return 0; } /* socket(domain, type, protocol)(d0/d1/d2) */ -static uae_u32 REGPARAM2 bsdsocklib_socket(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_socket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); return host_socket(ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2)); } /* bind(s, name, namelen)(d0/a0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_bind(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_bind (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); return host_bind(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_dreg(ctx, 1)); } /* listen(s, backlog)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_listen(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_listen (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); return host_listen(ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1)); } /* accept(s, addr, addrlen)(d0/a0/a1) */ -static uae_u32 REGPARAM2 bsdsocklib_accept(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_accept (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); host_accept(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1)); return sb->resultval; } /* connect(s, name, namelen)(d0/a0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_connect(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_connect (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); host_connect(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_dreg(ctx, 1)); return sb->sb_errno ? -1 : 0; } /* sendto(s, msg, len, flags, to, tolen)(d0/a0/d1/d2/a1/d3) */ -static uae_u32 REGPARAM2 bsdsocklib_sendto(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_sendto (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); host_sendto(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), NULL, trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), trap_get_areg(ctx, 1), trap_get_dreg(ctx, 3)); return sb->resultval; } /* send(s, msg, len, flags)(d0/a0/d1/d2) */ -static uae_u32 REGPARAM2 bsdsocklib_send(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_send (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); host_sendto(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), NULL, trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), 0, 0); return sb->resultval; } /* recvfrom(s, buf, len, flags, from, fromlen)(d0/a0/d1/d2/a1/a2) */ -static uae_u32 REGPARAM2 bsdsocklib_recvfrom(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_recvfrom (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); host_recvfrom(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), NULL, trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), trap_get_areg(ctx, 1), trap_get_areg(ctx, 2)); return sb->resultval; } /* recv(s, buf, len, flags)(d0/a0/d1/d2) */ -static uae_u32 REGPARAM2 bsdsocklib_recv(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_recv (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); host_recvfrom(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), NULL, trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), 0, 0); return sb->resultval; } /* shutdown(s, how)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_shutdown(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_shutdown (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); - return host_shutdown(ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1)); + struct socketbase *sb = get_socketbase (ctx); + return host_shutdown (ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1)); } /* setsockopt(s, level, optname, optval, optlen)(d0/d1/d2/a0/d3) */ -static uae_u32 REGPARAM2 bsdsocklib_setsockopt(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_setsockopt (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); - host_setsockopt(ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), + struct socketbase *sb = get_socketbase (ctx); + host_setsockopt (ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), trap_get_areg(ctx, 0), trap_get_dreg(ctx, 3)); return sb->resultval; } /* getsockopt(s, level, optname, optval, optlen)(d0/d1/d2/a0/a1) */ -static uae_u32 REGPARAM2 bsdsocklib_getsockopt(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_getsockopt (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); - return host_getsockopt(ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), + struct socketbase *sb = get_socketbase (ctx); + return host_getsockopt (ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1)); } /* getsockname(s, hostname, namelen)(d0/a0/a1) */ -static uae_u32 REGPARAM2 bsdsocklib_getsockname(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_getsockname (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); - return host_getsockname(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1)); + struct socketbase *sb = get_socketbase (ctx); + return host_getsockname (ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1)); } /* getpeername(s, hostname, namelen)(d0/a0/a1) */ -static uae_u32 REGPARAM2 bsdsocklib_getpeername(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_getpeername (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); - return host_getpeername(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1)); + struct socketbase *sb = get_socketbase (ctx); + return host_getpeername (ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1)); } /* *------ generic system calls related to sockets */ /* IoctlSocket(d, request, argp)(d0/d1/a0) */ -static uae_u32 REGPARAM2 bsdsocklib_IoctlSocket(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_IoctlSocket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); return host_IoctlSocket(ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_areg(ctx, 0)); } /* *------ AmiTCP/IP specific stuff */ /* CloseSocket(d)(d0) */ -static uae_u32 REGPARAM2 bsdsocklib_CloseSocket(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_CloseSocket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); return host_CloseSocket(ctx, sb, trap_get_dreg(ctx, 0)); } /* WaitSelect(nfds, readfds, writefds, execptfds, timeout, maskp)(d0/a0/a1/a2/a3/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_WaitSelect(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_WaitSelect (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); host_WaitSelect(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), trap_get_areg(ctx, 1), trap_get_areg(ctx, 2), trap_get_areg(ctx, 3), trap_get_dreg(ctx, 1)); return sb->resultval; } /* SetSocketSignals(SIGINTR, SIGIO, SIGURG)(d0/d1/d2) */ -static uae_u32 REGPARAM2 bsdsocklib_SetSocketSignals(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_SetSocketSignals (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); - BSDTRACE((_T("SetSocketSignals(0x%08x,0x%08x,0x%08x) -> "), trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2))); + BSDTRACE ((_T("SetSocketSignals(0x%08x,0x%08x,0x%08x) -> "), trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2))); sb->eintrsigs = trap_get_dreg(ctx, 0); sb->eventsigs = trap_get_dreg(ctx, 1); @@ -698,7 +695,7 @@ static uae_u32 REGPARAM2 bsdsocklib_SetSocketSignals(TrapContext *ctx) } /* SetDTableSize(size)(d0) */ -static uae_u32 bsdsocklib_SetDTableSize(SB, int newSize) +static uae_u32 bsdsocklib_SetDTableSize (SB, int newSize) { TrapContext *ctx = NULL; int *newdtable; @@ -711,9 +708,9 @@ static uae_u32 bsdsocklib_SetDTableSize(SB, int newSize) return 0; } - newdtable = xcalloc(int, newSize); - newftable = xcalloc(int, newSize); - newmtable = xcalloc(unsigned int, newSize); + newdtable = xcalloc (int, newSize); + newftable = xcalloc (int, newSize); + newmtable = xcalloc (unsigned int, newSize); if (newdtable == NULL || newftable == NULL || newmtable == NULL) { sb->resultval = -1; @@ -724,9 +721,9 @@ static uae_u32 bsdsocklib_SetDTableSize(SB, int newSize) return -1; } - memcpy(newdtable, sb->dtable, sb->dtablesize * sizeof(*sb->dtable)); - memcpy(newftable, sb->ftable, sb->dtablesize * sizeof(*sb->ftable)); - memcpy(newmtable, sb->mtable, sb->dtablesize * sizeof(*sb->mtable)); + memcpy (newdtable, sb->dtable, sb->dtablesize * sizeof(*sb->dtable)); + memcpy (newftable, sb->ftable, sb->dtablesize * sizeof(*sb->ftable)); + memcpy (newmtable, sb->mtable, sb->dtablesize * sizeof(*sb->mtable)); for (i = sb->dtablesize + 1; i < newSize; i++) newdtable[i] = -1; @@ -741,7 +738,7 @@ static uae_u32 bsdsocklib_SetDTableSize(SB, int newSize) return 0; } -static int sockpoolindex(long id) +static int sockpoolindex (long id) { int i; @@ -752,9 +749,9 @@ static int sockpoolindex(long id) } /* ObtainSocket(id, domain, type, protocol)(d0/d1/d2/d3) */ -static uae_u32 REGPARAM2 bsdsocklib_ObtainSocket(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_ObtainSocket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); int sd; int id; SOCKET_TYPE s; @@ -762,19 +759,19 @@ static uae_u32 REGPARAM2 bsdsocklib_ObtainSocket(TrapContext *ctx) id = trap_get_dreg(ctx, 0); - BSDTRACE((_T("ObtainSocket(%d,%d,%d,%d) -> "), id, trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), trap_get_dreg(ctx, 3))); + BSDTRACE ((_T("ObtainSocket(%d,%d,%d,%d) -> "), id, trap_get_dreg(ctx, 1), trap_get_dreg(ctx, 2), trap_get_dreg(ctx, 3))); - i = sockpoolindex(id); + i = sockpoolindex (id); if (i == -1) { - BSDTRACE((_T("[invalid key]\n"))); + BSDTRACE ((_T("[invalid key]\n"))); return -1; } s = sockdata->sockpoolsocks[i]; sd = getsd(ctx, sb, s); - BSDTRACE((_T(" -> Socket=%d\n"), sd)); + BSDTRACE ((_T(" -> Socket=%d\n"), sd)); if (sd != -1) { sb->ftable[sd - 1] = sockdata->sockpoolflags[i]; @@ -787,9 +784,9 @@ static uae_u32 REGPARAM2 bsdsocklib_ObtainSocket(TrapContext *ctx) } /* ReleaseSocket(fd, id)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); int sd; int id; SOCKET_TYPE s; @@ -800,51 +797,49 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket(TrapContext *ctx) id = trap_get_dreg(ctx, 1); sd++; - BSDTRACE((_T("ReleaseSocket(%d,%d) -> "), sd, id)); + BSDTRACE ((_T("ReleaseSocket(%d,%d) -> "), sd, id)); - s = getsock(ctx, sb, sd); + s = getsock (ctx, sb, sd); if (s != -1) { flags = sb->ftable[sd - 1]; if (flags & REP_ALL) { - write_log(_T("bsdsocket: ERROR: ReleaseSocket() is not supported for sockets with async event notification enabled!\n")); + write_log (_T("bsdsocket: ERROR: ReleaseSocket() is not supported for sockets with async event notification enabled!\n")); return -1; } releasesock(ctx, sb, sd); if (id == UNIQUE_ID) { for (;;) { - if (sockpoolindex(curruniqid) == -1) + if (sockpoolindex (curruniqid) == -1) break; curruniqid += 129; - if ((unsigned long)(curruniqid + 1) < 65536) + if ((unsigned long) (curruniqid + 1) < 65536) curruniqid += 65537; } id = curruniqid; - } - else if (id < 0 && id > 65535) { - if (sockpoolindex(id) != -1) { - BSDTRACE((_T("[unique ID already exists]\n"))); + } else if (id < 0 && id > 65535) { + if (sockpoolindex (id) != -1) { + BSDTRACE ((_T("[unique ID already exists]\n"))); return -1; } } - i = sockpoolindex(-1); + i = sockpoolindex (-1); if (i == -1) { - BSDTRACE((_T("-1\n"))); - write_log(_T("bsdsocket: ERROR: Global socket pool overflow\n")); + BSDTRACE ((_T("-1\n"))); + write_log (_T("bsdsocket: ERROR: Global socket pool overflow\n")); return -1; } sockdata->sockpoolids[i] = id; sockdata->sockpoolsocks[i] = s; sockdata->sockpoolflags[i] = flags; - BSDTRACE((_T("id %d s 0x%x\n"), id, s)); - } - else { - BSDTRACE((_T("[invalid socket descriptor]\n"))); + BSDTRACE ((_T("id %d s 0x%x\n"), id,s)); + } else { + BSDTRACE ((_T("[invalid socket descriptor]\n"))); return -1; } @@ -852,9 +847,9 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket(TrapContext *ctx) } /* ReleaseCopyOfSocket(fd, id)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_ReleaseCopyOfSocket(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_ReleaseCopyOfSocket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); int sd; int id; SOCKET_TYPE s; @@ -865,50 +860,48 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseCopyOfSocket(TrapContext *ctx) id = trap_get_dreg(ctx, 1); sd++; - BSDTRACE((_T("ReleaseSocket(%d,%d) -> "), sd, id)); + BSDTRACE ((_T("ReleaseSocket(%d,%d) -> "), sd, id)); - s = getsock(ctx, sb, sd); + s = getsock (ctx, sb, sd); if (s != -1) { flags = sb->ftable[sd - 1]; if (flags & REP_ALL) { - write_log(_T("bsdsocket: ERROR: ReleaseCopyOfSocket() is not supported for sockets with async event notification enabled!\n")); + write_log (_T("bsdsocket: ERROR: ReleaseCopyOfSocket() is not supported for sockets with async event notification enabled!\n")); return -1; } if (id == UNIQUE_ID) { for (;;) { - if (sockpoolindex(curruniqid) == -1) + if (sockpoolindex (curruniqid) == -1) break; curruniqid += 129; - if ((unsigned long)(curruniqid + 1) < 65536) + if ((unsigned long) (curruniqid + 1) < 65536) curruniqid += 65537; } id = curruniqid; - } - else if (id < 0 && id > 65535) { - if (sockpoolindex(id) != -1) { - BSDTRACE((_T("[unique ID already exists]\n"))); + } else if (id < 0 && id > 65535) { + if (sockpoolindex (id) != -1) { + BSDTRACE ((_T("[unique ID already exists]\n"))); return -1; } } - i = sockpoolindex(-1); + i = sockpoolindex (-1); if (i == -1) { - BSDTRACE((_T("-1\n"))); - write_log(_T("bsdsocket: ERROR: Global socket pool overflow\n")); + BSDTRACE ((_T("-1\n"))); + write_log (_T("bsdsocket: ERROR: Global socket pool overflow\n")); return -1; } sockdata->sockpoolids[i] = id; sockdata->sockpoolsocks[i] = s; sockdata->sockpoolflags[i] = flags; - BSDTRACE((_T("id %d s 0x%x\n"), id, s)); + BSDTRACE ((_T("id %d s 0x%x\n"), id,s)); - } - else { + } else { - BSDTRACE((_T("[invalid socket descriptor]\n"))); + BSDTRACE ((_T("[invalid socket descriptor]\n"))); return -1; } @@ -916,26 +909,26 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseCopyOfSocket(TrapContext *ctx) } /* Errno()() */ -static uae_u32 REGPARAM2 bsdsocklib_Errno(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_Errno (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); - BSDTRACE((_T("Errno() -> %d\n"), sb->sb_errno)); + struct socketbase *sb = get_socketbase (ctx); + BSDTRACE ((_T("Errno() -> %d\n"), sb->sb_errno)); return sb->sb_errno; } /* SetErrnoPtr(errno_p, size)(a0/d0) */ -static uae_u32 REGPARAM2 bsdsocklib_SetErrnoPtr(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_SetErrnoPtr (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); uae_u32 errnoptr = trap_get_areg(ctx, 0); uae_u32 size = trap_get_dreg(ctx, 0); - BSDTRACE((_T("SetErrnoPtr(0x%08x,%d) -> "), errnoptr, size)); + BSDTRACE ((_T("SetErrnoPtr(0x%08x,%d) -> "), errnoptr, size)); if (size == 1 || size == 2 || size == 4) { sb->errnoptr = errnoptr; sb->errnosize = size; - BSDTRACE((_T("OK\n"))); + BSDTRACE ((_T("OK\n"))); return 0; } bsdsocklib_seterrno(ctx, sb, 22); /* EINVAL */ @@ -945,127 +938,127 @@ static uae_u32 REGPARAM2 bsdsocklib_SetErrnoPtr(TrapContext *ctx) /* *------ inet library calls related to inet address manipulation */ /* Inet_NtoA(in)(d0) */ -static uae_u32 REGPARAM2 bsdsocklib_Inet_NtoA(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_Inet_NtoA (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); return host_Inet_NtoA(ctx, sb, trap_get_dreg(ctx, 0)); } /* inet_addr(cp)(a0) */ -static uae_u32 REGPARAM2 bsdsocklib_inet_addr(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_inet_addr (TrapContext *ctx) { return host_inet_addr(ctx, trap_get_areg(ctx, 0)); } /* Inet_LnaOf(in)(d0) */ -static uae_u32 REGPARAM2 bsdsocklib_Inet_LnaOf(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_Inet_LnaOf (TrapContext *ctx) { - write_log(_T("bsdsocket: UNSUPPORTED: Inet_LnaOf()\n")); + write_log (_T("bsdsocket: UNSUPPORTED: Inet_LnaOf()\n")); return 0; } /* Inet_NetOf(in)(d0) */ -static uae_u32 REGPARAM2 bsdsocklib_Inet_NetOf(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_Inet_NetOf (TrapContext *ctx) { - write_log(_T("bsdsocket: UNSUPPORTED: Inet_NetOf()\n")); + write_log (_T("bsdsocket: UNSUPPORTED: Inet_NetOf()\n")); return 0; } /* Inet_MakeAddr(net, host)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_Inet_MakeAddr(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_Inet_MakeAddr (TrapContext *ctx) { - write_log(_T("bsdsocket: UNSUPPORTED: Inet_MakeAddr()\n")); + write_log (_T("bsdsocket: UNSUPPORTED: Inet_MakeAddr()\n")); return 0; } /* inet_network(cp)(a0) */ -static uae_u32 REGPARAM2 bsdsocklib_inet_network(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_inet_network (TrapContext *ctx) { return host_inet_addr(ctx, trap_get_areg(ctx, 0)); } /* *------ gethostbyname etc */ /* gethostbyname(name)(a0) */ -static uae_u32 REGPARAM2 bsdsocklib_gethostbyname(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_gethostbyname (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); host_gethostbynameaddr(ctx, sb, trap_get_areg(ctx, 0), 0, -1); return sb->sb_herrno ? 0 : sb->hostent; } /* gethostbyaddr(addr, len, type)(a0/d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_gethostbyaddr(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_gethostbyaddr (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); host_gethostbynameaddr(ctx, sb, trap_get_areg(ctx, 0), trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1)); return sb->sb_herrno ? 0 : sb->hostent; } /* getnetbyname(name)(a0) */ -static uae_u32 REGPARAM2 bsdsocklib_getnetbyname(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_getnetbyname (TrapContext *ctx) { - write_log(_T("bsdsocket: UNSUPPORTED: getnetbyname()\n")); + write_log (_T("bsdsocket: UNSUPPORTED: getnetbyname()\n")); return 0; } /* getnetbyaddr(net, type)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_getnetbyaddr(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_getnetbyaddr (TrapContext *ctx) { - write_log(_T("bsdsocket: UNSUPPORTED: getnetbyaddr()\n")); + write_log (_T("bsdsocket: UNSUPPORTED: getnetbyaddr()\n")); return 0; } /* getservbyname(name, proto)(a0/a1) */ -static uae_u32 REGPARAM2 bsdsocklib_getservbyname(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_getservbyname (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); host_getservbynameport(ctx, sb, trap_get_areg(ctx, 0), trap_get_areg(ctx, 1), 0); return sb->sb_errno ? 0 : sb->servent; } /* getservbyport(port, proto)(d0/a0) */ -static uae_u32 REGPARAM2 bsdsocklib_getservbyport(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_getservbyport (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); host_getservbynameport(ctx, sb, trap_get_dreg(ctx, 0), trap_get_areg(ctx, 0), 1); return sb->sb_errno ? 0 : sb->servent; } /* getprotobyname(name)(a0) */ -static uae_u32 REGPARAM2 bsdsocklib_getprotobyname(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_getprotobyname (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); host_getprotobyname(ctx, sb, trap_get_areg(ctx, 0)); return sb->sb_errno ? 0 : sb->protoent; } /* getprotobynumber(proto)(d0) */ -static uae_u32 REGPARAM2 bsdsocklib_getprotobynumber(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_getprotobynumber (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); host_getprotobynumber(ctx, sb, trap_get_dreg(ctx, 0)); return sb->sb_errno ? 0 : sb->protoent; } /* *------ AmiTCP/IP 1.1 extensions */ /* Dup2Socket(fd1, fd2)(d0/d1) */ -static uae_u32 REGPARAM2 bsdsocklib_Dup2Socket(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_Dup2Socket (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); return host_dup2socket(ctx, sb, trap_get_dreg(ctx, 0), trap_get_dreg(ctx, 1)); } #define MSG_EOR 0x08 /* data completes record */ #define MSG_TRUNC 0x10 /* data discarded before delivery */ -static uae_u32 REGPARAM2 bsdsocklib_sendmsg(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_sendmsg (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); uaecptr sd = trap_get_dreg(ctx, 0); uaecptr msg = trap_get_areg(ctx, 0); uae_u32 flags = trap_get_dreg(ctx, 1); - SOCKET s = getsock(ctx, sb, sd + 1); + SOCKET s = getsock (ctx, sb, sd + 1); if (s == INVALID_SOCKET) return -1; @@ -1108,14 +1101,14 @@ static uae_u32 REGPARAM2 bsdsocklib_sendmsg(TrapContext *ctx) return sb->resultval; } -static uae_u32 REGPARAM2 bsdsocklib_recvmsg(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_recvmsg (TrapContext *ctx) { - struct socketbase *sb = get_socketbase(ctx); + struct socketbase *sb = get_socketbase (ctx); uaecptr sd = trap_get_dreg(ctx, 0); uaecptr msg = trap_get_areg(ctx, 0); uae_u32 flags = trap_get_dreg(ctx, 1); - SOCKET s = getsock(ctx, sb, sd + 1); + SOCKET s = getsock (ctx, sb, sd + 1); if (s == INVALID_SOCKET) return -1; @@ -1165,20 +1158,20 @@ static uae_u32 REGPARAM2 bsdsocklib_recvmsg(TrapContext *ctx) return sb->resultval; } -static uae_u32 REGPARAM2 bsdsocklib_gethostname(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_gethostname (TrapContext *ctx) { return host_gethostname(ctx, trap_get_areg(ctx, 0), trap_get_dreg(ctx, 0)); } -static uae_u32 REGPARAM2 bsdsocklib_gethostid(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_gethostid (TrapContext *ctx) { - write_log(_T("bsdsocket: WARNING: Process %08x calls deprecated function gethostid() - returning 127.0.0.1\n"), + write_log (_T("bsdsocket: WARNING: Process %08x calls deprecated function gethostid() - returning 127.0.0.1\n"), trap_get_long(ctx, gettask(ctx) + 10)); return 0x7f000001; } static const TCHAR *errortexts[] = -{ _T("No error"), _T("Operation not permitted"), _T("No such file or directory"), +{_T("No error"), _T("Operation not permitted"), _T("No such file or directory"), _T("No such process"), _T("Interrupted system call"), _T("Input/output error"), _T("Device not configured"), _T("Argument list too long"), _T("Exec format error"), _T("Bad file descriptor"), _T("No child processes"), _T("Resource deadlock avoided"), _T("Cannot allocate memory"), _T("Permission denied"), _T("Bad address"), @@ -1201,88 +1194,88 @@ _T("File name too long"), _T("Host is down"), _T("No route to host"), _T("Direct _T("Too many processes"), _T("Too many users"), _T("Disc quota exceeded"), _T("Stale NFS file handle"), _T("Too many levels of remote in path"), _T("RPC struct is bad"), _T("RPC version wrong"), _T("RPC prog. not avail"), _T("Program version wrong"), _T("Bad procedure for program"), _T("No locks available"), -_T("Function not implemented"), _T("Inappropriate file type or format"), _T("PError 0") }; +_T("Function not implemented"), _T("Inappropriate file type or format"), _T("PError 0")}; -static uae_u32 errnotextptrs[sizeof(errortexts) / sizeof(*errortexts)]; -static const uae_u32 number_sys_error = sizeof(errortexts) / sizeof(*errortexts); +static uae_u32 errnotextptrs[sizeof (errortexts) / sizeof (*errortexts)]; +static const uae_u32 number_sys_error = sizeof (errortexts) / sizeof (*errortexts); /* *------ syslog functions */ /* Syslog(level, format, ap)(d0/a0/a1) */ -static uae_u32 REGPARAM2 bsdsocklib_vsyslog(TrapContext *ctx) +static uae_u32 REGPARAM2 bsdsocklib_vsyslog (TrapContext *ctx) { return 0; } static const TCHAR *herrortexts[] = -{ _T("No error"), _T("Unknown host"), _T("Host name lookup failure"), _T("Unknown server error"), -_T("No address associated with name") }; +{_T("No error"), _T("Unknown host"), _T("Host name lookup failure"), _T("Unknown server error"), +_T("No address associated with name")}; -static uae_u32 herrnotextptrs[sizeof(herrortexts) / sizeof(*herrortexts)]; -static const uae_u32 number_host_error = sizeof(herrortexts) / sizeof(*herrortexts); +static uae_u32 herrnotextptrs[sizeof (herrortexts) / sizeof (*herrortexts)]; +static const uae_u32 number_host_error = sizeof (herrortexts) / sizeof (*herrortexts); -static const TCHAR *sana2io_errlist[] = +static const TCHAR *sana2io_errlist[] = { - _T("No error"), /* S2ERR_NO_ERROR */ - _T("Resource allocation failure"), /* S2ERR_NO_RESOURCES */ - _T("Unknown error code (2)"), - _T("Invalid argument"), /* S2ERR_BAD_ARGUMENT */ - _T("Inappropriate state"), /* S2ERR_BAD_STATE */ - _T("Invalid address"), /* S2ERR_BAD_ADDRESS */ - _T("Requested packet too large"), /* S2ERR_MTU_EXCEEDED */ - _T("Unknown error (7)"), - _T("Command is not supporter"), /* S2ERR_NOT_SUPPORTED */ - _T("Driver software error detected"), /* S2ERR_SOFTWARE */ - _T("Device driver is offline"), /* S2ERR_OUTOFSERVICE */ - _T("Transmission attempt failed") /* S2ERR_TX_FAILURE */ + _T("No error"), /* S2ERR_NO_ERROR */ + _T("Resource allocation failure"), /* S2ERR_NO_RESOURCES */ + _T("Unknown error code (2)"), + _T("Invalid argument"), /* S2ERR_BAD_ARGUMENT */ + _T("Inappropriate state"), /* S2ERR_BAD_STATE */ + _T("Invalid address"), /* S2ERR_BAD_ADDRESS */ + _T("Requested packet too large"), /* S2ERR_MTU_EXCEEDED */ + _T("Unknown error (7)"), + _T("Command is not supporter"), /* S2ERR_NOT_SUPPORTED */ + _T("Driver software error detected"), /* S2ERR_SOFTWARE */ + _T("Device driver is offline"), /* S2ERR_OUTOFSERVICE */ + _T("Transmission attempt failed") /* S2ERR_TX_FAILURE */ }; -static uae_u32 sana2iotextptrs[sizeof(sana2io_errlist) / sizeof(*sana2io_errlist)]; -static const uae_u32 number_sana2io_error = sizeof(sana2io_errlist) / sizeof(*sana2io_errlist); +static uae_u32 sana2iotextptrs[sizeof (sana2io_errlist) / sizeof (*sana2io_errlist)]; +static const uae_u32 number_sana2io_error = sizeof (sana2io_errlist) / sizeof (*sana2io_errlist); -static const TCHAR *sana2wire_errlist[] = +static const TCHAR *sana2wire_errlist[] = { - _T("Generic error: 0"), /* S2WERR_GENERIC_ERROR */ - _T("Unit not configured"), /* S2WERR_NOT_CONFIGURED */ - _T("Unit is currently online"), /* S2WERR_UNIT_ONLINE */ - _T("Unit is currently offline"), /* S2WERR_UNIT_OFFLINE */ - _T("Protocol already tracked"), /* S2WERR_ALREADY_TRACKED */ - _T("Protocol not tracked"), /* S2WERR_NOT_TRACKED */ - _T("Buff management function error"), /* S2WERR_BUFF_ERROR */ - _T("Source address error"), /* S2WERR_SRC_ADDRESS */ - _T("Destination address error"), /* S2WERR_DST_ADDRESS */ - _T("Broadcast address error"), /* S2WERR_BAD_BROADCAST */ - _T("Multicast address error"), /* S2WERR_BAD_MULTICAST */ - _T("Multicast address list full"), /* S2WERR_MULTICAST_FULL */ - _T("Unsupported event class"), /* S2WERR_BAD_EVENT */ - _T("Statdata failed sanity check"), /* S2WERR_BAD_STATDATA */ - _T("Unknown wire error (14)"), - _T("Attempt to config twice"), /* S2WERR_IS_CONFIGURED */ - _T("Null pointer detected"), /* S2WERR_NULL_POINTER */ - _T("tx failed - too many retries"), /* S2WERR_TOO_MANY_RETIRES */ - _T("Driver fixable HW error") /* S2WERR_RCVREL_HDW_ERR */ + _T("Generic error: 0"), /* S2WERR_GENERIC_ERROR */ + _T("Unit not configured"), /* S2WERR_NOT_CONFIGURED */ + _T("Unit is currently online"), /* S2WERR_UNIT_ONLINE */ + _T("Unit is currently offline"), /* S2WERR_UNIT_OFFLINE */ + _T("Protocol already tracked"), /* S2WERR_ALREADY_TRACKED */ + _T("Protocol not tracked"), /* S2WERR_NOT_TRACKED */ + _T("Buff management function error"), /* S2WERR_BUFF_ERROR */ + _T("Source address error"), /* S2WERR_SRC_ADDRESS */ + _T("Destination address error"), /* S2WERR_DST_ADDRESS */ + _T("Broadcast address error"), /* S2WERR_BAD_BROADCAST */ + _T("Multicast address error"), /* S2WERR_BAD_MULTICAST */ + _T("Multicast address list full"), /* S2WERR_MULTICAST_FULL */ + _T("Unsupported event class"), /* S2WERR_BAD_EVENT */ + _T("Statdata failed sanity check"), /* S2WERR_BAD_STATDATA */ + _T("Unknown wire error (14)"), + _T("Attempt to config twice"), /* S2WERR_IS_CONFIGURED */ + _T("Null pointer detected"), /* S2WERR_NULL_POINTER */ + _T("tx failed - too many retries"), /* S2WERR_TOO_MANY_RETIRES */ + _T("Driver fixable HW error") /* S2WERR_RCVREL_HDW_ERR */ }; -static uae_u32 sana2wiretextptrs[sizeof(sana2wire_errlist) / sizeof(*sana2wire_errlist)]; -static const uae_u32 number_sana2wire_error = sizeof(sana2wire_errlist) / sizeof(*sana2wire_errlist); +static uae_u32 sana2wiretextptrs[sizeof (sana2wire_errlist) / sizeof (*sana2wire_errlist)]; +static const uae_u32 number_sana2wire_error = sizeof (sana2wire_errlist) / sizeof (*sana2wire_errlist); -static const TCHAR *io_errlist[] = -{ - _T("Unknown error"), /* 0 */ - _T("Device or unit failed to open"), /* IOERR_OPENFAIL */ - _T("Request aborted"), /* IOERR_ABORTED */ - _T("Command not supported by device"), /* IOERR_NOCMD */ - _T("Invalid length"), /* IOERR_BADLENGTH */ - _T("Invalid address"), /* IOERR_BADADDRESS */ - _T("Requested unit is busy"), /* IOERR_UNITBUSY */ - _T("Hardware self-test failed") /* IOERR_SELFTEST */ +static const TCHAR *io_errlist[] = +{ + _T("Unknown error"), /* 0 */ + _T("Device or unit failed to open"), /* IOERR_OPENFAIL */ + _T("Request aborted"), /* IOERR_ABORTED */ + _T("Command not supported by device"), /* IOERR_NOCMD */ + _T("Invalid length"), /* IOERR_BADLENGTH */ + _T("Invalid address"), /* IOERR_BADADDRESS */ + _T("Requested unit is busy"), /* IOERR_UNITBUSY */ + _T("Hardware self-test failed") /* IOERR_SELFTEST */ }; -static uae_u32 iotextptrs[sizeof(io_errlist) / sizeof(*io_errlist)]; -static const uae_u32 number_io_error = sizeof(io_errlist) / sizeof(*io_errlist); +static uae_u32 iotextptrs[sizeof (io_errlist) / sizeof (*io_errlist)]; +static const uae_u32 number_io_error = sizeof (io_errlist) / sizeof (*io_errlist); static const TCHAR * const strErr = _T("Errlist lookup error"); @@ -1338,17 +1331,17 @@ static void tagcopy(TrapContext *ctx, uae_u32 currtag, uae_u32 currval, uae_u32 { switch (currtag & 0x8001) { - case 0x0000: /* SBTM_GETVAL */ + case 0x0000: /* SBTM_GETVAL */ trap_put_long(ctx, tagptr + 4, ptr ? *ptr : 0); break; - case 0x8000: /* SBTM_GETREF */ + case 0x8000: /* SBTM_GETREF */ trap_put_long(ctx, currval, ptr ? *ptr : 0); break; - case 0x0001: /* SBTM_SETVAL */ + case 0x0001: /* SBTM_SETVAL */ if (ptr) *ptr = currval; break; - default: /* SBTM_SETREF */ + default: /* SBTM_SETREF */ if (ptr) *ptr = trap_get_long(ctx, currval); break; @@ -1363,7 +1356,7 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList(TrapContext *ctx) uae_u32 currtag; uae_u32 currval; - BSDTRACE((_T("SocketBaseTagList("))); + BSDTRACE ((_T("SocketBaseTagList("))); for (;;) { currtag = trap_get_long(ctx, tagptr); @@ -1374,251 +1367,234 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList(TrapContext *ctx) switch (currtag) { - case TAG_DONE: - BSDTRACE((_T("TAG_DONE"))); - tagsprocessed = 0; - goto done; - case TAG_IGNORE: - BSDTRACE((_T("TAG_IGNORE"))); - break; - case TAG_MORE: - BSDTRACE((_T("TAG_MORE(0x%x)"), currval)); - tagptr = currval; - break; - case TAG_SKIP: - BSDTRACE((_T("TAG_SKIP(%d)"), currval)); - tagptr += currval * 8; - break; - default: - write_log(_T("bsdsocket: WARNING: Unsupported tag type (%08x) in SocketBaseTagList(%x)\n"), - currtag, trap_get_areg(ctx, 0)); - goto done; + case TAG_DONE: + BSDTRACE ((_T("TAG_DONE"))); + tagsprocessed = 0; + goto done; + case TAG_IGNORE: + BSDTRACE ((_T("TAG_IGNORE"))); + break; + case TAG_MORE: + BSDTRACE ((_T("TAG_MORE(0x%x)"), currval)); + tagptr = currval; + break; + case TAG_SKIP: + BSDTRACE ((_T("TAG_SKIP(%d)"), currval)); + tagptr += currval * 8; + break; + default: + write_log (_T("bsdsocket: WARNING: Unsupported tag type (%08x) in SocketBaseTagList(%x)\n"), + currtag, trap_get_areg(ctx, 0)); + goto done; } - } - else { + } else { - BSDTRACE((_T("SBTM_"))); - BSDTRACE((currtag & 0x0001 ? _T("SET") : _T("GET"))); - BSDTRACE((currtag & 0x8000 ? _T("REF(") : _T("VAL("))); + BSDTRACE ((_T("SBTM_"))); + BSDTRACE ((currtag & 0x0001 ? _T("SET") : _T("GET"))); + BSDTRACE ((currtag & 0x8000 ? _T("REF(") : _T("VAL("))); switch ((currtag >> 1) & SBTS_CODE) { - case SBTC_BREAKMASK: - BSDTRACE((_T("SBTC_BREAKMASK),0x%x,0x%x"), currval, sb->eintrsigs)); - tagcopy(ctx, currtag, currval, tagptr, &sb->eintrsigs); - break; - case SBTC_SIGIOMASK: - BSDTRACE((_T("SBTC_SIGIOMASK),0x%x,0x%x"), currval, sb->eventsigs)); - tagcopy(ctx, currtag, currval, tagptr, &sb->eventsigs); - break; - case SBTC_SIGURGMASK: - BSDTRACE((_T("SBTC_SIGURGMASK),0x%x"), currval)); - break; - case SBTC_SIGEVENTMASK: - BSDTRACE((_T("SBTC_SIGEVENTMASK),0x%x,0x%x"), currval, sb->eventsigs)); - tagcopy(ctx, currtag, currval, tagptr, &sb->eventsigs); - break; - case SBTC_ERRNO: - BSDTRACE((_T("SBTC_ERRNO),%x,%d"), currval, sb->sb_errno)); - tagcopy(ctx, currtag, currval, tagptr, (uae_u32*)&sb->sb_errno); - break; - case SBTC_HERRNO: - BSDTRACE((_T("SBTC_HERRNO),%x,%d"), currval, sb->sb_herrno)); - tagcopy(ctx, currtag, currval, tagptr, (uae_u32*)&sb->sb_herrno); - break; - case SBTC_DTABLESIZE: - BSDTRACE((_T("SBTC_DTABLESIZE),0x%x"), currval)); - if (currtag & 1) { - bsdsocklib_SetDTableSize(sb, currval); - } - else { - put_long(tagptr + 4, sb->dtablesize); - } - break; + case SBTC_BREAKMASK: + BSDTRACE ((_T("SBTC_BREAKMASK),0x%x,0x%x"), currval, sb->eintrsigs)); + tagcopy(ctx, currtag, currval, tagptr, &sb->eintrsigs); + break; + case SBTC_SIGIOMASK: + BSDTRACE ((_T("SBTC_SIGIOMASK),0x%x,0x%x"), currval, sb->eventsigs)); + tagcopy(ctx, currtag, currval, tagptr, &sb->eventsigs); + break; + case SBTC_SIGURGMASK: + BSDTRACE ((_T("SBTC_SIGURGMASK),0x%x"), currval)); + break; + case SBTC_SIGEVENTMASK: + BSDTRACE ((_T("SBTC_SIGEVENTMASK),0x%x,0x%x"), currval, sb->eventsigs)); + tagcopy(ctx, currtag, currval, tagptr, &sb->eventsigs); + break; + case SBTC_ERRNO: + BSDTRACE ((_T("SBTC_ERRNO),%x,%d"), currval, sb->sb_errno)); + tagcopy(ctx, currtag, currval, tagptr, (uae_u32*)&sb->sb_errno); + break; + case SBTC_HERRNO: + BSDTRACE ((_T("SBTC_HERRNO),%x,%d"), currval, sb->sb_herrno)); + tagcopy(ctx, currtag, currval, tagptr, (uae_u32*)&sb->sb_herrno); + break; + case SBTC_DTABLESIZE: + BSDTRACE ((_T("SBTC_DTABLESIZE),0x%x"), currval)); + if (currtag & 1) { + bsdsocklib_SetDTableSize(sb, currval); + } else { + put_long (tagptr + 4, sb->dtablesize); + } + break; - case SBTC_FDCALLBACK: - BSDTRACE((_T("SBTC_FDCALLBACK),%08x"), currval)); - tagcopy(ctx, currtag, currval, tagptr, &sb->fdcallback); - break; + case SBTC_FDCALLBACK: + BSDTRACE ((_T("SBTC_FDCALLBACK),%08x"), currval)); + tagcopy(ctx, currtag, currval, tagptr, &sb->fdcallback); + break; - case SBTC_LOGSTAT: - BSDTRACE((_T("SBTC_LOGSTAT),%08x"), currval)); - tagcopy(ctx, currtag, currval, tagptr, &sb->logstat); - sb->logstat &= 0xff; - break; - case SBTC_LOGTAGPTR: - BSDTRACE((_T("SBTC_LOGTAGPTR),%08x"), currval)); - tagcopy(ctx, currtag, currval, tagptr, &sb->logptr); - break; - case SBTC_LOGFACILITY: - BSDTRACE((_T("SBTC_LOGFACILITY),%08x"), currval)); - if (((currtag & 1) && currval != 0 && (currval & ~LOG_FACMASK)) || !(currtag & 1)) - tagcopy(ctx, currtag, currval, tagptr, &sb->logfacility); - break; - case SBTC_LOGMASK: - BSDTRACE((_T("SBTC_LOGMASK),%08x"), currval)); - tagcopy(ctx, currtag, currval, tagptr, &sb->logmask); - sb->logmask &= 0xff; - break; + case SBTC_LOGSTAT: + BSDTRACE ((_T("SBTC_LOGSTAT),%08x"), currval)); + tagcopy(ctx, currtag, currval, tagptr, &sb->logstat); + sb->logstat &= 0xff; + break; + case SBTC_LOGTAGPTR: + BSDTRACE ((_T("SBTC_LOGTAGPTR),%08x"), currval)); + tagcopy(ctx, currtag, currval, tagptr, &sb->logptr); + break; + case SBTC_LOGFACILITY: + BSDTRACE ((_T("SBTC_LOGFACILITY),%08x"), currval)); + if (((currtag & 1) && currval != 0 && (currval & ~LOG_FACMASK)) || !(currtag & 1)) + tagcopy(ctx, currtag, currval, tagptr, &sb->logfacility); + break; + case SBTC_LOGMASK: + BSDTRACE ((_T("SBTC_LOGMASK),%08x"), currval)); + tagcopy(ctx, currtag, currval, tagptr, &sb->logmask); + sb->logmask &= 0xff; + break; - case SBTC_IOERRNOSTRPTR: - if (currtag & 1) { - BSDTRACE((_T("IOERRNOSTRPTR),invalid"))); - goto done; - } - else { - unsigned long ulTmp; - if (currtag & 0x8000) { /* SBTM_GETREF */ - ulTmp = trap_get_long(ctx, currval); + case SBTC_IOERRNOSTRPTR: + if (currtag & 1) { + BSDTRACE ((_T("IOERRNOSTRPTR),invalid"))); + goto done; + } else { + unsigned long ulTmp; + if (currtag & 0x8000) { /* SBTM_GETREF */ + ulTmp = trap_get_long(ctx, currval); + } else { /* SBTM_GETVAL */ + ulTmp = currval; + } + BSDTRACE ((_T("IOERRNOSTRPTR),%lu"), ulTmp)); + if (ulTmp < number_sys_error) { + tagcopy(ctx, currtag, currval, tagptr, &iotextptrs[ulTmp]); + } else { + tagcopy(ctx, currtag, currval, tagptr, &strErrptr); + } } - else { /* SBTM_GETVAL */ - ulTmp = currval; + break; + case SBTC_S2ERRNOSTRPTR: + if (currtag & 1) { + BSDTRACE ((_T("S2ERRNOSTRPTR),invalid"))); + goto done; + } else { + unsigned long ulTmp; + if (currtag & 0x8000) { /* SBTM_GETREF */ + ulTmp = trap_get_long(ctx, currval); + } else { /* SBTM_GETVAL */ + ulTmp = currval; + } + BSDTRACE ((_T("S2ERRNOSTRPTR),%lu"), ulTmp)); + if (ulTmp < number_sys_error) { + tagcopy(ctx, currtag, currval, tagptr, &sana2iotextptrs[ulTmp]); + } else { + tagcopy(ctx, currtag, currval, tagptr, &strErrptr); + } } - BSDTRACE((_T("IOERRNOSTRPTR),%lu"), ulTmp)); - if (ulTmp < number_sys_error) { - tagcopy(ctx, currtag, currval, tagptr, &iotextptrs[ulTmp]); + break; + case SBTC_S2WERRNOSTRPTR: + if (currtag & 1) { + BSDTRACE ((_T("S2WERRNOSTRPTR),invalid"))); + goto done; + } else { + unsigned long ulTmp; + if (currtag & 0x8000) { /* SBTM_GETREF */ + ulTmp = trap_get_long(ctx, currval); + } else { /* SBTM_GETVAL */ + ulTmp = currval; + } + BSDTRACE ((_T("S2WERRNOSTRPTR),%lu"), ulTmp)); + if (ulTmp < number_sys_error) { + tagcopy(ctx, currtag, currval, tagptr, &sana2wiretextptrs[ulTmp]); + } else { + tagcopy(ctx, currtag, currval, tagptr, &strErrptr); + } } - else { - tagcopy(ctx, currtag, currval, tagptr, &strErrptr); + break; + case SBTC_ERRNOSTRPTR: + if (currtag & 1) { + BSDTRACE ((_T("ERRNOSTRPTR),invalid"))); + goto done; + } else { + unsigned long ulTmp; + if (currtag & 0x8000) { /* SBTM_GETREF */ + ulTmp = trap_get_long(ctx, currval); + } else { /* SBTM_GETVAL */ + ulTmp = currval; + } + BSDTRACE ((_T("ERRNOSTRPTR),%lu"), ulTmp)); + if (ulTmp < number_sys_error) { + tagcopy(ctx, currtag, currval, tagptr, &errnotextptrs[ulTmp]); + } else { + tagcopy(ctx, currtag, currval, tagptr, &strErrptr); + } } - } - break; - case SBTC_S2ERRNOSTRPTR: - if (currtag & 1) { - BSDTRACE((_T("S2ERRNOSTRPTR),invalid"))); - goto done; - } - else { - unsigned long ulTmp; - if (currtag & 0x8000) { /* SBTM_GETREF */ - ulTmp = trap_get_long(ctx, currval); + break; + case SBTC_HERRNOSTRPTR: + if (currtag & 1) { + BSDTRACE ((_T("HERRNOSTRPTR),invalid"))); + goto done; + } else { + unsigned long ulTmp; + if (currtag & 0x8000) { /* SBTM_GETREF */ + ulTmp = trap_get_long(ctx, currval); + } else { /* SBTM_GETVAL */ + ulTmp = currval; + } + BSDTRACE ((_T("HERRNOSTRPTR),%lu"), ulTmp)); + if (ulTmp < number_host_error) { + tagcopy(ctx, currtag, currval, tagptr, &herrnotextptrs[ulTmp]); + } else { + tagcopy(ctx, currtag, currval, tagptr, &strErrptr); + } } - else { /* SBTM_GETVAL */ - ulTmp = currval; - } - BSDTRACE((_T("S2ERRNOSTRPTR),%lu"), ulTmp)); - if (ulTmp < number_sys_error) { - tagcopy(ctx, currtag, currval, tagptr, &sana2iotextptrs[ulTmp]); - } - else { - tagcopy(ctx, currtag, currval, tagptr, &strErrptr); - } - } - break; - case SBTC_S2WERRNOSTRPTR: - if (currtag & 1) { - BSDTRACE((_T("S2WERRNOSTRPTR),invalid"))); - goto done; - } - else { - unsigned long ulTmp; - if (currtag & 0x8000) { /* SBTM_GETREF */ - ulTmp = trap_get_long(ctx, currval); - } - else { /* SBTM_GETVAL */ - ulTmp = currval; - } - BSDTRACE((_T("S2WERRNOSTRPTR),%lu"), ulTmp)); - if (ulTmp < number_sys_error) { - tagcopy(ctx, currtag, currval, tagptr, &sana2wiretextptrs[ulTmp]); - } - else { - tagcopy(ctx, currtag, currval, tagptr, &strErrptr); - } - } - break; - case SBTC_ERRNOSTRPTR: - if (currtag & 1) { - BSDTRACE((_T("ERRNOSTRPTR),invalid"))); - goto done; - } - else { - unsigned long ulTmp; - if (currtag & 0x8000) { /* SBTM_GETREF */ - ulTmp = trap_get_long(ctx, currval); - } - else { /* SBTM_GETVAL */ - ulTmp = currval; - } - BSDTRACE((_T("ERRNOSTRPTR),%lu"), ulTmp)); - if (ulTmp < number_sys_error) { - tagcopy(ctx, currtag, currval, tagptr, &errnotextptrs[ulTmp]); - } - else { - tagcopy(ctx, currtag, currval, tagptr, &strErrptr); - } - } - break; - case SBTC_HERRNOSTRPTR: - if (currtag & 1) { - BSDTRACE((_T("HERRNOSTRPTR),invalid"))); - goto done; - } - else { - unsigned long ulTmp; - if (currtag & 0x8000) { /* SBTM_GETREF */ - ulTmp = trap_get_long(ctx, currval); - } - else { /* SBTM_GETVAL */ - ulTmp = currval; - } - BSDTRACE((_T("HERRNOSTRPTR),%lu"), ulTmp)); - if (ulTmp < number_host_error) { - tagcopy(ctx, currtag, currval, tagptr, &herrnotextptrs[ulTmp]); - } - else { - tagcopy(ctx, currtag, currval, tagptr, &strErrptr); - } - } - break; + break; - case SBTC_ERRNOBYTEPTR: - BSDTRACE((_T("SBTC_ERRNOBYTEPTR),0x%x"), currval)); - tagcopy(ctx, currtag, currval, tagptr, &sb->errnoptr); - sb->errnosize = 1; - break; - case SBTC_ERRNOWORDPTR: - BSDTRACE((_T("SBTC_ERRNOWORDPTR),0x%x"), currval)); - tagcopy(ctx, currtag, currval, tagptr, &sb->errnoptr); - sb->errnosize = 2; - break; - case SBTC_ERRNOLONGPTR: - BSDTRACE((_T("SBTC_ERRNOLONGPTR),0x%x"), currval)); - tagcopy(ctx, currtag, currval, tagptr, &sb->errnoptr); - sb->errnosize = 4; - break; - case SBTC_HERRNOLONGPTR: - BSDTRACE((_T("SBTC_HERRNOLONGPTR),0x%x"), currval)); - tagcopy(ctx, currtag, currval, tagptr, &sb->herrnoptr); - sb->herrnosize = 4; - break; - default: - write_log(_T("bsdsocket: WARNING: Unsupported tag type (%08x=%d) in SocketBaseTagList(%x)\n"), - currtag, (currtag / 2) & SBTS_CODE, trap_get_areg(ctx, 0)); - goto done; + case SBTC_ERRNOBYTEPTR: + BSDTRACE ((_T("SBTC_ERRNOBYTEPTR),0x%x"), currval)); + tagcopy(ctx, currtag, currval, tagptr, &sb->errnoptr); + sb->errnosize = 1; + break; + case SBTC_ERRNOWORDPTR: + BSDTRACE ((_T("SBTC_ERRNOWORDPTR),0x%x"), currval)); + tagcopy(ctx, currtag, currval, tagptr, &sb->errnoptr); + sb->errnosize = 2; + break; + case SBTC_ERRNOLONGPTR: + BSDTRACE ((_T("SBTC_ERRNOLONGPTR),0x%x"), currval)); + tagcopy(ctx, currtag, currval, tagptr, &sb->errnoptr); + sb->errnosize = 4; + break; + case SBTC_HERRNOLONGPTR: + BSDTRACE ((_T("SBTC_HERRNOLONGPTR),0x%x"), currval)); + tagcopy(ctx, currtag, currval, tagptr, &sb->herrnoptr); + sb->herrnosize = 4; + break; + default: + write_log (_T("bsdsocket: WARNING: Unsupported tag type (%08x=%d) in SocketBaseTagList(%x)\n"), + currtag, (currtag / 2) & SBTS_CODE, trap_get_areg(ctx, 0)); + goto done; } } - BSDTRACE((_T(","))); + BSDTRACE ((_T(","))); tagptr += 8; } done: - BSDTRACE((_T(") -> %d\n"), tagsprocessed)); + BSDTRACE ((_T(") -> %d\n"), tagsprocessed)); return tagsprocessed; } static uae_u32 REGPARAM2 bsdsocklib_GetSocketEvents(TrapContext *ctx) { -#ifdef _WIN32_ +#ifdef _WIN32 struct socketbase *sb = get_socketbase(ctx); int i; int flags; uae_u32 ptr = trap_get_areg(ctx, 0); - BSDTRACE((_T("GetSocketEvents(0x%x) -> "), ptr)); + BSDTRACE ((_T("GetSocketEvents(0x%x) -> "), ptr)); for (i = sb->dtablesize; i--; sb->eventindex++) { if (sb->eventindex >= sb->dtablesize) @@ -1629,13 +1605,13 @@ static uae_u32 REGPARAM2 bsdsocklib_GetSocketEvents(TrapContext *ctx) if (flags) { sb->ftable[sb->eventindex] &= ~SET_ALL; trap_put_long(ctx, trap_get_areg(ctx, 0), flags >> 8); - BSDTRACE((_T("%d (0x%x)\n"), sb->eventindex + 1, flags >> 8)); + BSDTRACE ((_T("%d (0x%x)\n"), sb->eventindex + 1, flags >> 8)); return sb->eventindex; // xxx } } } #endif - BSDTRACE((_T("-1\n"))); + BSDTRACE ((_T("-1\n"))); return -1; } @@ -1654,9 +1630,9 @@ static uae_u32 REGPARAM2 bsdsocklib_init(TrapContext *ctx) uae_u32 tmp1; int i; - write_log(_T("Creating UAE bsdsocket.library 4.1\n")); + write_log (_T("Creating UAE bsdsocket.library 4.1\n")); if (SockLibBase) - bsdlib_reset(); + bsdlib_reset (); #if NEWTRAP trap_call_add_areg(ctx, 0, functable); @@ -1675,16 +1651,16 @@ static uae_u32 REGPARAM2 bsdsocklib_init(TrapContext *ctx) #endif if (!tmp1) { - write_log(_T("bsdoscket: FATAL: Cannot create bsdsocket.library!\n")); + write_log (_T("bsdoscket: FATAL: Cannot create bsdsocket.library!\n")); return 0; } - + #if NEWTRAP trap_call_add_areg(ctx, 1, tmp1); trap_call_lib(ctx, trap_get_areg(ctx, 6), -0x18c); /* AddLibrary */ #else trap_get_areg(ctx, 1) = tmp1; - CallLib(ctx, trap_get_areg(ctx, 6), -0x18c); /* AddLibrary */ + CallLib (ctx, trap_get_areg(ctx, 6), -0x18c); /* AddLibrary */ #endif SockLibBase = tmp1; @@ -1692,14 +1668,14 @@ static uae_u32 REGPARAM2 bsdsocklib_init(TrapContext *ctx) /* Install error strings in Amiga memory */ tmp1 = 0; for (i = number_sys_error; i--;) - tmp1 += _tcslen(errortexts[i]) + 1; + tmp1 += _tcslen (errortexts[i]) + 1; for (i = number_host_error; i--;) - tmp1 += _tcslen(herrortexts[i]) + 1; + tmp1 += _tcslen (herrortexts[i]) + 1; for (i = number_sana2io_error; i--;) - tmp1 += _tcslen(sana2io_errlist[i]) + 1; + tmp1 += _tcslen (sana2io_errlist[i]) + 1; for (i = number_sana2wire_error; i--;) - tmp1 += _tcslen(sana2wire_errlist[i]) + 1; - tmp1 += _tcslen(strErr) + 1; + tmp1 += _tcslen (sana2wire_errlist[i]) + 1; + tmp1 += _tcslen (strErr) + 1; #if NEWTRAP trap_call_add_dreg(ctx, 0, tmp1); @@ -1708,21 +1684,21 @@ static uae_u32 REGPARAM2 bsdsocklib_init(TrapContext *ctx) #else trap_get_dreg(ctx, 0) = tmp1; trap_get_dreg(ctx, 1) = 0; - tmp1 = CallLib(ctx, trap_get_areg(ctx, 6), -0xC6); /* AllocMem */ + tmp1 = CallLib (ctx, trap_get_areg(ctx, 6), -0xC6); /* AllocMem */ #endif if (!tmp1) { - write_log(_T("bsdsocket: FATAL: Ran out of memory while creating bsdsocket.library!\n")); + write_log (_T("bsdsocket: FATAL: Ran out of memory while creating bsdsocket.library!\n")); return 0; } - for (i = 0; i < (int)(number_sys_error); i++) + for (i = 0; i < (int) (number_sys_error); i++) errnotextptrs[i] = addstr(ctx, &tmp1, errortexts[i]); - for (i = 0; i < (int)(number_host_error); i++) + for (i = 0; i < (int) (number_host_error); i++) herrnotextptrs[i] = addstr(ctx, &tmp1, herrortexts[i]); - for (i = 0; i < (int)(number_sana2io_error); i++) + for (i = 0; i < (int) (number_sana2io_error); i++) sana2iotextptrs[i] = addstr(ctx, &tmp1, sana2io_errlist[i]); - for (i = 0; i < (int)(number_sana2wire_error); i++) + for (i = 0; i < (int) (number_sana2wire_error); i++) sana2wiretextptrs[i] = addstr(ctx, &tmp1, sana2wire_errlist[i]); strErrptr = addstr(ctx, &tmp1, strErr); @@ -1730,7 +1706,7 @@ static uae_u32 REGPARAM2 bsdsocklib_init(TrapContext *ctx) return 0; } -void bsdlib_reset(void) +void bsdlib_reset (void) { SB, *nsb; int i; @@ -1740,20 +1716,20 @@ void bsdlib_reset(void) SockLibBase = 0; - write_log(_T("BSDSOCK: cleanup start..\n")); - host_sbcleanup(NULL); + write_log (_T("BSDSOCK: cleanup start..\n")); + host_sbcleanup (NULL); for (sb = socketbases; sb; sb = nsb) { nsb = sb->next; - write_log(_T("BSDSOCK: cleanup start socket %p\n"), sb); - host_sbcleanup(sb); + write_log (_T("BSDSOCK: cleanup start socket %p\n"), sb); + host_sbcleanup (sb); - free(sb->dtable); - free(sb->ftable); + free (sb->dtable); + free (sb->ftable); - free(sb); + free (sb); } - write_log(_T("BSDSOCK: cleanup end\n")); + write_log (_T("BSDSOCK: cleanup end\n")); socketbases = NULL; #if 1 @@ -1763,12 +1739,12 @@ void bsdlib_reset(void) for (i = 0; i < SOCKPOOLSIZE; i++) { if (sockdata->sockpoolids[i] != UNIQUE_ID) { sockdata->sockpoolids[i] = UNIQUE_ID; - host_closesocketquick(sockdata->sockpoolsocks[i]); + host_closesocketquick (sockdata->sockpoolsocks[i]); } } - host_sbreset(); - write_log(_T("BSDSOCK: cleanup finished\n")); + host_sbreset (); + write_log (_T("BSDSOCK: cleanup finished\n")); } static const TrapHandler sockfuncs[] = { @@ -1803,11 +1779,11 @@ static const TCHAR * const funcnames[] = { _T("bsdsocklib_GetSocketEvents") }; -static uae_u32 sockfuncvecs[sizeof(sockfuncs) / sizeof(*sockfuncs)]; +static uae_u32 sockfuncvecs[sizeof (sockfuncs) / sizeof (*sockfuncs)]; static uae_u32 res_name, res_id, res_init; -uaecptr bsdlib_startup(TrapContext *ctx, uaecptr resaddr) +uaecptr bsdlib_startup (TrapContext *ctx, uaecptr resaddr) { if (res_name == 0 || !currprefs.socket_emu) return resaddr; @@ -1816,8 +1792,7 @@ uaecptr bsdlib_startup(TrapContext *ctx, uaecptr resaddr) trap_put_long(ctx, resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */ if (kickstart_version >= 37) { trap_put_long(ctx, resaddr + 0xA, 0x84040900 | AFTERDOS_PRI); /* RTF_AUTOINIT, RT_VERSION NT_LIBRARY, RT_PRI */ - } - else { + } else { trap_put_long(ctx, resaddr + 0xA, 0x80040905); /* RTF_AUTOINIT, RT_VERSION NT_LIBRARY, RT_PRI */ } trap_put_long(ctx, resaddr + 0xE, res_name); @@ -1827,72 +1802,72 @@ uaecptr bsdlib_startup(TrapContext *ctx, uaecptr resaddr) return resaddr; } -void bsdlib_install(void) +void bsdlib_install (void) { int i; if (!sockdata) { - sockdata = xcalloc(struct sockd, 1); + sockdata = xcalloc (struct sockd, 1); for (i = 0; i < SOCKPOOLSIZE; i++) sockdata->sockpoolids[i] = UNIQUE_ID; } - if (!init_socket_layer()) { - res_name = 0; - res_id = 0; + if (!init_socket_layer ()) { + res_name = 0; + res_id = 0; return; - } + } - res_name = ds(_T("bsdsocket.library")); - res_id = ds(_T("UAE bsdsocket.library 4.1")); + res_name = ds (_T("bsdsocket.library")); + res_id = ds (_T("UAE bsdsocket.library 4.1")); - for (i = 0; i < (int)(sizeof(sockfuncs) / sizeof(sockfuncs[0])); i++) { - sockfuncvecs[i] = here(); - calltrap(deftrap2(sockfuncs[i], TRAPFLAG_EXTRA_STACK, funcnames[i])); - dw(RTS); + for (i = 0; i < (int) (sizeof (sockfuncs) / sizeof (sockfuncs[0])); i++) { + sockfuncvecs[i] = here (); + calltrap (deftrap2 (sockfuncs[i], TRAPFLAG_EXTRA_STACK, funcnames[i])); + dw (RTS); } /* FuncTable */ - functable = here(); + functable = here (); for (i = 1; i < 4; i++) - dl(sockfuncvecs[i]); /* Open / Close / Expunge */ - dl(EXPANSION_nullfunc); /* Null */ - for (i = 4; i < (int)(sizeof(sockfuncs) / sizeof(sockfuncs[0])); i++) - dl(sockfuncvecs[i]); - dl(0xFFFFFFFF); /* end of table */ + dl (sockfuncvecs[i]); /* Open / Close / Expunge */ + dl (EXPANSION_nullfunc); /* Null */ + for (i = 4; i < (int) (sizeof (sockfuncs) / sizeof (sockfuncs[0])); i++) + dl (sockfuncvecs[i]); + dl (0xFFFFFFFF); /* end of table */ - /* DataTable */ - datatable = here(); - dw(0xE000); /* INITBYTE */ - dw(0x0008); /* LN_TYPE */ - dw(0x0900); /* NT_LIBRARY */ - dw(0xE000); /* INITBYTE */ - dw(0x0009); /* LN_PRI */ - dw(0xCE00); /* -50 */ - dw(0xC000); /* INITLONG */ - dw(0x000A); /* LN_NAME */ - dl(res_name); - dw(0xE000); /* INITBYTE */ - dw(0x000E); /* LIB_FLAGS */ - dw(0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */ - dw(0xD000); /* INITWORD */ - dw(0x0014); /* LIB_VERSION */ - dw(0x0004); - dw(0xD000); - dw(0x0016); /* LIB_REVISION */ - dw(0x0001); - dw(0xC000); - dw(0x0018); /* LIB_IDSTRING */ - dl(res_id); - dl(0x00000000); /* end of table */ + /* DataTable */ + datatable = here (); + dw (0xE000); /* INITBYTE */ + dw (0x0008); /* LN_TYPE */ + dw (0x0900); /* NT_LIBRARY */ + dw (0xE000); /* INITBYTE */ + dw (0x0009); /* LN_PRI */ + dw (0xCE00); /* -50 */ + dw (0xC000); /* INITLONG */ + dw (0x000A); /* LN_NAME */ + dl (res_name); + dw (0xE000); /* INITBYTE */ + dw (0x000E); /* LIB_FLAGS */ + dw (0x0600); /* LIBF_SUMUSED | LIBF_CHANGED */ + dw (0xD000); /* INITWORD */ + dw (0x0014); /* LIB_VERSION */ + dw (0x0004); + dw (0xD000); + dw (0x0016); /* LIB_REVISION */ + dw (0x0001); + dw (0xC000); + dw (0x0018); /* LIB_IDSTRING */ + dl (res_id); + dl (0x00000000); /* end of table */ - res_init = here(); - dl(512); - dl(functable); - dl(datatable); - dl(*sockfuncvecs); + res_init = here (); + dl (512); + dl (functable); + dl (datatable); + dl (*sockfuncvecs); - write_log(_T("bsdsocket.library installed\n")); + write_log (_T("bsdsocket.library installed\n")); } #endif /* ! BSDSOCKET */ diff --git a/src/calc.cpp b/src/calc.cpp index 78a6969f..af09a977 100644 --- a/src/calc.cpp +++ b/src/calc.cpp @@ -8,7 +8,7 @@ /* -Original code from http://en.wikipedia.org/wiki/Shunting_yard_algorithm + Original code from http://en.wikipedia.org/wiki/Shunting_yard_algorithm */ @@ -21,7 +21,7 @@ Original code from http://en.wikipedia.org/wiki/Shunting_yard_algorithm #include #include - + #define STACK_SIZE 32 #define MAX_VALUES 32 #define IOBUFFERS 256 @@ -36,183 +36,183 @@ static double parsedvalues[MAX_VALUES]; // 4 = right to left static int op_preced(const TCHAR c) { - switch (c) { - case '!': - return 4; - case '*': case '/': case '\\': case '%': - return 3; - case '+': case '-': - return 2; - case '=': - return 1; - } - return 0; + switch(c) { + case '!': + return 4; + case '*': case '/': case '\\': case '%': + return 3; + case '+': case '-': + return 2; + case '=': + return 1; + } + return 0; } - + static bool op_left_assoc(const TCHAR c) { - switch (c) { - // left to right - case '*': case '/': case '%': case '+': case '-': - return true; - // right to left - case '=': case '!': - return false; - } - return false; + switch(c) { + // left to right + case '*': case '/': case '%': case '+': case '-': + return true; + // right to left + case '=': case '!': + return false; + } + return false; } - + static unsigned int op_arg_count(const TCHAR c) { - switch (c) { - case '*': case '/': case '%': case '+': case '-': case '=': - return 2; - case '!': - return 1; - default: - return c - 'A'; - } - return 0; + switch(c) { + case '*': case '/': case '%': case '+': case '-': case '=': + return 2; + case '!': + return 1; + default: + return c - 'A'; + } + return 0; } - + #define is_operator(c) (c == '+' || c == '-' || c == '/' || c == '*' || c == '!' || c == '%' || c == '=') #define is_function(c) (c >= 'A' && c <= 'Z') #define is_ident(c) ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')) - + static bool shunting_yard(const TCHAR *input, TCHAR *output) { - const TCHAR *strpos = input, *strend = input + _tcslen(input); - TCHAR c, *outpos = output; - - TCHAR stack[STACK_SIZE]; // operator stack - unsigned int sl = 0; // stack length - TCHAR sc; // used for record stack element - - while (strpos < strend) { + const TCHAR *strpos = input, *strend = input + _tcslen(input); + TCHAR c, *outpos = output; + + TCHAR stack[STACK_SIZE]; // operator stack + unsigned int sl = 0; // stack length + TCHAR sc; // used for record stack element + + while(strpos < strend) { if (sl >= STACK_SIZE) return false; // read one token from the input stream - c = *strpos; - if (c != ' ') { - // If the token is a number (identifier), then add it to the output queue. - if (is_ident(c)) { - *outpos = c; ++outpos; - } - // If the token is a function token, then push it onto the stack. - else if (is_function(c)) { - stack[sl] = c; - ++sl; - } - // If the token is a function argument separator (e.g., a comma): - else if (c == ',') { - bool pe = false; - while (sl > 0) { - sc = stack[sl - 1]; - if (sc == '(') { - pe = true; - break; - } - else { - // Until the token at the top of the stack is a left parenthesis, - // pop operators off the stack onto the output queue. - *outpos = sc; - ++outpos; - sl--; - } - } - // If no left parentheses are encountered, either the separator was misplaced - // or parentheses were mismatched. - if (!pe) { - calc_log((_T("Error: separator or parentheses mismatched\n"))); - return false; - } - } - // If the token is an operator, op1, then: - else if (is_operator(c)) { - while (sl > 0) { - sc = stack[sl - 1]; - // While there is an operator token, o2, at the top of the stack - // op1 is left-associative and its precedence is less than or equal to that of op2, - // or op1 is right-associative and its precedence is less than that of op2, - if (is_operator(sc) && - ((op_left_assoc(c) && (op_preced(c) <= op_preced(sc))) || - (!op_left_assoc(c) && (op_preced(c) < op_preced(sc))))) { - // Pop o2 off the stack, onto the output queue; - *outpos = sc; - ++outpos; - sl--; - } - else { - break; - } - } - // push op1 onto the stack. - stack[sl] = c; - ++sl; - } - // If the token is a left parenthesis, then push it onto the stack. - else if (c == '(') { - stack[sl] = c; - ++sl; - } - // If the token is a right parenthesis: - else if (c == ')') { - bool pe = false; - // Until the token at the top of the stack is a left parenthesis, - // pop operators off the stack onto the output queue - while (sl > 0) { - sc = stack[sl - 1]; - if (sc == '(') { - pe = true; - break; - } - else { - *outpos = sc; - ++outpos; - sl--; - } - } - // If the stack runs out without finding a left parenthesis, then there are mismatched parentheses. - if (!pe) { - calc_log((_T("Error: parentheses mismatched\n"))); - return false; - } - // Pop the left parenthesis from the stack, but not onto the output queue. - sl--; - // If the token at the top of the stack is a function token, pop it onto the output queue. - if (sl > 0) { - sc = stack[sl - 1]; - if (is_function(sc)) { - *outpos = sc; - ++outpos; - sl--; - } - } - } - else { - calc_log((_T("Unknown token %c\n"), c)); - return false; // Unknown token - } - } - ++strpos; - } - // When there are no more tokens to read: - // While there are still operator tokens in the stack: - while (sl > 0) { - sc = stack[sl - 1]; - if (sc == '(' || sc == ')') { - printf("Error: parentheses mismatched\n"); - return false; - } - *outpos = sc; - ++outpos; - --sl; - } - *outpos = 0; // Null terminator - return true; + c = *strpos; + if(c != ' ') { + // If the token is a number (identifier), then add it to the output queue. + if(is_ident(c)) { + *outpos = c; ++outpos; + } + // If the token is a function token, then push it onto the stack. + else if(is_function(c)) { + stack[sl] = c; + ++sl; + } + // If the token is a function argument separator (e.g., a comma): + else if(c == ',') { + bool pe = false; + while(sl > 0) { + sc = stack[sl - 1]; + if(sc == '(') { + pe = true; + break; + } + else { + // Until the token at the top of the stack is a left parenthesis, + // pop operators off the stack onto the output queue. + *outpos = sc; + ++outpos; + sl--; + } + } + // If no left parentheses are encountered, either the separator was misplaced + // or parentheses were mismatched. + if(!pe) { + calc_log ((_T("Error: separator or parentheses mismatched\n"))); + return false; + } + } + // If the token is an operator, op1, then: + else if(is_operator(c)) { + while(sl > 0) { + sc = stack[sl - 1]; + // While there is an operator token, o2, at the top of the stack + // op1 is left-associative and its precedence is less than or equal to that of op2, + // or op1 is right-associative and its precedence is less than that of op2, + if(is_operator(sc) && + ((op_left_assoc(c) && (op_preced(c) <= op_preced(sc))) || + (!op_left_assoc(c) && (op_preced(c) < op_preced(sc))))) { + // Pop o2 off the stack, onto the output queue; + *outpos = sc; + ++outpos; + sl--; + } + else { + break; + } + } + // push op1 onto the stack. + stack[sl] = c; + ++sl; + } + // If the token is a left parenthesis, then push it onto the stack. + else if(c == '(') { + stack[sl] = c; + ++sl; + } + // If the token is a right parenthesis: + else if(c == ')') { + bool pe = false; + // Until the token at the top of the stack is a left parenthesis, + // pop operators off the stack onto the output queue + while(sl > 0) { + sc = stack[sl - 1]; + if(sc == '(') { + pe = true; + break; + } + else { + *outpos = sc; + ++outpos; + sl--; + } + } + // If the stack runs out without finding a left parenthesis, then there are mismatched parentheses. + if(!pe) { + calc_log ((_T("Error: parentheses mismatched\n"))); + return false; + } + // Pop the left parenthesis from the stack, but not onto the output queue. + sl--; + // If the token at the top of the stack is a function token, pop it onto the output queue. + if(sl > 0) { + sc = stack[sl - 1]; + if(is_function(sc)) { + *outpos = sc; + ++outpos; + sl--; + } + } + } + else { + calc_log ((_T("Unknown token %c\n"), c)); + return false; // Unknown token + } + } + ++strpos; + } + // When there are no more tokens to read: + // While there are still operator tokens in the stack: + while(sl > 0) { + sc = stack[sl - 1]; + if(sc == '(' || sc == ')') { + printf("Error: parentheses mismatched\n"); + return false; + } + *outpos = sc; + ++outpos; + --sl; + } + *outpos = 0; // Null terminator + return true; } - + struct calcstack { @@ -224,15 +224,15 @@ static double docalcx(TCHAR op, double v1, double v2) { switch (op) { - case '-': + case '-': return v1 - v2; - case '+': + case '+': return v1 + v2; - case '*': + case '*': return v1 * v2; - case '/': + case '/': return v1 / v2; - case '\\': + case '\\': return (int)v1 % (int)v2; } @@ -244,9 +244,8 @@ static double stacktoval(struct calcstack *st) if (st->s) { if (_tcslen(st->s) == 1 && st->s[0] >= 'a' && st->s[0] <= 'z') return parsedvalues[st->s[0] - 'a']; - return _tstof(st->s); - } - else { + return _tstof (st->s); + } else { return st->val; } } @@ -257,19 +256,19 @@ static double docalc2(TCHAR op, struct calcstack *sv1, struct calcstack *sv2) v1 = stacktoval(sv1); v2 = stacktoval(sv2); - return docalcx(op, v1, v2); + return docalcx (op, v1, v2); } static double docalc1(TCHAR op, struct calcstack *sv1, double v2) { double v1; v1 = stacktoval(sv1); - return docalcx(op, v1, v2); + return docalcx (op, v1, v2); } static TCHAR *chartostack(TCHAR c) { - TCHAR *s = xmalloc(TCHAR, 2); + TCHAR *s = xmalloc (TCHAR, 2); s[0] = c; s[1] = 0; return s; @@ -277,96 +276,96 @@ static TCHAR *chartostack(TCHAR c) static bool execution_order(const TCHAR *input, double *outval) { - const TCHAR *strpos = input, *strend = input + _tcslen(input); - TCHAR c, res[4]; - unsigned int sl = 0, rn = 0; + const TCHAR *strpos = input, *strend = input + _tcslen(input); + TCHAR c, res[4]; + unsigned int sl = 0, rn = 0; struct calcstack stack[STACK_SIZE] = { { 0 } }, *sc, *sc2; double val = 0; int i; bool ok = false; // While there are input tokens left - while (strpos < strend) { + while(strpos < strend) { if (sl >= STACK_SIZE) return false; - // Read the next token from input. + // Read the next token from input. c = *strpos; - // If the token is a value or identifier - if (is_ident(c)) { - // Push it onto the stack. - stack[sl].s = chartostack(c); - ++sl; + // If the token is a value or identifier + if(is_ident(c)) { + // Push it onto the stack. + stack[sl].s = chartostack (c); + ++sl; + } + // Otherwise, the token is an operator (operator here includes both operators, and functions). + else if(is_operator(c) || is_function(c)) { + _stprintf(res, _T("_%02d"), rn); + calc_log ((_T("%s = "), res)); + ++rn; + // It is known a priori that the operator takes n arguments. + unsigned int nargs = op_arg_count(c); + // If there are fewer than n values on the stack + if(sl < nargs) { + // (Error) The user has not input sufficient values in the expression. + return false; + } + // Else, Pop the top n values from the stack. + // Evaluate the operator, with the values as arguments. + if(is_function(c)) { + calc_log ((_T("%c("), c)); + while(nargs > 0){ + sc = &stack[sl - nargs]; // to remove reverse order of arguments + if(nargs > 1) { + calc_log ((_T("%s, "), sc)); + } + else { + calc_log ((_T("%s)\n"), sc)); + } + --nargs; + } + sl-=op_arg_count(c); + } + else { + if(nargs == 1) { + sc = &stack[sl - 1]; + sl--; + val = docalc1 (c, sc, val); + calc_log ((_T("%c %s = %f;\n"), c, stacktostr(sc), val)); + } + else { + sc = &stack[sl - 2]; + calc_log ((_T("%s %c "), stacktostr(sc), c)); + sc2 = &stack[sl - 1]; + val = docalc2 (c, sc, sc2); + sl--;sl--; + calc_log ((_T("%s = %f;\n"), stacktostr(sc2), val)); + } + } + // Push the returned results, if any, back onto the stack. + stack[sl].val = val; + stack[sl].s = NULL; + ++sl; + } + ++strpos; + } + // If there is only one value in the stack + // That value is the result of the calculation. + if(sl == 1) { + sc = &stack[sl - 1]; + sl--; + calc_log ((_T("result = %f\n"), val)); + if (outval) + *outval = val; + ok = true; } - // Otherwise, the token is an operator (operator here includes both operators, and functions). - else if (is_operator(c) || is_function(c)) { - _stprintf(res, _T("_%02d"), rn); - calc_log((_T("%s = "), res)); - ++rn; - // It is known a priori that the operator takes n arguments. - unsigned int nargs = op_arg_count(c); - // If there are fewer than n values on the stack - if (sl < nargs) { - // (Error) The user has not input sufficient values in the expression. - return false; - } - // Else, Pop the top n values from the stack. - // Evaluate the operator, with the values as arguments. - if (is_function(c)) { - calc_log((_T("%c("), c)); - while (nargs > 0) { - sc = &stack[sl - nargs]; // to remove reverse order of arguments - if (nargs > 1) { - calc_log((_T("%s, "), sc)); - } - else { - calc_log((_T("%s)\n"), sc)); - } - --nargs; - } - sl -= op_arg_count(c); - } - else { - if (nargs == 1) { - sc = &stack[sl - 1]; - sl--; - val = docalc1(c, sc, val); - calc_log((_T("%c %s = %f;\n"), c, stacktostr(sc), val)); - } - else { - sc = &stack[sl - 2]; - calc_log((_T("%s %c "), stacktostr(sc), c)); - sc2 = &stack[sl - 1]; - val = docalc2(c, sc, sc2); - sl--; sl--; - calc_log((_T("%s = %f;\n"), stacktostr(sc2), val)); - } - } - // Push the returned results, if any, back onto the stack. - stack[sl].val = val; - stack[sl].s = NULL; - ++sl; - } - ++strpos; - } - // If there is only one value in the stack - // That value is the result of the calculation. - if (sl == 1) { - sc = &stack[sl - 1]; - sl--; - calc_log((_T("result = %f\n"), val)); - if (outval) - *outval = val; - ok = true; - } - for (i = 0; i < STACK_SIZE; i++) - xfree(stack[i].s); + for (i = 0; i < STACK_SIZE; i++) + xfree (stack[i].s); + + // If there are more values in the stack + // (Error) The user input has too many values. - // If there are more values in the stack - // (Error) The user input has too many values. - - return ok; + return ok; } static bool is_separator(TCHAR c) @@ -383,7 +382,7 @@ static bool parse_values(const TCHAR *ins, TCHAR *out) TCHAR inbuf[IOBUFFERS]; int op; - _tcscpy(inbuf, ins); + _tcscpy (inbuf, ins); TCHAR *in = inbuf; TCHAR *p = out; op = 0; @@ -397,15 +396,14 @@ static bool parse_values(const TCHAR *ins, TCHAR *out) in[1] = ' '; in[2] = ' '; in[3] = ' '; - } - else if (!_tcsncmp(in, _T("false"), 5) && is_separator(in[5])) { + } else if (!_tcsncmp(in, _T("false"), 5) && is_separator(in[5])) { in[0] = '0'; in[1] = ' '; in[2] = ' '; in[3] = ' '; in[4] = ' '; } - if (_istdigit(*in)) { + if (_istdigit (*in)) { if (ident >= MAX_VALUES) return false; if (op > 1 && (in[-1] == '-' || in[-1] == '+')) { @@ -413,15 +411,14 @@ static bool parse_values(const TCHAR *ins, TCHAR *out) p--; } *p++ = ident + 'a'; - while (_istdigit(*in) || *in == '.') + while (_istdigit (*in) || *in == '.') in++; tmp = *in; *in = 0; - parsedvalues[ident++] = _tstof(instart); + parsedvalues[ident++] = _tstof (instart); *in = tmp; op = 0; - } - else { + } else { if (is_operator(*in)) op++; *p++ = *in++; @@ -433,27 +430,26 @@ static bool parse_values(const TCHAR *ins, TCHAR *out) bool calc(const TCHAR *input, double *outval) { - TCHAR output[IOBUFFERS], output2[IOBUFFERS]; - calc_log((_T("IN: '%s'\n"), input)); + TCHAR output[IOBUFFERS], output2[IOBUFFERS]; + calc_log ((_T("IN: '%s'\n"), input)); if (parse_values(input, output2)) { - if (shunting_yard(output2, output)) { - calc_log((_T("RPN OUT: %s\n"), output)); - if (!execution_order(output, outval)) { - calc_log((_T("PARSE ERROR!\n"))); - } - else { + if(shunting_yard(output2, output)) { + calc_log ((_T("RPN OUT: %s\n"), output)); + if(!execution_order(output, outval)) { + calc_log ((_T("PARSE ERROR!\n"))); + } else { return true; } } - } - return false; + } + return false; } -bool iscalcformula(const TCHAR *formula) +bool iscalcformula (const TCHAR *formula) { - for (int i = 0; i < _tcslen(formula); i++) { + for (int i = 0; i < _tcslen (formula); i++) { TCHAR c = formula[i]; - if (is_operator(c)) + if (is_operator (c)) return true; } return false; diff --git a/src/cd32_fmv.cpp b/src/cd32_fmv.cpp index c028f4ff..d5ecbc74 100644 --- a/src/cd32_fmv.cpp +++ b/src/cd32_fmv.cpp @@ -11,7 +11,7 @@ #include "sysdeps.h" #include "options.h" -#include "include/memory.h" +#include "memory.h" #include "rommgr.h" #include "custom.h" #include "newcpu.h" @@ -24,7 +24,7 @@ #include "cda_play.h" #include "archivers/mp2/kjmp2.h" -#ifdef AMIBERRY +#ifndef WIN32 extern "C" { #include "mpeg2dec/mpeg2.h" #include "mpeg2dec/mpeg2convert.h" diff --git a/src/cd32_fmv_genlock.cpp b/src/cd32_fmv_genlock.cpp index 2069f8cc..0ba66481 100644 --- a/src/cd32_fmv_genlock.cpp +++ b/src/cd32_fmv_genlock.cpp @@ -11,7 +11,7 @@ #include "sysdeps.h" #include "options.h" -#include "include/memory.h" +#include "memory.h" #include "cd32_fmv.h" #include "custom.h" #include "xwin.h" @@ -47,7 +47,7 @@ void cd32_fmv_new_image(int w, int h, int d, uae_u8 *s) { if (!mpeg_out_buffer) mpeg_out_buffer = xmalloc(uae_u8, MAX_MPEG_WIDTH * MAX_MPEG_HEIGHT * MPEG_PIXBYTES_32); - if (s == nullptr || w > MAX_MPEG_WIDTH || h > MAX_MPEG_HEIGHT) { + if (s == NULL || w > MAX_MPEG_WIDTH || h > MAX_MPEG_HEIGHT) { memset(mpeg_out_buffer, 0, MAX_MPEG_WIDTH * MAX_MPEG_HEIGHT * MPEG_PIXBYTES_32); mpeg_width = MAX_MPEG_WIDTH; mpeg_height = MAX_MPEG_HEIGHT; @@ -72,11 +72,11 @@ static void genlock_32(struct vidbuffer *vbin, struct vidbuffer *vbout, int w, i for (int hh = 0, sh = -voffset; hh < h; sh++, hh += mult) { for (int h2 = 0; h2 < mult; h2++) { uae_u8 *d8 = vbout->bufmem + vbout->rowbytes * (hh + h2 + voffset); - uae_u32 *d32 = reinterpret_cast(d8); + uae_u32 *d32 = (uae_u32*)d8; uae_u8 *s8 = vbin->bufmem + vbin->rowbytes * (hh + h2 + voffset) ; - uae_u32 *srcp = nullptr; + uae_u32 *srcp = NULL; if (sh >= 0 && sh < mpeg_height) - srcp = reinterpret_cast(mpeg_out_buffer + sh * mpeg_width * MPEG_PIXBYTES_32); + srcp = (uae_u32*)(mpeg_out_buffer + sh * mpeg_width * MPEG_PIXBYTES_32); for (int ww = 0, sw = -hoffset; ww < w; sw++, ww += mult) { uae_u32 sv = fmv_border_color; if (sw >= 0 && sw < mpeg_width && srcp) @@ -84,7 +84,7 @@ static void genlock_32(struct vidbuffer *vbin, struct vidbuffer *vbout, int w, i for (int w2 = 0; w2 < mult; w2++) { uae_u32 v; if (s8[0] >= GENLOCK_VAL_32) { - v = *reinterpret_cast(s8); + v = *((uae_u32*)s8); } else { v = sv; } @@ -101,19 +101,19 @@ static void genlock_16(struct vidbuffer *vbin, struct vidbuffer *vbout, int w, i for (int hh = 0, sh = -voffset; hh < h; sh++, hh += mult) { for (int h2 = 0; h2 < mult; h2++) { uae_u8 *d8 = vbout->bufmem + vbout->rowbytes * (hh + h2 + voffset); - uae_u16 *d16 = reinterpret_cast(d8); + uae_u16 *d16 = (uae_u16*)d8; uae_u8 *s8 = vbin->bufmem + vbin->rowbytes * (hh + h2 + voffset) ; - uae_u16 *srcp = nullptr; + uae_u16 *srcp = NULL; if (sh >= 0 && sh < mpeg_height) - srcp = reinterpret_cast(mpeg_out_buffer + sh * mpeg_width * MPEG_PIXBYTES_16); + srcp = (uae_u16*)(mpeg_out_buffer + sh * mpeg_width * MPEG_PIXBYTES_16); for (int ww = 0, sw = -hoffset; ww < w; sw++, ww += mult) { uae_u16 sv = fmv_border_color_16; if (sw >= 0 && sw < mpeg_width && srcp) sv = srcp[sw]; for (int w2 = 0; w2 < mult; w2++) { uae_u32 v; - if ((reinterpret_cast(s8)[0] >> 11) >= GENLOCK_VAL_16) { - v = *reinterpret_cast(s8); + if ((((uae_u16*)s8)[0] >> 11) >= GENLOCK_VAL_16) { + v = *((uae_u16*)s8); } else { v = sv; } @@ -129,18 +129,18 @@ static void genlock_16_nomult(struct vidbuffer *vbin, struct vidbuffer *vbout, i { for (int hh = 0, sh = -voffset; hh < h; sh++, hh++) { uae_u8 *d8 = vbout->bufmem + vbout->rowbytes * (hh + voffset); - uae_u16 *d16 = reinterpret_cast(d8); + uae_u16 *d16 = (uae_u16*)d8; uae_u8 *s8 = vbin->bufmem + vbin->rowbytes * (hh + voffset) ; uae_u16 *srcp = NULL; if (sh >= 0 && sh < mpeg_height) - srcp = reinterpret_cast(mpeg_out_buffer + sh * mpeg_width * MPEG_PIXBYTES_16); + srcp = (uae_u16*)(mpeg_out_buffer + sh * mpeg_width * MPEG_PIXBYTES_16); for (int ww = 0, sw = -hoffset; ww < w; sw++, ww++) { uae_u16 sv = fmv_border_color_16; if (sw >= 0 && sw < mpeg_width && srcp) sv = srcp[sw]; uae_u32 v; - if ((reinterpret_cast(s8)[0] >> 11) >= GENLOCK_VAL_16) { - v = *reinterpret_cast(s8); + if ((((uae_u16*)s8)[0] >> 11) >= GENLOCK_VAL_16) { + v = *((uae_u16*)s8); } else { v = sv; } @@ -152,6 +152,7 @@ static void genlock_16_nomult(struct vidbuffer *vbin, struct vidbuffer *vbout, i void cd32_fmv_genlock(struct vidbuffer *vbin, struct vidbuffer *vbout) { + int hoffset, voffset, mult; int w = vbin->outwidth; int h = vbin->outheight; int d = vbin->pixbytes; @@ -159,7 +160,7 @@ void cd32_fmv_genlock(struct vidbuffer *vbin, struct vidbuffer *vbout) if (!mpeg_out_buffer) return; - int mult = 1; + mult = 1; for (;;) { if (mult < 4 && mpeg_width * (mult << 1) <= w + 8 && mpeg_height * (mult << 1) <= h + 8) { mult <<= 1; @@ -169,8 +170,8 @@ void cd32_fmv_genlock(struct vidbuffer *vbin, struct vidbuffer *vbout) } } - int hoffset = (w / mult - mpeg_width) / 2; - int voffset = (h / mult - mpeg_height) / 2; + hoffset = (w / mult - mpeg_width) / 2; + voffset = (h / mult - mpeg_height) / 2; if (hoffset < 0) hoffset = 0; diff --git a/src/cfgfile.cpp b/src/cfgfile.cpp index ce1f1536..36a3a4be 100644 --- a/src/cfgfile.cpp +++ b/src/cfgfile.cpp @@ -28,7 +28,6 @@ #include "fsdb.h" #include "disk.h" #include "blkdev.h" -#include "statusline.h" #include "calc.h" #include "gfxboard.h" #include "native2amiga_api.h" @@ -46,48 +45,27 @@ static int uaeconfig; * as a help text. */ struct cfg_lines { - const TCHAR *config_label, *config_help; + const TCHAR *config_label, *config_help; }; -static const TCHAR* guimode1[] = {_T("no"), _T("yes"), _T("nowait"), nullptr}; -static const TCHAR* guimode2[] = {_T("false"), _T("true"), _T("nowait"), nullptr}; -static const TCHAR* guimode3[] = {_T("0"), _T("1"), _T("nowait"), nullptr}; -static const TCHAR* csmode[] = {_T("ocs"), _T("ecs_agnus"), _T("ecs_denise"), _T("ecs"), _T("aga"), nullptr}; -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"), - nullptr }; -static const TCHAR *speedmode[] = { _T("max"), _T("real"), nullptr }; -static const TCHAR *colormode1[] = { _T("8bit"), _T("15bit"), _T("16bit"), _T("8bit_dither"), _T("4bit_dither"), _T("32bit"), nullptr }; -static const TCHAR *colormode2[] = { _T("8"), _T("15"), _T("16"), _T("8d"), _T("4d"), _T("32"), nullptr }; -static const TCHAR *soundmode1[] = { _T("none"), _T("interrupts"), _T("normal"), _T("exact"), nullptr }; -static const TCHAR *soundmode2[] = { _T("none"), _T("interrupts"), _T("good"), _T("best"), nullptr }; -static const TCHAR *centermode1[] = { _T("none"), _T("simple"), _T("smart"), nullptr }; -static const TCHAR *centermode2[] = { _T("false"), _T("true"), _T("smart"), nullptr }; -static const TCHAR *stereomode[] = { _T("mono"), _T("stereo"), _T("clonedstereo"), _T("4ch"), _T("clonedstereo6ch"), _T("6ch"), _T("mixed"), nullptr }; -static const TCHAR *interpolmode[] = { _T("none"), _T("anti"), _T("sinc"), _T("rh"), _T("crux"), nullptr }; -static const TCHAR *collmode[] = { _T("none"), _T("sprites"), _T("playfields"), _T("full"), nullptr }; -static const TCHAR *compmode[] = { _T("direct"), _T("indirect"), _T("indirectKS"), _T("afterPic"), nullptr }; -static const TCHAR *flushmode[] = { _T("soft"), _T("hard"), nullptr }; -static const TCHAR *kbleds[] = { _T("none"), _T("POWER"), _T("DF0"), _T("DF1"), _T("DF2"), _T("DF3"), _T("HD"), _T("CD"), nullptr }; -static const TCHAR *onscreenleds[] = { _T("false"), _T("true"), _T("rtg"), _T("both"), nullptr }; -static const TCHAR *soundfiltermode1[] = { _T("off"), _T("emulated"), _T("on"), nullptr }; -static const TCHAR *soundfiltermode2[] = { _T("standard"), _T("enhanced"), nullptr }; -static const TCHAR *lorestype1[] = { _T("lores"), _T("hires"), _T("superhires"), nullptr }; -static const TCHAR *lorestype2[] = { _T("true"), _T("false"), nullptr }; -static const TCHAR *loresmode[] = { _T("normal"), _T("filtered"), nullptr }; -static const TCHAR *horizmode[] = { _T("vertical"), _T("lores"), _T("hires"), _T("superhires"), nullptr }; -static const TCHAR *vertmode[] = { _T("horizontal"), _T("single"), _T("double"), _T("quadruple"), nullptr }; -#ifdef GFXFILTER -static const TCHAR *filtermode2[] = { _T("1x"), _T("2x"), _T("3x"), _T("4x"), 0 }; -#endif -static const TCHAR *cartsmode[] = { _T("none"), _T("hrtmon"), nullptr }; -static const TCHAR *idemode[] = { _T("none"), _T("a600/a1200"), _T("a4000"), nullptr }; -static const TCHAR *rtctype[] = { _T("none"), _T("MSM6242B"), _T("RP5C01A"), _T("MSM6242B_A2000"), nullptr }; -static const TCHAR *ciaatodmode[] = { _T("vblank"), _T("50hz"), _T("60hz"), nullptr }; -static const TCHAR *ksmirrortype[] = { _T("none"), _T("e0"), _T("a8+e0"), nullptr }; +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 *speedmode[] = { _T("max"), _T("real"), 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 *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 *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 *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 *cscompa[] = { _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"), @@ -95,48 +73,15 @@ static const TCHAR *cscompa[] = { nullptr }; static const TCHAR *qsmodes[] = { - _T("A500"), _T("A500+"), _T("A600"), _T("A1200"), _T("A4000"), _T("CD32"), nullptr }; -/* 3-state boolean! */ -static const TCHAR *fullmodes[] = { _T("false"), _T("true"), /* "FILE_NOT_FOUND", */ _T("fullwindow"), nullptr }; -/* bleh for compatibility */ -static const TCHAR *scsimode[] = { _T("false"), _T("true"), _T("scsi"), nullptr }; -static const TCHAR *maxhoriz[] = { _T("lores"), _T("hires"), _T("superhires"), nullptr }; -static const TCHAR *maxvert[] = { _T("nointerlace"), _T("interlace"), nullptr }; -static const TCHAR *abspointers[] = { _T("none"), _T("mousehack"), _T("tablet"), nullptr }; -static const TCHAR *magiccursors[] = { _T("both"), _T("native"), _T("host"), nullptr }; -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"), nullptr }; -static const TCHAR *autoscale_rtg[] = { _T("resize"), _T("scale"), _T("center"), _T("integer"), nullptr }; -static const TCHAR *joyportmodes[] = { _T(""), _T("mouse"), _T("mousenowheel"), _T("djoy"), _T("gamepad"), _T("ajoy"), _T("cdtvjoy"), _T("cd32joy"), _T("lightpen"), nullptr }; -static const TCHAR *joyaf[] = { _T("none"), _T("normal"), _T("toggle"), nullptr }; -static const TCHAR *epsonprinter[] = { _T("none"), _T("ascii"), _T("epson_matrix_9pin"), _T("epson_matrix_24pin"), _T("epson_matrix_48pin"), nullptr }; -static const TCHAR *aspects[] = { _T("none"), _T("vga"), _T("tv"), nullptr }; -static const TCHAR *vsyncmodes[] = { _T("false"), _T("true"), _T("autoswitch"), nullptr }; -static const TCHAR *vsyncmodes2[] = { _T("normal"), _T("busywait"), nullptr }; -static const TCHAR *filterapi[] = { _T("directdraw"), _T("direct3d"), nullptr }; -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"), - nullptr -}; -static const TCHAR *cdmodes[] = { _T("disabled"), _T(""), _T("image"), _T("ioctl"), _T("spti"), _T("aspi"), nullptr }; -static const TCHAR *cdconmodes[] = { _T(""), _T("uae"), _T("ide"), _T("scsi"), _T("cdtv"), _T("cd32"), nullptr }; -static const TCHAR *specialmonitors[] = { _T("none"), _T("autodetect"), _T("a2024"), _T("graffiti"), nullptr }; -static const TCHAR *rtgtype[] = { - _T("ZorroII"), _T("ZorroIII"), - _T("PicassoII"), - _T("PicassoII+"), - _T("Piccolo_Z2"), _T("Piccolo_Z3"), - _T("PiccoloSD64_Z2"), _T("PiccoloSD64_Z3"), - _T("Spectrum28/24_Z2"), _T("Spectrum28/24_Z3"), - _T("PicassoIV_Z2"), _T("PicassoIV_Z3"), - nullptr }; -static const TCHAR *waitblits[] = { _T("disabled"), _T("automatic"), _T("noidleonly"), _T("always"), nullptr }; -static const TCHAR *autoext2[] = { _T("disabled"), _T("copy"), _T("replace"), nullptr }; -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"), nullptr }; -static int leds_order[] = { 3, 6, 7, 8, 9, 4, 5, 2, 1, 0, 9 }; -static const TCHAR *lacer[] = { _T("off"), _T("i"), _T("p"), nullptr }; + _T("A500"), _T("A500+"), _T("A600"), _T("A1200"), _T("A4000"), _T("CD32"), NULL }; +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 }; +static const TCHAR *joyaf[] = { _T("none"), _T("normal"), _T("toggle"), _T("always"), 0 }; +static const TCHAR *vsyncmodes[] = { _T("adaptive"), _T("false"), _T("true"), _T("autoswitch"), 0 }; +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 *waitblits[] = { _T("disabled"), _T("automatic"), _T("noidleonly"), _T("always"), 0 }; +static const TCHAR *autoext2[] = { _T("disabled"), _T("copy"), _T("replace"), 0 }; struct hdcontrollerconfig { @@ -246,15 +191,15 @@ 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) { for (int i = 0; table[i] != nullptr; i++) if (_tcsicmp(table[i], str) == 0) @@ -352,10 +297,10 @@ static TCHAR *cfgfile_escape_min(const TCHAR *s) 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), c2; + TCHAR *s2 = xmalloc (TCHAR, _tcslen (s) + 1); TCHAR *p = s2; if (s[0] == '\"') { s++; @@ -374,31 +319,31 @@ static TCHAR *cfgfile_unescape(const TCHAR *s, const TCHAR **endpos, TCHAR separ } if (c == '\\') { char v = 0; + TCHAR c2; 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; } } @@ -407,18 +352,17 @@ static TCHAR *cfgfile_unescape(const TCHAR *s, const TCHAR **endpos, TCHAR separ *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); @@ -1155,25 +1099,23 @@ void cfgfile_save_options(struct zfile *f, struct uae_prefs *p, int type) } } - 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_write(f, _T("cd_speed"), _T("%d"), p->cd_speed); + 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_write (f, _T("cd_speed"), _T("%d"), p->cd_speed); - 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); + 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 (f, _T("sound_volume_cd"), _T("%d"), p->sound_volume_cd); - cfgfile_write(f, _T("cachesize"), _T("%d"), p->cachesize); + cfgfile_write (f, _T("cachesize"), _T("%d"), p->cachesize); for (i = 0; i < MAX_JPORTS; i++) { struct jport *jp = &p->jports[i]; @@ -1226,59 +1168,61 @@ void cfgfile_save_options(struct zfile *f, struct uae_prefs *p, int type) cfgfile_dwrite_str(f, _T("uaeboard"), uaeboard[p->uaeboard]); cfgfile_dwrite_str(f, _T("absolute_mouse"), abspointers[p->input_tablet]); - 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 (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]); - cfgfile_write_str(f, _T("gfx_vsync_picasso"), vsyncmodes[p->gfx_apmode[1].gfx_vsync]); - 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_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("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("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_write_bool (f, _T("ntsc"), p->ntscmode); - 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)); - - 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")); + cfgfile_dwrite_bool (f, _T("show_leds"), p->leds_on_screen); + 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); + cfgfile_write (f, _T("chipset_refreshrate"), _T("%f"), p->chipset_refreshrate); for (int i = 0; i < MAX_CHIPSET_REFRESH_TOTAL; i++) { - if (p->cr[i].rate <= 0) - continue; struct chipset_refresh *cr = &p->cr[i]; + if (!cr->inuse) + continue; cr->index = i; - _stprintf(tmp, _T("%f"), cr->rate); - TCHAR *s = tmp + _tcslen(tmp); + 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); + s += _stprintf (s, _T(",t=%s"), cr->label); if (cr->horiz > 0) - s += _stprintf(s, _T(",h=%d"), cr->horiz); + s += _stprintf (s, _T(",h=%d"), cr->horiz); if (cr->vert > 0) - s += _stprintf(s, _T(",v=%d"), cr->vert); + s += _stprintf (s, _T(",v=%d"), cr->vert); if (cr->locked) - _tcscat(s, _T(",locked")); + _tcscat (s, _T(",locked")); if (cr->ntsc > 0) - _tcscat(s, _T(",ntsc")); + _tcscat (s, _T(",ntsc")); else if (cr->ntsc == 0) - _tcscat(s, _T(",pal")); + _tcscat (s, _T(",pal")); if (cr->lace > 0) - _tcscat(s, _T(",lace")); + _tcscat (s, _T(",lace")); else if (cr->lace == 0) - _tcscat(s, _T(",nlace")); + _tcscat (s, _T(",nlace")); if ((cr->resolution & 7) != 7) { if (cr->resolution & 1) _tcscat(s, _T(",lores")); @@ -1288,11 +1232,11 @@ void cfgfile_save_options(struct zfile *f, struct uae_prefs *p, int type) _tcscat(s, _T(",shres")); } if (cr->vsync > 0) - _tcscat(s, _T(",vsync")); + _tcscat (s, _T(",vsync")); else if (cr->vsync == 0) - _tcscat(s, _T(",nvsync")); + _tcscat (s, _T(",nvsync")); if (cr->rtg) - _tcscat(s, _T(",rtg")); + _tcscat (s, _T(",rtg")); if (cr->defaultdata) _tcscat(s, _T(",default")); if (i == CHIPSET_REFRESH_PAL) @@ -1408,9 +1352,6 @@ void cfgfile_save_options(struct zfile *f, struct uae_prefs *p, int type) cfgfile_write(f, _T("rtg_modes"), _T("0x%x"), p->picasso96_modeflags); - cfgfile_dwrite(f, _T("state_replay_rate"), _T("%d"), p->statecapturerate); - cfgfile_dwrite(f, _T("state_replay_buffers"), _T("%d"), p->statecapturebuffersize); - 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") @@ -1883,7 +1824,6 @@ static int cfgfile_parse_host(struct uae_prefs *p, TCHAR *option, TCHAR *value) TCHAR *next2 = _tcschr(next, ':'); if (next2) *next2++ = 0; - int tmpval = 0; if (!_tcsicmp(next, _T("delay"))) { p->cdslots[i].delayed = true; next = next2; @@ -1989,37 +1929,31 @@ static int cfgfile_parse_host(struct uae_prefs *p, TCHAR *option, TCHAR *value) 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_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)) { - if (vb) - p->leds_on_screen |= STATUSLINE_CHIPSET; - else - p->leds_on_screen &= ~STATUSLINE_CHIPSET; + if(cfgfile_yesno (option, value, _T("show_leds"), &vb)) { + p->leds_on_screen = vb; return 1; - } - 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 (_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; - } + 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; + } 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); @@ -3067,66 +3001,64 @@ 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) { int tmpval, dummyint, i; - bool tmpbool, dummybool; - TCHAR *section = nullptr; TCHAR tmpbuf[CONFIG_BLEN]; - if (cfgfile_yesno(option, value, _T("immediate_blits"), &p->immediate_blits) + 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) - || cfgfile_yesno(option, value, _T("pcmcia"), &p->cs_pcmcia) + || 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("cia_overlay"), &p->cs_ciaoverlay) || 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("cia_todbug"), &p->cs_ciatodbug) || 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("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; + return 1; - 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; + 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; - 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_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) || 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; + 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)) + || 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_string(option, value, _T("uaeboard_options"), tmpbuf, sizeof tmpbuf / sizeof(TCHAR))) { TCHAR *s = cfgfile_option_get(value, _T("order")); @@ -3461,6 +3393,7 @@ static void calcformula(struct uae_prefs *prefs, TCHAR *in) else _stprintf(in, _T("%d"), (int)val); updatestore = true; + return; } } @@ -3468,10 +3401,6 @@ int cfgfile_parse_option(struct uae_prefs *p, const TCHAR *option, TCHAR *value, { calcformula(p, value); - 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"))) @@ -3503,7 +3432,7 @@ static int isutf8ext(TCHAR *s) return 0; } -int cfgfile_separate_linea(const TCHAR *filename, char *line, TCHAR *line1b, TCHAR *line2b) +int cfgfile_separate_linea (const TCHAR *filename, char *line, TCHAR *line1b, TCHAR *line2b) { char *line1 = line; line1 += strspn(line1, "\t \r\n"); @@ -3636,24 +3565,6 @@ static void cfgfile_parse_separated_line(struct uae_prefs *p, TCHAR *line1b, TCH } } -void cfgfile_parse_lines(struct uae_prefs *p, const TCHAR *lines, int 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); -} - void cfgfile_parse_line(struct uae_prefs *p, TCHAR *line, int type) { TCHAR line1b[CONFIG_BLEN], line2b[CONFIG_BLEN]; @@ -3820,19 +3731,6 @@ end: return v; } -void cfgfile_backup(const TCHAR *path) -{ - TCHAR dpath[MAX_DPATH]; - - 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_save(struct uae_prefs *p, const TCHAR *filename, int type) { struct zfile *fh = zfile_fopen(filename, _T("w"), ZFD_NORMAL); @@ -4486,10 +4384,6 @@ void default_prefs(struct uae_prefs *p, bool reset, int type) p->mountconfig[i].unitnum = -1; } - memset(&p->jports[0], 0, sizeof(struct jport)); - memset(&p->jports[1], 0, sizeof(struct jport)); - memset(&p->jports[2], 0, sizeof(struct jport)); - memset(&p->jports[3], 0, sizeof(struct jport)); p->jports[0].id = -1; p->jports[1].id = -1; p->jports[2].id = -1; @@ -4500,22 +4394,29 @@ void default_prefs(struct uae_prefs *p, bool reset, int type) } p->keyboard_lang = KBD_LANG_US; - 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 = 1; - p->sound_filter = FILTER_SOUND_OFF; - p->sound_filter_type = 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->cachesize = 0; - p->gfx_framerate = 0; + p->gfx_framerate = 0; + +#ifdef RASPBERRY p->gfx_size.width = 640; p->gfx_size.height = 256; p->gfx_resolution = RES_HIRES; +#else + p->gfx_size.width = 320; + p->gfx_size.height = 240; + p->gfx_resolution = RES_LORES; +#endif p->immediate_blits = false; p->waiting_blits = 0; @@ -4523,6 +4424,11 @@ void default_prefs(struct uae_prefs *p, bool reset, int type) p->collision_level = 2; p->leds_on_screen = 0; p->boot_rom = 0; +#ifdef PANDORA + p->fast_copper = 1; +#else + p->fast_copper = 0; +#endif p->cart_internal = 1; p->cs_compatible = CP_GENERIC; @@ -4540,10 +4446,10 @@ void default_prefs(struct uae_prefs *p, bool reset, int type) p->cs_df0idhw = true; p->cs_ciatodbug = false; - _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")); + _tcscpy (p->floppyslots[0].df, _T("")); + _tcscpy (p->floppyslots[1].df, _T("")); + _tcscpy (p->floppyslots[2].df, _T("")); + _tcscpy (p->floppyslots[3].df, _T("")); configure_rom(p, roms, 0); _tcscpy(p->romextfile, _T("")); diff --git a/src/cia.cpp b/src/cia.cpp index 6e3971fc..d5027a32 100644 --- a/src/cia.cpp +++ b/src/cia.cpp @@ -31,10 +31,10 @@ #include "autoconf.h" #include "rtc.h" -/* - * Akiko internal CIA differences: - * - * - BFE101 and BFD100: reads 3F if data direction is in. +/* 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 @@ -334,6 +334,7 @@ static void CIA_calctimers (void) int div10diff = DIV10 - div10; eventtab[ev_cia].oldcycles = get_cycles (); + if ((ciaacra & 0x21) == 0x01) { ciaatimea = div10diff + DIV10 * (ciaata + ciaastarta); } @@ -381,7 +382,7 @@ static bool checkalarm (unsigned long tod, unsigned long alarm, bool inc) { if (tod == alarm) return true; - if (!currprefs.cs_ciatodbug) + if (!currprefs.cs_ciatodbug) return false; if (!inc) return false; @@ -396,7 +397,7 @@ static bool checkalarm (unsigned long tod, unsigned long alarm, bool inc) return false; } -STATIC_INLINE void ciab_checkalarm(bool inc, bool irq) +STATIC_INLINE void 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 @@ -404,17 +405,17 @@ STATIC_INLINE void ciab_checkalarm(bool inc, bool irq) // at least 1 or larger due to bus cycle delays when reading // old value. #if 1 - if ((munge24(m68k_getpc()) & 0xFFF80000) != 0xF80000) { + if ((munge24 (m68k_getpc ()) & 0xFFF80000) != 0xF80000) { if (ciabtod == 0 && ciabalarm == 0) return; } #endif - if (checkalarm(ciabtod, ciabalarm, inc)) { + if (checkalarm (ciabtod, ciabalarm, inc)) { if (irq) { - ciabicr |= 4; - RethinkICRB(); - } - } + ciabicr |= 4; + RethinkICRB (); + } + } } STATIC_INLINE void ciaa_checkalarm (bool inc) @@ -425,9 +426,9 @@ STATIC_INLINE void ciaa_checkalarm (bool inc) } } -static void setcode(uae_u8 keycode) +static void setcode (uae_u8 keycode) { - kbcode = ~((keycode << 1) | (keycode >> 7)); + kbcode = ~((keycode << 1) | (keycode >> 7)); } static void keyreq (void) @@ -439,9 +440,9 @@ static void keyreq (void) } /* 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; @@ -449,33 +450,33 @@ 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) +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 @@ -483,13 +484,13 @@ static void CIAB_tod_check(void) event2_newevent(ev2_ciab_tod, -hpos, 0); } -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)) { // causes interrupt on this line, add event ciab_tod_event_state = 2; // event active event2_newevent(ev2_ciab_tod, ciab_tod_hoffset, 0); @@ -498,66 +499,65 @@ void CIAB_tod_handler(int hoffset) STATIC_INLINE void check_keyboard(void) { - 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 ((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 (); } } -void CIA_hsync_posthandler(bool ciahsync) +void CIA_hsync_posthandler (bool ciahsync) { 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 { + } else { // custom hsync - if ((hsync_counter & 15) == 0) - check_keyboard(); - } + if ((hsync_counter & 15) == 0) + check_keyboard(); + } } -void CIA_vsync_prehandler(void) +void CIA_vsync_prehandler (void) { - CIA_handler(); + CIA_handler (); if (kblostsynccnt > 0) { kblostsynccnt -= maxvpos; if (kblostsynccnt <= 0) { kblostsynccnt = 0; - keyreq(); + keyreq (); } } } -void CIAA_tod_handler(uae_u32 v) +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) { if (!ciaatodon) return; @@ -578,458 +578,449 @@ STATIC_INLINE void check_led (void) } } -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 { + 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_u8 ReadCIAA(unsigned int addr) +static uae_u8 ReadCIAA (unsigned int addr) { - unsigned int tmp; - int reg = addr & 15; + unsigned int tmp; + int reg = addr & 15; - compute_passed_time(); + compute_passed_time (); - switch (reg) { - case 0: + 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; + uae_u8 v = DISK_status_ciaa() & 0x3c; + v |= handle_joystick_buttons (ciaapra, ciaadra); + v |= (ciaapra | (ciaadra ^ 3)) & 0x03; + return v; } - case 1: + case 1: #ifdef INPUTDEVICE_SIMPLE - tmp = (ciaaprb & ciaadrb) | (ciaadrb ^ 0xff); + tmp = (ciaaprb & ciaadrb) | (ciaadrb ^ 0xff); #else - tmp = handle_parport_joystick(0, ciaaprb, ciaadrb); + tmp = handle_parport_joystick (0, ciaaprb, ciaadrb); #endif - if (ciaacrb & 2) { - int pb7 = 0; - if (ciaacrb & 4) - pb7 = ciaacrb & 1; - tmp &= ~0x80; - tmp |= pb7 ? 0x80 : 00; - } - if (ciaacra & 2) { - int pb6 = 0; - if (ciaacra & 4) - pb6 = ciaacra & 1; - tmp &= ~0x40; - tmp |= pb6 ? 0x40 : 00; - } - return tmp; - case 2: - return ciaadra; - case 3: - return ciaadrb; - case 4: - return (uae_u8)((ciaata - ciaata_passed) & 0xff); - case 5: - return (uae_u8)((ciaata - ciaata_passed) >> 8); - case 6: - return (uae_u8)((ciaatb - ciaatb_passed) & 0xff); - case 7: - return (uae_u8)((ciaatb - ciaatb_passed) >> 8); - case 8: - if (ciaatlatch) { - ciaatlatch = 0; - return (uae_u8)ciaatol; - } - else - return (uae_u8)ciaatod; - case 9: - if (ciaatlatch) - return (uae_u8)(ciaatol >> 8); - else - return (uae_u8)(ciaatod >> 8); - case 10: - /* only if not already latched. A1200 confirmed. (TW) */ - if (!ciaatlatch) { - /* no latching if ALARM is set */ - if (!(ciaacrb & 0x80)) - ciaatlatch = 1; - ciaatol = ciaatod; - } - return (uae_u8)(ciaatol >> 16); + if (ciaacrb & 2) { + int pb7 = 0; + if (ciaacrb & 4) + pb7 = ciaacrb & 1; + tmp &= ~0x80; + tmp |= pb7 ? 0x80 : 00; + } + if (ciaacra & 2) { + int pb6 = 0; + if (ciaacra & 4) + pb6 = ciaacra & 1; + tmp &= ~0x40; + tmp |= pb6 ? 0x40 : 00; + } + return tmp; + case 2: + return ciaadra; + case 3: + return ciaadrb; + case 4: + return (uae_u8)((ciaata - ciaata_passed) & 0xff); + case 5: + return (uae_u8)((ciaata - ciaata_passed) >> 8); + case 6: + return (uae_u8)((ciaatb - ciaatb_passed) & 0xff); + case 7: + return (uae_u8)((ciaatb - ciaatb_passed) >> 8); + case 8: + if (ciaatlatch) { + ciaatlatch = 0; + return (uae_u8)ciaatol; + } else + return (uae_u8)ciaatod; + case 9: + if (ciaatlatch) + return (uae_u8)(ciaatol >> 8); + else + return (uae_u8)(ciaatod >> 8); + case 10: + /* only if not already latched. A1200 confirmed. (TW) */ + if (!ciaatlatch) { + /* 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: + case 12: + return ciaasdr; + case 13: tmp = ciaaicr & ~(0x40 | 0x20); ciaaicr = 0; - return tmp; - case 14: - return ciaacra; - case 15: - return ciaacrb; - } - return 0; + return tmp; + case 14: + return ciaacra; + case 15: + return ciaacrb; + } + return 0; } -static uae_u8 ReadCIAB(unsigned int addr) +static uae_u8 ReadCIAB (unsigned int addr) { - unsigned int tmp; - int reg = addr & 15; + unsigned int tmp; + int reg = addr & 15; - compute_passed_time(); + compute_passed_time (); - switch (reg) { - case 0: + switch (reg) { + case 0: tmp = 0; #ifdef INPUTDEVICE_SIMPLE tmp = ((ciabpra & ciabdra) | (ciabdra ^ 0xff)) & 0x7; #else - tmp |= handle_parport_joystick(1, ciabpra, ciabdra); + tmp |= handle_parport_joystick (1, ciabpra, ciabdra); #endif return tmp; - case 1: - tmp = ciabprb; - if (ciabcrb & 2) { - int pb7 = 0; - if (ciabcrb & 4) - pb7 = ciabcrb & 1; - tmp &= ~0x80; - tmp |= pb7 ? 0x80 : 00; - } - if (ciabcra & 2) { - int pb6 = 0; - if (ciabcra & 4) - pb6 = ciabcra & 1; - tmp &= ~0x40; - tmp |= pb6 ? 0x40 : 00; - } - return tmp; - case 2: - return ciabdra; - case 3: - return ciabdrb; - case 4: - return (uae_u8)((ciabta - ciabta_passed) & 0xff); - case 5: - return (uae_u8)((ciabta - ciabta_passed) >> 8); - case 6: - return (uae_u8)((ciabtb - ciabtb_passed) & 0xff); - 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)) - ciabtlatch = 1; - ciabtol = ciabtod; - } - return (uae_u8)(ciabtol >> 16); + case 1: + tmp = ciabprb; + if (ciabcrb & 2) { + int pb7 = 0; + if (ciabcrb & 4) + pb7 = ciabcrb & 1; + tmp &= ~0x80; + tmp |= pb7 ? 0x80 : 00; + } + if (ciabcra & 2) { + int pb6 = 0; + if (ciabcra & 4) + pb6 = ciabcra & 1; + tmp &= ~0x40; + tmp |= pb6 ? 0x40 : 00; + } + return tmp; + case 2: + return ciabdra; + case 3: + return ciabdrb; + case 4: + return (uae_u8)((ciabta - ciabta_passed) & 0xff); + case 5: + return (uae_u8)((ciabta - ciabta_passed) >> 8); + case 6: + return (uae_u8)((ciabtb - ciabtb_passed) & 0xff); + 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)) + ciabtlatch = 1; + ciabtol = ciabtod; + } + return (uae_u8)(ciabtol >> 16); case 11: break; - case 12: - return ciabsdr; - case 13: + case 12: + return ciabsdr; + case 13: tmp = ciabicr & ~(0x40 | 0x20); ciabicr = 0; - return tmp; - case 14: - return ciabcra; - case 15: - return ciabcrb; - } - return 0; + return tmp; + case 14: + return ciabcra; + case 15: + return ciabcrb; + } + return 0; } -static void WriteCIAA(uae_u16 addr, uae_u8 val) +static void WriteCIAA (uae_u16 addr,uae_u8 val) { int reg = addr & 15; #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; + 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; + } + 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; + } + 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: 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 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; + } } -static void WriteCIAB(uae_u16 addr, uae_u8 val) +static void WriteCIAB (uae_u16 addr,uae_u8 val) { int reg = addr & 15; #ifdef ACTION_REPLAY ar_ciab[reg] = val; #endif - switch (reg) { - case 0: - ciabpra = val; - break; - case 1: + switch (reg) { + case 0: + ciabpra = val; + 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; + 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; + } + 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; + } + 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: 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 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) +void cia_set_overlay (bool overlay) { oldovl = overlay; } @@ -1037,98 +1028,95 @@ void cia_set_overlay(bool overlay) /* CIA memory access */ DECLARE_MEMORY_FUNCTIONS(cia); -static uae_u32 REGPARAM3 cia_bget_compatible(uaecptr) REGPARAM; +static uae_u32 REGPARAM3 cia_bget_compatible (uaecptr) REGPARAM; addrbank cia_bank = { - cia_lget, cia_wget, cia_bget, - cia_lput, cia_wput, cia_bput, + 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 + 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; + if (currprefs.cpu_model == 68000 && currprefs.cpu_compatible) + cia_bank.bget = cia_bget_compatible; + else + cia_bank.bget = cia_bget; - kblostsynccnt = 0; + kblostsynccnt = 0; oldcd32mute = 1; 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; + ciaatol = ciabtol = ciaaprb = ciaadrb = ciabprb = ciabdrb = 0; + CIA_calctimers (); + DISK_select_set (ciabprb); + } + map_overlay (0); + check_led (); + 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) +static void cia_wait_pre (void) { if (currprefs.cachesize) return; - int div = (get_cycles() - eventtab[ev_cia].oldcycles) % DIV10; - int cycles; + int div = (get_cycles () - eventtab[ev_cia].oldcycles) % DIV10; + int cycles; - if (div >= DIV10 * ECLOCK_DATA_CYCLE / 10) { - cycles = DIV10 - div; - cycles += DIV10 * ECLOCK_DATA_CYCLE / 10; - } - else if (div) { + if (div >= DIV10 * ECLOCK_DATA_CYCLE / 10) { + cycles = DIV10 - div; + cycles += DIV10 * ECLOCK_DATA_CYCLE / 10; + } else if (div) { cycles = DIV10 + DIV10 * ECLOCK_DATA_CYCLE / 10 - div; - } - else { - cycles = DIV10 * ECLOCK_DATA_CYCLE / 10 - div; - } + } else { + cycles = DIV10 * ECLOCK_DATA_CYCLE / 10 - div; + } if (cycles) { - do_cycles(cycles); - } + do_cycles (cycles); + } } -static void cia_wait_post(uae_u32 value) +static void cia_wait_post (uae_u32 value) { if (currprefs.cachesize) { - do_cycles(8 * CYCLE_UNIT / 2); - } - else { + do_cycles (8 * CYCLE_UNIT / 2); + } else { int c = 6 * CYCLE_UNIT / 2; - do_cycles(c); - } + do_cycles (c); + } } // Gayle or Fat Gary does not enable CIA /CS lines if both CIAs are selected @@ -1152,7 +1140,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); @@ -1178,7 +1166,46 @@ static int cia_chipselect(uaecptr addr) return cs; } -static uae_u32 REGPARAM2 cia_bget_compatible(uaecptr addr) +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) { int r = (addr & 0xf00) >> 8; uae_u8 v = 0; @@ -1186,75 +1213,36 @@ static uae_u32 REGPARAM2 cia_bget_compatible(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) ? 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; + 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; case 3: - cia_wait_pre(); - v = (addr & 1) ? regs.irc : regs.irc >> 8; - cia_wait_post(v); - break; - } + v = 0xff; + break; + } - return v; + return v; } -static uae_u32 REGPARAM2 cia_bget(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) ? 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; - case 3: - v = 0xff; - break; - } - - 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; @@ -1262,138 +1250,137 @@ static uae_u32 REGPARAM2 cia_wget(uaecptr addr) if (isgarynocia(addr)) return dummy_get(addr, 2, false, 0); - if (!isgaylenocia(addr)) + if (!isgaylenocia (addr)) return dummy_get_safe(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 (); + v = (ReadCIAB (r) << 8) | ReadCIAA (r); + cia_wait_post (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 (); + 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; 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 (); + v = regs.irc; + cia_wait_post (v); + } + 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 (uaecptr 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)) { 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 (); + if ((cs & 2) == 0) + WriteCIAB (r, value); + if ((cs & 1) == 0) + WriteCIAA (r, value); + cia_wait_post (value); + } } -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)) { 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 (); + if ((cs & 2) == 0) + WriteCIAB (r, value >> 8); + if ((cs & 1) == 0) + WriteCIAA (r, value & 0xff); + cia_wait_post (value); + } } -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 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 */ + } else if (currprefs.cs_rtc == 2) { /* RF5C01A */ return get_clock_ricoh(&rtc_ricoh, addr, ct); } return v; @@ -1406,87 +1393,85 @@ void rtc_hardreset(void) 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 */ + } 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); + 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 */ } } -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; + 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); + } + time_t t = time(0); + 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) { 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) { 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) { if ((addr & 0xffff) >= 0x8000 && currprefs.cs_fatgaryrev >= 0) { return; } - addr &= 0x3f; + 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 */ + } else if (currprefs.cs_rtc == 2) { /* RF5C01A */ put_clock_ricoh(&rtc_ricoh, addr, value); } } @@ -1495,205 +1480,205 @@ static void REGPARAM2 clock_bput(uaecptr addr, uae_u32 value) /* 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; 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); + 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, 100); - 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 (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(); + 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 657bcf89..3a301a6e 100644 --- a/src/custom.cpp +++ b/src/custom.cpp @@ -664,14 +664,6 @@ static int toscr_delay[2]; we can do more work at once. */ static int toscr_nbits; -/* undocumented bitplane delay hardware feature */ -static int delayoffset; - -STATIC_INLINE void compute_delay_offset() -{ - delayoffset = (16 << fetchmode) - (((plfstrt - HARD_DDF_START_REAL) & fetchstart_mask) << 1); -} - static void record_color_change2(int hpos, int regno, unsigned long value) { int pos = hpos * 2; @@ -720,20 +712,6 @@ STATIC_INLINE void update_denise(int hpos) } } -static int islinetoggle() -{ - 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_1(int bplcon1) { @@ -1845,11 +1823,6 @@ STATIC_INLINE void decide_fetch(int hpos) } } -STATIC_INLINE void decide_fetch_safe(int hpos) -{ - decide_fetch(hpos); -} - static void reset_bpl_vars(void) { out_nbits = 0; @@ -4586,48 +4559,47 @@ static void update_copper(int until_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; - // } - //} + /* 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; + } break; - } - - cop_state.state = COP_read1; - } - break; - - case COP_skip1: - { - unsigned int vcmp, hcmp, vp1, hp1; + + case COP_skip1: + { + unsigned int vcmp, hcmp, vp1, hp1; if (c_hpos >= (maxhpos & ~1) || (c_hpos & 1)) break; @@ -4655,14 +4627,14 @@ static void update_copper(int until_hpos) 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(); - //} + + 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) @@ -4696,14 +4668,14 @@ 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); + + if(currprefs.fast_copper) { + predict_copper (); + if (! eventtab[ev_copper].active) + set_special (SPCFLAG_COPPER); } - else*/ - set_special(SPCFLAG_COPPER); + else + set_special (SPCFLAG_COPPER); } static void copper_handler(void) @@ -5579,9 +5551,6 @@ static void hsync_handler_post(bool onvsync) events_dmal_hsync(); if (currprefs.m68k_speed < 0) { - if (vpos > 0 && !(vpos & 0x3f)) - partial_draw_frame(); - 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 */ @@ -6945,7 +6914,8 @@ void check_prefs_changed_custom(void) 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.collision_level = changed_prefs.collision_level; + currprefs.fast_copper = changed_prefs.fast_copper; currprefs.cs_ciaatod = changed_prefs.cs_ciaatod; currprefs.cs_rtc = changed_prefs.cs_rtc; diff --git a/src/disk.cpp b/src/disk.cpp index 3543511c..a1e9bf93 100644 --- a/src/disk.cpp +++ b/src/disk.cpp @@ -1,4 +1,4 @@ -/* + /* * UAE - The Un*x Amiga Emulator * * Floppy disk emulation @@ -103,13 +103,12 @@ 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; + uae_u16 len; + uae_u32 offs; + int bitlen, track; + uae_u16 sync; + image_tracktype type; int revolutions; } trackid; @@ -131,56 +130,55 @@ typedef struct { #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_IPF, ADF_SCP, ADF_CATWEASEL, ADF_PCDOS, ADF_KICK, ADF_SKICK } drive_filetype; - typedef struct { - struct zfile *diskfile; - struct zfile *writediskfile; + 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; + 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 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; + 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 */ + 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 */ } drive; #define MIN_STEPLIMIT_CYCLE (CYCLE_UNIT * 140) @@ -189,14 +187,14 @@ static uae_u16 bigmfmbufw[0x4000 * DDHDMULT]; static drive floppy[MAX_FLOPPY_DRIVES]; static TCHAR dfxhistory[HISTORY_MAX][MAX_PREVIOUS_IMAGES][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, @@ -211,52 +209,52 @@ 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; + 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; - } + 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, NULL); tv.tv_sec -= _timezone; mtv.tv_sec = tv.tv_sec; mtv.tv_usec = tv.tv_usec; - timeval_to_amiga(&mtv, &days, &mins, &ticks, 50); + timeval_to_amiga (&mtv, &days, &mins, &ticks, 50); if (days == pdays && mins == pmins && ticks == pticks) { ticks++; if (ticks >= 50 * 60) { @@ -264,52 +262,52 @@ static void disk_date(uae_u8 *p) 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[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[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) + char *dn = ua (disk_name); + if (strlen (dn) >= 30) dn[30] = 0; const char *dn2 = dn; 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); - xfree(dn); + 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); + 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; } @@ -320,119 +318,118 @@ static int getblock(uae_u8 *bitmap, int *prev) 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 ((char *)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 ((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; - 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 (;;) { uae_u32 mask = 0; @@ -441,108 +438,108 @@ static void createbitmapblock(uae_u8 *sector, uae_u8 *bitmap) 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; + 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; + 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); + 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); - createbitmapblock(sector1, bitmap); - writeimageblock(dst, sector1, 881 * FS_FLOPPY_BLOCKSIZE); + createbootblock (sector1, 1); + writeimageblock (dst, sector1, 0 * FS_FLOPPY_BLOCKSIZE); - createbootblock(sector1, 1); - writeimageblock(dst, sector1, 0 * FS_FLOPPY_BLOCKSIZE); - - return 1; + return 1; } -static bool isfloppysound(drive *drv) +static bool isfloppysound (drive *drv) { return drv->useturbo == 0; } -static int get_floppy_speed(void) +static int get_floppy_speed (void) { - int m = currprefs.floppy_speed; - if (m <= 10) - m = 100; - m = NORMAL_FLOPPY_SPEED * 100 / m; - return m; + int m = currprefs.floppy_speed; + if (m <= 10) + m = 100; + m = NORMAL_FLOPPY_SPEED * 100 / m; + return m; } -static int get_floppy_speed2(drive *drv) +static int get_floppy_speed2 (drive *drv) { - int m = get_floppy_speed() * drv->tracklen / (2 * 8 * FLOPPY_WRITE_LEN * drv->ddhd); - if (m <= 0) - m = 1; - return m; + int m = get_floppy_speed () * drv->tracklen / (2 * 8 * FLOPPY_WRITE_LEN * drv->ddhd); + if (m <= 0) + m = 1; + return m; } static const 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"); - } + 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"); } @@ -551,238 +548,236 @@ 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; + 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: + case DRV_PC_ONLY_40: + case DRV_PC_ONLY_80: + 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: + case ADF_FDI: #ifdef FDI2RAW - fdi2raw_header_free(drv->fdi); - drv->fdi = 0; + fdi2raw_header_free (drv->fdi); + drv->fdi = 0; #endif - break; - } - drv->filetype = ADF_NONE; - zfile_fclose(drv->diskfile); + break; + } + drv->filetype = ADF_NONE; + zfile_fclose (drv->diskfile); drv->diskfile = NULL; - zfile_fclose(drv->writediskfile); + zfile_fclose (drv->writediskfile); drv->writediskfile = NULL; zfile_fclose(drv->pcdecodedfile); drv->pcdecodedfile = NULL; } -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 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); + 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; + 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; + 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->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; + && 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); + 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); } -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; + 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 (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); + if (wrprot) + *wrprot = 1; + 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)) { + } 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); - } + *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); + } return 1; - } - else { - if (wrprot) - *wrprot = 1; - return 0; - } - } + } else { + if (wrprot) + *wrprot = 1; + 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; + 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) +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; + 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); + 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; + 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) { int i; - i = _tcslen(name) - 1; + i = _tcslen (name) - 1; while (i > 0) { if (name[i] == '/' || name[i] == '\\') { name[i] = 0; @@ -809,7 +804,7 @@ static void saveimagecutfilepart(TCHAR *name) int i; _tcscpy(tmp, name); - i = _tcslen(tmp) - 1; + i = _tcslen (tmp) - 1; while (i > 0) { if (tmp[i] == '/' || tmp[i] == '\\') { _tcscpy(name, tmp + i + 1); @@ -839,13 +834,13 @@ static void saveimageaddfilename(TCHAR *dst, const TCHAR *src, int type) _tcscat(dst, _T("_save.adf")); } -static TCHAR *DISK_get_default_saveimagepath(const TCHAR *name) +static TCHAR *DISK_get_default_saveimagepath (const TCHAR *name) { TCHAR name1[MAX_DPATH]; TCHAR path[MAX_DPATH]; _tcscpy(name1, name); saveimagecutfilepart(name1); - fetch_saveimagepath(path, sizeof path / sizeof(TCHAR), 1); + fetch_saveimagepath (path, sizeof path / sizeof (TCHAR), 1); saveimageaddfilename(path, name1, 0); return my_strdup(path); } @@ -885,174 +880,172 @@ static struct zfile *getexistingwritefile(struct uae_prefs *p, const TCHAR *name struct zfile *zf = NULL; TCHAR *path; path = DISK_get_saveimagepath(name, 0); - DISK_validate_filename(p, path, 1, wrprot, NULL, &zf); + 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); + DISK_validate_filename (p, path, 1, wrprot, NULL, &zf); xfree(path); 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 = 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; } -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 = 0; 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; + 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; } -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; - } + 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; + 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; } -static bool isrecognizedext(const TCHAR *name) +static bool isrecognizedext (const TCHAR *name) { - const TCHAR *ext = _tcsrchr(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"))) + if (!_tcsicmp (ext, _T("adf")) || !_tcsicmp (ext, _T("adz")) || !_tcsicmp (ext, _T("st")) || !_tcsicmp (ext, _T("ima")) || !_tcsicmp (ext, _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); + 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); + 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->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; + 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; } - if (!drv->motoroff) { + if (!drv->motoroff) { drv->dskready_up_time = DSKREADY_UP_TIME * 312 + (uaerand() & 511); - drv->dskready_down_time = 0; - } + drv->dskready_down_time = 0; + } - if (drv->diskfile == 0) { - track_reset(drv); - return 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; + _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); + 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); - } + 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))) + 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) @@ -1061,74 +1054,68 @@ static int drive_insert(drive * drv, struct uae_prefs *p, int dnum, const TCHAR if (0) { #ifdef FDI2RAW - } - else if ((drv->fdi = fdi2raw_header(drv->diskfile))) { + } 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->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) { + } 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; + 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 ((char *) 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; - } + 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; + } 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; tid->revolutions = 1; - } - drv->useturbo = 1; + } + drv->useturbo = 1; - } - else if (canauto && ( + } else if (canauto && ( // 320k double sided size == 8 * 40 * 2 * 512 || @@ -1151,696 +1138,676 @@ static int drive_insert(drive * drv, struct uae_prefs *p, int dnum, const TCHAR 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; + /* PC formatted image */ + int i, side; - drv->num_secs = 9; - drv->ddhd = 1; + 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; - } - 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 + 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; - 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)); + } else if (size == 9 * 40 * side * 512) { + drv->num_secs = 9; + drv->ddhd = 1; break; - } - if (size == i * 12 * 512 * 2) { // ds 12 sectors - drv->num_tracks = size / (512 * (drv->num_secs = 12)); - ds = 1; + } else if (size == 8 * 40 * side * 512) { + drv->num_secs = 8; + drv->ddhd = 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)); - } + } else if (size == 15 * 80 * side * 512) { + drv->num_secs = 15; + drv->ddhd = 1; + break; + } + } - 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->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; 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; + } + } + 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); + update_drive_gui (drv - floppy, false); } - return 1; + 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; + return drv->diskfile == 0 && 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)) + 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 (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++; - } + if (drv->cyl) { + drv->cyl--; + } + } else { + int maxtrack = drv->hard_num_cyls; + if (drv->cyl < maxtrack + 3) { + drv->cyl++; + } if (drv->cyl >= maxtrack) - write_log(_T("program tried to step over track %d\n"), maxtrack); - } - rand_shifter(drv); + write_log (_T("program tried to step over track %d\n"), maxtrack); + } + rand_shifter (drv); } -static int drive_track0(drive * drv) +static int drive_track0 (drive * drv) { - return drv->cyl == 0; + 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; } -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 drive_motor (drive * drv, bool off) { - if (drv->motoroff && !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); + } + 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; drv->dskready_up_time = 0; - } - else { + } else { drv->dskready_down_time = 0; - } + } } -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 (len == 0) + return; if (tid->track == 0) { if (type == ADF_KICK) { - memset(dst, 0, len > 512 ? 512 : len); + memset (dst, 0, len > 512 ? 512 : len); if (offset == 0) { - memcpy(dst, "KICK", 4); + memcpy (dst, "KICK", 4); len -= 512; } - } - else if (type == ADF_SKICK) { - memset(dst, 0, len > 512 ? 512 : len); + } else if (type == ADF_SKICK) { + memset (dst, 0, len > 512 ? 512 : len); if (offset == 0) { - memcpy(dst, "KICKSUP0", 8); + 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); + 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 + 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]; - } + } } /* -* diskspare format -* -* 0 <4489> <4489> 0 track sector crchi, crclo, data[512] (520 bytes per sector) -* -* 0xAAAA 0x4489 0x4489 0x2AAA oddhi, oddlo, evenhi, evenlo, ... -* -* NOTE: data is MFM encoded using same method as ADOS header, not like ADOS data! -* -*/ + * diskspare format + * + * 0 <4489> <4489> 0 track sector crchi, crclo, data[512] (520 bytes per sector) + * + * 0xAAAA 0x4489 0x4489 0x2AAA oddhi, oddlo, evenhi, evenlo, ... + * + * NOTE: data is MFM encoded using same method as ADOS header, not like ADOS data! + * + */ -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; int rev = -1; - if (!drv->diskfile || tr >= drv->num_tracks) { - track_reset(drv); - return; - } + 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 (!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->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 (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); - } - - } - else if (drv->filetype == ADF_FDI) { + } else if (drv->filetype == ADF_FDI) { #ifdef FDI2RAW - fdi2raw_loadtrack(drv->fdi, drv->bigmfmbuf, drv->tracktiming, tr, &drv->tracklen, &drv->indexoffset, &drv->multi_revolution, 1); + fdi2raw_loadtrack (drv->fdi, drv->bigmfmbuf, drv->tracktiming, tr, &drv->tracklen, &drv->indexoffset, &drv->multi_revolution, 1); #endif - } - else if (ti->type == TRACK_PCDOS) { + } else if (ti->type == TRACK_PCDOS) { - decode_pcdos(drv); + decode_pcdos(drv); - } - else if (ti->type == TRACK_AMIGADOS) { + } else if (ti->type == TRACK_AMIGADOS) { - decode_amigados(drv); + decode_amigados(drv); - } - else if (ti->type == TRACK_DISKSPARE) { + } else if (ti->type == TRACK_DISKSPARE) { - decode_diskspare(drv); + decode_diskspare (drv); - } - else if (ti->type == TRACK_NONE) { + } 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); - } + } 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 ((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); + } } #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 -static void check_valid_mfm(uae_u16 *mbuf, int words, int sector) +static void check_valid_mfm (uae_u16 *mbuf, int words, int sector) { int prevbit = 0; for (int i = 0; i < words * 8; i++) { @@ -1852,302 +1819,302 @@ 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 (_T("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, %ld)\n"), trackoffs, id, mbuf - mstart); + if (filetype == ADF_EXT2) + return 2; + continue; + } #if MFM_VALIDATOR - check_valid_mfm(mbuf - 4, 544 - 4 + 1, trackoffs); + 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) { - 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) { - 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) { - 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 (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) { + 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) { + 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")); + write_log (_T("Disk decode: unsupported format\n")); if (secwritten < 0) - write_log(_T("Disk decode: sector labels ignored\n")); - *drvsecp = drvsec; - return 0; + write_log (_T("Disk decode: sector labels ignored\n")); + *drvsecp = drvsec; + return 0; } 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, struct zfile *zf, bool count) { - 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 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; + 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) { int mfmcount; mfmcount = 0; - while (getmfmword(mbuf, shift) != 0x4489) { + while (getmfmword (mbuf, shift) != 0x4489) { mfmcount++; - if (mbuf >= mend) + if (mbuf >= mend) return -1; - shift++; - if (shift == 16) { - shift = 0; - mbuf++; - } + 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) + if (mbuf >= mend) return -1; - mbuf++; - } + 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) { - write_log(_T("PCDOS: track %d, corrupted sector header\n"), drv->cyl * 2 + side); + if (get_crc16 (tmp, 8) != crc || cyl != drv->cyl || head != side || size != 2 || sector < 1 || sector > drv->num_secs || sector >= sizeof sectable) { + write_log (_T("PCDOS: track %d, corrupted sector header\n"), drv->cyl * 2 + side); 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) { - write_log(_T("PCDOS: track %d, sector %d data checksum error\n"), + } + 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) { + write_log (_T("PCDOS: track %d, sector %d data checksum error\n"), drv->cyl * 2 + side, sector + 1); - continue; - } + 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); + 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); } - sector = -1; - } + sector = -1; + } if (!count && secwritten != drv->num_secs) - write_log(_T("PCDOS: track %d, %d corrupted sectors ignored\n"), - drv->cyl * 2 + side, drv->num_secs - secwritten); + write_log (_T("PCDOS: track %d, %d corrupted sectors ignored\n"), + drv->cyl * 2 + side, drv->num_secs - secwritten); return secwritten; } -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; offset = 0; - 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); + 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++) { + 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; + 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; } -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; @@ -2155,461 +2122,451 @@ 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 (&currprefs, name, 1, hd ? DRV_35_HD : DRV_35_DD, -1, NULL, 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); + 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); + if (!disk_creatediskfile (&currprefs, name, 1, hd ? DRV_35_HD : DRV_35_DD, -1, NULL, 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); + 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 (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; + } + } } - 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; - } - } - } - 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, drv->diskfile, 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, 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; + 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); + 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 */ + 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 */ } -static void floppy_get_bootblock(uae_u8 *dst, bool ffs, bool bootable) +static void floppy_get_bootblock (uae_u8 *dst, bool ffs, bool bootable) { - strcpy((char*)dst, "DOS"); + strcpy ((char*)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, bool hd) { - dst[0 + 3] = 2; // primary type - dst[12 + 3] = 0x48; // size of hash table + 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 - xfree(s); + 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 + xfree (s); dst[508 + 3] = 1; // secondary type - disk_date(dst + 420); // root modification date + disk_date (dst + 420); // root modification date disk_date(dst + 484); // creation date - disk_checksum(dst, dst + 20); + disk_checksum (dst, dst + 20); /* bitmap block */ - memset(dst + 512 + 4, 0xff, 2 * block / 8); + memset (dst + 512 + 4, 0xff, 2 * block / 8); if (!hd) 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) +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) { int size = 32768; - struct zfile *f; - int i, l, file_size, tracks, track_len, sectors; + struct zfile *f; + int i, l, file_size, tracks, track_len, sectors; uae_u8 *chunk = NULL; 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 (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; - } + 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; + file_size *= 2; + track_len *= 2; ddhd = 2; - } - else if (adftype == DRV_PC_ONLY_40) { - file_size /= 2; - tracks /= 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); + 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); + 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 (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); + } 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); + 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); + 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[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); + memcpy (dostrack, rawtrack, sizeof rawtrack); dostrack[3] = 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); + bool dodos = ffs || bootable || (disk_name && _tcslen (disk_name) > 0); 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); + memset (chunk, 0, size); if (copyfrom) { - zfile_fread(chunk, 11 * ddhd, 512, 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); + } } - 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); - } - } - zfile_fwrite(chunk, l, 1, f); + 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)) { - write_log(_T("failed to access '%s'\n"), name); - return; + int mode, oldmode; + + if (!my_stat (name, &st)) { + write_log (_T("failed to access '%s'\n"), name); + 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)) + 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); } 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; + 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) return 0; - if (zfile_iscompressed(zf1)) - wrprot1 = 1; - zfile_fclose(zf1); + 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); - } + 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); + } - if (!needwritefile) - diskfile_readonly(name, writeprotected); - diskfile_readonly(name2, writeprotected); - return 1; + if (!needwritefile) + diskfile_readonly (name, writeprotected); + diskfile_readonly (name2, writeprotected); + 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) { + return 0; + if (name == NULL) { if (idx < 0) return 0; dfxhistory[type][idx][0] = 0; - return 1; - } - if (name[0] == 0) - return 0; - if (idx >= 0) { + return 1; + } + if (name[0] == 0) + return 0; + if (idx >= 0) { if (idx >= MAX_PREVIOUS_IMAGES) - return 0; + return 0; dfxhistory[type][idx][0] = 0; for (i = 0; i < MAX_PREVIOUS_IMAGES; i++) { - if (!_tcsicmp(dfxhistory[type][i], name)) - return 0; - } - _tcscpy(dfxhistory[type][idx], name); - return 1; - } + if (!_tcsicmp (dfxhistory[type][i], name)) + return 0; + } + _tcscpy (dfxhistory[type][idx], name); + return 1; + } for (i = 0; i < MAX_PREVIOUS_IMAGES; i++) { - if (!_tcscmp(dfxhistory[type][i], name)) { + if (!_tcscmp (dfxhistory[type][i], name)) { while (i < MAX_PREVIOUS_IMAGES - 1) { - _tcscpy(dfxhistory[type][i], dfxhistory[type][i + 1]); - i++; - } + _tcscpy (dfxhistory[type][i], dfxhistory[type][i + 1]); + i++; + } dfxhistory[type][MAX_PREVIOUS_IMAGES - 1][0] = 0; - break; - } - } + break; + } + } for (i = MAX_PREVIOUS_IMAGES - 2; i >= 0; i--) - _tcscpy(dfxhistory[type][i + 1], dfxhistory[type][i]); - _tcscpy(dfxhistory[type][0], name); - return 1; + _tcscpy (dfxhistory[type][i + 1], dfxhistory[type][i]); + _tcscpy (dfxhistory[type][0], name); + return 1; } -TCHAR *DISK_history_get(int idx, int type) +TCHAR *DISK_history_get (int idx, int type) { if (idx >= MAX_PREVIOUS_IMAGES) 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; - if (forced) { - drive_insert(drv, &currprefs, num, name, false, forcedwriteprotect); - return; - } - if (!_tcscmp(currprefs.floppyslots[num].df, name)) - return; + 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); + _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); + DISK_history_add (name, -1, HISTORY_FLOPPY, 0); if (name[0] == 0) { - disk_eject(num); - } - else if (!drive_empty(drv) || drv->dskchange_time > 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); + } 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, 0, 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); + 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) +void disk_insert_force (int num, const TCHAR *name, bool forcedwriteprotect) { - disk_insert_2(num, name, 1, forcedwriteprotect); + disk_insert_2 (num, name, 1, forcedwriteprotect); } -static void DISK_check_change(void) +static void DISK_check_change (void) { - if (currprefs.floppy_speed != changed_prefs.floppy_speed) - currprefs.floppy_speed = changed_prefs.floppy_speed; + 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; + 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 @@ -2618,29 +2575,29 @@ static void DISK_check_change(void) */ setdskchangetime(drv, 2 * 50 * 312); } - if (currprefs.floppyslots[i].dfxtype != changed_prefs.floppyslots[i].dfxtype) { - currprefs.floppyslots[i].dfxtype = changed_prefs.floppyslots[i].dfxtype; - reset_drive(i); - } + 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 (void) { - DISK_check_change(); + 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); - } + 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--) @@ -2655,284 +2612,279 @@ 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 ((prev_data & 0x80) != (data & 0x80)) { + for (dr = 0; dr < 4; dr++) { if (floppy[dr].indexhackmode > 1 && !((selected | disabled) & (1 << dr))) { - floppy[dr].indexhack = 1; - } - } - } + 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 (!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; - } - } - } + 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 st = 0x3c; + uae_u8 st = 0x3c; - 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 { + 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) */ + /* 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; - } - } + 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; + 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) +static void disk_dmafinished (void) { - INTREQ(0x8000 | 0x0002); - longwritemode = 0; - dskdmaen = DSKDMA_OFF; + 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: + case ADF_FDI: #ifdef FDI2RAW - fdi2raw_loadrevolution(drv->fdi, drv->bigmfmbuf, drv->tracktiming, drv->cyl * 2 + side, &drv->tracklen, 1); + fdi2raw_loadrevolution(drv->fdi, drv->bigmfmbuf, drv->tracktiming, drv->cyl * 2 + side, &drv->tracklen, 1); #endif - break; + break; } } -static void do_disk_index(void) +static void do_disk_index (void) { 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); + 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_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; + 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; - } + 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) { + 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); + 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 (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; - } + continue; + drive_write_data (drv); + } + } + } + } + } + floppybits -= drv->trackspeed; + } } -static void update_jitter(void) +static void update_jitter (void) { - disk_jitter = ((uaerand() >> 4) % 3) + 1; + disk_jitter = ((uaerand () >> 4) % 3) + 1; } -static void updatetrackspeed(drive *drv, int mfmpos) +static void updatetrackspeed (drive *drv, int mfmpos) { 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) { + } 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; @@ -2947,63 +2899,63 @@ static void disk_doupdate_predict(int startcycle) 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); + 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); - } + 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; + 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; + if (mfmpos == 0) + diskevent_flag |= DISK_REVOLUTION << (drv - floppy); + if (mfmpos == drv->indexoffset) + diskevent_flag |= DISK_INDEXSYNC; } if (dskdmaen != DSKDMA_WRITE && mfmpos == drv->skipoffset) { - int skipcnt = disk_jitter; - while (skipcnt-- > 0) { - mfmpos++; - mfmpos %= drv->tracklen; + 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 (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 (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); - } + event2_newevent (ev2_disk, (finaleventcycle - startcycle) >> 8, ((finaleventcycle >> 8) << 8) | finaleventflag); + } } -int disk_fifostatus(void) +int disk_fifostatus (void) { if (fifo_inuse[0] && fifo_inuse[1] && fifo_inuse[2]) return 1; @@ -3012,66 +2964,65 @@ int disk_fifostatus(void) return 0; } -static int doreaddma(void) +static int doreaddma (void) { - if (dmaen(DMA_DISK) && bitoffset == 15 && dma_enable && dskdmaen == DSKDMA_READ && 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(); + 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); + uae_u16 w = DSKDATR (); + chipmem_wput_indirect (dskpt, w); dskpt += 2; } } - if (disk_fifostatus() > 0) { - write_log(_T("doreaddma() fifo overflow detected, retrying..\n")); + 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(); - } + 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 wordsync_detected(bool startup) { - dsksync_cycles = get_cycles() + WORDSYNC_TIME * CYCLE_UNIT; - if (dskdmaen != DSKDMA_OFF) { + dsksync_cycles = get_cycles () + WORDSYNC_TIME * CYCLE_UNIT; + if (dskdmaen != DSKDMA_OFF) { if (!startup) - dma_enable = 1; - INTREQ(0x8000 | 0x1000); - } + dma_enable = 1; + INTREQ (0x8000 | 0x1000); + } if (adkcon & 0x0400) { bitoffset = 15; } } -static void disk_doupdate_read(drive * drv, int floppybits) +static void disk_doupdate_read (drive * drv, int floppybits) { /* uae_u16 *mfmbuf = drv->bigmfmbuf; @@ -3091,115 +3042,115 @@ static void disk_doupdate_read(drive * drv, int floppybits) mfmbuf[6] = 0x4444; mfmbuf[7] = 0x4444; */ - while (floppybits >= drv->trackspeed) { - if (drv->tracktiming[0]) - updatetrackspeed(drv, drv->mfmpos); - word <<= 1; + 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) { + 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(); - } + drv->mfmpos++; + drv->mfmpos %= drv->tracklen; + if (drv->mfmpos == drv->indexoffset) { + drv->indexhack = 0; + do_disk_index (); + } if (drv->mfmpos == 0) { - fetchnextrevolution(drv); + fetchnextrevolution (drv); if (drv->tracktiming[0]) - updatetrackspeed(drv, drv->mfmpos); + updatetrackspeed (drv, drv->mfmpos); } - if (drv->mfmpos == drv->skipoffset) { + if (drv->mfmpos == drv->skipoffset) { int skipcnt = disk_jitter; while (skipcnt-- > 0) { drv->mfmpos++; - drv->mfmpos %= drv->tracklen; + drv->mfmpos %= drv->tracklen; if (drv->mfmpos == drv->indexoffset) { drv->indexhack = 0; - do_disk_index(); - } + do_disk_index (); + } if (drv->mfmpos == 0) { - fetchnextrevolution(drv); + 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; - } + bitoffset++; + bitoffset &= 15; + floppybits -= drv->trackspeed; + } } /* 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; + 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; + 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; } - return v; + return v; } -static void DISK_start(void) +static void DISK_start (void) { - int dr; + int dr; for (int i = 0; i < 3; i++) fifo_inuse[i] = false; fifo_filled = 0; - 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 (!((selected | disabled) & (1 << dr))) { - int tr = drv->cyl * 2 + side; - trackid *ti = drv->trackdata + tr; + 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; + 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; } - } - drv->floppybitcounter = 0; - } + } + drv->floppybitcounter = 0; + } dma_enable = (adkcon & 0x400) ? 0 : 1; if (word == dsksync) @@ -3208,21 +3159,21 @@ static void DISK_start(void) static int linecounter; -void DISK_hsync(void) +void DISK_hsync (void) { - 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; @@ -3231,99 +3182,99 @@ void DISK_hsync(void) 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); + 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; if (disk_hpos < 0) { - disk_hpos = -disk_hpos; + 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 (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; - } + 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; + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { + drive *drv = &floppy[dr]; + if (drv->motoroff || !drv->trackspeed) + continue; if ((selected | disabled) & (1 << dr)) - continue; + continue; if (!done_jitter) { update_jitter(); done_jitter = true; } /* 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); + disk_doupdate_write (drv, drv->floppybitcounter); + else + disk_doupdate_read (drv, drv->floppybitcounter); - drv->floppybitcounter %= drv->trackspeed; + drv->floppybitcounter %= drv->trackspeed; didaccess = 1; - } - /* no floppy selected but read dma */ + } + /* no floppy selected but read dma */ if (!didaccess && dskdmaen == DSKDMA_READ) { - disk_doupdate_read_nothing(cycles); - } + 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); dsklen = v; dsklength2 = dsklength = dsklen & 0x3fff; @@ -3334,48 +3285,48 @@ void DSKLEN(uae_u16 v, int hpos) 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)) { + 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); - } - } + /* 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 ((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); return; } dskdmaen = DSKDMA_WRITE; - DISK_start(); - } + DISK_start (); + } for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; @@ -3385,171 +3336,167 @@ void DSKLEN(uae_u16 v, int hpos) continue; } - 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; - } + 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); + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) + update_drive_gui (dr, false); - /* Try to make floppy access from Kickstart faster. */ + /* 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]; + 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; + 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; - } + 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; + while (dsklength-- > 0) { + chipmem_wput_indirect (dskpt, floppysupported ? drv->bigmfmbuf[pos >> 4] : uaerand()); + dskpt += 2; + pos += 16; pos %= drv->tracklen; } - } - else { + } else { pos += uaerand(); - pos %= drv->tracklen; - } + pos %= drv->tracklen; + } drv->mfmpos = pos; if (floppysupported) - INTREQ(0x8000 | 0x1000); + INTREQ (0x8000 | 0x1000); done = 2; - } - else if (dskdmaen == DSKDMA_WRITE) { /* TURBO write */ + } 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 { + 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 (!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; - } + } + } + 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; + } - if (done) { + if (done) { linecounter = done; 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 (void) { return dskdmaen == DSKDMA_WRITE; } -void DSKDAT(uae_u16 v) +void DSKDAT (uae_u16 v) { if (fifo_inuse[2]) { - write_log(_T("DSKDAT: FIFO overflow!\n")); + write_log (_T("DSKDAT: FIFO overflow!\n")); return; } fifo_inuse[2] = fifo_inuse[1]; 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; } -uae_u16 DSKDATR(void) +uae_u16 DSKDATR (void) { int i; uae_u16 v = 0; @@ -3561,15 +3508,14 @@ uae_u16 DSKDATR(void) } } if (i < 0) { - write_log(_T("DSKDATR: FIFO underflow!\n")); - } - else if (dskdmaen > 0 && dskdmaen < 3 && dsklength <= 0 && disk_fifostatus() < 0) { - disk_dmafinished(); + write_log (_T("DSKDATR: FIFO underflow!\n")); + } else if (dskdmaen > 0 && dskdmaen < 3 && dsklength <= 0 && disk_fifostatus () < 0) { + disk_dmafinished (); } return v; } -uae_u16 disk_dmal(void) +uae_u16 disk_dmal (void) { uae_u16 dmal = 0; if (dskdmaen) { @@ -3580,65 +3526,64 @@ uae_u16 disk_dmal(void) 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 (void) { 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 (void) { for (int dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { - drive *drv = &floppy[dr]; - drive_image_free(drv); - } + drive *drv = &floppy[dr]; + drive_image_free (drv); + } } -void DISK_init(void) +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")); + 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) +void DISK_reset (void) { - if (savestate_state) - return; + if (savestate_state) + return; - disk_hpos = 0; - dskdmaen = 0; - disabled = 0; + 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); + reset_drive (dr); } } -static void load_track(int num, int cyl, int side, int *sectable) +static void load_track (int num, int cyl, int side, int *sectable) { int oldcyl, oldside, drvsec; @@ -3649,133 +3594,133 @@ static void load_track(int num, int cyl, int side, int *sectable) 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; - 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); + decode_buffer (drv->bigmfmbuf, drv->cyl, 11, drv->ddhd, drv->filetype, &drvsec, sectable, 1); di->hd = drv->ddhd == 2; 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 (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); + load_track (num, 40, 0, sectable); if (sectable[0]) { - if (!disk_checksum(writebuffer, NULL) && + if (!disk_checksum (writebuffer, NULL) && 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[512 - 20 * 4 + 1 + writebuffer[512 - 20 * 4]] = 0; - TCHAR *n = au((const char*)(writebuffer + 512 - 20 * 4 + 1)); - if (_tcslen(n) >= sizeof(di->diskname)) - n[sizeof(di->diskname) - 1] = 0; - _tcscpy(di->diskname, n); - xfree(n); + TCHAR *n = au ((const char*)(writebuffer + 512 - 20 * 4 + 1)); + if (_tcslen (n) >= sizeof (di->diskname)) + n[sizeof (di->diskname) - 1] = 0; + _tcscpy (di->diskname, n); + xfree (n); } } 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 -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 */ -static uae_u32 getadfcrc(drive *drv) +static uae_u32 getadfcrc (drive *drv) { uae_u8 *b; uae_u32 crc32; @@ -3783,175 +3728,172 @@ static uae_u32 getadfcrc(drive *drv) if (!drv->diskfile) return 0; - zfile_fseek(drv->diskfile, 0, SEEK_END); - size = zfile_ftell(drv->diskfile); - b = xmalloc(uae_u8, size); + 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 (void) { int cnt = 0; for (int i = 0; i < MAX_FLOPPY_DRIVES; i++) { if (currprefs.floppyslots[i].dfxtype >= 0) { - update_drive_gui(i, true); + update_drive_gui (i, true); cnt++; } } currprefs.nr_floppies = changed_prefs.nr_floppies = cnt; - DISK_check_change(); + DISK_check_change (); } -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; + TCHAR old[MAX_DPATH]; + TCHAR *s; + int newis; + drive_type dfxtype; - 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 = 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->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]; - uae_u32 m = restore_u32(); + uae_u32 m = restore_u32 (); if (m) { - drv->floppybitcounter = restore_u16(); - drv->tracklen = restore_u32(); - drv->trackspeed = restore_u16(); - drv->skipoffset = restore_u32(); - drv->indexoffset = restore_u32(); + drv->floppybitcounter = restore_u16 (); + drv->tracklen = restore_u32 (); + drv->trackspeed = restore_u16 (); + drv->skipoffset = restore_u32 (); + drv->indexoffset = restore_u32 (); drv->buffered_cyl = drv->cyl; drv->buffered_side = side; for (int j = 0; j < (drv->tracklen + 15) / 16; j++) { - drv->bigmfmbuf[j] = restore_u16(); + drv->bigmfmbuf[j] = restore_u16 (); if (m & 2) - drv->tracktiming[j] = restore_u16(); + drv->tracktiming[j] = restore_u16 (); } - drv->revolutions = 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; + 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 */ - 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_path(usepath ? currprefs.floppyslots[num].df : _T(""), SAVESTATE_PATH_FLOPPY);/* image name */ - save_u16(drv->dskready_up_time); - save_u16(drv->dskready_down_time); + 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_path (usepath ? currprefs.floppyslots[num].df : _T(""), SAVESTATE_PATH_FLOPPY);/* image name */ + save_u16 (drv->dskready_up_time); + save_u16 (drv->dskready_down_time); *len = dst - dstbak; 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; + uae_u8 *dstbak,*dst; drive *drv = &floppy[num]; int m = 0; @@ -3968,66 +3910,66 @@ uae_u8 *save_disk2(int num, int *len, uae_u8 *dstptr) if (dstptr) dstbak = dst = dstptr; else - dstbak = dst = xmalloc(uae_u8, 4 + 2 + 4 + 2 + 4 + 4 + size + 2); + dstbak = dst = xmalloc (uae_u8, 4 + 2 + 4 + 2 + 4 + 4 + size + 2); - save_u32(m); - save_u16(drv->floppybitcounter); - save_u32(drv->tracklen); - save_u16(drv->trackspeed); - save_u32(drv->skipoffset); - save_u32(drv->indexoffset); + save_u32 (m); + save_u16 (drv->floppybitcounter); + save_u32 (drv->tracklen); + save_u16 (drv->trackspeed); + save_u32 (drv->skipoffset); + save_u32 (drv->indexoffset); for (int j = 0; j < (drv->tracklen + 15) / 16; j++) { - save_u16(drv->bigmfmbuf[j]); + save_u16 (drv->bigmfmbuf[j]); if (drv->tracktiming[0]) - save_u16(drv->tracktiming[j]); + save_u16 (drv->tracktiming[j]); } - save_u16(drv->revolutions); + 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) { - word = restore_u16(); - bitoffset = restore_u8(); - dma_enable = restore_u8(); - disk_hpos = restore_u8() & 0xff; - dskdmaen = 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++) { - fifo[i] = restore_u16(); - fifo_inuse[i] = restore_u8(); + fifo[i] = restore_u16 (); + fifo_inuse[i] = restore_u8 (); if (dskdmaen == 0) fifo_inuse[i] = false; } fifo_filled = fifo_inuse[0] || fifo_inuse[1] || fifo_inuse[2]; - dsklength = restore_u16(); - return src; + dsklength = restore_u16 (); + return src; } uae_u8 *save_floppy(int *len, uae_u8 *dstptr) { - uae_u8 *dstbak, *dst; + uae_u8 *dstbak, *dst; - if (dstptr) - dstbak = dst = dstptr; - else - dstbak = dst = xmalloc(uae_u8, 100); + 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 */ + 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 (fifo[i]); + save_u8 (fifo_inuse[i]); } - save_u16(dsklength); - *len = dst - dstbak; - return dstbak; + save_u16 (dsklength); + *len = dst - dstbak; + return dstbak; } #endif /* SAVESTATE */ diff --git a/src/drawing.cpp b/src/drawing.cpp index 007f153e..4d4bdaef 100644 --- a/src/drawing.cpp +++ b/src/drawing.cpp @@ -50,6 +50,13 @@ #include "audio.h" #include "devices.h" +#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; + extern int sprite_buffer_res; int lores_shift; @@ -590,32 +597,26 @@ STATIC_INLINE int DECODE_HAM8_3(int col, int pv) STATIC_INLINE int DECODE_HAM6_1(int col, int pv) { - __asm__( - "lsl %[pv], %[pv], #1 \n\t" - "bfi %[col], %[pv], #0, #5 \n\t" - : [col] "+r"(col), - [pv] "+r"(pv)); - return (col); + __asm__ ( + "bfi %[col], %[pv], #1, #4 \n\t" + : [col] "+r" (col) : [pv] "r" (pv) ); + return (col); } STATIC_INLINE int DECODE_HAM6_2(int col, int pv) { - __asm__( - "lsl %[pv], %[pv], #1 \n\t" - "bfi %[col], %[pv], #11, #5 \n\t" - : [col] "+r"(col), - [pv] "+r"(pv)); - return (col); + __asm__ ( + "bfi %[col], %[pv], #12, #4 \n\t" + : [col] "+r" (col) : [pv] "r" (pv) ); + return (col); } STATIC_INLINE int DECODE_HAM6_3(int col, int pv) { - __asm__( - "lsl %[pv], %[pv], #2 \n\t" - "bfi %[col], %[pv], #5, #6 \n\t" - : [col] "+r"(col), - [pv] "+r"(pv)); - return (col); + __asm__ ( + "bfi %[col], %[pv], #7, #4 \n\t" + : [col] "+r" (col) : [pv] "r" (pv) ); + return (col); } #endif @@ -674,21 +675,18 @@ static void init_ham_decoding(void) while (unpainted_amiga-- > 0) { int pv = pixdata.apixels[ham_decode_pixel++] ^ bplxor; - switch (pv & 0x30) - { - case 0x00: ham_lastcolor = colors_for_drawing.acolors[pv]; - break; + 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_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; + 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 |= (pv & 0xF) << 4; break; - case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pv & 0xF) << 20; break; - case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pv & 0xF) << 12; break; + 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; #endif } } @@ -770,21 +768,18 @@ static void decode_ham(int pix, int stoppos) while (todraw_amiga-- > 0) { int pv = pixdata.apixels[ham_decode_pixel] ^ bplxor; - switch (pv & 0x30) - { - case 0x00: ham_lastcolor = colors_for_drawing.acolors[pv]; - break; + 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_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; + 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 |= (pv & 0xF) << 4; break; - case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pv & 0xF) << 20; break; - case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pv & 0xF) << 12; break; + 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; #endif } ham_linebuf[ham_decode_pixel++] = ham_lastcolor; @@ -2334,10 +2329,26 @@ bool vsync_handle_check(void) void vsync_handle_redraw(void) { - if (framecnt == 0) - finish_drawing_frame(); + if (framecnt == 0) { + if(render_tid) { + write_comm_pipe_u32 (render_pipe, RENDER_SIGNAL_FRAME_DONE, 1); + uae_sem_wait (&render_sem); + } + } if (quit_program < 0) { + if(render_tid) { + 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; + } + quit_program = -quit_program; set_inhibit_frame(IHF_QUIT_PROGRAM); set_special(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE); @@ -2357,7 +2368,11 @@ void hsync_record_line_state(int lineno) if (framecnt != 0) return; - linestate_first_undecided = lineno + 1; + linestate_first_undecided = lineno + 1; + + if(render_tid && !(linestate_first_undecided & 0x1f)) { + write_comm_pipe_u32 (render_pipe, RENDER_SIGNAL_PARTIAL, 1); + } } bool notice_interlace_seen(bool lace) @@ -2405,12 +2420,44 @@ static void gen_direct_drawing_table(void) } } -void drawing_init(void) +static void *render_thread (void *unused) +{ + for(;;) { + uae_u32 signal = read_comm_pipe_u32_blocking(render_pipe); + switch(signal) { + case RENDER_SIGNAL_PARTIAL: + partial_draw_frame(); + break; + + 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_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; @@ -2423,4 +2470,4 @@ void drawing_init(void) inhibit_frame = 0; reset_drawing(); -} \ No newline at end of file +} diff --git a/src/events.cpp b/src/events.cpp index 66e8e346..447ca2b0 100644 --- a/src/events.cpp +++ b/src/events.cpp @@ -20,75 +20,75 @@ int is_syncline; frame_time_t vsyncmintime, vsyncmaxtime, vsyncwaittime; int vsynctimebase; -void events_schedule(void) +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) +void do_cycles_cpu_fastest (unsigned long cycles_to_add) { - if ((regs.pissoff -= cycles_to_add) > 0) - return; + if ((regs.pissoff -= cycles_to_add) > 0) + return; - cycles_to_add = -regs.pissoff; - regs.pissoff = 0; + cycles_to_add = -regs.pissoff; + regs.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) { + 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; + } - 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) +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; @@ -96,40 +96,39 @@ do_cycles_func do_cycles = do_cycles_cpu_norm; void MISC_handler(void) { int i; - evt mintime; - evt ct = get_cycles(); - static int recursive; + evt mintime; + evt ct = get_cycles(); + static int recursive; if (recursive) { - return; + return; } - recursive++; - eventtab[ev_misc].active = 0; + recursive++; + eventtab[ev_misc].active = 0; - mintime = ~0L; - for (i = 0; i < ev2_max; i++) { - if (eventtab2[i].active) { - if (eventtab2[i].evtime == ct) { + 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); + eventtab2[i].handler(eventtab2[i].data); if (eventtab2[i].active) { - evt eventtime = eventtab2[i].evtime - ct; - if (eventtime < mintime) - mintime = eventtime; + evt eventtime = eventtab2[i].evtime - ct; + if (eventtime < mintime) + mintime = eventtime; } - } - else { - 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 != ~0UL) { + if (mintime != ~0UL) { eventtab[ev_misc].active = true; - eventtab[ev_misc].evtime = ct + mintime; - events_schedule(); - } - recursive--; + eventtab[ev_misc].evtime = ct + mintime; + events_schedule(); + } + recursive--; } diff --git a/src/expansion.cpp b/src/expansion.cpp index e58f023f..2e51d0a7 100644 --- a/src/expansion.cpp +++ b/src/expansion.cpp @@ -15,7 +15,7 @@ #include "options.h" #include "uae.h" #include "traps.h" -#include "include/memory.h" +#include "memory.h" #include "rommgr.h" #include "custom.h" #include "newcpu.h" @@ -30,7 +30,7 @@ #define CARD_FLAG_CAN_Z3 1 - // More information in first revision HRM Appendix_G +// More information in first revision HRM Appendix_G #define BOARD_PROTOAUTOCONFIG 1 #define BOARD_AUTOCONFIG_Z2 2 @@ -44,9 +44,9 @@ #define MAX_EXPANSION_BOARD_SPACE 16 - /* ********************************************************** */ - /* 00 / 02 */ - /* er_Type */ +/* ********************************************************** */ +/* 00 / 02 */ +/* er_Type */ #define Z2_MEM_8MB 0x00 /* Size of Memory Block */ #define Z2_MEM_4MB 0x07 @@ -56,7 +56,7 @@ #define Z2_MEM_256KB 0x03 #define Z2_MEM_128KB 0x02 #define Z2_MEM_64KB 0x01 - /* extended definitions */ +/* extended definitions */ #define Z3_MEM_16MB 0x00 #define Z3_MEM_32MB 0x01 #define Z3_MEM_64MB 0x02 @@ -69,7 +69,7 @@ #define rom_card 0x10 /* ROM vector is valid */ #define add_memory 0x20 /* Link RAM into free memory list */ - /* Type of Expansion Card */ +/* Type of Expansion Card */ #define protoautoconfig 0x40 #define zorroII 0xc0 #define zorroIII 0x80 @@ -158,8 +158,8 @@ static int do_mount; 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; @@ -197,6 +197,7 @@ static bool ks11orolder(void) return kickstart_version && kickstart_version < 33; } + /* ********************************************************** */ /* Please note: ZorroIII implementation seems to work different @@ -218,7 +219,7 @@ static bool ks11orolder(void) * -- Bernd */ - /* Autoconfig address space at 0xE80000 */ +/* Autoconfig address space at 0xE80000 */ static uae_u8 expamem[65536]; #define AUTOMATIC_AUTOCONFIG_MAX_ADDRESS 0x80 static int expamem_autoconfig_mode; @@ -255,28 +256,28 @@ bool expamem_z3hack(struct uae_prefs *p) * stops working because it sets kicktag at the end * of chip ram... */ -static void addextrachip(uae_u32 sysbase) +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; @@ -284,22 +285,21 @@ 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; } @@ -309,8 +309,8 @@ addrbank expamem_null; 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,27 +324,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); + memset (expamem, 0xff, sizeof expamem); expamem_hi = expamem_lo = 0; 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); @@ -352,17 +351,17 @@ 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(); return NULL; } @@ -375,26 +374,25 @@ 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; } static void call_card_init(int index) -{ +{ addrbank *ab, *abe; card_data *cd = cards[ecard]; struct autoconfig_info *aci = &cd->aci; @@ -410,16 +408,14 @@ static void call_card_init(int index) 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 { + } else { write_log(_T("Card %d: skipping autoconfig (init failed)\n"), ecard); expamem_next(NULL, NULL); return; @@ -445,19 +441,16 @@ 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); } @@ -470,26 +463,23 @@ static void call_card_init(int index) 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) @@ -503,7 +493,7 @@ 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 ")), @@ -524,7 +514,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; @@ -542,8 +532,7 @@ 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; } @@ -559,16 +548,15 @@ static void expamemz3_map(void) uaecptr addr = ((expamem_hi << 8) | expamem_lo) << 16; if (!expamem_z3hack(&currprefs)) { expamem_board_pointer = addr; - } - else { + } 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); + put_word (regs.regs[11] + 0x20, expamem_board_pointer >> 16); + put_word (regs.regs[11] + 0x28, expamem_board_pointer >> 16); } } } -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) { @@ -576,11 +564,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) { @@ -592,17 +580,17 @@ 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); + 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) { @@ -610,12 +598,12 @@ 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]; + 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) { @@ -624,151 +612,149 @@ 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; + value &= 0xffff; + 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; + } + } + // 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; + } 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; + value &= 0xff; + 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.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; - 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 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) @@ -778,20 +764,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) @@ -802,25 +788,22 @@ 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) { + } 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) @@ -836,16 +819,16 @@ static void REGPARAM2 expamemz3_wput(uaecptr addr, uae_u32 value) } 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; @@ -857,8 +840,8 @@ static bool expamem_init_cd32fmv(struct autoconfig_info *aci) /* ********************************************************** */ /* -* Fast Memory -*/ + * Fast Memory + */ MEMORY_ARRAY_FUNCTIONS(fastmem, 0); @@ -877,7 +860,7 @@ addrbank fastmem_bank[MAX_RAM_BOARDS] = /* * Filesystem device ROM/RAM space -*/ + */ DECLARE_MEMORY_FUNCTIONS(filesys); addrbank filesys_bank = { @@ -893,29 +876,29 @@ 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; + uae_u8 *m; addr -= filesys_bank.start; - addr &= 65535; - m = filesys_bank.baseaddr + addr; - return do_get_mem_long((uae_u32 *)m); + addr &= 65535; + m = filesys_bank.baseaddr + addr; + 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; + uae_u8 *m; addr -= filesys_bank.start; - addr &= 65535; - m = filesys_bank.baseaddr + addr; - return do_get_mem_word((uae_u16 *)m); + addr &= 65535; + m = filesys_bank.baseaddr + addr; + 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 &= 65535; + return filesys_bank.baseaddr[addr]; } static void REGPARAM2 filesys_bput(uaecptr addr, uae_u32 b) @@ -927,7 +910,7 @@ static void REGPARAM2 filesys_bput(uaecptr addr, uae_u32 b) 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 &= 65535; @@ -939,7 +922,7 @@ 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 &= 65535; @@ -1129,8 +1112,8 @@ static bool expamem_init_uaeboard(struct autoconfig_info *aci) } /* -* Z3fastmem Memory -*/ + * Z3fastmem Memory + */ MEMORY_ARRAY_FUNCTIONS(z3fastmem, 0); @@ -1142,14 +1125,14 @@ 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 - } + } }; /* ********************************************************** */ /* * 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) { @@ -1160,15 +1143,15 @@ 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; uae_u8 ac[16] = { 0 }; int boardnum = aci->devnum; @@ -1181,34 +1164,29 @@ 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 { - pid = 81; - } - } - else { + } 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); + : 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 = 83; + } flags |= care_addr | force_z3 | (allocated > 0x800000 ? ext_size : subsize); } } @@ -1225,17 +1203,16 @@ 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; } expamem_write(0x00, ac[0x00 / 4]); @@ -1249,10 +1226,10 @@ 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.*/ return true; } @@ -1267,7 +1244,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) @@ -1318,9 +1295,9 @@ static bool expamem_rtarea_init(struct autoconfig_info *aci) return true; } -/* -* Filesystem device -*/ +/* + * Filesystem device + */ static void expamem_map_filesys_update(void) { @@ -1331,7 +1308,7 @@ 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) { mapped_free(&filesys_bank); filesys_bank.start = expamem_board_pointer; @@ -1339,7 +1316,7 @@ static addrbank *expamem_map_filesys(struct autoconfig_info *aci) 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(); @@ -1391,58 +1368,58 @@ static bool expamem_init_filesys(struct autoconfig_info *aci) aci->addrbankp = &filesys_bank; } - /* struct DiagArea - the size has to be large enough to store several device ROMTags */ + /* 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, 0, 0, 0, (uae_u8)('U'), (uae_u8)('A'), (uae_u8)('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, 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 */ + /* 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 */ + /* 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); - /* 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(); @@ -1452,10 +1429,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]; @@ -1470,7 +1447,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"); @@ -1490,7 +1467,7 @@ 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(); + 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); @@ -1502,17 +1479,17 @@ static bool expamem_init_z3fastmem(struct autoconfig_info *aci) uae_u32 start = bank->start; bool alwaysmapz3 = aci->prefs->z3_mapping_mode != Z3MAPPING_REAL; 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; @@ -1520,7 +1497,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; @@ -1528,27 +1505,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; @@ -1556,24 +1533,24 @@ 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]; @@ -1581,11 +1558,11 @@ static bool expamem_init_gfxcard(struct autoconfig_info *aci, bool z3) } 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 @@ -1595,12 +1572,12 @@ static size_t fast_filepos[MAX_RAM_BOARDS], z3_filepos[MAX_RAM_BOARDS]; static size_t 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; @@ -1614,12 +1591,12 @@ static bool mapped_malloc_dynamic(uae_u32 *currpsize, uae_u32 *changedpsize, add 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; } @@ -1630,8 +1607,7 @@ 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)) @@ -1640,49 +1616,48 @@ 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)); } 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; + } 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")); + } + } } - 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); - } - } + 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; @@ -1690,77 +1665,77 @@ 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); } - } + } #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]); + 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); + } + } #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; *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; + 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; + return b; if (p->rtgboards[0].rtgmem_size) return b; if (p->chipmem_size > 2 * 1024 * 1024) - return b; + return b; if (p->boot_rom >= 3) return b; if (p->boot_rom == 2 && b == 0xf00000) { @@ -1768,20 +1743,20 @@ 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_expansions(struct uae_prefs *p, int zorro, int *fastmem_nump, int mode) @@ -1871,8 +1846,7 @@ 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; @@ -1890,8 +1864,7 @@ 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. @@ -1931,20 +1904,20 @@ 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 */ + /* check if Kickstart version is below 1.3 */ if (ks12orolder() && do_mount) { - /* warn user */ + /* 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; @@ -1981,7 +1954,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]; @@ -1989,8 +1962,7 @@ struct autoconfig_info *expansion_get_autoconfig_info(struct uae_prefs *p, int r if (cd->rc->back->device_type == romtype && cd->rc->back->device_num == devnum) { return &cd->aci; } - } - else { + } 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"))) @@ -2022,12 +1994,11 @@ static void expansion_init_cards(struct uae_prefs *p) 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)) { uae_u8 ac2[16]; const uae_u8 *a = aci->autoconfigp; @@ -2122,8 +2093,7 @@ static void expansion_parse_cards(struct uae_prefs *p, bool log) aci->start = 0xffffffff; if (cd->initnum) { ok = cd->initnum(aci); - } - else { + } else { aci->rc = cd->rc; ok = cd->initrc(aci); } @@ -2146,11 +2116,9 @@ 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) { + } else if (aci->addrbankp && aci->addrbankp->label) { _tcscpy(label, aci->addrbankp->label); - } - else { + } else { _tcscpy(label, _T("")); } } @@ -2200,8 +2168,7 @@ 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; @@ -2217,21 +2184,18 @@ 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) { @@ -2242,16 +2206,14 @@ 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 { + } else { if (log) write_log(_T("init failed.\n"), i); } @@ -2428,7 +2390,7 @@ 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) { @@ -2451,7 +2413,7 @@ static void expansion_add_autoconfig(struct uae_prefs *p) 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++) { @@ -2463,7 +2425,7 @@ 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 /* Z3 boards last */ @@ -2493,7 +2455,7 @@ 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 // add non-memory Z3 boards @@ -2512,13 +2474,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); @@ -2526,21 +2488,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++) { @@ -2551,13 +2513,13 @@ void expansion_init(void) #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; + } + } + + allocate_expamem (); if (currprefs.uaeboard) { uaeboard_bank.reserved_size = 0x10000; @@ -2566,21 +2528,21 @@ 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]); + } #ifdef PICASSO96 for (int i = 0; i < MAX_RTG_BOARDS; i++) { - mapped_free(gfxmem_banks[i]); + mapped_free (gfxmem_banks[i]); } #endif #ifdef FILESYS - mapped_free(&filesys_bank); + mapped_free (&filesys_bank); #endif if (currprefs.uaeboard) { mapped_free(&uaeboard_bank); @@ -2601,21 +2563,21 @@ 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]); + } for (int i = 0; i < MAX_RTG_BOARDS; i++) { - clear_bank(gfxmem_banks[i]); + clear_bank (gfxmem_banks[i]); } } @@ -2623,68 +2585,68 @@ 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; + *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; + 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 (0 /* fastmem_bank[1].start */); + *len = dst - dstbak; + 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 (); + 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; } uae_u8 *save_expansion_info(int *len, uae_u8 *dstptr) @@ -2704,8 +2666,7 @@ 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); @@ -2743,7 +2704,7 @@ uae_u8 *restore_expansion_info(uae_u8 *src) #endif /* SAVESTATE */ const struct expansionromtype expansionroms[] = { - /* built-in controllers */ + /* built-in controllers */ { _T("cd32fmv"), _T("CD32 FMV"), _T("Commodore"), expamem_init_cd32fmv, NULL, NULL, ROMTYPE_CD32CART, 0, 0, BOARD_AUTOCONFIG_Z2, true, diff --git a/src/filesys b/src/filesys new file mode 100644 index 00000000..6a424d9a Binary files /dev/null and b/src/filesys differ diff --git a/src/filesys.cpp b/src/filesys.cpp index 3f3b1fb3..29e58c38 100644 --- a/src/filesys.cpp +++ b/src/filesys.cpp @@ -74,9 +74,9 @@ int log_filesys = 0; static int bootrom_header; -static uae_u32 dlg(uae_u32 a) +static uae_u32 dlg (uae_u32 a) { - return (dbg(a + 0) << 24) | (dbg(a + 1) << 16) | (dbg(a + 2) << 8) | (dbg(a + 3) << 0); + return (dbg (a + 0) << 24) | (dbg (a + 1) << 16) | (dbg (a + 2) << 8) | (dbg (a + 3) << 0); } #define UAEFS_VERSION "UAEfs 0.5" @@ -105,37 +105,37 @@ static uaecptr ROM_filesys_hack_remove; 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; - 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; + /* 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]; @@ -151,84 +151,83 @@ typedef struct { } UnitInfo; struct uaedev_mount_info { - UnitInfo ui[MAX_FILESYSTEM_UNITS]; + UnitInfo ui[MAX_FILESYSTEM_UNITS]; }; static struct uaedev_mount_info mountinfo; -int nr_units(void) +int nr_units (void) { - int i, cnt = 0; - for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { + int i, cnt = 0; + for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { if (mountinfo.ui[i].open > 0) - cnt++; - } - return cnt; + cnt++; + } + 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) +static int is_virtual (int unit_no) { - int t = is_hardfile(unit_no); + int t = is_hardfile (unit_no); return t == FILESYS_VIRTUAL; } -int is_hardfile(int unit_no) +int is_hardfile (int unit_no) { if (mountinfo.ui[unit_no].volname || mountinfo.ui[unit_no].wasisempty || mountinfo.ui[unit_no].unknown_media) { - return FILESYS_VIRTUAL; - } - if (mountinfo.ui[unit_no].hf.ci.sectors == 0) { + return FILESYS_VIRTUAL; + } + if (mountinfo.ui[unit_no].hf.ci.sectors == 0) { return FILESYS_HARDFILE_RDB; - } - return FILESYS_HARDFILE; + } + return FILESYS_HARDFILE; } -static void close_filesys_unit(UnitInfo *uip) +static void close_filesys_unit (UnitInfo *uip) { - if (!uip->open) - return; + if (!uip->open) + return; if (uip->hf.handle_valid) - hdf_close(&uip->hf); - if (uip->volname != 0) - xfree(uip->volname); - if (uip->devname != 0) - xfree(uip->devname); - if (uip->rootdir != 0) - xfree(uip->rootdir); - if (uip->unit_pipe) - xfree(uip->unit_pipe); - if (uip->back_pipe) - xfree(uip->back_pipe); + hdf_close (&uip->hf); + if (uip->volname != 0) + xfree (uip->volname); + if (uip->devname != 0) + xfree (uip->devname); + if (uip->rootdir != 0) + xfree (uip->rootdir); + if (uip->unit_pipe) + xfree (uip->unit_pipe); + if (uip->back_pipe) + xfree (uip->back_pipe); - uip->unit_pipe = 0; - uip->back_pipe = 0; + uip->unit_pipe = 0; + uip->back_pipe = 0; uip->hf.handle_valid = 0; - uip->volname = 0; - uip->devname = 0; - uip->rootdir = 0; - uip->open = 0; + uip->volname = 0; + uip->devname = 0; + uip->rootdir = 0; + uip->open = 0; } -static uaedev_config_data *getuci(struct uaedev_config_data *uci, int nr) +static uaedev_config_data *getuci (struct uaedev_config_data *uci, int nr) { return &uci[nr]; } @@ -236,152 +235,148 @@ static uaedev_config_data *getuci(struct uaedev_config_data *uci, int nr) static UnitInfo *getuip(struct uae_prefs *p, int index) { - if (index < 0) - return NULL; - index = p->mountconfig[index].configoffset; - if (index < 0) - return NULL; - return &mountinfo.ui[index]; + if (index < 0) + return NULL; + index = p->mountconfig[index].configoffset; + if (index < 0) + return NULL; + return &mountinfo.ui[index]; } -static int getuindex(struct uae_prefs *p, int 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) +int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo *mi) { - UnitInfo *ui = getuip(p, index); + UnitInfo *ui = getuip(p, index); struct uaedev_config_data *uci = &p->mountconfig[index]; - UnitInfo uitmp; + UnitInfo uitmp; - memset(mi, 0, sizeof(struct mountedinfo)); - memset(&uitmp, 0, sizeof uitmp); - _tcscpy(mi->rootdir, uci->ci.rootdir); - if (!ui) { - ui = &uitmp; + memset(mi, 0, sizeof (struct mountedinfo)); + memset(&uitmp, 0, sizeof uitmp); + _tcscpy (mi->rootdir, uci->ci.rootdir); + if (!ui) { + ui = &uitmp; if (uci->ci.type == UAEDEV_DIR) { - mi->ismounted = 1; - if (uci->ci.rootdir && _tcslen(uci->ci.rootdir) == 0) - return FILESYS_VIRTUAL; - if (my_existsfile(uci->ci.rootdir)) { - mi->ismedia = 1; - return FILESYS_VIRTUAL; - } - if (my_getvolumeinfo(uci->ci.rootdir) < 0) - return -1; - mi->ismedia = true; - return FILESYS_VIRTUAL; - } - else if (uci->ci.type == UAEDEV_HDF) { + mi->ismounted = 1; + if (uci->ci.rootdir && _tcslen (uci->ci.rootdir) == 0) + return FILESYS_VIRTUAL; + if (my_existsfile (uci->ci.rootdir)) { + mi->ismedia = 1; + return FILESYS_VIRTUAL; + } + if (my_getvolumeinfo (uci->ci.rootdir) < 0) + return -1; + mi->ismedia = true; + return FILESYS_VIRTUAL; + } 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); + int err = hdf_open (&ui->hf, uci->ci.rootdir); if (err <= 0) { - mi->ismedia = false; - mi->ismounted = true; + mi->ismedia = false; + mi->ismounted = true; mi->error = err; if (uci->ci.reserved == 0 && uci->ci.sectors == 0 && uci->ci.surfaces == 0) { return FILESYS_HARDFILE_RDB; - } - return -1; - } - mi->ismedia = true; - if (ui->hf.drive_empty) - mi->ismedia = 0; - hdf_close(&ui->hf); - } - else if (uci->ci.type == UAEDEV_CD) { + } + return -1; + } + mi->ismedia = true; + if (ui->hf.drive_empty) + mi->ismedia = 0; + hdf_close (&ui->hf); + } else if (uci->ci.type == UAEDEV_CD) { struct device_info di; ui->hf.ci.readonly = true; ui->hf.ci.blocksize = uci->ci.blocksize; mi->size = -1; mi->ismounted = true; - if (blkdev_get_info(p, ui->hf.ci.device_emu_unit, &di)) { + if (blkdev_get_info (p, ui->hf.ci.device_emu_unit, &di)) { mi->ismedia = di.media_inserted != 0; - _tcscpy(mi->rootdir, di.label); + _tcscpy (mi->rootdir, di.label); } - } - } - else { - if (ui->controller_type == HD_CONTROLLER_TYPE_UAE) { // what is this? || (ui->controller && p->cs_ide)) { - mi->ismounted = 1; + } + } else { + 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->ismedia = ui->hf.drive_empty ? false : true; + else + mi->ismedia = true; + } + } if (mi->size < 0) return -1; - mi->size = ui->hf.virtsize; + mi->size = ui->hf.virtsize; if (uci->ci.highcyl) { uci->ci.cyls = mi->nrcyls = uci->ci.highcyl; - } - else { + } else { uci->ci.cyls = mi->nrcyls = (int)(uci->ci.sectors * uci->ci.surfaces ? (ui->hf.virtsize / uci->ci.blocksize) / (uci->ci.sectors * uci->ci.surfaces) : 0); } if (uci->ci.type == UAEDEV_DIR) - return FILESYS_VIRTUAL; + return FILESYS_VIRTUAL; if (uci->ci.reserved == 0 && uci->ci.sectors == 0 && uci->ci.surfaces == 0) { - return FILESYS_HARDFILE_RDB; - } - return FILESYS_HARDFILE; + return FILESYS_HARDFILE_RDB; + } + return FILESYS_HARDFILE; } static void stripsemicolon(TCHAR *s) { - if (!s) - return; - while (_tcslen(s) > 0 && s[_tcslen(s) - 1] == ':') - s[_tcslen(s) - 1] = 0; + if (!s) + return; + while(_tcslen(s) > 0 && s[_tcslen(s) - 1] == ':') + s[_tcslen(s) - 1] = 0; } -static void stripspace(TCHAR *s) +static void stripspace (TCHAR *s) { int i; if (!s) return; - for (i = 0; i < _tcslen(s); i++) { + for (i = 0; i < _tcslen (s); i++) { if (s[i] == ' ') s[i] = '_'; } } -static void striplength(TCHAR *s, int len) +static void striplength (TCHAR *s, int len) { if (!s) return; - if (_tcslen(s) <= len) + if (_tcslen (s) <= len) return; s[len] = 0; } -static void fixcharset(TCHAR *s) +static void fixcharset (TCHAR *s) { char tmp[MAX_DPATH]; if (!s) return; - ua_fs_copy(tmp, MAX_DPATH, s, '_'); - au_fs_copy(s, strlen(tmp) + 1, tmp); + ua_fs_copy (tmp, MAX_DPATH, 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); @@ -389,97 +384,94 @@ 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; - TCHAR *p = NULL; + TCHAR *nvol = NULL; + int i, archivehd; + TCHAR *p = NULL; - archivehd = -1; - if (my_existsfile(rootdir)) - archivehd = 1; - else if (my_existsdir(rootdir)) - archivehd = 0; + archivehd = -1; + if (my_existsfile(rootdir)) + archivehd = 1; + else if (my_existsdir(rootdir)) + archivehd = 0; if (zv && zv->volumename && _tcslen(zv->volumename) > 0) { nvol = my_strdup(zv->volumename); - nvol = validatevolumename(nvol, def); + 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--) { - TCHAR c = p[i]; - if (c == ':' || c == '/' || c == '\\') { - if (i == _tcslen(p) - 1) - continue; - if (!_tcscmp(p + i, _T(":\\"))) { - xfree(p); - p = xmalloc(TCHAR, 10); - p[0] = rootdir[0]; - p[1] = 0; - i = 0; - } - else { - i++; - } - break; - } - } - if (i >= 0) - nvol = my_strdup(p + i); - } - if (!nvol && archivehd >= 0) { - if (volname && _tcslen(volname) > 0) - nvol = my_strdup(volname); - else - nvol = my_strdup(def); - } - if (!nvol) { - if (volname && _tcslen(volname)) - nvol = my_strdup(volname); - else - nvol = my_strdup(_T("")); - } - nvol = validatevolumename(nvol, def); - xfree(p); - return nvol; + if ((!volname || _tcslen (volname) == 0) && rootdir && archivehd >= 0) { + p = my_strdup (rootdir); + for (i = _tcslen (p) - 1; i >= 0; i--) { + TCHAR c = p[i]; + if (c == ':' || c == '/' || c == '\\') { + if (i == _tcslen (p) - 1) + continue; + if (!_tcscmp (p + i, _T(":\\"))) { + xfree (p); + p = xmalloc (TCHAR, 10); + p[0] = rootdir[0]; + p[1] = 0; + i = 0; + } else { + i++; + } + break; + } + } + if (i >= 0) + nvol = my_strdup (p + i); + } + if (!nvol && archivehd >= 0) { + if (volname && _tcslen (volname) > 0) + nvol = my_strdup (volname); + else + nvol = my_strdup (def); + } + if (!nvol) { + if (volname && _tcslen (volname)) + nvol = my_strdup (volname); + else + nvol = my_strdup (_T("")); + } + nvol = validatevolumename (nvol, def); + xfree (p); + return nvol; } static int set_filesys_volume(const TCHAR *rootdir, int *flags, bool *readonly, bool *emptydrive, struct zvolume **zvp) { - *emptydrive = 0; - if (my_existsfile(rootdir)) { - struct zvolume *zv; - zv = zfile_fopen_archive(rootdir); - if (!zv) { - error_log(_T("'%s' is not a supported archive file."), rootdir); - return -1; - } - *zvp = zv; - *flags = MYVOLUMEINFO_ARCHIVE; - *readonly = 1; - } - else { - *flags = my_getvolumeinfo(rootdir); - if (*flags < 0) { - if (rootdir && rootdir[0]) - error_log(_T("directory '%s' not found, mounting as empty drive."), rootdir); - *emptydrive = 1; - *flags = 0; - } - else if ((*flags) & MYVOLUMEINFO_READONLY) { - error_log(_T("'%s' set to read-only."), rootdir); - *readonly = 1; - } - } - return 1; + *emptydrive = 0; + if (my_existsfile(rootdir)) { + struct zvolume *zv; + zv = zfile_fopen_archive(rootdir); + if (!zv) { + error_log (_T("'%s' is not a supported archive file."), rootdir); + return -1; + } + *zvp = zv; + *flags = MYVOLUMEINFO_ARCHIVE; + *readonly = 1; + } else { + *flags = my_getvolumeinfo (rootdir); + if (*flags < 0) { + if (rootdir && rootdir[0]) + error_log (_T("directory '%s' not found, mounting as empty drive."), rootdir); + *emptydrive = 1; + *flags = 0; + } else if ((*flags) & MYVOLUMEINFO_READONLY) { + error_log (_T("'%s' set to read-only."), rootdir); + *readonly = 1; + } + } + return 1; } -void uci_set_defaults(struct uaedev_config_info *uci, bool rdb) +void uci_set_defaults (struct uaedev_config_info *uci, bool rdb) { - memset(uci, 0, sizeof(struct uaedev_config_info)); + memset (uci, 0, sizeof (struct uaedev_config_info)); if (!rdb) { uci->sectors = 32; uci->reserved = 2; @@ -496,115 +488,113 @@ void uci_set_defaults(struct uaedev_config_info *uci, bool rdb) uci->device_emu_unit = -1; } -static int set_filesys_unit_1(int nr, struct uaedev_config_info *ci) +static int set_filesys_unit_1 (int nr, struct uaedev_config_info *ci) { - UnitInfo *ui; - int i; - bool emptydrive = false; + UnitInfo *ui; + int i; + bool emptydrive = false; struct uaedev_config_info c; - memcpy(&c, ci, sizeof(struct uaedev_config_info)); + memcpy (&c, ci, sizeof (struct uaedev_config_info)); - if (nr < 0) { - for (nr = 0; nr < MAX_FILESYSTEM_UNITS; nr++) { - if (!mountinfo.ui[nr].open) - break; - } - if (nr == MAX_FILESYSTEM_UNITS) { - error_log(_T("No slot allocated for this unit")); - return -1; - } - } + if (nr < 0) { + for (nr = 0; nr < MAX_FILESYSTEM_UNITS; nr++) { + if (!mountinfo.ui[nr].open) + break; + } + if (nr == MAX_FILESYSTEM_UNITS) { + error_log (_T("No slot allocated for this unit")); + return -1; + } + } 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)); + 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++) { + for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { if (nr == i || !mountinfo.ui[i].open || mountinfo.ui[i].rootdir == NULL) - continue; - if (_tcslen(c.rootdir) > 0 && !_tcsicmp(mountinfo.ui[i].rootdir, c.rootdir)) { - error_log(_T("directory/hardfile '%s' already added."), c.rootdir); - return -1; - } - } + continue; + if (_tcslen (c.rootdir) > 0 && !_tcsicmp (mountinfo.ui[i].rootdir, c.rootdir)) { + error_log (_T("directory/hardfile '%s' already added."), c.rootdir); + return -1; + } + } - ui = &mountinfo.ui[nr]; - memset(ui, 0, sizeof(UnitInfo)); + ui = &mountinfo.ui[nr]; + memset (ui, 0, sizeof (UnitInfo)); - if (c.volname[0]) { - int flags = 0; - emptydrive = 1; + if (c.volname[0]) { + int flags = 0; + emptydrive = 1; if (c.rootdir[0]) { - 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->volflags = flags; - } - else { + 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->volflags = flags; + } else { ui->unit_type = UNIT_FILESYSTEM; - memcpy(&ui->hf.ci, &c, sizeof(struct uaedev_config_info)); + memcpy (&ui->hf.ci, &c, sizeof (struct uaedev_config_info)); ui->hf.unitnum = nr; - ui->volname = 0; + ui->volname = 0; if (ui->hf.ci.rootdir[0]) { - if (hdf_open(&ui->hf) <= 0 && !c.readonly) { - write_log(_T("Attempting to open '%s' in read-only mode.\n"), ui->hf.ci.rootdir); + if (hdf_open (&ui->hf) <= 0 && !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) { - error_log(_T("'%s' opened in read-only mode.\n"), ui->hf.ci.rootdir); + if (hdf_open (&ui->hf) > 0) { + error_log (_T("'%s' opened in read-only mode.\n"), ui->hf.ci.rootdir); } - } - } - else { + } + } else { // empty drive? ui->hf.drive_empty = 1; } - if (!ui->hf.drive_empty) { + if (!ui->hf.drive_empty) { if (ui->hf.handle_valid == 0) { - error_log(_T("Hardfile '%s' not found."), ui->hf.ci.rootdir); - goto err; - } + error_log (_T("Hardfile '%s' not found."), ui->hf.ci.rootdir); + goto err; + } if (ui->hf.ci.blocksize > ui->hf.virtsize || ui->hf.virtsize == 0) { - error_log(_T("Hardfile '%s' too small."), ui->hf.ci.rootdir); + error_log (_T("Hardfile '%s' too small."), ui->hf.ci.rootdir); goto err; } } if ((ui->hf.ci.blocksize & (ui->hf.ci.blocksize - 1)) != 0 || ui->hf.ci.blocksize == 0) { - error_log(_T("Hardfile '%s' bad blocksize %d."), ui->hf.ci.rootdir, ui->hf.ci.blocksize); - goto err; - } + error_log (_T("Hardfile '%s' bad blocksize %d."), ui->hf.ci.rootdir, ui->hf.ci.blocksize); + goto err; + } if ((ui->hf.ci.sectors || ui->hf.ci.surfaces || ui->hf.ci.reserved) && (ui->hf.ci.sectors < 1 || ui->hf.ci.surfaces < 1 || ui->hf.ci.surfaces > 1023 || - ui->hf.ci.reserved < 0 || ui->hf.ci.reserved > 1023) != 0) { - error_log(_T("Hardfile '%s' bad hardfile geometry."), ui->hf.ci.rootdir); - goto err; - } + ui->hf.ci.reserved < 0 || ui->hf.ci.reserved > 1023) != 0) { + error_log (_T("Hardfile '%s' bad hardfile geometry."), ui->hf.ci.rootdir); + goto err; + } if (!ui->hf.ci.highcyl) { ui->hf.ci.cyls = (int)(ui->hf.ci.sectors * ui->hf.ci.surfaces ? (ui->hf.virtsize / ui->hf.ci.blocksize) / (ui->hf.ci.sectors * ui->hf.ci.surfaces) : 0); - } + } if (!ui->hf.ci.cyls) ui->hf.ci.cyls = ui->hf.ci.highcyl; if (!ui->hf.ci.cyls) ui->hf.ci.cyls = 1; } - ui->self = 0; - ui->reset_state = FS_STARTUP; - ui->wasisempty = emptydrive; - ui->canremove = emptydrive && (ci->flags & MYVOLUMEINFO_REUSABLE); - ui->rootdir = my_strdup(c.rootdir); - if (c.devname != 0) { - ui->devname = my_strdup(c.devname); - stripsemicolon(ui->devname); - } + ui->self = 0; + ui->reset_state = FS_STARTUP; + ui->wasisempty = emptydrive; + ui->canremove = emptydrive && (ci->flags & MYVOLUMEINFO_REUSABLE); + ui->rootdir = my_strdup (c.rootdir); + if(c.devname != 0) { + ui->devname = my_strdup (c.devname); + stripsemicolon(ui->devname); + } if (c.filesys[0]) - ui->filesysdir = my_strdup(c.filesys); + ui->filesysdir = my_strdup (c.filesys); ui->readonly = c.readonly; if (c.bootpri < -129) c.bootpri = -129; @@ -612,68 +602,68 @@ static int set_filesys_unit_1(int nr, struct uaedev_config_info *ci) c.bootpri = 127; ui->bootpri = c.bootpri; ui->inject_icons = c.inject_icons; - ui->open = 1; + ui->open = 1; - return nr; + return nr; err: if (ui->hf.handle_valid) - hdf_close(&ui->hf); - return -1; + hdf_close (&ui->hf); + return -1; } -static int set_filesys_unit(int nr, struct uaedev_config_info *ci) +static int set_filesys_unit (int nr, struct uaedev_config_info *ci) { - int ret; + int ret; - ret = set_filesys_unit_1(nr, ci); - return ret; + ret = set_filesys_unit_1 (nr, ci); + return ret; } -static int add_filesys_unit(struct uaedev_config_info *ci) +static int add_filesys_unit (struct uaedev_config_info *ci) { - int ret; + int ret; - if (nr_units() >= MAX_FILESYSTEM_UNITS) - return -1; + if (nr_units() >= MAX_FILESYSTEM_UNITS) + return -1; - ret = set_filesys_unit_1(-1, ci); - return ret; + ret = set_filesys_unit_1 (-1, ci); + 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) +int move_filesys_unitconfig (struct uae_prefs *p, int nr, int to) { struct uaedev_config_data *uci1, *uci2, tmpuci; - uci1 = getuci(p->mountconfig, nr); - uci2 = getuci(p->mountconfig, to); - if (nr == to) - return 0; - memcpy(&tmpuci, uci1, sizeof(struct uaedev_config_data)); - memcpy(uci1, uci2, sizeof(struct uaedev_config_data)); - memcpy(uci2, &tmpuci, sizeof(struct uaedev_config_data)); - return 1; + uci1 = getuci (p->mountconfig, nr); + uci2 = getuci (p->mountconfig, to); + if (nr == to) + return 0; + memcpy (&tmpuci, uci1, sizeof (struct uaedev_config_data)); + memcpy (uci1, uci2, sizeof (struct uaedev_config_data)); + memcpy (uci2, &tmpuci, sizeof (struct uaedev_config_data)); + return 1; } -static void allocuci(struct uae_prefs *p, int nr, int idx, int unitnum) +static void allocuci (struct uae_prefs *p, int nr, int idx, int unitnum) { struct uaedev_config_data *uci = &p->mountconfig[nr]; if (idx >= 0) { @@ -682,15 +672,14 @@ static void allocuci(struct uae_prefs *p, int nr, int idx, int unitnum) ui = &mountinfo.ui[idx]; ui->configureddrive = 1; uci->unitnum = unitnum; - } - else { + } else { uci->configoffset = -1; uci->unitnum = -1; } } -static void allocuci(struct uae_prefs *p, int nr, int idx) +static void allocuci (struct uae_prefs *p, int nr, int idx) { - allocuci(p, nr, idx, -1); + allocuci (p, nr, idx, -1); } static const TCHAR *getunittype(struct uaedev_config_info *uci) @@ -733,22 +722,22 @@ static bool add_ide_unit(int type, int unit, struct uaedev_config_info *uci) static void initialize_mountinfo(void) { - int nr; - UnitInfo *uip = &mountinfo.ui[0]; + int nr; + UnitInfo *uip = &mountinfo.ui[0]; autocreatedunit = 0; - for (nr = 0; nr < currprefs.mountitems; nr++) { + 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)); + 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(); + int idx = set_filesys_unit_1 (-1, &ci); + allocuci (&currprefs, nr, idx); + } + } + nr = nr_units (); // init all controllers first add_cpuboard_unit_init(); @@ -773,59 +762,55 @@ static void initialize_mountinfo(void) 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) { + } 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) { + } 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) { + } else if (type == HD_CONTROLLER_TYPE_PCMCIA) { if (uci->controller_type_unit == 0) { - gayle_add_pcmcia_sram_unit(uci); - added = true; + gayle_add_pcmcia_sram_unit (uci); + added = true; + } else { + gayle_add_pcmcia_ide_unit (uci); + added = true; } - else { - gayle_add_pcmcia_ide_unit(uci); - added = true; - } - } + } if (added) - allocuci(&currprefs, nr, -1); - } + allocuci (&currprefs, nr, -1); + } } -int sprintf_filesys_unit(TCHAR *buffer, int num) +int sprintf_filesys_unit (TCHAR *buffer, int num) { - UnitInfo *uip = mountinfo.ui; + UnitInfo *uip = mountinfo.ui; - 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("")); - else - _stprintf(buffer, _T("(DH%d:) Hardfile, \"%s\", size %d Mbytes"), num, - uip[num].rootdir, (int)(uip[num].hf.virtsize / (1024 * 1024))); - return 0; + 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("")); + else + _stprintf (buffer, _T("(DH%d:) Hardfile, \"%s\", size %d Mbytes"), num, + uip[num].rootdir, (int)(uip[num].hf.virtsize / (1024 * 1024))); + return 0; } -static void free_mountinfo(void) +static void free_mountinfo (void) { - int i; - for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) - close_filesys_unit(mountinfo.ui + i); - gayle_free_units(); + 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) +struct hardfiledata *get_hardfile_data (int nr) { - UnitInfo *uip = mountinfo.ui; - if (nr < 0 || nr >= MAX_FILESYSTEM_UNITS || uip[nr].open == 0 || is_virtual(nr)) - return 0; - return &uip[nr].hf; + UnitInfo *uip = mountinfo.ui; + if (nr < 0 || nr >= MAX_FILESYSTEM_UNITS || uip[nr].open == 0 || is_virtual(nr)) + return 0; + return &uip[nr].hf; } /* minimal AmigaDOS definitions */ @@ -871,8 +856,8 @@ struct hardfiledata *get_hardfile_data(int nr) #define MAXFILESIZE32 (0xffffffff) #else /* technically correct but most native -* filesystems don't enforce it -*/ + * filesystems don't enforce it + */ #define MAXFILESIZE32 (0x7fffffff) #endif #define MAXFILESIZE32_2G (0x7fffffff) @@ -965,11 +950,11 @@ typedef struct _dpacket { } dpacket; typedef struct { - uae_u32 uniq; - /* The directory we're going through. */ - a_inode *aino; - /* The file we're going to look up next. */ - a_inode *curr_file; + uae_u32 uniq; + /* The directory we're going through. */ + a_inode *aino; + /* The file we're going to look up next. */ + a_inode *curr_file; } ExamineKey; struct lockrecord @@ -984,34 +969,34 @@ struct lockrecord }; typedef struct key { - struct key *next; - a_inode *aino; - uae_u32 uniq; - struct fs_filehandle *fd; - uae_u64 file_pos; - int dosmode; - int createmode; - int notifyactive; + struct key *next; + a_inode *aino; + uae_u32 uniq; + struct fs_filehandle *fd; + uae_u64 file_pos; + int dosmode; + int createmode; + int notifyactive; struct lockrecord *record; } Key; typedef struct notify { - struct notify *next; - uaecptr notifyrequest; - TCHAR *fullname; - TCHAR *partname; + struct notify *next; + uaecptr notifyrequest; + TCHAR *fullname; + TCHAR *partname; } Notify; typedef struct exallkey { - uae_u32 id; - struct fs_dirhandle *dirhandle; - TCHAR *fn; - uaecptr control; + uae_u32 id; + struct fs_dirhandle *dirhandle; + TCHAR *fn; + uaecptr control; } ExAllKey; /* Since ACTION_EXAMINE_NEXT is so braindamaged, we have to keep -* some of these around -*/ + * some of these around + */ #define EXKEYS 128 #define EXALLKEYS 100 @@ -1021,69 +1006,69 @@ typedef struct exallkey { /* handler state info */ typedef struct _unit { - struct _unit *next; + struct _unit *next; - /* Amiga stuff */ - uaecptr dosbase; + /* Amiga stuff */ + uaecptr dosbase; /* volume points to our IO board, always 1:1 mapping */ - uaecptr volume; - uaecptr port; /* Our port */ - uaecptr locklist; + uaecptr volume; + uaecptr port; /* Our port */ + uaecptr locklist; - /* Native stuff */ - uae_s32 unit; /* unit number */ - UnitInfo ui; /* unit startup info */ - TCHAR tmpbuf3[256]; + /* Native stuff */ + uae_s32 unit; /* unit number */ + UnitInfo ui; /* unit startup info */ + TCHAR tmpbuf3[256]; - /* Dummy message processing */ - uaecptr dummy_message; - volatile unsigned int cmds_sent; - volatile unsigned int cmds_complete; - volatile unsigned int cmds_acked; + /* Dummy message processing */ + uaecptr dummy_message; + volatile unsigned int cmds_sent; + volatile unsigned int cmds_complete; + volatile unsigned int cmds_acked; - /* ExKeys */ - ExamineKey examine_keys[EXKEYS]; - int next_exkey; + /* ExKeys */ + ExamineKey examine_keys[EXKEYS]; + int next_exkey; unsigned int total_locked_ainos; - /* ExAll */ - ExAllKey exalls[EXALLKEYS]; - int exallid; + /* ExAll */ + ExAllKey exalls[EXALLKEYS]; + int exallid; - /* Keys */ - struct key *keys; + /* Keys */ + struct key *keys; struct lockrecord *waitingrecords; - a_inode rootnode; + a_inode rootnode; unsigned int aino_cache_size; - a_inode *aino_hash[MAX_AINO_HASH]; + a_inode *aino_hash[MAX_AINO_HASH]; unsigned int nr_cache_hits; unsigned int nr_cache_lookups; - struct notify *notifyhash[NOTIFY_HASH_SIZE]; + struct notify *notifyhash[NOTIFY_HASH_SIZE]; - int volflags; - uae_u32 lockkey; - bool inhibited; - bool canremovable; + int volflags; + uae_u32 lockkey; + bool inhibited; + bool canremovable; /* increase when media is changed. - * used to detect if cached aino is valid - */ - int mountcount; + * used to detect if cached aino is valid + */ + int mountcount; int mount_changed; - struct zvolume *zarchive; + struct zvolume *zarchive; TCHAR *mount_volume; TCHAR *mount_rootdir; bool mount_readonly; int mount_flags; - int reinsertdelay; - TCHAR *newvolume; - TCHAR *newrootdir; - bool newreadonly; - int newflags; + int reinsertdelay; + TCHAR *newvolume; + TCHAR *newrootdir; + bool newreadonly; + int newflags; } Unit; static uae_u32 a_uniq, key_uniq; @@ -1120,8 +1105,7 @@ static void readdpacket(TrapContext *ctx, dpacket *packet, uaecptr pck) trap_get_bytes(ctx, packet->packet_array, pck, dp_Max); packet->packet_data = packet->packet_array; packet->need_flush = true; - } - else { + } else { packet->packet_data = get_real_address(pck); packet->need_flush = false; } @@ -1134,8 +1118,7 @@ static void writedpacket(TrapContext *ctx, dpacket *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 { + } else { // dp_Res1 and dp_Res2 trap_put_bytes(ctx, packet->packet_data + 12, packet->packet_addr + 12, 20 - 12); } @@ -1156,81 +1139,81 @@ static uae_u64 get_quadp(TrapContext *ctx, uaecptr p) static int flush_cache(Unit *unit, int num); -static TCHAR *char1(TrapContext *ctx, uaecptr addr) +static TCHAR *char1 (TrapContext *ctx, uaecptr addr) { uae_char buf[1024]; #if TRAPMD trap_get_string(ctx, (uae_u8*)buf, addr, sizeof(buf)); #else - unsigned int i = 0; - do { + unsigned int i = 0; + do { buf[i] = trap_get_byte(ctx, addr); - addr++; - } while (buf[i++] && i < sizeof(buf)); + addr++; + } while (buf[i++] && i < sizeof(buf)); #endif return au_fs(buf); } -static TCHAR *bstr1(TrapContext *ctx, uaecptr addr) +static TCHAR *bstr1 (TrapContext *ctx, uaecptr addr) { uae_char buf[257]; - int n = trap_get_byte(ctx, addr); + int n = trap_get_byte(ctx, addr); - 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); + for (int i = 0; i < n; i++, addr++) + buf[i] = trap_get_byte(ctx, addr); #endif - buf[n] = 0; + buf[n] = 0; return au_fs(buf); } -static TCHAR *bstr(TrapContext *ctx, Unit *unit, uaecptr addr) +static TCHAR *bstr (TrapContext *ctx, Unit *unit, uaecptr addr) { - int n = trap_get_byte(ctx, addr); + int n = trap_get_byte(ctx, addr); uae_char buf[257]; - addr++; + addr++; #if TRAPMD trap_get_bytes(ctx, (uae_u8*)buf, addr, n); #else - for (int i = 0; i < n; i++, addr++) + for (int i = 0; i < n; i++, addr++) buf[i] = trap_get_byte(ctx, addr); #endif buf[n] = 0; - au_fs_copy(unit->tmpbuf3, sizeof(unit->tmpbuf3) / sizeof(TCHAR), buf); - return unit->tmpbuf3; + 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 (TrapContext *ctx, Unit *unit, uaecptr addr) { uae_char buf[257]; trap_get_string(ctx, buf, addr, sizeof buf); - au_fs_copy(unit->tmpbuf3, sizeof(unit->tmpbuf3) / sizeof(TCHAR), buf); + 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 (TrapContext *ctx, Unit *unit, uaecptr addr) { - TCHAR *p = unit->tmpbuf3; + TCHAR *p = unit->tmpbuf3; int i, colon_seen = 0, off; int n = trap_get_byte(ctx, addr); uae_char buf[257]; off = 0; - addr++; - for (i = 0; i < n; i++, addr++) { + addr++; + for (i = 0; i < n; i++, addr++) { uae_u8 c = trap_get_byte(ctx, addr); buf[i] = c; - if (c == '/' || (c == ':' && colon_seen++ == 0)) + if (c == '/' || (c == ':' && colon_seen++ == 0)) off = i + 1; - } + } buf[i] = 0; - au_fs_copy(unit->tmpbuf3, sizeof(unit->tmpbuf3) / sizeof(TCHAR), buf); + au_fs_copy (unit->tmpbuf3, sizeof (unit->tmpbuf3) / sizeof (TCHAR), buf); return &p[off]; } @@ -1238,7 +1221,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, int tickcount) { /* tv.tv_sec is secs since 1-1-1970 */ /* days since 1-1-1978 */ @@ -1256,7 +1239,7 @@ void timeval_to_amiga(struct mytimeval *tv, int *days, int *mins, int *ticks, in *ticks = t / (1000 / tickcount); } -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, int tickcount) { uae_s64 t; @@ -1280,229 +1263,226 @@ void amiga_to_timeval(struct mytimeval *tv, int days, int mins, int ticks, int t 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) - if (u->port == port) - break; + Unit* u; + for (u = units; u; u = u->next) + if (u->port == port) + break; - return u; + return u; } - -static struct fs_dirhandle *fs_opendir(Unit *u, a_inode *aino) + +static struct fs_dirhandle *fs_opendir (Unit *u, a_inode *aino) { - struct fs_dirhandle *fsd = xmalloc(struct fs_dirhandle, 1); + struct fs_dirhandle *fsd = xmalloc (struct fs_dirhandle, 1); fsd->fstype = (u->volflags & MYVOLUMEINFO_ARCHIVE) ? FS_ARCHIVE : FS_DIRECTORY; if (fsd->fstype == FS_ARCHIVE) { - fsd->zd = zfile_opendir_archive(aino->nname); + fsd->zd = zfile_opendir_archive (aino->nname); if (fsd->zd) return fsd; - } - else if (fsd->fstype == FS_DIRECTORY) { - fsd->od = my_opendir(aino->nname); + } else if (fsd->fstype == FS_DIRECTORY) { + fsd->od = my_opendir (aino->nname); if (fsd->od) return fsd; - } - xfree(fsd); + } + xfree (fsd); return NULL; } -static void fs_closedir(struct fs_dirhandle *fsd) +static void fs_closedir (struct fs_dirhandle *fsd) { if (!fsd) return; - if (fsd->fstype == FS_ARCHIVE) - zfile_closedir_archive(fsd->zd); + if (fsd->fstype == FS_ARCHIVE) + zfile_closedir_archive (fsd->zd); else if (fsd->fstype == FS_DIRECTORY) - my_closedir(fsd->od); - xfree(fsd); + my_closedir (fsd->od); + xfree (fsd); } -static struct fs_filehandle *fs_openfile(Unit *u, a_inode *aino, int flags) +static struct fs_filehandle *fs_openfile (Unit *u, a_inode *aino, int flags) { - struct fs_filehandle *fsf = xmalloc(struct fs_filehandle, 1); + struct fs_filehandle *fsf = xmalloc (struct fs_filehandle, 1); fsf->fstype = (u->volflags & MYVOLUMEINFO_ARCHIVE) ? FS_ARCHIVE : FS_DIRECTORY; if (fsf->fstype == FS_ARCHIVE) { - fsf->zf = zfile_open_archive(aino->nname, flags); + fsf->zf = zfile_open_archive (aino->nname, flags); if (fsf->zf) return fsf; - } - else if (fsf->fstype == FS_DIRECTORY) { - fsf->of = my_open(aino->nname, flags); + } else if (fsf->fstype == FS_DIRECTORY) { + fsf->of = my_open (aino->nname, flags); if (fsf->of) return fsf; } - xfree(fsf); + xfree (fsf); return NULL; } -static void fs_closefile(struct fs_filehandle *fsf) +static void fs_closefile (struct fs_filehandle *fsf) { if (!fsf) return; if (fsf->fstype == FS_ARCHIVE) { - zfile_close_archive(fsf->zf); - } - else if (fsf->fstype == FS_DIRECTORY) { - my_close(fsf->of); - } - xfree(fsf); + zfile_close_archive (fsf->zf); + } else if (fsf->fstype == FS_DIRECTORY) { + my_close (fsf->of); + } + xfree (fsf); } -static unsigned int fs_read(struct fs_filehandle *fsf, void *b, unsigned int size) +static unsigned int fs_read (struct fs_filehandle *fsf, void *b, unsigned int size) { if (fsf->fstype == FS_ARCHIVE) - return zfile_read_archive(fsf->zf, b, size); + return zfile_read_archive (fsf->zf, b, size); else if (fsf->fstype == FS_DIRECTORY) - return my_read(fsf->of, b, size); + return my_read (fsf->of, b, size); return 0; } -static unsigned int fs_write(struct fs_filehandle *fsf, void *b, unsigned int size) +static unsigned int fs_write (struct fs_filehandle *fsf, void *b, unsigned int size) { if (fsf->fstype == FS_DIRECTORY) - return my_write(fsf->of, b, size); + return my_write (fsf->of, b, size); return 0; } /* return value = old position. -1 = error. */ -static uae_s64 fs_lseek64(struct fs_filehandle *fsf, uae_s64 offset, int whence) +static uae_s64 fs_lseek64 (struct fs_filehandle *fsf, uae_s64 offset, int whence) { if (fsf->fstype == FS_ARCHIVE) - return zfile_lseek_archive(fsf->zf, offset, whence); + return zfile_lseek_archive (fsf->zf, offset, whence); else if (fsf->fstype == FS_DIRECTORY) - return my_lseek(fsf->of, offset, whence); + return my_lseek (fsf->of, offset, whence); return -1; } -static uae_s32 fs_lseek(struct fs_filehandle *fsf, uae_s32 offset, int whence) +static uae_s32 fs_lseek (struct fs_filehandle *fsf, uae_s32 offset, int whence) { - uae_s64 v = fs_lseek64(fsf, offset, whence); + uae_s64 v = fs_lseek64 (fsf, offset, whence); if (v < 0 || v > 0x7fffffff) return -1; return (uae_s32)v; } -static uae_s64 fs_fsize64(struct fs_filehandle *fsf) +static uae_s64 fs_fsize64 (struct fs_filehandle *fsf) { if (fsf->fstype == FS_ARCHIVE) - return zfile_fsize_archive(fsf->zf); + return zfile_fsize_archive (fsf->zf); else if (fsf->fstype == FS_DIRECTORY) - return my_fsize(fsf->of); + return my_fsize (fsf->of); return -1; } -static uae_u32 fs_fsize(struct fs_filehandle *fsf) +static uae_u32 fs_fsize (struct fs_filehandle *fsf) { - return (uae_u32)fs_fsize64(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); + 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); + return fs_lseek64 (k->fd, offset, whence); } -static void set_volume_name(Unit *unit, struct mytimeval *tv) +static void set_volume_name (Unit *unit, struct mytimeval *tv) { - int namelen; - int i; + int namelen; + int i; char *s; - s = ua_fs(unit->ui.volname, -1); - namelen = strlen(s); + s = ua_fs (unit->ui.volname, -1); + namelen = strlen (s); if (namelen >= 58) namelen = 58; - put_byte(unit->volume + 64, 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 + 64, namelen); + for (i = 0; i < namelen; i++) + put_byte (unit->volume + 64 + 1 + i, s[i]); + put_byte (unit->volume + 64 + 1 + namelen, 0); if (tv && (tv->tv_sec || tv->tv_usec)) { int days, mins, ticks; - timeval_to_amiga(tv, &days, &mins, &ticks, 50); - put_long(unit->volume + 16, days); - put_long(unit->volume + 20, mins); - put_long(unit->volume + 24, ticks); + timeval_to_amiga (tv, &days, &mins, &ticks, 50); + put_long (unit->volume + 16, days); + put_long (unit->volume + 20, mins); + put_long (unit->volume + 24, ticks); } - xfree(s); - unit->rootnode.aname = unit->ui.volname; - unit->rootnode.nname = unit->ui.rootdir; - unit->rootnode.mountcount = unit->mountcount; + xfree (s); + unit->rootnode.aname = unit->ui.volname; + unit->rootnode.nname = unit->ui.rootdir; + unit->rootnode.mountcount = unit->mountcount; } 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 + 64) || unit->ui.unknown_media; } static void clear_exkeys(Unit *unit) { - int i; - a_inode *a; - for (i = 0; i < EXKEYS; i++) { - unit->examine_keys[i].aino = 0; - unit->examine_keys[i].curr_file = 0; - unit->examine_keys[i].uniq = 0; - } - for (i = 0; i < EXALLKEYS; i++) { - fs_closedir(unit->exalls[i].dirhandle); - unit->exalls[i].dirhandle = NULL; - xfree(unit->exalls[i].fn); - unit->exalls[i].fn = NULL; - unit->exalls[i].id = 0; - } - unit->exallid = 0; - unit->next_exkey = 1; - a = &unit->rootnode; - while (a) { - a->exnext_count = 0; - if (a->locked_children) { - a->locked_children = 0; - unit->total_locked_ainos--; - } - a = a->next; - if (a == &unit->rootnode) - break; - } + int i; + a_inode *a; + for (i = 0; i < EXKEYS; i++) { + unit->examine_keys[i].aino = 0; + unit->examine_keys[i].curr_file = 0; + unit->examine_keys[i].uniq = 0; + } + for (i = 0; i < EXALLKEYS; i++) { + fs_closedir (unit->exalls[i].dirhandle); + unit->exalls[i].dirhandle = NULL; + xfree (unit->exalls[i].fn); + unit->exalls[i].fn = NULL; + unit->exalls[i].id = 0; + } + unit->exallid = 0; + unit->next_exkey = 1; + a = &unit->rootnode; + while (a) { + a->exnext_count = 0; + if (a->locked_children) { + a->locked_children = 0; + unit->total_locked_ainos--; + } + a = a->next; + if (a == &unit->rootnode) + break; + } } -static void filesys_delayed_change(Unit *u, int frames, const TCHAR *rootdir, const TCHAR *volume, bool readonly, int flags) +static void filesys_delayed_change (Unit *u, int frames, const TCHAR *rootdir, const TCHAR *volume, bool readonly, int flags) { u->reinsertdelay = 50; u->newflags = flags; u->newreadonly = readonly; - u->newrootdir = my_strdup(rootdir); + u->newrootdir = my_strdup (rootdir); if (volume) - u->newvolume = my_strdup(volume); + u->newvolume = my_strdup (volume); filesys_eject(u->unit); - if (!rootdir || _tcslen(rootdir) == 0) - u->reinsertdelay = 0; + if (!rootdir || _tcslen (rootdir) == 0) + u->reinsertdelay = 0; if (u->reinsertdelay > 0) - write_log(_T("FILESYS: delayed insert %d: '%s' ('%s')\n"), u->unit, volume ? volume : _T(""), rootdir); + write_log (_T("FILESYS: delayed insert %d: '%s' ('%s')\n"), u->unit, volume ? volume : _T(""), rootdir); } -int filesys_eject(int nr) +int filesys_eject (int nr) { - UnitInfo *ui = &mountinfo.ui[nr]; - Unit *u = ui->self; + UnitInfo *ui = &mountinfo.ui[nr]; + Unit *u = ui->self; if (!mountertask || u->mount_changed) - return 0; + return 0; if (ui->open <= 0 || u == NULL) - return 0; - if (!is_virtual(nr)) - return 0; - if (!filesys_isvolume(u)) - return 0; + return 0; + if (!is_virtual (nr)) + return 0; + if (!filesys_isvolume(u)) + return 0; u->mount_changed = -1; - u->mountcount++; - write_log(_T("FILESYS: volume '%s' removal request\n"), u->ui.volname); + u->mountcount++; + write_log (_T("FILESYS: volume '%s' removal request\n"), u->ui.volname); // -1 = remove, -2 = remove + remove device node - put_byte(u->volume + 172 - 32, -2); - uae_Signal(get_long(u->volume + 176 - 32), 1 << 13); - return 1; + put_byte (u->volume + 172 - 32, -2); + uae_Signal (get_long (u->volume + 176 - 32), 1 << 13); + return 1; } static uae_u32 heartbeat; @@ -1512,18 +1492,18 @@ static uae_u32 REGPARAM2 debugger_helper(TrapContext *ctx) int mode = trap_get_dreg(ctx, 1); switch (mode) { - case 1: + 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: + case 2: // called when RunCommand() returns // D0 = RunCommand() return code. write_log(_T("debugger #2\n")); break; - default: + default: write_log(_T("Unknown debugger hook %d\n"), mode); return 0; } @@ -1538,74 +1518,73 @@ static void debugger_boot(void) 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); - uae_Signal(get_long(u->volume + 176 - 32), 1 << 13); + uae_Signal (get_long (u->volume + 176 - 32), 1 << 13); break; } } } -int filesys_insert(int nr, const TCHAR *volume, const TCHAR *rootdir, bool readonly, int flags) +int filesys_insert (int nr, const TCHAR *volume, const TCHAR *rootdir, bool readonly, int flags) { - UnitInfo *ui; - Unit *u; + UnitInfo *ui; + Unit *u; TrapContext *ctx = NULL; - if (!mountertask) - return 0; + if (!mountertask) + return 0; - write_log(_T("filesys_insert(%d,'%s','%s','%d','%d)\n"), nr, volume ? volume : _T(""), rootdir, readonly, flags); + write_log (_T("filesys_insert(%d,'%s','%s','%d','%d)\n"), nr, volume ? volume : _T(""), rootdir, readonly, flags); - if (nr < 0) { - for (u = units; u; u = u->next) { - if (is_virtual(u->unit)) { - if (!filesys_isvolume(u) && mountinfo.ui[u->unit].canremove) - break; - } - } - if (!u) { - for (u = units; u; u = u->next) { - if (is_virtual(u->unit)) { - if (mountinfo.ui[u->unit].canremove) - break; - } - } - } - if (!u) - return 0; - nr = u->unit; - ui = &mountinfo.ui[nr]; - } - else { - ui = &mountinfo.ui[nr]; - u = ui->self; - } + if (nr < 0) { + for (u = units; u; u = u->next) { + if (is_virtual (u->unit)) { + if (!filesys_isvolume (u) && mountinfo.ui[u->unit].canremove) + break; + } + } + if (!u) { + for (u = units; u; u = u->next) { + if (is_virtual (u->unit)) { + if (mountinfo.ui[u->unit].canremove) + break; + } + } + } + if (!u) + return 0; + nr = u->unit; + ui = &mountinfo.ui[nr]; + } else { + ui = &mountinfo.ui[nr]; + u = ui->self; + } if (ui->open <= 0 || u == NULL) - return 0; - if (u->reinsertdelay) - return -1; - if (!is_virtual(nr)) - return 0; - if (filesys_isvolume(u)) { - filesys_delayed_change(u, 50, rootdir, volume, readonly, flags); - return -1; - } - u->mountcount++; + return 0; + if (u->reinsertdelay) + return -1; + if (!is_virtual(nr)) + return 0; + if (filesys_isvolume (u)) { + filesys_delayed_change (u, 50, rootdir, volume, readonly, flags); + return -1; + } + u->mountcount++; u->mount_changed = 1; - u->mount_volume = volume ? my_strdup(volume) : NULL; - u->mount_rootdir = my_strdup(rootdir); + u->mount_volume = volume ? my_strdup (volume) : NULL; + u->mount_rootdir = my_strdup (rootdir); u->mount_readonly = readonly; u->mount_flags = flags; - write_log(_T("filesys_insert %d done!\n"), nr); + write_log (_T("filesys_insert %d done!\n"), nr); - put_byte(u->volume + 172 - 32, -3); // wait for insert - uae_Signal(get_long(u->volume + 176 - 32), 1 << 13); + put_byte (u->volume + 172 - 32, -3); // wait for insert + uae_Signal (get_long (u->volume + 176 - 32), 1 << 13); return 100 + nr; } -static uae_u32 filesys_media_change_reply(int mode) +static uae_u32 filesys_media_change_reply (int mode) { int nr; UnitInfo *ui = NULL; @@ -1618,200 +1597,195 @@ static uae_u32 filesys_media_change_reply(int mode) break; } if (nr >= MAX_FILESYSTEM_UNITS) { - write_log(_T("FILESYS: filesys_media_change_reply without mount_changed flag!?\n")); + write_log (_T("FILESYS: filesys_media_change_reply without mount_changed flag!?\n")); return 0; } if (u->mount_changed < 0) { // eject if (mode == 0) { - write_log(_T("FILESYS: got media change reply, '%s' removal finished\n"), u->ui.volname); - flush_cache(u, -1); - zfile_fclose_archive(u->zarchive); + write_log (_T("FILESYS: got media change reply, '%s' removal finished\n"), u->ui.volname); + flush_cache (u, -1); + zfile_fclose_archive (u->zarchive); u->zarchive = NULL; u->ui.unknown_media = false; - } - else { + } else { u->mount_changed = 0; } return 1; - } - else if (u->mount_changed > 0) { + } else if (u->mount_changed > 0) { if (mode == 0) { // insert 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); - flush_cache(u, -1); - xfree(u->ui.volname); + clear_exkeys (u); + xfree (u->ui.rootdir); + ui->rootdir = u->ui.rootdir = my_strdup (u->mount_rootdir); + flush_cache(u, -1); + xfree (u->ui.volname); ui->volname = u->ui.volname = NULL; - if (set_filesys_volume(u->mount_rootdir, &u->mount_flags, &u->mount_readonly, &emptydrive, &u->zarchive) < 0) - return 0; - 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")); - uci = getuci(currprefs.mountconfig, nr); + if (set_filesys_volume (u->mount_rootdir, &u->mount_flags, &u->mount_readonly, &emptydrive, &u->zarchive) < 0) + return 0; + 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")); + 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 { - write_log(_T("FILESYS: inserted volume NR=%d RO=%d '%s' ('%s')\n"), nr, u->mount_readonly, ui->volname, u->mount_rootdir); - set_volume_name(u, &ctime); + write_log (_T("FILESYS: inserted unreadable volume NR=%d RO=%d\n"), nr, u->mount_readonly); + } else { + write_log (_T("FILESYS: inserted volume NR=%d RO=%d '%s' ('%s')\n"), nr, u->mount_readonly, ui->volname, u->mount_rootdir); + set_volume_name (u, &ctime); if (u->mount_flags >= 0) ui->volflags = u->volflags = u->ui.volflags = u->mount_flags; if (uci != NULL) { - _tcscpy(uci->ci.volname, ui->volname); - _tcscpy(uci->ci.rootdir, u->mount_rootdir); - } + _tcscpy (uci->ci.volname, ui->volname); + _tcscpy (uci->ci.rootdir, u->mount_rootdir); + } if (u->mount_flags >= 0) { ui->readonly = u->ui.readonly = u->mount_readonly; if (uci != NULL) uci->ci.readonly = u->mount_readonly; } - put_byte(u->volume + 64, 0); - put_byte(u->volume + 172 - 32, 1); + put_byte (u->volume + 64, 0); + put_byte (u->volume + 172 - 32, 1); } - - xfree(u->mount_volume); - xfree(u->mount_rootdir); + + xfree (u->mount_volume); + xfree (u->mount_rootdir); u->mount_rootdir = NULL; u->mount_volume = NULL; - } - else { + } else { u->mount_changed = 0; } - + return 1; } return 0; } -int filesys_media_change(const TCHAR *rootdir, int inserted, struct uaedev_config_data *uci) +int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_config_data *uci) { - Unit *u; - UnitInfo *ui; - int nr = -1; - TCHAR volname[MAX_DPATH], *volptr; - TCHAR devname[MAX_DPATH]; + Unit *u; + UnitInfo *ui; + int nr = -1; + TCHAR volname[MAX_DPATH], *volptr; + TCHAR devname[MAX_DPATH]; TrapContext *ctx = NULL; - if (!mountertask) - return 0; - if (automountunit >= 0) - return -1; + if (!mountertask) + return 0; + if (automountunit >= 0) + return -1; - write_log(_T("filesys_media_change('%s',%d,%p)\n"), rootdir, inserted, uci); + write_log (_T("filesys_media_change('%s',%d,%p)\n"), rootdir, inserted, uci); - nr = -1; - for (u = units; u; u = u->next) { - if (is_virtual(u->unit)) { - ui = &mountinfo.ui[u->unit]; + nr = -1; + for (u = units; u; u = u->next) { + if (is_virtual (u->unit)) { + ui = &mountinfo.ui[u->unit]; // inserted == 2: drag&drop insert, do not replace existing normal drives - if (inserted < 2 && ui->rootdir && !memcmp(ui->rootdir, rootdir, _tcslen(rootdir)) && _tcslen(rootdir) + 3 >= _tcslen(ui->rootdir)) { - if (filesys_isvolume(u) && inserted) { - if (uci) - filesys_delayed_change(u, 50, rootdir, uci->ci.volname, uci->ci.readonly, 0); - return 0; - } - nr = u->unit; - break; - } - } - } - ui = NULL; - if (nr >= 0) - ui = &mountinfo.ui[nr]; - /* only configured drives have automount support if automount is disabled */ - if ((!ui || !ui->configureddrive) && (inserted == 0 || inserted == 1)) - return 0; - if (nr < 0 && !inserted) - return 0; - /* already mounted volume was ejected? */ - if (nr >= 0 && !inserted) - return filesys_eject(nr); - if (inserted) { + if (inserted < 2 && ui->rootdir && !memcmp (ui->rootdir, rootdir, _tcslen (rootdir)) && _tcslen (rootdir) + 3 >= _tcslen (ui->rootdir)) { + if (filesys_isvolume (u) && inserted) { + if (uci) + filesys_delayed_change (u, 50, rootdir, uci->ci.volname, uci->ci.readonly, 0); + return 0; + } + nr = u->unit; + break; + } + } + } + ui = NULL; + if (nr >= 0) + ui = &mountinfo.ui[nr]; + /* only configured drives have automount support if automount is disabled */ + if ((!ui || !ui->configureddrive) && (inserted == 0 || inserted == 1)) + return 0; + if (nr < 0 && !inserted) + return 0; + /* already mounted volume was ejected? */ + if (nr >= 0 && !inserted) + return filesys_eject (nr); + if (inserted) { struct uaedev_config_info ci = { 0 }; - if (uci) { - volptr = my_strdup(uci->ci.volname); - } - else { + 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); + target_get_volume_name (&mountinfo, &ci2, 1, 0, -1); _tcscpy(volname, ci2.volname); - volptr = volname; - if (!volname[0]) - volptr = NULL; - if (ui && ui->configureddrive && ui->volname) { - volptr = volname; - _tcscpy(volptr, ui->volname); - } - } - if (!volptr) { - volptr = filesys_createvolname(NULL, rootdir, NULL, _T("removable")); - _tcscpy(volname, volptr); - xfree(volptr); - volptr = volname; - } + volptr = volname; + if (!volname[0]) + volptr = NULL; + if (ui && ui->configureddrive && ui->volname) { + volptr = volname; + _tcscpy (volptr, ui->volname); + } + } + if (!volptr) { + volptr = filesys_createvolname (NULL, rootdir, NULL, _T("removable")); + _tcscpy (volname, volptr); + xfree (volptr); + volptr = volname; + } - /* new volume inserted and it was previously mounted? */ - if (nr >= 0) { - if (!filesys_isvolume(u)) /* not going to mount twice */ - return filesys_insert(nr, volptr, rootdir, false, -1); - return 0; - } - if (inserted < 0) /* -1 = only mount if already exists */ - return 0; - /* new volume inserted and it was not previously mounted? - * perhaps we have some empty device slots? */ - nr = filesys_insert(-1, volptr, rootdir, 0, 0); - if (nr >= 100) { - if (uci) - uci->configoffset = nr - 100; - return nr; - } - /* nope, uh, need black magic now.. */ - if (uci) - _tcscpy(devname, uci->ci.devname); - else - _stprintf(devname, _T("RDH%d"), autocreatedunit++); - _tcscpy(ci.devname, devname); - _tcscpy(ci.volname, volptr); - _tcscpy(ci.rootdir, rootdir); + /* new volume inserted and it was previously mounted? */ + if (nr >= 0) { + if (!filesys_isvolume (u)) /* not going to mount twice */ + return filesys_insert (nr, volptr, rootdir, false, -1); + return 0; + } + if (inserted < 0) /* -1 = only mount if already exists */ + return 0; + /* new volume inserted and it was not previously mounted? + * perhaps we have some empty device slots? */ + nr = filesys_insert (-1, volptr, rootdir, 0, 0); + if (nr >= 100) { + if (uci) + uci->configoffset = nr - 100; + return nr; + } + /* nope, uh, need black magic now.. */ + if (uci) + _tcscpy (devname, uci->ci.devname); + else + _stprintf (devname, _T("RDH%d"), autocreatedunit++); + _tcscpy (ci.devname, devname); + _tcscpy (ci.volname, volptr); + _tcscpy (ci.rootdir, rootdir); ci.flags = MYVOLUMEINFO_REUSABLE; - nr = add_filesys_unit(&ci); - if (nr < 0) - return 0; - if (inserted > 1) - mountinfo.ui[nr].canremove = 1; - automountunit = nr; - uae_Signal(mountertask, 1 << 13); - /* poof */ - if (uci) - uci->configoffset = nr; - return 100 + nr; + nr = add_filesys_unit (&ci); + if (nr < 0) + return 0; + if (inserted > 1) + mountinfo.ui[nr].canremove = 1; + automountunit = nr; + uae_Signal (mountertask, 1 << 13); + /* poof */ + if (uci) + uci->configoffset = nr; + return 100 + nr; } return 0; } -int hardfile_added(struct uaedev_config_info *ci) +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); + return gayle_add_pcmcia_ide_unit(ci); if (ci->controller_type_unit == 0) - return gayle_add_pcmcia_sram_unit(ci); + 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) +int hardfile_media_change (struct hardfiledata *hfd, struct uaedev_config_info *ci, bool inserted, bool timer) { if (!hfd) return 0; @@ -1820,33 +1794,32 @@ int hardfile_media_change(struct hardfiledata *hfd, struct uaedev_config_info *c if (hfd->reinsertdelay < 0) { hfd->reinsertdelay = 0; if (!hfd->isreinsert) { - hdf_close(hfd); - hardfile_send_disk_change(hfd, false); + hdf_close (hfd); + hardfile_send_disk_change (hfd, false); if (hfd->delayedci.rootdir[0]) { hfd->reinsertdelay = 50; hfd->isreinsert = true; - write_log(_T("HARDFILE: delayed insert %d: '%s'\n"), hfd->unitnum, ci->rootdir ? ci->rootdir : _T("")); + write_log (_T("HARDFILE: delayed insert %d: '%s'\n"), hfd->unitnum, ci->rootdir ? ci->rootdir : _T("")); return 0; - } - else { + } else { return 1; } } - memcpy(&hfd->ci, &hfd->delayedci, sizeof(struct uaedev_config_info)); - if (hdf_open(hfd) <= 0) { - write_log(_T("HARDFILE: '%s' failed to open\n"), hfd->ci.rootdir); + memcpy (&hfd->ci, &hfd->delayedci, sizeof (struct uaedev_config_info)); + if (hdf_open (hfd) <= 0) { + write_log (_T("HARDFILE: '%s' failed to open\n"), hfd->ci.rootdir); return 0; } - hardfile_send_disk_change(hfd, true); + hardfile_send_disk_change (hfd, true); return 1; } if (ci) { - memcpy(&hfd->delayedci, ci, sizeof(struct uaedev_config_info)); + memcpy (&hfd->delayedci, ci, sizeof (struct uaedev_config_info)); if (hfd && !hfd->drive_empty) { hfd->reinsertdelay = 50; hfd->isreinsert = false; - write_log(_T("HARDFILE: delayed eject %d: '%s'\n"), hfd->unitnum, hfd->ci.rootdir ? hfd->ci.rootdir : _T("")); + write_log (_T("HARDFILE: delayed eject %d: '%s'\n"), hfd->unitnum, hfd->ci.rootdir ? hfd->ci.rootdir : _T("")); return 0; } if (!hfd) { @@ -1854,770 +1827,763 @@ int hardfile_media_change(struct hardfiledata *hfd, struct uaedev_config_info *c } hfd->reinsertdelay = 2; hfd->isreinsert = true; - } - else { + } else { if (inserted) { hfd->reinsertdelay = 2; hfd->isreinsert = true; - memcpy(&hfd->delayedci, &hfd->ci, sizeof(struct uaedev_config_info)); - } - else { + memcpy (&hfd->delayedci, &hfd->ci, sizeof (struct uaedev_config_info)); + } else { hfd->reinsertdelay = 2; hfd->isreinsert = false; - memcpy(&hfd->delayedci, &hfd->ci, sizeof(struct uaedev_config_info)); + memcpy (&hfd->delayedci, &hfd->ci, sizeof (struct uaedev_config_info)); hfd->delayedci.rootdir[0] = 0; } - } - return 0; + } + return 0; } /* flags and comments supported? */ -static int fsdb_cando(Unit *unit) +static int fsdb_cando (Unit *unit) { - if (unit->volflags & MYVOLUMEINFO_ARCHIVE) - return 1; - return 1; + if (unit->volflags & MYVOLUMEINFO_ARCHIVE) + return 1; + return 1; } -static void prepare_for_open(TCHAR *name) +static void prepare_for_open (TCHAR *name) { } -static void de_recycle_aino(Unit *unit, a_inode *aino) +static void de_recycle_aino (Unit *unit, a_inode *aino) { - if (aino->next == 0 || aino == &unit->rootnode) - return; - aino->next->prev = aino->prev; - aino->prev->next = aino->next; - aino->next = aino->prev = 0; - unit->aino_cache_size--; + if (aino->next == 0 || aino == &unit->rootnode) + return; + aino->next->prev = aino->prev; + aino->prev->next = aino->next; + aino->next = aino->prev = 0; + unit->aino_cache_size--; } -static void dispose_aino(Unit *unit, a_inode **aip, a_inode *aino) +static void dispose_aino (Unit *unit, a_inode **aip, a_inode *aino) { - int hash = aino->uniq % MAX_AINO_HASH; - if (unit->aino_hash[hash] == aino) - unit->aino_hash[hash] = 0; + int hash = aino->uniq % MAX_AINO_HASH; + if (unit->aino_hash[hash] == aino) + unit->aino_hash[hash] = 0; - if (aino->dirty && aino->parent) - fsdb_dir_writeback(aino->parent); + if (aino->dirty && aino->parent) + fsdb_dir_writeback (aino->parent); - *aip = aino->sibling; + *aip = aino->sibling; - xfree(aino->aname); - xfree(aino->comment); - xfree(aino->nname); - xfree(aino); + xfree (aino->aname); + xfree (aino->comment); + xfree (aino->nname); + xfree (aino); } -static void free_all_ainos(Unit *u, a_inode *parent) +static void free_all_ainos (Unit *u, a_inode *parent) { - a_inode *a; + a_inode *a; while ((a = parent->child)) { - free_all_ainos(u, a); - dispose_aino(u, &parent->child, a); - } + free_all_ainos (u, a); + dispose_aino (u, &parent->child, a); + } } static int flush_cache(Unit *unit, int num) { - int i = 0; - int cnt = 100; + int i = 0; + int cnt = 100; - //write_log (_T("FILESYS: flushing cache unit %d (max %d items)\n"), unit->unit, num); - if (num == 0) - num = -1; - while (i < num || num < 0) { - int ii = i; - a_inode *parent = unit->rootnode.prev->parent; - a_inode **aip; + //write_log (_T("FILESYS: flushing cache unit %d (max %d items)\n"), unit->unit, num); + if (num == 0) + num = -1; + while (i < num || num < 0) { + int ii = i; + a_inode *parent = unit->rootnode.prev->parent; + a_inode **aip; - aip = &parent->child; - if (parent && !parent->locked_children) { - for (;;) { - a_inode *aino = *aip; - if (aino == 0) - break; - /* Not recyclable if next == 0 (i.e., not chained into - recyclable list), or if parent directory is being - ExNext()ed. */ - if (aino->next == 0) { - aip = &aino->sibling; - } - else { - if (aino->shlock > 0 || aino->elock) - write_log(_T("panic: freeing locked a_inode!\n")); - de_recycle_aino(unit, aino); - dispose_aino(unit, aip, aino); - i++; - } - } - } - { //if (unit->rootnode.next != unit->rootnode.prev) { - /* In the previous loop, we went through all children of one - parent. Re-arrange the recycled list so that we'll find a - different parent the next time around. - (infinite loop if there is only one parent?) - */ - int maxloop = 10000; - do { - unit->rootnode.next->prev = unit->rootnode.prev; - unit->rootnode.prev->next = unit->rootnode.next; - unit->rootnode.next = unit->rootnode.prev; - unit->rootnode.prev = unit->rootnode.prev->prev; - unit->rootnode.prev->next = unit->rootnode.next->prev = &unit->rootnode; - } while (unit->rootnode.prev->parent == parent && maxloop-- > 0); - } - if (i == ii) - cnt--; - if (cnt <= 0) - break; - } - return unit->aino_cache_size > 0 ? 0 : 1; + aip = &parent->child; + if (parent && !parent->locked_children) { + for (;;) { + a_inode *aino = *aip; + if (aino == 0) + break; + /* Not recyclable if next == 0 (i.e., not chained into + recyclable list), or if parent directory is being + ExNext()ed. */ + if (aino->next == 0) { + aip = &aino->sibling; + } else { + if (aino->shlock > 0 || aino->elock) + write_log (_T("panic: freeing locked a_inode!\n")); + de_recycle_aino (unit, aino); + dispose_aino (unit, aip, aino); + i++; + } + } + } + { //if (unit->rootnode.next != unit->rootnode.prev) { + /* In the previous loop, we went through all children of one + parent. Re-arrange the recycled list so that we'll find a + different parent the next time around. + (infinite loop if there is only one parent?) + */ + int maxloop = 10000; + do { + unit->rootnode.next->prev = unit->rootnode.prev; + unit->rootnode.prev->next = unit->rootnode.next; + unit->rootnode.next = unit->rootnode.prev; + unit->rootnode.prev = unit->rootnode.prev->prev; + unit->rootnode.prev->next = unit->rootnode.next->prev = &unit->rootnode; + } while (unit->rootnode.prev->parent == parent && maxloop-- > 0); + } + if (i == ii) + cnt--; + if (cnt <= 0) + break; + } + return unit->aino_cache_size > 0 ? 0 : 1; } -static void recycle_aino(Unit *unit, a_inode *new_aino) +static void recycle_aino (Unit *unit, a_inode *new_aino) { - if (new_aino->dir || new_aino->shlock > 0 - || new_aino->elock || new_aino == &unit->rootnode) - /* Still in use */ - return; + if (new_aino->dir || new_aino->shlock > 0 + || new_aino->elock || new_aino == &unit->rootnode) + /* Still in use */ + return; TRACE3((_T("Recycling; cache size %u, 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); - } + 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); + } - /* 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; + /* 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; - unit->aino_cache_size++; + unit->aino_cache_size++; } -void filesys_flush_cache(void) +void filesys_flush_cache (void) { } -static void update_child_names(Unit *unit, a_inode *a, a_inode *parent) +static void update_child_names (Unit *unit, a_inode *a, a_inode *parent) { - int l0 = _tcslen(parent->nname) + 2; + int l0 = _tcslen (parent->nname) + 2; - while (a != 0) { - TCHAR *name_start; - TCHAR *new_name; - TCHAR dirsep[2] = { FSDB_DIR_SEPARATOR, '\0' }; - - a->parent = parent; - name_start = _tcsrchr(a->nname, FSDB_DIR_SEPARATOR); - if (name_start == 0) { - write_log(_T("malformed file name")); - } - name_start++; - new_name = xmalloc(TCHAR, _tcslen(name_start) + l0); - _tcscpy(new_name, parent->nname); - _tcscat(new_name, dirsep); - _tcscat(new_name, name_start); - xfree(a->nname); - a->nname = new_name; - if (a->child) - update_child_names(unit, a->child, a); - a = a->sibling; - } + while (a != 0) { + TCHAR *name_start; + TCHAR *new_name; + TCHAR dirsep[2] = { FSDB_DIR_SEPARATOR, '\0' }; + + a->parent = parent; + name_start = _tcsrchr (a->nname, FSDB_DIR_SEPARATOR); + if (name_start == 0) { + write_log (_T("malformed file name")); + } + name_start++; + new_name = xmalloc (TCHAR, _tcslen (name_start) + l0); + _tcscpy (new_name, parent->nname); + _tcscat (new_name, dirsep); + _tcscat (new_name, name_start); + xfree (a->nname); + a->nname = new_name; + if (a->child) + update_child_names (unit, a->child, a); + a = a->sibling; + } } -static void move_aino_children(Unit *unit, a_inode *from, a_inode *to) +static void move_aino_children (Unit *unit, a_inode *from, a_inode *to) { - to->child = from->child; - from->child = 0; - update_child_names(unit, to->child, to); + to->child = from->child; + from->child = 0; + update_child_names (unit, to->child, to); } -static void delete_aino(Unit *unit, a_inode *aino) +static void delete_aino (Unit *unit, a_inode *aino) { - a_inode **aip; + a_inode **aip; - TRACE((_T("deleting aino %x\n"), aino->uniq)); + TRACE((_T("deleting aino %x\n"), aino->uniq)); - aino->dirty = 1; - aino->deleted = 1; - de_recycle_aino(unit, aino); + aino->dirty = 1; + aino->deleted = 1; + de_recycle_aino (unit, 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"))); - } - } - } - } + /* 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"))); + } + } + } + } - aip = &aino->parent->child; - while (*aip != aino && *aip != 0) - aip = &(*aip)->sibling; - if (*aip != aino) { - write_log(_T("Couldn't delete aino.\n")); - return; - } - dispose_aino(unit, aip, aino); + aip = &aino->parent->child; + while (*aip != aino && *aip != 0) + aip = &(*aip)->sibling; + if (*aip != aino) { + write_log (_T("Couldn't delete aino.\n")); + return; + } + dispose_aino (unit, aip, aino); } -static a_inode *lookup_sub(a_inode *dir, uae_u32 uniq) +static a_inode *lookup_sub (a_inode *dir, uae_u32 uniq) { - a_inode **cp = &dir->child; - a_inode *c, *retval; + a_inode **cp = &dir->child; + a_inode *c, *retval; - for (;;) { - c = *cp; - if (c == 0) - return 0; + for (;;) { + c = *cp; + if (c == 0) + return 0; - if (c->uniq == uniq) { - retval = c; - break; - } - if (c->dir) { - a_inode *a = lookup_sub(c, uniq); - if (a != 0) { - retval = a; - break; - } - } - cp = &c->sibling; - } - if (!dir->locked_children) { - /* Move to the front to speed up repeated lookups. Don't do this if - an ExNext is going on in this directory, or we'll terminally - confuse it. */ - *cp = c->sibling; - c->sibling = dir->child; - dir->child = c; - } - return retval; + if (c->uniq == uniq) { + retval = c; + break; + } + if (c->dir) { + a_inode *a = lookup_sub (c, uniq); + if (a != 0) { + retval = a; + break; + } + } + cp = &c->sibling; + } + if (! dir->locked_children) { + /* Move to the front to speed up repeated lookups. Don't do this if + an ExNext is going on in this directory, or we'll terminally + confuse it. */ + *cp = c->sibling; + c->sibling = dir->child; + dir->child = c; + } + return retval; } -static a_inode *lookup_aino(Unit *unit, uae_u32 uniq) +static a_inode *lookup_aino (Unit *unit, uae_u32 uniq) { - a_inode *a; - int hash = uniq % MAX_AINO_HASH; + a_inode *a; + int hash = uniq % MAX_AINO_HASH; - if (uniq == 0) - return &unit->rootnode; - a = unit->aino_hash[hash]; - if (a == 0 || a->uniq != uniq) - a = lookup_sub(&unit->rootnode, uniq); - else - unit->nr_cache_hits++; - unit->nr_cache_lookups++; - unit->aino_hash[hash] = a; - return a; + if (uniq == 0) + return &unit->rootnode; + a = unit->aino_hash[hash]; + if (a == 0 || a->uniq != uniq) + a = lookup_sub (&unit->rootnode, uniq); + else + unit->nr_cache_hits++; + unit->nr_cache_lookups++; + unit->aino_hash[hash] = a; + return a; } -static a_inode *aino_from_lock(TrapContext *ctx, Unit *unit, uaecptr lock) +static a_inode *aino_from_lock (TrapContext *ctx, Unit *unit, uaecptr lock) { - return lookup_aino(unit, trap_get_long(ctx, lock + 4)); + return lookup_aino (unit, trap_get_long(ctx, lock + 4)); } -TCHAR *build_nname(const TCHAR *d, const TCHAR *n) +TCHAR *build_nname (const TCHAR *d, const TCHAR *n) { - TCHAR dsep[2] = { FSDB_DIR_SEPARATOR, 0 }; - TCHAR *p = xmalloc(TCHAR, _tcslen(d) + 1 + _tcslen(n) + 1); - _tcscpy(p, d); - _tcscat(p, dsep); - _tcscat(p, n); - return p; + TCHAR dsep[2] = { FSDB_DIR_SEPARATOR, 0 }; + TCHAR *p = xmalloc (TCHAR, _tcslen (d) + 1 + _tcslen (n) + 1); + _tcscpy (p, d); + _tcscat (p, dsep); + _tcscat (p, n); + return p; } -TCHAR *build_aname(const TCHAR *d, const TCHAR *n) +TCHAR *build_aname (const TCHAR *d, const TCHAR *n) { - TCHAR *p = xmalloc(TCHAR, _tcslen(d) + 1 + _tcslen(n) + 1); - _tcscpy(p, d); - _tcscat(p, _T("/")); - _tcscat(p, n); - return p; + TCHAR *p = xmalloc (TCHAR, _tcslen (d) + 1 + _tcslen (n) + 1); + _tcscpy (p, d); + _tcscat (p, _T("/")); + _tcscat (p, n); + return p; } /* This gets called to translate an Amiga name that some program used to -* a name that we can use on the native filesystem. */ -static TCHAR *get_nname(Unit *unit, a_inode *base, TCHAR *rel, TCHAR **modified_rel, uae_u64 *uniq_ext) + * a name that we can use on the native filesystem. */ +static TCHAR *get_nname (Unit *unit, a_inode *base, TCHAR *rel, TCHAR **modified_rel, uae_u64 *uniq_ext) { - TCHAR *found; + TCHAR *found; - *modified_rel = 0; + *modified_rel = 0; + + if (unit->volflags & MYVOLUMEINFO_ARCHIVE) { + if (zfile_exists_archive(base->nname, rel)) + return build_nname(base->nname, rel); + return NULL; + } - if (unit->volflags & MYVOLUMEINFO_ARCHIVE) { - if (zfile_exists_archive(base->nname, rel)) - return build_nname(base->nname, rel); - return NULL; - } - - /* 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 - * file called ".". We can't represent this in our filesystem, - * so we create a special file "uae_xxx" and record the mapping - * aname "." -> nname "uae_xxx" in the database. Then, the Amiga - * program looks up "uae_xxx" (yes, it's contrived). The filesystem - * should not make the uae_xxx file visible to the Amiga side. */ - if (fsdb_used_as_nname(base, rel)) - return 0; - /* A file called "." (or whatever else is invalid on this filesystem) + /* 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 + * file called ".". We can't represent this in our filesystem, + * so we create a special file "uae_xxx" and record the mapping + * aname "." -> nname "uae_xxx" in the database. Then, the Amiga + * program looks up "uae_xxx" (yes, it's contrived). The filesystem + * should not make the uae_xxx file visible to the Amiga side. */ + if (fsdb_used_as_nname (base, rel)) + return 0; + /* A file called "." (or whatever else is invalid on this filesystem) * does not exist, as far as the Amiga side is concerned. */ - if (fsdb_name_invalid_dir(rel)) - return 0; + if (fsdb_name_invalid_dir (rel)) + return 0; - /* See if we have a file that has the same name as the aname we are - * looking for. */ - found = fsdb_search_dir(base->nname, rel); - if (found == 0) - return found; - if (found == rel) - return build_nname(base->nname, rel); + /* See if we have a file that has the same name as the aname we are + * looking for. */ + found = fsdb_search_dir (base->nname, rel); + if (found == 0) + return found; + if (found == rel) + return build_nname (base->nname, rel); - *modified_rel = found; - return build_nname(base->nname, found); + *modified_rel = found; + return build_nname (base->nname, found); } -static TCHAR *create_nname(Unit *unit, a_inode *base, TCHAR *rel) +static TCHAR *create_nname (Unit *unit, a_inode *base, TCHAR *rel) { - TCHAR *p; + TCHAR *p; - /* 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)) { - p = fsdb_create_unique_nname(base, rel); - return p; - } - p = build_nname(base->nname, rel); - return p; + /* 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)) { + p = fsdb_create_unique_nname (base, rel); + return p; + } + p = build_nname (base->nname, rel); + return p; } static int fill_file_attrs(Unit *u, a_inode *base, a_inode *c) { - if (u->volflags & MYVOLUMEINFO_ARCHIVE) { - int isdir, flags; - TCHAR *comment; - zfile_fill_file_attrs_archive(c->nname, &isdir, &flags, &comment); - c->dir = isdir; - c->amigaos_mode = 0; - if (flags >= 0) - c->amigaos_mode = flags; - c->comment = comment; - return 1; - } - else { - return fsdb_fill_file_attrs(base, c); - } - return 0; + if (u->volflags & MYVOLUMEINFO_ARCHIVE) { + int isdir, flags; + TCHAR *comment; + zfile_fill_file_attrs_archive(c->nname, &isdir, &flags, &comment); + c->dir = isdir; + c->amigaos_mode = 0; + if (flags >= 0) + c->amigaos_mode = flags; + c->comment = comment; + return 1; + } else { + return fsdb_fill_file_attrs (base, c); + } + return 0; } /* -* This gets called if an ACTION_EXAMINE_NEXT happens and we hit an object -* for which we know the name on the native filesystem, but no corresponding -* Amiga filesystem name. -* @@@ For DOS filesystems, it might make sense to declare the new name -* "weak", so that it can get overriden by a subsequent call to get_nname(). -* That way, if someone does "dir :" and there is a file "foobar.inf", and -* someone else tries to open "foobar.info", get_nname() could maybe made to -* figure out that this is supposed to be the file "foobar.inf". -* DOS sucks... -*/ -static TCHAR *get_aname(Unit *unit, a_inode *base, TCHAR *rel) + * This gets called if an ACTION_EXAMINE_NEXT happens and we hit an object + * for which we know the name on the native filesystem, but no corresponding + * Amiga filesystem name. + * @@@ For DOS filesystems, it might make sense to declare the new name + * "weak", so that it can get overriden by a subsequent call to get_nname(). + * That way, if someone does "dir :" and there is a file "foobar.inf", and + * someone else tries to open "foobar.info", get_nname() could maybe made to + * figure out that this is supposed to be the file "foobar.inf". + * DOS sucks... + */ +static TCHAR *get_aname (Unit *unit, a_inode *base, TCHAR *rel) { - return my_strdup(rel); + return my_strdup (rel); } static void init_child_aino_tree(Unit *unit, a_inode *base, a_inode *aino) { - /* Update tree structure */ - aino->parent = base; - aino->child = 0; - aino->sibling = base->child; - base->child = aino; - aino->next = aino->prev = 0; - aino->volflags = unit->volflags; + /* Update tree structure */ + aino->parent = base; + aino->child = 0; + aino->sibling = base->child; + base->child = aino; + aino->next = aino->prev = 0; + aino->volflags = unit->volflags; } -static void init_child_aino(Unit *unit, a_inode *base, a_inode *aino) +static void init_child_aino (Unit *unit, a_inode *base, a_inode *aino) { - aino->uniq = ++a_uniq; - if (a_uniq == 0xFFFFFFFF) { - write_log(_T("Running out of a_inodes (prepare for big trouble)!\n")); - } - aino->shlock = 0; - aino->elock = 0; + aino->uniq = ++a_uniq; + if (a_uniq == 0xFFFFFFFF) { + write_log (_T("Running out of a_inodes (prepare for big trouble)!\n")); + } + aino->shlock = 0; + aino->elock = 0; - aino->dirty = 0; - aino->deleted = 0; - aino->mountcount = unit->mountcount; + aino->dirty = 0; + aino->deleted = 0; + aino->mountcount = unit->mountcount; - /* For directories - this one isn't being ExNext()ed yet. */ - aino->locked_children = 0; - aino->exnext_count = 0; - /* But the parent might be. */ - if (base->exnext_count) { - unit->total_locked_ainos++; - base->locked_children++; - } - init_child_aino_tree(unit, base, aino); + /* For directories - this one isn't being ExNext()ed yet. */ + aino->locked_children = 0; + aino->exnext_count = 0; + /* But the parent might be. */ + if (base->exnext_count) { + unit->total_locked_ainos++; + base->locked_children++; + } + init_child_aino_tree(unit, base, aino); } -static a_inode *new_child_aino(Unit *unit, a_inode *base, TCHAR *rel) +static a_inode *new_child_aino (Unit *unit, a_inode *base, TCHAR *rel) { - TCHAR *modified_rel; - TCHAR *nn; - a_inode *aino = NULL; - int isvirtual = unit->volflags & MYVOLUMEINFO_ARCHIVE; + TCHAR *modified_rel; + TCHAR *nn; + a_inode *aino = NULL; + int isvirtual = unit->volflags & MYVOLUMEINFO_ARCHIVE; - TRACE((_T("new_child_aino %s, %s\n"), base->aname, rel)); + TRACE((_T("new_child_aino %s, %s\n"), base->aname, rel)); - if (!isvirtual) - aino = fsdb_lookup_aino_aname(base, rel); - if (aino == 0) { + if (!isvirtual) + aino = fsdb_lookup_aino_aname (base, rel); + if (aino == 0) { uae_u64 uniq_ext = 0; - nn = get_nname(unit, base, rel, &modified_rel, &uniq_ext); - if (nn == 0) - return 0; + nn = get_nname (unit, base, rel, &modified_rel, &uniq_ext); + if (nn == 0) + return 0; - aino = xcalloc(a_inode, 1); - if (aino == 0) - return 0; + aino = xcalloc (a_inode, 1); + if (aino == 0) + return 0; aino->uniq_external = uniq_ext; - aino->aname = modified_rel ? modified_rel : my_strdup(rel); - aino->nname = nn; + aino->aname = modified_rel ? modified_rel : my_strdup (rel); + aino->nname = nn; - aino->comment = 0; - aino->has_dbentry = 0; + aino->comment = 0; + aino->has_dbentry = 0; - if (!fill_file_attrs(unit, base, aino)) { - xfree(aino); - return 0; - } - if (aino->dir && !isvirtual) - fsdb_clean_dir(aino); - } - init_child_aino(unit, base, aino); + if (!fill_file_attrs (unit, base, aino)) { + xfree (aino); + return 0; + } + if (aino->dir && !isvirtual) + fsdb_clean_dir (aino); + } + 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; + recycle_aino (unit, aino); + TRACE((_T("created aino %x, lookup, amigaos_mode %d\n"), aino->uniq, aino->amigaos_mode)); + return aino; } -static a_inode *create_child_aino(Unit *unit, a_inode *base, TCHAR *rel, int isdir) +static a_inode *create_child_aino (Unit *unit, a_inode *base, TCHAR *rel, int isdir) { - a_inode *aino = xcalloc(a_inode, 1); - if (aino == 0) - return 0; + a_inode *aino = xcalloc (a_inode, 1); + if (aino == 0) + return 0; - aino->nname = create_nname(unit, base, rel); - if (!aino->nname) { - free(aino); - return 0; - } - aino->aname = my_strdup(rel); + aino->nname = create_nname (unit, base, rel); + if (!aino->nname) { + free (aino); + return 0; + } + aino->aname = my_strdup (rel); - init_child_aino(unit, base, aino); - aino->amigaos_mode = 0; - aino->dir = isdir; + init_child_aino (unit, base, aino); + aino->amigaos_mode = 0; + aino->dir = isdir; - aino->comment = 0; - aino->has_dbentry = 0; - aino->dirty = 1; + aino->comment = 0; + aino->has_dbentry = 0; + aino->dirty = 1; - recycle_aino(unit, aino); + recycle_aino (unit, aino); TRACE((_T("created aino %x, create\n"), aino->uniq)); - return aino; + return aino; } -static a_inode *lookup_child_aino(Unit *unit, a_inode *base, TCHAR *rel, int *err) +static a_inode *lookup_child_aino (Unit *unit, a_inode *base, TCHAR *rel, int *err) { - a_inode *c = base->child; - int l0 = _tcslen(rel); + a_inode *c = base->child; + int l0 = _tcslen (rel); - if (base->dir == 0) { - *err = ERROR_OBJECT_WRONG_TYPE; - return 0; - } - - while (c != 0) { - int l1 = _tcslen(c->aname); - if (l0 <= l1 && same_aname(rel, c->aname + l1 - l0) - && (l0 == l1 || c->aname[l1 - l0 - 1] == '/') && c->mountcount == unit->mountcount) - break; - c = c->sibling; - } - if (c != 0) - return c; - c = new_child_aino(unit, base, rel); - if (c == 0) - *err = ERROR_OBJECT_NOT_AROUND; - return c; + if (base->dir == 0) { + *err = ERROR_OBJECT_WRONG_TYPE; + return 0; + } + + while (c != 0) { + int l1 = _tcslen (c->aname); + if (l0 <= l1 && same_aname (rel, c->aname + l1 - l0) + && (l0 == l1 || c->aname[l1-l0-1] == '/') && c->mountcount == unit->mountcount) + break; + c = c->sibling; + } + if (c != 0) + return c; + c = new_child_aino (unit, base, rel); + if (c == 0) + *err = ERROR_OBJECT_NOT_AROUND; + return c; } /* 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, struct virtualfilesysobject *vfso) { - a_inode *c = base->child; - int l0 = _tcslen(rel); - int isvirtual = unit->volflags & MYVOLUMEINFO_ARCHIVE; + a_inode *c = base->child; + int l0 = _tcslen (rel); + int isvirtual = unit->volflags & MYVOLUMEINFO_ARCHIVE; - *err = 0; - while (c != 0) { - int l1 = _tcslen(c->nname); - /* Note: using _tcscmp here. */ - if (l0 <= l1 && _tcscmp(rel, c->nname + l1 - l0) == 0 - && (l0 == l1 || c->nname[l1 - l0 - 1] == FSDB_DIR_SEPARATOR) && c->mountcount == unit->mountcount) - break; - c = c->sibling; - } - if (c != 0) - return c; + *err = 0; + while (c != 0) { + int l1 = _tcslen (c->nname); + /* Note: using _tcscmp here. */ + if (l0 <= l1 && _tcscmp (rel, c->nname + l1 - l0) == 0 + && (l0 == l1 || c->nname[l1-l0-1] == FSDB_DIR_SEPARATOR) && c->mountcount == unit->mountcount) + break; + c = c->sibling; + } + if (c != 0) + return c; if (!isvirtual && !vfso) - c = fsdb_lookup_aino_nname(base, rel); - if (c == 0) { - c = xcalloc(a_inode, 1); - if (c == 0) { - *err = ERROR_NO_FREE_STORE; - return 0; - } + c = fsdb_lookup_aino_nname (base, rel); + if (c == 0) { + c = xcalloc (a_inode, 1); + if (c == 0) { + *err = ERROR_NO_FREE_STORE; + return 0; + } - c->nname = build_nname(base->nname, rel); - c->aname = get_aname(unit, base, rel); - c->comment = 0; + c->nname = build_nname (base->nname, rel); + c->aname = get_aname (unit, base, rel); + c->comment = 0; c->uniq_external = uniq_external; - c->has_dbentry = 0; + 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)) { - xfree(c); - *err = ERROR_NO_FREE_STORE; - return 0; - } + } else if (!fill_file_attrs (unit, base, c)) { + xfree (c); + *err = ERROR_NO_FREE_STORE; + return 0; + } if (c->dir && !isvirtual && !vfso) - fsdb_clean_dir(c); - } - init_child_aino(unit, base, c); + fsdb_clean_dir (c); + } + init_child_aino (unit, base, c); - recycle_aino(unit, c); + recycle_aino (unit, c); TRACE((_T("created aino %s:%d, exnext\n"), c->nname, c->uniq)); - return c; + return c; } -static a_inode *get_aino(Unit *unit, a_inode *base, const TCHAR *rel, int *err) +static a_inode *get_aino (Unit *unit, a_inode *base, const TCHAR *rel, int *err) { - TCHAR *tmp; - TCHAR *p; - a_inode *curr; - int i; + TCHAR *tmp; + TCHAR *p; + a_inode *curr; + int i; - *err = 0; + *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++) + ; + if (':' == rel[i]) + rel += i+1; + + tmp = my_strdup (rel); + p = tmp; + curr = base; + + while (*p) { + /* start with a slash? go up a level. */ + if (*p == '/') { + if (curr->parent != 0) + curr = curr->parent; + p++; + } else { + a_inode *next; - /* root-relative path? */ - for (i = 0; rel[i] && rel[i] != '/' && rel[i] != ':'; i++) - ; - if (':' == rel[i]) - rel += i + 1; - - tmp = my_strdup(rel); - p = tmp; - curr = base; - - while (*p) { - /* start with a slash? go up a level. */ - if (*p == '/') { - if (curr->parent != 0) - curr = curr->parent; - 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; - } - } - xfree(tmp); - return curr; + 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); + return curr; } -static uae_u32 notifyhash(const TCHAR *s) +static uae_u32 notifyhash (const TCHAR *s) { - uae_u32 hash = 0; - while (*s) - hash = (hash << 5) + *s++; - return hash % NOTIFY_HASH_SIZE; + uae_u32 hash = 0; + while (*s) + hash = (hash << 5) + *s++; + return hash % NOTIFY_HASH_SIZE; } -static Notify *new_notify(Unit *unit, TCHAR *name) +static Notify *new_notify (Unit *unit, TCHAR *name) { - Notify *n = xmalloc(Notify, 1); - uae_u32 hash = notifyhash(name); - n->next = unit->notifyhash[hash]; - unit->notifyhash[hash] = n; - n->partname = name; - return n; + Notify *n = xmalloc(Notify, 1); + uae_u32 hash = notifyhash (name); + n->next = unit->notifyhash[hash]; + unit->notifyhash[hash] = n; + n->partname = name; + return n; } -static void free_notify(Unit *unit, int hash, Notify *n) +static void free_notify (Unit *unit, int hash, Notify *n) { - Notify *n1, *prev = 0; - for (n1 = unit->notifyhash[hash]; n1; n1 = n1->next) { - if (n == n1) { - if (prev) - prev->next = n->next; - else - unit->notifyhash[hash] = n->next; - break; - } - prev = n1; - } + Notify *n1, *prev = 0; + for (n1 = unit->notifyhash[hash]; n1; n1 = n1->next) { + if (n == n1) { + if (prev) + prev->next = n->next; + else + unit->notifyhash[hash] = n->next; + break; + } + prev = n1; + } } -static void startup_update_unit(Unit *unit, UnitInfo *uinfo) +static void startup_update_unit (Unit *unit, UnitInfo *uinfo) { - if (!unit) - return; - xfree(unit->ui.volname); - memcpy(&unit->ui, uinfo, sizeof(UnitInfo)); - unit->ui.devname = uinfo->devname; - unit->ui.volname = my_strdup(uinfo->volname); /* might free later for rename */ + if (!unit) + return; + xfree (unit->ui.volname); + memcpy (&unit->ui, uinfo, sizeof (UnitInfo)); + unit->ui.devname = uinfo->devname; + 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 (TrapContext *ctx, UnitInfo *uinfo, int num) { - int i; - Unit *unit, *u; + int i; + Unit *unit, *u; - unit = xcalloc(Unit, 1); - /* keep list in insertion order */ - u = units; - if (u) { - while (u->next) - u = u->next; - u->next = unit; - } - else { - units = unit; - } - uinfo->self = unit; + unit = xcalloc (Unit, 1); + /* keep list in insertion order */ + u = units; + if (u) { + while (u->next) + u = u->next; + u->next = unit; + } else { + units = unit; + } + uinfo->self = unit; - unit->volume = 0; + unit->volume = 0; unit->port = trap_get_areg(ctx, 5); - unit->unit = num; + unit->unit = num; - startup_update_unit(unit, uinfo); + startup_update_unit (unit, uinfo); - unit->cmds_complete = 0; - unit->cmds_sent = 0; - unit->cmds_acked = 0; - clear_exkeys(unit); - unit->total_locked_ainos = 0; - unit->keys = 0; - for (i = 0; i < NOTIFY_HASH_SIZE; i++) { - Notify *n = unit->notifyhash[i]; - while (n) { - Notify *n2 = n; - n = n->next; - xfree(n2->fullname); - xfree(n2->partname); - xfree(n2); - } - unit->notifyhash[i] = 0; - } + unit->cmds_complete = 0; + unit->cmds_sent = 0; + unit->cmds_acked = 0; + clear_exkeys(unit); + unit->total_locked_ainos = 0; + unit->keys = 0; + for (i = 0; i < NOTIFY_HASH_SIZE; i++) { + Notify *n = unit->notifyhash[i]; + while (n) { + Notify *n2 = n; + n = n->next; + xfree(n2->fullname); + xfree(n2->partname); + xfree(n2); + } + unit->notifyhash[i] = 0; + } - unit->rootnode.aname = uinfo->volname; - unit->rootnode.nname = uinfo->rootdir; - unit->rootnode.sibling = 0; - unit->rootnode.next = unit->rootnode.prev = &unit->rootnode; - unit->rootnode.uniq = 0; - unit->rootnode.parent = 0; - unit->rootnode.child = 0; - unit->rootnode.dir = 1; - unit->rootnode.amigaos_mode = 0; - unit->rootnode.shlock = 0; - unit->rootnode.elock = 0; - unit->rootnode.comment = 0; - unit->rootnode.has_dbentry = 0; - unit->rootnode.volflags = uinfo->volflags; - unit->aino_cache_size = 0; - for (i = 0; i < MAX_AINO_HASH; i++) - unit->aino_hash[i] = 0; - return unit; + unit->rootnode.aname = uinfo->volname; + unit->rootnode.nname = uinfo->rootdir; + unit->rootnode.sibling = 0; + unit->rootnode.next = unit->rootnode.prev = &unit->rootnode; + unit->rootnode.uniq = 0; + unit->rootnode.parent = 0; + unit->rootnode.child = 0; + unit->rootnode.dir = 1; + unit->rootnode.amigaos_mode = 0; + unit->rootnode.shlock = 0; + unit->rootnode.elock = 0; + unit->rootnode.comment = 0; + unit->rootnode.has_dbentry = 0; + unit->rootnode.volflags = uinfo->volflags; + unit->aino_cache_size = 0; + for (i = 0; i < MAX_AINO_HASH; i++) + unit->aino_hash[i] = 0; + return unit; } #ifdef UAE_FILESYS_THREADS -static void *filesys_thread(void *unit_v); +static void *filesys_thread (void *unit_v); #endif -static void filesys_start_thread(UnitInfo *ui, int nr) +static void filesys_start_thread (UnitInfo *ui, int nr) { - ui->unit_pipe = 0; - ui->back_pipe = 0; - ui->reset_state = FS_STARTUP; - if (!isrestore()) { - ui->startup = 0; - ui->self = 0; - } + ui->unit_pipe = 0; + ui->back_pipe = 0; + ui->reset_state = FS_STARTUP; + if (!isrestore ()) { + ui->startup = 0; + ui->self = 0; + } #ifdef UAE_FILESYS_THREADS - 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->back_pipe, 100, 1); - uae_start_thread(_T("filesys"), filesys_thread, (void *)ui, &ui->tid); - } + 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->back_pipe, 100, 1); + uae_start_thread (_T("filesys"), filesys_thread, (void *)ui, &ui->tid); + } #endif - if (isrestore()) { - startup_update_unit(ui->self, ui); - } + if (isrestore ()) { + startup_update_unit (ui->self, ui); + } } -static uae_u32 REGPARAM2 startup_handler(TrapContext *ctx) +static uae_u32 REGPARAM2 startup_handler (TrapContext *ctx) { 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. */ + * 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); @@ -2625,11 +2591,11 @@ static uae_u32 REGPARAM2 startup_handler(TrapContext *ctx) uaecptr arg2 = trap_get_long(ctx, pkt + dp_Arg2); uaecptr arg3 = trap_get_long(ctx, pkt + dp_Arg3); uaecptr devnode, volume; - int nr; - Unit *unit; - UnitInfo *uinfo; - int late = 0; - int ed, ef; + int nr; + Unit *unit; + UnitInfo *uinfo; + int late = 0; + int ed, ef; uae_u64 uniq = 0; uae_u32 cdays; struct mytimeval ctime = { 0 }; @@ -2639,57 +2605,57 @@ static uae_u32 REGPARAM2 startup_handler(TrapContext *ctx) // dp_Arg2 = works as documented // dp_Arg3 = NULL (!?). (Should be DeviceNode) - for (nr = 0; nr < MAX_FILESYSTEM_UNITS; nr++) { - /* Hardfile volume name? */ + for (nr = 0; nr < MAX_FILESYSTEM_UNITS; nr++) { + /* Hardfile volume name? */ if (mountinfo.ui[nr].open <= 0) - continue; - if (!is_virtual(nr)) - continue; - if (mountinfo.ui[nr].startup == arg2) - break; - } + 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")); + 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); - return 0; - } - uinfo = mountinfo.ui + nr; + 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); - return 0; - } + 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); + return 0; + } - if (!uinfo->unit_pipe) { - late = 1; - filesys_start_thread(uinfo, nr); - } + if (!uinfo->unit_pipe) { + late = 1; + filesys_start_thread (uinfo, nr); + } unit = startup_create_unit(ctx, uinfo, nr); - unit->volflags = uinfo->volflags; + unit->volflags = uinfo->volflags; unit->rootnode.uniq_external = uniq; - /* write_comm_pipe_int (unit->ui.unit_pipe, -1, 1);*/ + /* write_comm_pipe_int (unit->ui.unit_pipe, -1, 1);*/ - write_log(_T("FS: %s (flags=%08X,E=%d,ED=%d,EF=%d,native='%s') starting..\n"), - unit->ui.volname, unit->volflags, uinfo->wasisempty, ed, ef, unit->ui.rootdir); - - /* fill in our process in the device node */ + write_log (_T("FS: %s (flags=%08X,E=%d,ED=%d,EF=%d,native='%s') starting..\n"), + 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); - /* make new volume */ + /* make new volume */ unit->volume = volume; - put_long(unit->volume + 180 - 32, devnode); + put_long (unit->volume + 180 - 32, devnode); #ifdef UAE_FILESYS_THREADS unit->locklist = trap_get_areg(ctx, 3) + 8; #else @@ -2700,30 +2666,30 @@ static uae_u32 REGPARAM2 startup_handler(TrapContext *ctx) trap_put_long(ctx, unit->dummy_message + 10, 0); /* Prepare volume information */ - put_long(unit->volume + 4, 2); /* Type = dt_volume */ - put_long(unit->volume + 12, 0); /* Lock */ - put_long(unit->volume + 16, cdays); /* Creation Date */ - 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 + 4, 2); /* Type = dt_volume */ + put_long (unit->volume + 12, 0); /* Lock */ + put_long (unit->volume + 16, cdays); /* Creation Date */ + 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_byte(unit->volume + 64, 0); + put_byte (unit->volume + 64, 0); if (!uinfo->wasisempty && !uinfo->unknown_media) { int isvirtual = unit->volflags & (MYVOLUMEINFO_ARCHIVE); /* Set volume if non-empty */ - set_volume_name(unit, &ctime); + set_volume_name (unit, &ctime); if (!isvirtual) - fsdb_clean_dir(&unit->rootnode); - } + fsdb_clean_dir (&unit->rootnode); + } - put_long(unit->volume + 8, unit->port); + 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); trap_put_long(ctx, pkt + dp_Res1, DOS_TRUE); - return 1 | (late ? 2 : 0); + return 1 | (late ? 2 : 0); } static bool is_writeprotected(Unit *unit) @@ -2733,33 +2699,32 @@ static bool is_writeprotected(Unit *unit) static void do_info(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr info, bool disk_info) { - struct fs_usage fsu; + 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 - + uae_u8 buf[36] = { 0 }; // InfoData + blocksize = 512; dostype = get_long(unit->volume + 32); nr = unit->unit; - if (unit->volflags & MYVOLUMEINFO_ARCHIVE) { - ret = zfile_fs_usage_archive(unit->ui.rootdir, 0, &fsu); + if (unit->volflags & MYVOLUMEINFO_ARCHIVE) { + ret = zfile_fs_usage_archive (unit->ui.rootdir, 0, &fsu); fs = true; - media = filesys_isvolume(unit) != 0; - } - else { - ret = get_fs_usage(unit->ui.rootdir, 0, &fsu); + media = filesys_isvolume (unit) != 0; + } else { + ret = get_fs_usage (unit->ui.rootdir, 0, &fsu); if (ret) - err = dos_errno(); + err = dos_errno (); fs = true; - media = filesys_isvolume(unit) != 0; - } - if (ret != 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err); - return; + media = filesys_isvolume (unit) != 0; } + if (ret != 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + 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 */ @@ -2767,27 +2732,25 @@ static void do_info(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr info, put_long_host(buf + 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); + 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); - } - else if (!media) { + } else if (!media) { if (!disk_info) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_NO_DISK); + 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); - } - else { + } else { if (fs && currprefs.filesys_limit) { if (fsu.total > (uae_s64)currprefs.filesys_limit * 1024) { uae_s64 oldtotal = fsu.total; @@ -2804,7 +2767,7 @@ static void do_info(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr info, if (numblocks <= 0x7fffffff) break; blocksize *= 2; - } + } uae_s64 inuse = (numblocks * blocksize - fsu.avail) / blocksize; if (inuse > numblocks) inuse = numblocks; @@ -2817,138 +2780,135 @@ static void do_info(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr info, put_long_host(buf + 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); + PUT_PCK_RES1 (packet, DOS_TRUE); } static void action_disk_info(TrapContext *ctx, Unit *unit, dpacket *packet) { - TRACE((_T("ACTION_DISK_INFO\n"))); - do_info(ctx, unit, packet, GET_PCK_ARG1(packet) << 2, true); + TRACE((_T("ACTION_DISK_INFO\n"))); + do_info(ctx, unit, packet, GET_PCK_ARG1 (packet) << 2, true); } static void action_info(TrapContext *ctx, Unit *unit, dpacket *packet) { - TRACE((_T("ACTION_INFO\n"))); - do_info(ctx, unit, packet, GET_PCK_ARG2(packet) << 2, false); + TRACE((_T("ACTION_INFO\n"))); + do_info(ctx, unit, packet, GET_PCK_ARG2 (packet) << 2, false); } -static void free_key(Unit *unit, Key *k) +static void free_key (Unit *unit, Key *k) { - Key *k1; - Key *prev = 0; - for (k1 = unit->keys; k1; k1 = k1->next) { - if (k == k1) { - if (prev) - prev->next = k->next; - else - unit->keys = k->next; - break; - } - prev = k1; - } + Key *k1; + Key *prev = 0; + for (k1 = unit->keys; k1; k1 = k1->next) { + if (k == k1) { + if (prev) + prev->next = k->next; + else + unit->keys = k->next; + break; + } + prev = k1; + } for (struct lockrecord *lr = k->record; lr;) { struct lockrecord *next = lr->next; - xfree(lr); + xfree (lr); lr = next; - } + } - if (k->fd != NULL) - fs_closefile(k->fd); + if (k->fd != NULL) + fs_closefile (k->fd); - xfree(k); + xfree(k); } -static Key *lookup_key(Unit *unit, uae_u32 uniq) +static Key *lookup_key (Unit *unit, uae_u32 uniq) { - Key *k; - unsigned int total = 0; - /* It's hardly worthwhile to optimize this - most of the time there are - * only one or zero keys. */ - for (k = unit->keys; k; k = k->next) { - total++; - if (uniq == k->uniq) - return k; - } - write_log(_T("Error: couldn't find key %u / %u!\n"), uniq, total); - return 0; + Key *k; + unsigned int total = 0; + /* It's hardly worthwhile to optimize this - most of the time there are + * only one or zero keys. */ + for (k = unit->keys; k; k = k->next) { + total++; + if (uniq == k->uniq) + return k; + } + write_log (_T("Error: couldn't find key %u / %u!\n"), uniq, total); + return 0; } -static Key *new_key(Unit *unit) +static Key *new_key (Unit *unit) { - Key *k = xcalloc(Key, 1); - k->uniq = ++key_uniq; - k->fd = NULL; - k->file_pos = 0; - k->next = unit->keys; - unit->keys = k; + Key *k = xcalloc (Key, 1); + k->uniq = ++key_uniq; + k->fd = NULL; + k->file_pos = 0; + k->next = unit->keys; + unit->keys = k; - return k; + return k; } #if TRACING_ENABLED -static void dumplock(TrapContext *ctx, Unit *unit, uaecptr lock) +static void dumplock (TrapContext *ctx, Unit *unit, uaecptr lock) { - a_inode *a; + a_inode *a; TRACE((_T("LOCK: 0x%x"), lock)); - if (!lock) { + if (!lock) { TRACE((_T("\n"))); - return; - } + return; + } TRACE((_T("{ next=0x%x, mode=%d, handler=0x%x, volume=0x%x, aino %x "), trap_get_long(ctx, lock) << 2, trap_get_long(ctx, lock + 8), trap_get_long(ctx, lock + 12), trap_get_long(ctx, lock + 16), trap_get_long(ctx, lock + 4))); if (log_filesys > 0) { - a = aino_from_lock(ctx, unit, lock); - if (a == 0) { - TRACE((_T("not found!"))); - } - else { - TRACE((_T("%s"), a->nname)); - } - } + a = aino_from_lock (ctx, unit, lock); + if (a == 0) { + TRACE((_T("not found!"))); + } else { + TRACE((_T("%s"), a->nname)); + } + } TRACE((_T(" }\n"))); } #endif -static a_inode *find_aino(TrapContext *ctx, Unit *unit, uaecptr lock, const TCHAR *name, int *err) +static a_inode *find_aino (TrapContext *ctx, Unit *unit, uaecptr lock, const TCHAR *name, int *err) { - a_inode *a; - - if (lock) { + a_inode *a; + + if (lock) { a_inode *olda = aino_from_lock(ctx, unit, lock); - if (olda == 0) { - /* That's the best we can hope to do. */ - a = get_aino(unit, &unit->rootnode, name, err); - } - else { + 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) { + 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)); - } - return a; + } + return a; } -static uaecptr make_lock(TrapContext *ctx, Unit *unit, uae_u32 uniq, long mode) +static uaecptr make_lock (TrapContext *ctx, Unit *unit, uae_u32 uniq, long mode) { - /* allocate lock from the list kept by the assembly code */ - uaecptr lock; + /* allocate lock from the list kept by the assembly code */ + uaecptr lock; #if TRAPMD - struct trapmd md1[] = + struct trapmd md1[] = { - { TRAPCMD_GET_LONG,{ unit->locklist }, 1, 0 }, - { TRAPCMD_GET_LONG,{ 0 }, 2, 1 }, - { TRAPCMD_PUT_LONG,{ unit->locklist, 0 } }, + { 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; @@ -2957,22 +2917,22 @@ static uaecptr make_lock(TrapContext *ctx, Unit *unit, uae_u32 uniq, long mode) lock = trap_get_long(ctx, unit->locklist); trap_put_long(ctx, unit->locklist, trap_get_long(ctx, lock)); - lock += 4; + 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 } }, + { 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 } } + { 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)); @@ -2983,14 +2943,14 @@ static uaecptr make_lock(TrapContext *ctx, Unit *unit, uae_u32 uniq, long mode) trap_put_long(ctx, lock + 12, unit->port); trap_put_long(ctx, lock + 16, unit->volume >> 2); - /* prepend to lock chain */ + /* 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 - DUMPLOCK(ctx, unit, lock); - return lock; + DUMPLOCK(ctx, unit, lock); + return lock; } #define NOTIFY_CLASS 0x40000000 @@ -3002,142 +2962,139 @@ 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 (TrapContext *ctx, Unit *unit, Notify *n) { - uaecptr nr = n->notifyrequest; + uaecptr nr = n->notifyrequest; int flags = trap_get_long(ctx, 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) { + 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); - } - } - else if (flags & NRF_SEND_SIGNAL) { - uae_Signal(trap_get_long(ctx, nr + 16), 1 << trap_get_byte(ctx, nr + 20)); - } + } + } else if (flags & NRF_SEND_SIGNAL) { + uae_Signal (trap_get_long(ctx, nr + 16), 1 << trap_get_byte(ctx, nr + 20)); + } } -static void notify_check(TrapContext *ctx, Unit *unit, a_inode *a) +static void notify_check (TrapContext *ctx, Unit *unit, a_inode *a) { - Notify *n; - int hash = notifyhash(a->aname); - for (n = unit->notifyhash[hash]; n; n = n->next) { - uaecptr nr = n->notifyrequest; - if (same_aname(n->partname, a->aname)) { - int err; + Notify *n; + int hash = notifyhash (a->aname); + for (n = unit->notifyhash[hash]; n; n = n->next) { + uaecptr nr = n->notifyrequest; + if (same_aname(n->partname, a->aname)) { + int err; a_inode *a2 = find_aino(ctx, unit, 0, n->fullname, &err); - if (err == 0 && a == a2) + if (err == 0 && a == a2) notify_send(ctx, unit, n); - } - } - if (a->parent) { - hash = notifyhash(a->parent->aname); - for (n = unit->notifyhash[hash]; n; n = n->next) { - uaecptr nr = n->notifyrequest; - if (same_aname(n->partname, a->parent->aname)) { - int err; + } + } + if (a->parent) { + hash = notifyhash (a->parent->aname); + for (n = unit->notifyhash[hash]; n; n = n->next) { + uaecptr nr = n->notifyrequest; + if (same_aname(n->partname, a->parent->aname)) { + int err; a_inode *a2 = find_aino(ctx, unit, 0, n->fullname, &err); - if (err == 0 && a->parent == a2) + if (err == 0 && a->parent == a2) notify_send(ctx, unit, n); - } - } - } + } + } + } } static void action_add_notify(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr nr = GET_PCK_ARG1(packet); - int flags; - Notify *n; - TCHAR *name, *p, *partname; + uaecptr nr = GET_PCK_ARG1 (packet); + int flags; + Notify *n; + TCHAR *name, *p, *partname; TRACE((_T("ACTION_ADD_NOTIFY\n"))); - name = char1(ctx, trap_get_long(ctx, nr + 4)); - flags = trap_get_long(ctx, nr + 12); + name = char1 (ctx, trap_get_long(ctx, nr + 4)); + flags = trap_get_long(ctx, 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 (!(flags & (NRF_SEND_MESSAGE | NRF_SEND_SIGNAL))) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_BAD_NUMBER); + return; + } - p = name + _tcslen(name) - 1; - if (p[0] == ':') - p--; - while (p > name && p[0] != ':' && p[0] != '/') - p--; - if (p[0] == ':' || p[0] == '/') - p++; - partname = my_strdup(p); - n = new_notify(unit, partname); - n->notifyrequest = nr; - n->fullname = name; - if (flags & NRF_NOTIFY_INITIAL) { - int err; + p = name + _tcslen (name) - 1; + if (p[0] == ':') + p--; + while (p > name && p[0] != ':' && p[0] != '/') + p--; + if (p[0] == ':' || p[0] == '/') + p++; + partname = my_strdup (p); + n = new_notify (unit, partname); + n->notifyrequest = nr; + n->fullname = name; + if (flags & NRF_NOTIFY_INITIAL) { + int err; a_inode *a = find_aino(ctx, unit, 0, n->fullname, &err); - if (err == 0) + if (err == 0) notify_send(ctx, unit, n); - } - PUT_PCK_RES1(packet, DOS_TRUE); + } + PUT_PCK_RES1 (packet, DOS_TRUE); } static void action_remove_notify(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr nr = GET_PCK_ARG1(packet); - Notify *n; - int hash; + 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) { + for (hash = 0; hash < NOTIFY_HASH_SIZE; hash++) { + for (n = unit->notifyhash[hash]; n; n = n->next) { + if (n->notifyrequest == nr) { //write_log (_T("NotifyRequest %08X freed\n"), n->notifyrequest); - xfree(n->fullname); - xfree(n->partname); - free_notify(unit, hash, n); - PUT_PCK_RES1(packet, DOS_TRUE); - return; - } - } - } - write_log(_T("Tried to free non-existing NotifyRequest %08X\n"), nr); - PUT_PCK_RES1(packet, DOS_TRUE); + xfree (n->fullname); + xfree (n->partname); + free_notify (unit, hash, n); + PUT_PCK_RES1 (packet, DOS_TRUE); + return; + } + } + } + write_log (_T("Tried to free non-existing NotifyRequest %08X\n"), nr); + PUT_PCK_RES1 (packet, DOS_TRUE); } -static void free_lock(TrapContext *ctx, Unit *unit, uaecptr lock) +static void free_lock (TrapContext *ctx, Unit *unit, uaecptr lock) { - if (!lock) - return; + if (! lock) + return; - uaecptr curlock = get_long(unit->volume + 28); - if (lock == curlock << 2) { - put_long(unit->volume + 28, trap_get_long(ctx, lock)); - } - else { - uaecptr current = curlock; - uaecptr next = 0; - while (current) { + uaecptr curlock = get_long(unit->volume + 28); + if (lock == curlock << 2) { + put_long(unit->volume + 28, trap_get_long(ctx, lock)); + } else { + uaecptr current = curlock; + uaecptr next = 0; + while (current) { next = trap_get_long(ctx, current << 2); - if (lock == next << 2) - break; - current = next; - } - if (!current) { - write_log(_T("tried to unlock non-existing lock %x\n"), lock); - return; - } + if (lock == next << 2) + break; + current = next; + } + if (!current) { + write_log (_T("tried to unlock non-existing lock %x\n"), lock); + return; + } trap_put_long(ctx, current << 2, trap_get_long(ctx, lock)); - } - lock -= 4; + } + lock -= 4; #if TRAPMD struct trapmd md2[] = { - { TRAPCMD_GET_LONG,{ unit->locklist }, 1, 1 }, - { TRAPCMD_PUT_LONG,{ lock } }, - { TRAPCMD_PUT_LONG,{ unit->locklist, lock } } + { 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 @@ -3148,137 +3105,137 @@ static void free_lock(TrapContext *ctx, Unit *unit, uaecptr lock) static void action_lock(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr lock = GET_PCK_ARG1(packet) << 2; - uaecptr name = GET_PCK_ARG2(packet) << 2; - int mode = GET_PCK_ARG3(packet); - a_inode *a; - int err; + uaecptr lock = GET_PCK_ARG1 (packet) << 2; + uaecptr name = GET_PCK_ARG2 (packet) << 2; + int 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; - } + 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; + } - TRACE((_T("ACTION_LOCK(0x%08x, \"%s\", %d)\n"), lock, bstr(ctx, unit, name), mode)); - DUMPLOCK(ctx, unit, lock); + TRACE((_T("ACTION_LOCK(0x%08x, \"%s\", %d)\n"), lock, bstr (ctx, unit, name), mode)); + DUMPLOCK(ctx, unit, lock); a = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err); - if (err == 0 && (a->elock || (mode != SHARED_LOCK && a->shlock > 0))) { - err = ERROR_OBJECT_IN_USE; - } - /* Lock() doesn't do access checks. */ - if (err != 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err); - return; - } - if (mode == SHARED_LOCK) - a->shlock++; - else - a->elock = 1; - de_recycle_aino(unit, a); - PUT_PCK_RES1(packet, make_lock(ctx, unit, a->uniq, mode) >> 2); + if (err == 0 && (a->elock || (mode != SHARED_LOCK && a->shlock > 0))) { + err = ERROR_OBJECT_IN_USE; + } + /* Lock() doesn't do access checks. */ + if (err != 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, err); + return; + } + if (mode == SHARED_LOCK) + a->shlock++; + else + a->elock = 1; + de_recycle_aino (unit, a); + PUT_PCK_RES1 (packet, make_lock (ctx, unit, a->uniq, mode) >> 2); } static void action_free_lock(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr lock = GET_PCK_ARG1(packet) << 2; - a_inode *a; + uaecptr lock = GET_PCK_ARG1 (packet) << 2; + a_inode *a; TRACE((_T("ACTION_FREE_LOCK(0x%x)\n"), lock)); - DUMPLOCK(ctx, unit, lock); + DUMPLOCK(ctx, unit, lock); a = aino_from_lock(ctx, unit, lock); - if (a == 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_NOT_AROUND); - return; - } - if (a->elock) - a->elock = 0; - else - a->shlock--; - recycle_aino(unit, a); + if (a == 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND); + return; + } + if (a->elock) + a->elock = 0; + else + a->shlock--; + recycle_aino (unit, a); free_lock(ctx, unit, lock); - PUT_PCK_RES1(packet, DOS_TRUE); + PUT_PCK_RES1 (packet, DOS_TRUE); } static uaecptr action_dup_lock_2(TrapContext *ctx, Unit *unit, dpacket *packet, uae_u32 uniq) { - uaecptr out; - a_inode *a; + uaecptr out; + a_inode *a; - a = lookup_aino(unit, uniq); - if (a == 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_NOT_AROUND); - return 0; - } - /* DupLock()ing exclusive locks isn't possible, says the Autodoc, but - * at least the RAM-Handler seems to allow it. Let's see what happens - * if we don't. */ - if (a->elock) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_IN_USE); - return 0; - } - a->shlock++; - de_recycle_aino(unit, a); + a = lookup_aino (unit, uniq); + if (a == 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND); + return 0; + } + /* DupLock()ing exclusive locks isn't possible, says the Autodoc, but + * at least the RAM-Handler seems to allow it. Let's see what happens + * if we don't. */ + if (a->elock) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_IN_USE); + return 0; + } + a->shlock++; + de_recycle_aino (unit, a); out = make_lock(ctx, unit, a->uniq, -2) >> 2; - PUT_PCK_RES1(packet, out); - return out; + PUT_PCK_RES1 (packet, out); + return out; } static void action_dup_lock(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr lock = GET_PCK_ARG1(packet) << 2; + uaecptr lock = GET_PCK_ARG1 (packet) << 2; TRACE((_T("ACTION_DUP_LOCK(0x%x)\n"), lock)); - if (!lock) { - PUT_PCK_RES1(packet, 0); - return; - } + if (!lock) { + PUT_PCK_RES1 (packet, 0); + return; + } action_dup_lock_2(ctx, unit, packet, trap_get_long(ctx, lock + 4)); } static void action_lock_from_fh(TrapContext *ctx, Unit *unit, dpacket *packet) { - Key *k = lookup_key(unit, GET_PCK_ARG1(packet)); - TRACE((_T("ACTION_COPY_DIR_FH(0x%x,'%s')\n"), GET_PCK_ARG1(packet), k ? k->aino->aname : _T(""))); - if (k == 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - return; - } + Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); + TRACE((_T("ACTION_COPY_DIR_FH(0x%x,'%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); } -static void free_exkey(Unit *unit, a_inode *aino) +static void free_exkey (Unit *unit, a_inode *aino) { if (--aino->exnext_count == 0) { - TRACE((_T("Freeing ExKey and reducing total_locked from %d by %d\n"), + TRACE ((_T("Freeing ExKey and reducing total_locked from %d by %d\n"), unit->total_locked_ainos, aino->locked_children)); unit->total_locked_ainos -= aino->locked_children; aino->locked_children = 0; - } + } } -static void move_exkeys(Unit *unit, a_inode *from, a_inode *to) +static void move_exkeys (Unit *unit, a_inode *from, a_inode *to) { - to->exnext_count = from->exnext_count; - to->locked_children = from->locked_children; - from->exnext_count = 0; - from->locked_children = 0; + to->exnext_count = from->exnext_count; + to->locked_children = from->locked_children; + from->exnext_count = 0; + from->locked_children = 0; } 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(struct mystat)); /* No error checks - this had better work. */ if (unit->volflags & MYVOLUMEINFO_ARCHIVE) - ok = zfile_stat_archive(aino->nname, statbuf) != 0; + ok = zfile_stat_archive (aino->nname, statbuf) != 0; else - my_stat(aino->nname, statbuf); + my_stat (aino->nname, statbuf); return ok; } @@ -3286,9 +3243,9 @@ static void get_fileinfo(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr { struct mystat statbuf; int days, mins, ticks; - int i, n, entrytype, blocksize; + int i, n, entrytype, blocksize; uae_s64 numblocks; - int fsdb_can = fsdb_cando(unit); + int fsdb_can = fsdb_cando (unit); const TCHAR *xs; char *x, *x2; uae_u8 *buf; @@ -3296,8 +3253,7 @@ static void get_fileinfo(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr if (!valid_address(info, (sizeof buf_array) - 36)) { buf = buf_array; - } - else { + } else { buf = get_real_address(info); } @@ -3307,45 +3263,43 @@ static void get_fileinfo(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr statbuf.mtime.tv_sec = 0; statbuf.mtime.tv_usec = 0; statbuf.size = aino->vfso->size; - } - else if (!get_statinfo(unit, aino, &statbuf)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_NOT_A_DOS_DISK); + } else 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.. - */ + if (aino->parent == 0) { + /* Guru book says ST_ROOT = 1 (root directory, not currently used) + * but some programs really expect 2 from root dir.. + */ entrytype = ST_USERDIR; xs = unit->ui.volname; - } - else { - entrytype = aino->dir ? ST_USERDIR : ST_FILE; + } else { + entrytype = aino->dir ? ST_USERDIR : ST_FILE; xs = aino->aname; - } + } put_long_host(buf + 4, entrytype); - /* AmigaOS docs say these have to contain the same value. */ + /* AmigaOS docs say these have to contain the same value. */ put_long_host(buf + 120, entrytype); TRACE((_T("name=\"%s\"\n"), xs)); - x2 = x = ua_fs(xs, -1); - n = strlen(x); - if (n > 107) - n = 107; - if (n > abs(currprefs.filesys_max_name)) - n = abs(currprefs.filesys_max_name); - i = 8; + x2 = x = ua_fs (xs, -1); + n = strlen (x); + if (n > 107) + n = 107; + if (n > abs (currprefs.filesys_max_name)) + n = abs (currprefs.filesys_max_name); + i = 8; put_byte_host(buf + i, n); i++; - while (n--) + while (n--) put_byte_host(buf + i, *x), i++, x++; - while (i < 108) + while (i < 108) put_byte_host(buf + i, 0), i++; - xfree(x2); + xfree (x2); - put_long_host(buf + 116, fsdb_can ? aino->amigaos_mode : fsdb_mode_supported(aino)); + put_long_host(buf + 116, fsdb_can ? aino->amigaos_mode : fsdb_mode_supported (aino)); if (kickstart_version >= 36) { put_word_host(buf + 224, 0); // OwnerUID @@ -3363,63 +3317,61 @@ static void get_fileinfo(TrapContext *ctx, Unit *unit, dpacket *packet, uaecptr put_long_host(buf + 232, (uae_u32)statbuf.size); put_long_host(buf + 236, numblocks >> 32); put_long_host(buf + 240, (uae_u32)numblocks); - } - else { + } else { put_long_host(buf + 124, statbuf.size > MAXFILESIZE32 ? MAXFILESIZE32 : (uae_u32)statbuf.size); - } + } - timeval_to_amiga(&statbuf.mtime, &days, &mins, &ticks, 50); + 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); - if (aino->comment == 0 || !fsdb_can) + if (aino->comment == 0 || !fsdb_can) put_long_host(buf + 144, 0); - else { + else { TRACE((_T("comment=\"%s\"\n"), aino->comment)); - i = 144; + i = 144; xs = aino->comment; if (!xs) - xs = _T(""); - x2 = x = ua_fs(xs, -1); - n = strlen(x); - if (n > 78) - n = 78; + xs= _T(""); + x2 = x = ua_fs (xs, -1); + n = strlen (x); + if (n > 78) + n = 78; put_byte_host(buf + i, n); i++; - while (n--) + while (n--) put_byte_host(buf + i, *x), i++, x++; - while (i < 224) + while (i < 224) put_byte_host(buf + i, 0), i++; - xfree(x2); - } + 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 { + } else { // FIB only trap_put_bytes(ctx, buf, info, (sizeof buf_array) - 36); } } - PUT_PCK_RES1(packet, DOS_TRUE); + PUT_PCK_RES1 (packet, DOS_TRUE); } int get_native_path(TrapContext *ctx, uae_u32 lock, TCHAR *out) { - int i = 0; - for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { - if (mountinfo.ui[i].self) { + 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); - if (a) { - _tcscpy(out, a->nname); - return 0; - } - } - } - return -1; + if (a) { + _tcscpy (out, a->nname); + return 0; + } + } + } + return -1; } #define REC_EXCLUSIVE 0 @@ -3427,9 +3379,9 @@ 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 (dpacket *packet, uae_u64 pos, uae_u64 len, uae_u32 mode, uae_u32 timeout, uae_u32 msg) { - struct lockrecord *lr = xcalloc(struct lockrecord, 1); + struct lockrecord *lr = xcalloc (struct lockrecord, 1); lr->packet = packet; lr->pos = pos; lr->len = len; @@ -3439,7 +3391,7 @@ static struct lockrecord *new_record(dpacket *packet, uae_u64 pos, uae_u64 len, return lr; } -static bool record_hit(Unit *unit, Key *k, uae_u64 pos, uae_u64 len, uae_u32 mode) +static bool record_hit (Unit *unit, Key *k, uae_u64 pos, uae_u64 len, uae_u32 mode) { bool exclusive = mode == REC_EXCLUSIVE || mode == REC_EXCLUSIVE_IMMED; for (Key *k2 = unit->keys; k2; k2 = k2->next) { @@ -3465,7 +3417,7 @@ static bool record_hit(Unit *unit, Key *k, uae_u64 pos, uae_u64 len, uae_u32 mod return false; } -static void record_timeout(TrapContext *ctx, Unit *unit) +static void record_timeout (TrapContext *ctx, Unit *unit) { bool retry = true; while (retry) { @@ -3474,18 +3426,18 @@ static void record_timeout(TrapContext *ctx, Unit *unit) for (struct lockrecord *lr = unit->waitingrecords; lr; lr = lr->next) { lr->timeout--; if (lr->timeout == 0) { - Key *k = lookup_key(unit, GET_PCK_ARG1(lr->packet)); - PUT_PCK_RES1(lr->packet, DOS_FALSE); - PUT_PCK_RES2(lr->packet, ERROR_LOCK_TIMEOUT); + Key *k = lookup_key (unit, GET_PCK_ARG1 (lr->packet)); + 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); - uae_Signal(get_long(unit->volume + 176 - 32), 1 << 13); + uae_Signal (get_long (unit->volume + 176 - 32), 1 << 13); if (prev) prev->next = lr->next; else unit->waitingrecords = lr->next; - write_log(_T("queued record timed out '%s',%lld,%lld,%d,%d\n"), k ? k->aino->nname : _T("NULL"), lr->pos, lr->len, lr->mode, lr->timeout); - xfree(lr); + write_log (_T("queued record timed out '%s',%lld,%lld,%d,%d\n"), k ? k->aino->nname : _T("NULL"), lr->pos, lr->len, lr->mode, lr->timeout); + xfree (lr); retry = true; break; } @@ -3494,23 +3446,23 @@ static void record_timeout(TrapContext *ctx, Unit *unit) } } -static void record_check_waiting(TrapContext *ctx, Unit *unit) +static void record_check_waiting (TrapContext *ctx, Unit *unit) { bool retry = true; while (retry) { retry = false; struct lockrecord *prev = NULL; for (struct lockrecord *lr = unit->waitingrecords; lr; lr = lr->next) { - Key *k = lookup_key(unit, GET_PCK_ARG1(lr->packet)); - if (!k || !record_hit(unit, k, lr->pos, lr->len, lr->mode)) { + Key *k = lookup_key (unit, GET_PCK_ARG1 (lr->packet)); + if (!k || !record_hit (unit, k, lr->pos, lr->len, lr->mode)) { if (prev) 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',%llud,%llu,%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); - xfree(lr); + xfree (lr); retry = true; break; } @@ -3521,69 +3473,67 @@ static void record_check_waiting(TrapContext *ctx, Unit *unit) static int action_lock_record(TrapContext *ctx, Unit *unit, dpacket *packet, uae_u32 msg) { - Key *k = lookup_key(unit, GET_PCK_ARG1(packet)); - uae_u32 pos = GET_PCK_ARG2(packet); - uae_u32 len = GET_PCK_ARG3(packet); - uae_u32 mode = GET_PCK_ARG4(packet); - uae_u32 timeout = GET_PCK_ARG5(packet); + Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); + uae_u32 pos = GET_PCK_ARG2 (packet); + uae_u32 len = GET_PCK_ARG3 (packet); + uae_u32 mode = GET_PCK_ARG4 (packet); + uae_u32 timeout = GET_PCK_ARG5 (packet); bool exclusive = mode == REC_EXCLUSIVE || mode == REC_EXCLUSIVE_IMMED; - write_log(_T("action_lock_record('%s',%d,%d,%d,%d)\n"), k ? k->aino->nname : _T("null"), pos, len, mode, timeout); + write_log (_T("action_lock_record('%s',%d,%d,%d,%d)\n"), k ? k->aino->nname : _T("null"), pos, len, mode, timeout); if (!k || mode > REC_SHARED_IMMED) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_WRONG_TYPE); + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_WRONG_TYPE); return 1; } if (mode == REC_EXCLUSIVE_IMMED || mode == REC_SHARED_IMMED) timeout = 0; - if (record_hit(unit, k, pos, len, mode)) { + if (record_hit (unit, k, pos, len, mode)) { if (timeout && msg) { // queue it and do not reply - struct lockrecord *lr = new_record(packet, pos, len, mode, timeout, msg); + struct lockrecord *lr = new_record (packet, pos, len, mode, timeout, msg); if (unit->waitingrecords) { lr->next = unit->waitingrecords; unit->waitingrecords = lr; - } - else { + } else { unit->waitingrecords = lr; } - write_log(_T("-> collision, timeout queued\n")); + write_log (_T("-> collision, timeout queued\n")); return -1; } - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_LOCK_COLLISION); - write_log(_T("-> ERROR_LOCK_COLLISION\n")); + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_LOCK_COLLISION); + write_log (_T("-> ERROR_LOCK_COLLISION\n")); return 1; } - struct lockrecord *lr = new_record(packet, pos, len, mode, timeout, 0); + struct lockrecord *lr = new_record (packet, pos, len, mode, timeout, 0); if (k->record) { lr->next = k->record; k->record = lr; - } - else { + } else { k->record = lr; } - PUT_PCK_RES1(packet, DOS_TRUE); - write_log(_T("-> OK\n")); + PUT_PCK_RES1 (packet, DOS_TRUE); + write_log (_T("-> OK\n")); return 1; } static void action_free_record(TrapContext *ctx, Unit *unit, dpacket *packet) { - Key *k = lookup_key(unit, GET_PCK_ARG1(packet)); - uae_u32 pos = GET_PCK_ARG2(packet); - uae_u32 len = GET_PCK_ARG3(packet); + Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); + uae_u32 pos = GET_PCK_ARG2 (packet); + uae_u32 len = GET_PCK_ARG3 (packet); - write_log(_T("action_free_record('%s',%d,%d)\n"), k ? k->aino->nname : _T("null"), pos, len); + write_log (_T("action_free_record('%s',%d,%d)\n"), k ? k->aino->nname : _T("null"), pos, len); if (!k) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_WRONG_TYPE); + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_WRONG_TYPE); return; } @@ -3594,396 +3544,390 @@ static void action_free_record(TrapContext *ctx, Unit *unit, dpacket *packet) prev->next = lr->next; else k->record = lr->next; - xfree(lr); - write_log(_T("->OK\n")); + xfree (lr); + write_log (_T("->OK\n")); record_check_waiting(ctx, unit); - PUT_PCK_RES1(packet, DOS_TRUE); + PUT_PCK_RES1 (packet, DOS_TRUE); return; } } - write_log(_T("-> ERROR_RECORD_NOT_LOCKED\n")); - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_RECORD_NOT_LOCKED); + write_log (_T("-> ERROR_RECORD_NOT_LOCKED\n")); + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_RECORD_NOT_LOCKED); } #define EXALL_END 0xde1111ad -static ExAllKey *getexall(Unit *unit, uaecptr control, int id) +static ExAllKey *getexall (Unit *unit, uaecptr control, int id) { - int i; - if (id < 0) { - for (i = 0; i < EXALLKEYS; i++) { - if (unit->exalls[i].id == 0) { - unit->exallid++; - if (unit->exallid == EXALL_END) - unit->exallid++; - unit->exalls[i].id = unit->exallid; - unit->exalls[i].control = control; - return &unit->exalls[i]; - } - } - } - else if (id > 0) { - for (i = 0; i < EXALLKEYS; i++) { - if (unit->exalls[i].id == id) - return &unit->exalls[i]; - } - } - return NULL; + int i; + if (id < 0) { + for (i = 0; i < EXALLKEYS; i++) { + if (unit->exalls[i].id == 0) { + unit->exallid++; + if (unit->exallid == EXALL_END) + unit->exallid++; + unit->exalls[i].id = unit->exallid; + unit->exalls[i].control = control; + return &unit->exalls[i]; + } + } + } else if (id > 0) { + for (i = 0; i < EXALLKEYS; i++) { + if (unit->exalls[i].id == id) + return &unit->exalls[i]; + } + } + 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 (TrapContext *ctx, 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; + uaecptr exp = exalldata; + int i; + int size, size2; + int entrytype; const TCHAR *xs = NULL, *commentx = NULL; - uae_u32 flags = 15; + uae_u32 flags = 15; int days, mins, ticks; struct mystat statbuf; - int fsdb_can = fsdb_cando(unit); - uae_u16 uid = 0, gid = 0; - char *x = NULL, *comment = NULL; - int ret = 0; + int fsdb_can = fsdb_cando (unit); + uae_u16 uid = 0, gid = 0; + char *x = NULL, *comment = NULL; + int ret = 0; - memset(&statbuf, 0, sizeof statbuf); - if (unit->volflags & MYVOLUMEINFO_ARCHIVE) - zfile_stat_archive(aino->nname, &statbuf); - else - my_stat(aino->nname, &statbuf); + memset(&statbuf, 0, sizeof statbuf); + if (unit->volflags & MYVOLUMEINFO_ARCHIVE) + zfile_stat_archive (aino->nname, &statbuf); + else + my_stat (aino->nname, &statbuf); - if (aino->parent == 0) { + if (aino->parent == 0) { entrytype = ST_USERDIR; xs = unit->ui.volname; - } - else { - entrytype = aino->dir ? ST_USERDIR : ST_FILE; + } else { + entrytype = aino->dir ? ST_USERDIR : ST_FILE; xs = aino->aname; - } - x = ua_fs(xs, -1); + } + x = ua_fs (xs, -1); - size = 0; - size2 = 4; - if (type >= 1) { - size2 += 4; - size += strlen(x) + 1; - size = (size + 3) & ~3; - } - if (type >= 2) - size2 += 4; - if (type >= 3) - size2 += 4; - if (type >= 4) { - flags = fsdb_can ? aino->amigaos_mode : fsdb_mode_supported(aino); - size2 += 4; - } - if (type >= 5) { - timeval_to_amiga(&statbuf.mtime, &days, &mins, &ticks, 50); - size2 += 12; - } - if (type >= 6) { - size2 += 4; - if (aino->comment == 0 || !fsdb_can) + size = 0; + size2 = 4; + if (type >= 1) { + size2 += 4; + size += strlen (x) + 1; + size = (size + 3) & ~3; + } + if (type >= 2) + size2 += 4; + if (type >= 3) + size2 += 4; + if (type >= 4) { + flags = fsdb_can ? aino->amigaos_mode : fsdb_mode_supported(aino); + size2 += 4; + } + if (type >= 5) { + timeval_to_amiga (&statbuf.mtime, &days, &mins, &ticks, 50); + size2 += 12; + } + if (type >= 6) { + size2 += 4; + if (aino->comment == 0 || !fsdb_can) commentx = _T(""); - else + else commentx = aino->comment; - comment = ua_fs(commentx, -1); - size += strlen(comment) + 1; - size = (size + 3) & ~3; - } - if (type >= 7) { - size2 += 4; - uid = 0; - gid = 0; - } + comment = ua_fs (commentx, -1); + size += strlen (comment) + 1; + size = (size + 3) & ~3; + } + if (type >= 7) { + size2 += 4; + uid = 0; + gid = 0; + } if (type >= 8) { size2 += 8; } i = trap_get_long(ctx, control + 0); - while (i > 0) { + while (i > 0) { exp = trap_get_long(ctx, exp); /* ed_Next */ - i--; - } + i--; + } - if (exalldata + exalldatasize - exp < size + size2) - goto end; /* not enough space */ + if (exalldata + exalldatasize - exp < size + size2) + goto end; /* not enough space */ trap_put_long(ctx, exp, exp + size + size2); /* ed_Next */ - if (type >= 1) { + if (type >= 1) { trap_put_long(ctx, exp + 4, exp + size2); - for (i = 0; i <= strlen(x); i++) { + for (i = 0; i <= strlen (x); i++) { trap_put_byte(ctx, exp + size2, x[i]); - size2++; - } - } - if (type >= 2) + size2++; + } + } + if (type >= 2) trap_put_long(ctx, exp + 8, entrytype); - if (type >= 3) + if (type >= 3) trap_put_long(ctx, exp + 12, statbuf.size > MAXFILESIZE32 ? MAXFILESIZE32 : statbuf.size); - if (type >= 4) + if (type >= 4) trap_put_long(ctx, exp + 16, flags); - if (type >= 5) { + if (type >= 5) { trap_put_long(ctx, exp + 20, days); trap_put_long(ctx, exp + 24, mins); trap_put_long(ctx, exp + 28, ticks); - } - if (type >= 6) { + } + if (type >= 6) { trap_put_long(ctx, exp + 32, exp + size2); - trap_put_byte(ctx, exp + size2, strlen(comment)); - for (i = 0; i <= strlen(comment); i++) { + trap_put_byte(ctx, exp + size2, strlen (comment)); + for (i = 0; i <= strlen (comment); i++) { trap_put_byte(ctx, exp + size2, comment[i]); - size2++; - } - } - if (type >= 7) { + size2++; + } + } + if (type >= 7) { trap_put_word(ctx, exp + 36, uid); trap_put_word(ctx, 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); } trap_put_long(ctx, control + 0, trap_get_long(ctx, control + 0) + 1); - ret = 1; + ret = 1; end: - xfree(x); - xfree(comment); - return ret; + xfree (x); + xfree (comment); + return ret; } -static bool filesys_name_invalid(const TCHAR *fn) +static bool filesys_name_invalid (const TCHAR *fn) { - return _tcslen(fn) > currprefs.filesys_max_name; + 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); + ok = zfile_readdir_archive (d->zd, fn); else if (d->fstype == FS_DIRECTORY) - ok = my_readdir(d->od, fn); + 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 (TrapContext *ctx, Unit *unit, uaecptr lock, ExAllKey *eak, uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaecptr control) { - a_inode *aino, *base = NULL; - int ok; - uae_u32 err; - struct fs_dirhandle *d; - TCHAR fn[MAX_DPATH]; + a_inode *aino, *base = NULL; + int ok; + uae_u32 err; + struct fs_dirhandle *d; + TCHAR fn[MAX_DPATH]; - if (lock != 0) + if (lock != 0) base = aino_from_lock(ctx, unit, lock); - if (base == 0) - base = &unit->rootnode; - for (;;) { + if (base == 0) + base = &unit->rootnode; + for (;;) { uae_u64 uniq = 0; - d = eak->dirhandle; - if (!eak->fn) { - do { + d = eak->dirhandle; + if (!eak->fn) { + do { ok = filesys_readdir(d, fn, &uniq); - } while (ok && d->fstype == FS_DIRECTORY && (filesys_name_invalid(fn) || fsdb_name_invalid_dir(fn))); - if (!ok) - return 0; - } - else { - _tcscpy(fn, eak->fn); - xfree(eak->fn); - eak->fn = NULL; - } - aino = lookup_child_aino_for_exnext(unit, base, fn, &err, uniq, NULL); - if (!aino) - return 0; - eak->id = unit->exallid++; + } while (ok && d->fstype == FS_DIRECTORY && (filesys_name_invalid (fn) || fsdb_name_invalid_dir (fn))); + if (!ok) + return 0; + } else { + _tcscpy (fn, eak->fn); + xfree (eak->fn); + eak->fn = NULL; + } + aino = lookup_child_aino_for_exnext (unit, base, fn, &err, uniq, NULL); + 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)) { - eak->fn = my_strdup(fn); /* no space in exallstruct, save current entry */ - break; - } - } - return 1; + if (!exalldo (ctx, exalldata, exalldatasize, type, control, unit, aino)) { + eak->fn = my_strdup (fn); /* no space in exallstruct, save current entry */ + break; + } + } + return 1; } static int action_examine_all_end(TrapContext *ctx, Unit *unit, dpacket *packet) { - uae_u32 id; - uae_u32 doserr = 0; - ExAllKey *eak; - uaecptr control = GET_PCK_ARG5(packet); + uae_u32 id; + uae_u32 doserr = 0; + ExAllKey *eak; + uaecptr control = GET_PCK_ARG5 (packet); - if (kickstart_version < 36) - return 0; + if (kickstart_version < 36) + return 0; id = trap_get_long(ctx, control + 4); - eak = getexall(unit, control, id); - if (!eak) { - write_log(_T("FILESYS: EXALL_END non-existing ID %d\n"), id); - doserr = ERROR_OBJECT_WRONG_TYPE; - } - else { - eak->id = 0; - fs_closedir(eak->dirhandle); - xfree(eak->fn); - eak->fn = NULL; - eak->dirhandle = NULL; - } - if (doserr) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, doserr); - } - else { - PUT_PCK_RES1(packet, DOS_TRUE); - } - return 1; + eak = getexall (unit, control, id); + if (!eak) { + write_log (_T("FILESYS: EXALL_END non-existing ID %d\n"), id); + doserr = ERROR_OBJECT_WRONG_TYPE; + } else { + eak->id = 0; + fs_closedir (eak->dirhandle); + xfree (eak->fn); + eak->fn = NULL; + eak->dirhandle = NULL; + } + if (doserr) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, doserr); + } else { + PUT_PCK_RES1 (packet, DOS_TRUE); + } + return 1; } static int action_examine_all(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr lock = GET_PCK_ARG1(packet) << 2; - uaecptr exalldata = GET_PCK_ARG2(packet); - uae_u32 exalldatasize = GET_PCK_ARG3(packet); - uae_u32 type = GET_PCK_ARG4(packet); - uaecptr control = GET_PCK_ARG5(packet); + uaecptr lock = GET_PCK_ARG1 (packet) << 2; + uaecptr exalldata = GET_PCK_ARG2 (packet); + uae_u32 exalldatasize = GET_PCK_ARG3 (packet); + uae_u32 type = GET_PCK_ARG4 (packet); + uaecptr control = GET_PCK_ARG5 (packet); - ExAllKey *eak = NULL; + ExAllKey *eak = NULL; a_inode *base = NULL; - struct fs_dirhandle *d; - int ok, i; - uaecptr exp; - uae_u32 id, doserr = ERROR_NO_MORE_ENTRIES; + struct fs_dirhandle *d; + int ok, i; + uaecptr exp; + uae_u32 id, doserr = ERROR_NO_MORE_ENTRIES; - ok = 0; + ok = 0; trap_put_long(ctx, control + 0, 0); /* eac_Entries */ - /* EXAMINE ALL might use dos.library MatchPatternNoCase() which is >=36 */ - if (kickstart_version < 36) - return 0; + /* EXAMINE ALL might use dos.library MatchPatternNoCase() which is >=36 */ + if (kickstart_version < 36) + return 0; if (type == 0 || type > 8) { - doserr = ERROR_BAD_NUMBER; - goto fail; - } + doserr = ERROR_BAD_NUMBER; + goto fail; + } - PUT_PCK_RES1(packet, DOS_TRUE); + PUT_PCK_RES1 (packet, DOS_TRUE); id = trap_get_long(ctx, control + 4); - if (id == EXALL_END) { - write_log(_T("FILESYS: EXALL called twice with ERROR_NO_MORE_ENTRIES\n")); - goto fail; /* already ended exall() */ - } - if (id) { - eak = getexall(unit, control, id); - if (!eak) { - write_log(_T("FILESYS: EXALL non-existing ID %d\n"), id); - doserr = ERROR_OBJECT_WRONG_TYPE; - goto fail; - } + if (id == EXALL_END) { + write_log (_T("FILESYS: EXALL called twice with ERROR_NO_MORE_ENTRIES\n")); + goto fail; /* already ended exall() */ + } + if (id) { + eak = getexall (unit, control, id); + if (!eak) { + write_log (_T("FILESYS: EXALL non-existing ID %d\n"), id); + doserr = ERROR_OBJECT_WRONG_TYPE; + goto fail; + } if (!action_examine_all_do(ctx, unit, lock, eak, exalldata, exalldatasize, type, control)) - goto fail; + goto fail; if (trap_get_long(ctx, control + 0) == 0) { - /* uh, no space for first entry.. */ - doserr = ERROR_NO_FREE_STORE; - goto fail; - } + /* uh, no space for first entry.. */ + doserr = ERROR_NO_FREE_STORE; + goto fail; + } - } - else { + } else { - eak = getexall(unit, control, -1); - if (!eak) - goto fail; - if (lock != 0) + eak = getexall (unit, control, -1); + if (!eak) + goto fail; + if (lock != 0) base = aino_from_lock(ctx, unit, lock); - if (base == 0) - base = &unit->rootnode; - d = fs_opendir(unit, base); - if (!d) - goto fail; - eak->dirhandle = d; + if (base == 0) + base = &unit->rootnode; + 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)) - goto fail; + if (!action_examine_all_do (ctx, unit, lock, eak, exalldata, exalldatasize, type, control)) + goto fail; if (trap_get_long(ctx, control + 0) == 0) { - /* uh, no space for first entry.. */ - doserr = ERROR_NO_FREE_STORE; - goto fail; - } + /* uh, no space for first entry.. */ + doserr = ERROR_NO_FREE_STORE; + goto fail; + } - } - ok = 1; + } + ok = 1; fail: - /* Clear last ed_Next. This "list" is quite non-Amiga like.. */ - exp = exalldata; + /* Clear last ed_Next. This "list" is quite non-Amiga like.. */ + exp = exalldata; i = trap_get_long(ctx, control + 0); - for (;;) { - if (i <= 1) { - if (exp) + for (;;) { + if (i <= 1) { + if (exp) trap_put_long(ctx, exp, 0); - break; - } + break; + } exp = trap_get_long(ctx, exp); /* ed_Next */ - i--; - } + i--; + } - if (!ok) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, doserr); - if (eak) { - eak->id = 0; - fs_closedir(eak->dirhandle); - eak->dirhandle = NULL; - xfree(eak->fn); - eak->fn = NULL; - } - if (doserr == ERROR_NO_MORE_ENTRIES) + if (!ok) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, doserr); + if (eak) { + eak->id = 0; + fs_closedir (eak->dirhandle); + eak->dirhandle = NULL; + xfree (eak->fn); + eak->fn = NULL; + } + if (doserr == ERROR_NO_MORE_ENTRIES) trap_put_long(ctx, control + 4, EXALL_END); - } - return 1; + } + return 1; } static uae_u32 exall_helper(TrapContext *ctx) { - int i; - Unit *u; + 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); + uae_u32 id = trap_get_long(ctx, control + 4); - 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) { + 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); - } - } - } - return 1; + } + } + } + return 1; } -static uae_u32 REGPARAM2 fsmisc_helper(TrapContext *ctx) +static uae_u32 REGPARAM2 fsmisc_helper (TrapContext *ctx) { int mode = trap_get_dreg(ctx, 0); switch (mode) { case 0: - return exall_helper(ctx); + return exall_helper (ctx); case 1: - return filesys_media_change_reply(0); + return filesys_media_change_reply (0); case 2: - return filesys_media_change_reply(1); + return filesys_media_change_reply (1); case 3: - uae_u32 t = getlocaltime(); + uae_u32 t = getlocaltime (); uae_u32 secs = (uae_u32)t - (8 * 365 + 2) * 24 * 60 * 60; return secs; } @@ -3992,17 +3936,17 @@ static uae_u32 REGPARAM2 fsmisc_helper(TrapContext *ctx) static void action_examine_object(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr lock = GET_PCK_ARG1(packet) << 2; - uaecptr info = GET_PCK_ARG2(packet) << 2; - a_inode *aino = 0; + uaecptr lock = GET_PCK_ARG1 (packet) << 2; + uaecptr info = GET_PCK_ARG2 (packet) << 2; + a_inode *aino = 0; TRACE((_T("ACTION_EXAMINE_OBJECT(0x%x,0x%x)\n"), lock, info)); - DUMPLOCK(ctx, unit, lock); + DUMPLOCK(ctx, unit, lock); - if (lock != 0) + if (lock != 0) aino = aino_from_lock(ctx, unit, lock); - if (aino == 0) - aino = &unit->rootnode; + if (aino == 0) + aino = &unit->rootnode; get_fileinfo(ctx, unit, packet, info, aino, false); } @@ -4061,8 +4005,7 @@ static void inject_icons_to_directory(Unit *unit, a_inode *base) struct virtualfilesysobject *vfso; if (aino->dir) { vfso = &vfso_icon_drawer; - } - else { + } else { if (aino->amigaos_mode & A_FIBF_EXECUTE) vfso = &vfso_icon_project; else @@ -4073,99 +4016,98 @@ static void inject_icons_to_directory(Unit *unit, a_inode *base) } /* Read a directory's contents, create a_inodes for each file, and -mark them as locked in memory so that recycle_aino will not reap -them. -We do this to avoid problems with the host OS: we don't want to -leave the directory open on the host side until all ExNext()s have -finished - they may never finish! */ + mark them as locked in memory so that recycle_aino will not reap + them. + We do this to avoid problems with the host OS: we don't want to + leave the directory open on the host side until all ExNext()s have + finished - they may never finish! */ -static void populate_directory(Unit *unit, a_inode *base) +static void populate_directory (Unit *unit, a_inode *base) { - struct fs_dirhandle *d; - a_inode *aino; + struct fs_dirhandle *d; + a_inode *aino; - d = fs_opendir(unit, base); - if (!d) - return; - for (aino = base->child; aino; aino = aino->sibling) { - base->locked_children++; - unit->total_locked_ainos++; - } + d = fs_opendir (unit, base); + if (!d) + return; + for (aino = base->child; aino; aino = aino->sibling) { + base->locked_children++; + unit->total_locked_ainos++; + } TRACE3((_T("Populating directory, child %s, locked_children %d\n"), base->child ? base->child->nname : _T(""), base->locked_children)); - for (;;) { + for (;;) { uae_u64 uniq = 0; - TCHAR fn[MAX_DPATH]; - int ok; - uae_u32 err; + TCHAR fn[MAX_DPATH]; + int ok; + uae_u32 err; - /* Find next file that belongs to the Amiga fs (skipping things - like "..", "." etc. */ - do { + /* Find next file that belongs to the Amiga fs (skipping things + like "..", "." etc. */ + do { ok = filesys_readdir(d, fn, &uniq); - } 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); - } - fs_closedir(d); + } 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); + } + 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) { - for (;;) { - TCHAR *name; + for (;;) { + TCHAR *name; if (!aino) - break; + break; name = aino->nname; - get_fileinfo(ctx, unit, packet, info, aino, longfilesize); - if (!aino->vfso && !(unit->volflags & MYVOLUMEINFO_ARCHIVE) && !fsdb_exists(name)) { - TRACE((_T("%s orphaned"), name)); + get_fileinfo (ctx, unit, packet, info, aino, longfilesize); + if (!aino->vfso && !(unit->volflags & MYVOLUMEINFO_ARCHIVE) && !fsdb_exists(name)) { + TRACE ((_T("%s orphaned"), name)); return false; - } + } return true; - } + } TRACE((_T("no more entries\n"))); - free_exkey(unit, aino->parent); - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_NO_MORE_ENTRIES); + free_exkey (unit, aino->parent); + 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) { - uaecptr lock = GET_PCK_ARG1(packet) << 2; - uaecptr info = GET_PCK_ARG2(packet) << 2; + uaecptr lock = GET_PCK_ARG1 (packet) << 2; + uaecptr info = GET_PCK_ARG2 (packet) << 2; a_inode *aino = 0, *daino = 0; - uae_u32 uniq; + uae_u32 uniq; TRACE((_T("ACTION_EXAMINE_NEXT(0x%x,0x%x,%d)\n"), lock, info, largefilesize)); - gui_flicker_led(UNIT_LED(unit), unit->unit, 1); - DUMPLOCK(ctx, unit, lock); + gui_flicker_led (UNIT_LED(unit), unit->unit, 1); + DUMPLOCK(ctx, unit, lock); - if (lock != 0) + if (lock != 0) aino = aino_from_lock(ctx, unit, lock); - if (aino == 0) - aino = &unit->rootnode; + if (aino == 0) + aino = &unit->rootnode; uniq = trap_get_long(ctx, info); - for (;;) { - if (uniq == aino->uniq) { + 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; + 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->exnext_count++ == 0) + populate_directory (unit, aino); if (!aino->child) goto no_more_entries; daino = aino->child; - } - else { + } else { daino = lookup_aino(unit, uniq); if (!daino) { // deleted? Look for next larger uniq in same directory. @@ -4186,225 +4128,221 @@ static void action_examine_next(TrapContext *ctx, Unit *unit, dpacket *packet, b // didn't find any but there are still entries? restart from beginning. if (!daino && aino->child) { daino = aino->child; - } - } - else { - daino = daino->sibling; - } - } + } + } else { + daino = daino->sibling; + } + } 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); - goto no_more_entries; - } + goto no_more_entries; + } uniq = daino->uniq; if (daino->mountcount != unit->mountcount) continue; if (!do_examine(ctx, unit, packet, daino, info, largefilesize)) continue; - return; + return; } no_more_entries: free_exkey(unit, aino); - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_NO_MORE_ENTRIES); + 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) { - 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; + 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; - int err; - mode_t openmode; - int aino_created = 0; - int isvirtual = unit->volflags & MYVOLUMEINFO_ARCHIVE; + int err; + mode_t openmode; + int aino_created = 0; + int isvirtual = unit->volflags & MYVOLUMEINFO_ARCHIVE; TRACE((_T("ACTION_FIND_*(0x%08x,0x%08x,\"%s\",%d,%d)\n"), fh, lock, bstr(ctx, unit, name), mode, create)); TRACE((_T("fh=%x lock=%x name=%x\n"), fh, lock, name)); - DUMPLOCK(ctx, unit, lock); + DUMPLOCK(ctx, unit, lock); aino = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err); - if (aino == 0 || (err != 0 && err != ERROR_OBJECT_NOT_AROUND)) { - /* Whatever it is, we can't handle it. */ - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err); - return; - } - if (err == 0) { - /* Object exists. */ - if (aino->dir) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_WRONG_TYPE); - return; - } - if (aino->elock || (create == 2 && aino->shlock > 0)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_IN_USE); - return; - } + if (aino == 0 || (err != 0 && err != ERROR_OBJECT_NOT_AROUND)) { + /* Whatever it is, we can't handle it. */ + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, err); + return; + } + if (err == 0) { + /* Object exists. */ + if (aino->dir) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_WRONG_TYPE); + return; + } + if (aino->elock || (create == 2 && aino->shlock > 0)) { + PUT_PCK_RES1 (packet, DOS_FALSE); + 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); + 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 (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)) - && 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. */ + && 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)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DISK_WRITE_PROTECTED); - return; - } - if (((mode & aino->amigaos_mode) & A_FIBF_WRITE) != 0 - || mode == 0) - { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_WRITE_PROTECTED); - return; - } - if (((mode & aino->amigaos_mode) & A_FIBF_READ) != 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_READ_PROTECTED); - return; - } - } - } - else if (create == 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err); - 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); - if (aino == 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DISK_IS_FULL); /* best we can do */ - return; - } - aino_created = 1; - } - - prepare_for_open(aino->nname); + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); + return; + } + if (((mode & aino->amigaos_mode) & A_FIBF_WRITE) != 0 + || mode == 0) + { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_WRITE_PROTECTED); + return; + } + if (((mode & aino->amigaos_mode) & A_FIBF_READ) != 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_READ_PROTECTED); + return; + } + } + } else if (create == 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, err); + 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); + if (aino == 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_DISK_IS_FULL); /* best we can do */ + return; + } + aino_created = 1; + } + + 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; - k->aino = aino; - k->dosmode = mode; - k->createmode = create; - k->notifyactive = create ? 1 : 0; - - if (create && isvirtual) - fsdb_set_file_attrs(aino); + k = new_key (unit); + k->fd = fd; + k->aino = aino; + k->dosmode = mode; + k->createmode = create; + k->notifyactive = create ? 1 : 0; + if (create && isvirtual) + fsdb_set_file_attrs (aino); + trap_put_long(ctx, fh + 36, k->uniq); - if (create == 2) { - aino->elock = 1; - // clear comment if file already existed - if (aino->comment) { - xfree(aino->comment); - aino->comment = 0; - } - fsdb_set_file_attrs(aino); - } - else { - aino->shlock++; - } - de_recycle_aino(unit, aino); + if (create == 2) { + aino->elock = 1; + // clear comment if file already existed + if (aino->comment) { + xfree (aino->comment); + aino->comment = 0; + } + fsdb_set_file_attrs (aino); + } else { + aino->shlock++; + } + de_recycle_aino (unit, aino); - PUT_PCK_RES1(packet, DOS_TRUE); + PUT_PCK_RES1 (packet, DOS_TRUE); } static void action_fh_from_lock(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr fh = GET_PCK_ARG1(packet) << 2; - uaecptr lock = GET_PCK_ARG2(packet) << 2; - a_inode *aino; - Key *k; - struct fs_filehandle *fd; - mode_t openmode; - int mode; + uaecptr fh = GET_PCK_ARG1 (packet) << 2; + uaecptr lock = GET_PCK_ARG2 (packet) << 2; + a_inode *aino; + Key *k; + struct fs_filehandle *fd; + mode_t openmode; + int mode; TRACE((_T("ACTION_FH_FROM_LOCK(0x%x,0x%x)\n"), fh, lock)); - DUMPLOCK(ctx, unit, lock); + DUMPLOCK(ctx, unit,lock); - if (!lock) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, 0); - return; - } + if (!lock) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, 0); + return; + } aino = aino_from_lock(ctx, unit, lock); - if (aino == 0) - aino = &unit->rootnode; + if (aino == 0) + aino = &unit->rootnode; - mode = aino->amigaos_mode; /* Use same mode for opened filehandle as existing Lock() */ + mode = aino->amigaos_mode; /* Use same mode for opened filehandle as existing Lock() */ - prepare_for_open(aino->nname); + 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 + 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. */ + /* the files on CD really can have the write-bit set. */ if (is_writeprotected(unit)) - openmode = O_RDONLY; + openmode = O_RDONLY; - fd = fs_openfile(unit, aino, openmode | O_BINARY); + fd = fs_openfile (unit, aino, openmode | O_BINARY); - if (fd == NULL) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, dos_errno()); - return; - } - k = new_key(unit); - k->fd = fd; - k->aino = aino; + if (fd == NULL) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, dos_errno()); + return; + } + k = new_key (unit); + k->fd = fd; + k->aino = aino; trap_put_long(ctx, fh + 36, k->uniq); - /* I don't think I need to play with shlock count here, because I'm - opening from an existing lock ??? */ + /* 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 */ - PUT_PCK_RES1(packet, DOS_TRUE); - /* PUT_PCK_RES2 (packet, k->uniq); - this shouldn't be necessary, try without it */ + de_recycle_aino (unit, aino); + free_lock (ctx, 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) @@ -4415,135 +4353,130 @@ static void action_find_input(TrapContext *ctx, Unit *unit, dpacket *packet) static void action_find_output(TrapContext *ctx, Unit *unit, dpacket *packet) { if (is_writeprotected(unit)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DISK_WRITE_PROTECTED); - return; - } + 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); } static void action_find_write(TrapContext *ctx, Unit *unit, dpacket *packet) { if (is_writeprotected(unit)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DISK_WRITE_PROTECTED); - return; - } + 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); } /* change file/dir's parent dir modification time */ -static void updatedirtime(a_inode *a1, int now) +static void updatedirtime (a_inode *a1, int now) { struct mystat statbuf; - if (!a1->parent) - return; - if (!now) { - if (!my_stat(a1->nname, &statbuf)) - return; - my_utime(a1->parent->nname, &statbuf.mtime); - } - else { - my_utime(a1->parent->nname, NULL); - } + if (!a1->parent) + return; + if (!now) { + if (!my_stat (a1->nname, &statbuf)) + return; + my_utime (a1->parent->nname, &statbuf.mtime); + } else { + my_utime (a1->parent->nname, NULL); + } } static void action_end(TrapContext *ctx, Unit *unit, dpacket *packet) { - Key *k; - TRACE((_T("ACTION_END(0x%x)\n"), GET_PCK_ARG1(packet))); + Key *k; + TRACE((_T("ACTION_END(0x%x)\n"), GET_PCK_ARG1 (packet))); - k = lookup_key(unit, GET_PCK_ARG1(packet)); - if (k != 0) { - if (k->notifyactive) { + k = lookup_key (unit, GET_PCK_ARG1 (packet)); + if (k != 0) { + if (k->notifyactive) { notify_check(ctx, unit, k->aino); - updatedirtime(k->aino, 1); - } - if (k->aino->elock) - k->aino->elock = 0; - else - k->aino->shlock--; - recycle_aino(unit, k->aino); - free_key(unit, k); - } - PUT_PCK_RES1(packet, DOS_TRUE); - PUT_PCK_RES2(packet, 0); + updatedirtime (k->aino, 1); + } + if (k->aino->elock) + k->aino->elock = 0; + else + k->aino->shlock--; + recycle_aino (unit, k->aino); + free_key (unit, k); + } + PUT_PCK_RES1 (packet, DOS_TRUE); + PUT_PCK_RES2 (packet, 0); } static void action_read(TrapContext *ctx, 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); + 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 = 0; - + if (k == 0) { - PUT_PCK_RES1(packet, DOS_FALSE); + PUT_PCK_RES1 (packet, DOS_FALSE); /* PUT_PCK_RES2 (packet, EINVAL); */ return; } TRACE((_T("ACTION_READ(%s,0x%x,%d)\n"), k->aino->nname, addr, size)); - gui_flicker_led(UNIT_LED(unit), unit->unit, 1); + 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) { + 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); + PUT_PCK_RES1 (packet, actual); size = 0; - } - else { + } else { /* check if filesize < size */ uae_s64 filesize, cur; - + filesize = key_filesize(k); cur = k->file_pos; if (size > filesize - cur) size = filesize - cur; if (size == 0) { - PUT_PCK_RES1(packet, 0); - PUT_PCK_RES2(packet, 0); - } - else if (!trap_valid_address(ctx, addr, size)) { + PUT_PCK_RES1 (packet, 0); + PUT_PCK_RES2 (packet, 0); + } else if (!trap_valid_address(ctx, addr, size)) { /* it really crosses memory boundary */ - uae_u8 *buf; + uae_u8 *buf; - /* ugh this is inefficient but easy */ + /* ugh this is inefficient but easy */ if (key_seek(k, k->file_pos, SEEK_SET) < 0) { - PUT_PCK_RES1(packet, 0); - PUT_PCK_RES2(packet, dos_errno()); - return; - } + PUT_PCK_RES1 (packet, 0); + PUT_PCK_RES2 (packet, dos_errno ()); + return; + } - buf = xmalloc(uae_u8, size); - if (!buf) { - PUT_PCK_RES1(packet, -1); - PUT_PCK_RES2(packet, ERROR_NO_FREE_STORE); - return; - } - - actual = fs_read(k->fd, buf, size); + buf = xmalloc (uae_u8, size); + if (!buf) { + PUT_PCK_RES1 (packet, -1); + 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 { - PUT_PCK_RES1(packet, actual); + PUT_PCK_RES1 (packet, 0); + PUT_PCK_RES2 (packet, dos_errno()); + } else { + PUT_PCK_RES1 (packet, actual); trap_put_bytes(ctx, buf, addr, actual); - k->file_pos += actual; - } - xfree(buf); + k->file_pos += actual; + } + xfree (buf); size = 0; } } @@ -4551,25 +4484,23 @@ static void action_read(TrapContext *ctx, Unit *unit, dpacket *packet) if (size) { if (key_seek(k, k->file_pos, SEEK_SET) < 0) { - PUT_PCK_RES1(packet, 0); - PUT_PCK_RES2(packet, dos_errno()); + 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); + uae_u8 *realpt = get_real_address (addr); + actual = fs_read (k->fd, realpt, size); if (actual == 0) { - PUT_PCK_RES1(packet, 0); - PUT_PCK_RES2(packet, 0); - } - else if (actual < 0) { - PUT_PCK_RES1(packet, 0); - PUT_PCK_RES2(packet, dos_errno()); - } - else { - PUT_PCK_RES1(packet, actual); + PUT_PCK_RES1 (packet, 0); + PUT_PCK_RES2 (packet, 0); + } else if (actual < 0) { + PUT_PCK_RES1 (packet, 0); + PUT_PCK_RES2 (packet, dos_errno ()); + } else { + PUT_PCK_RES1 (packet, actual); k->file_pos += actual; } } @@ -4579,839 +4510,818 @@ static void action_read(TrapContext *ctx, Unit *unit, dpacket *packet) static void action_write(TrapContext *ctx, 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); + 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; - + if (k == 0) { - PUT_PCK_RES1(packet, DOS_FALSE); + PUT_PCK_RES1 (packet, DOS_FALSE); /* PUT_PCK_RES2 (packet, EINVAL); */ 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%x,%d)\n"), k->aino->nname, addr, size)); - + if (is_writeprotected(unit) || k->aino->vfso) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DISK_WRITE_PROTECTED); + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); return; } + + if (size == 0) { - if (size == 0) { + actual = 0; + PUT_PCK_RES1 (packet, 0); + PUT_PCK_RES2 (packet, 0); - actual = 0; - PUT_PCK_RES1(packet, 0); - PUT_PCK_RES2(packet, 0); - - } - else if (trap_valid_address(ctx, addr, size)) { + } else if (trap_valid_address(ctx, addr, size)) { if (key_seek(k, k->file_pos, SEEK_SET) < 0) { - PUT_PCK_RES1(packet, 0); - PUT_PCK_RES2(packet, dos_errno()); + 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); + uae_u8 *realpt = get_real_address (addr); + actual = fs_write (k->fd, realpt, size); - } - else { - /* ugh this is inefficient but easy */ + } else { + /* ugh this is inefficient but easy */ if (key_seek(k, k->file_pos, SEEK_SET) < 0) { - PUT_PCK_RES1(packet, 0); - PUT_PCK_RES2(packet, dos_errno()); - return; - } - - buf = xmalloc(uae_u8, size); - if (!buf) { - PUT_PCK_RES1(packet, -1); - PUT_PCK_RES2(packet, ERROR_NO_FREE_STORE); + PUT_PCK_RES1 (packet, 0); + PUT_PCK_RES2 (packet, dos_errno ()); return; } + buf = xmalloc (uae_u8, size); + if (!buf) { + PUT_PCK_RES1 (packet, -1); + PUT_PCK_RES2 (packet, ERROR_NO_FREE_STORE); + return; + } + trap_get_bytes(ctx, buf, addr, size); - - actual = fs_write(k->fd, buf, size); - xfree(buf); - } + + actual = fs_write(k->fd, buf, size); + xfree (buf); + } TRACE((_T("=%d\n"), actual)); - PUT_PCK_RES1(packet, actual); + PUT_PCK_RES1 (packet, actual); if (actual != size) - PUT_PCK_RES2(packet, dos_errno()); + PUT_PCK_RES2 (packet, dos_errno ()); if ((uae_s32)actual != -1) k->file_pos += actual; - - k->notifyactive = 1; + + k->notifyactive = 1; } static void action_seek(TrapContext *ctx, 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); - uae_s64 res; - uae_s64 cur; - int whence = SEEK_CUR; + 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); + uae_s64 res; + uae_s64 cur; + int whence = SEEK_CUR; uae_s64 temppos, filesize; - if (k == 0) { - PUT_PCK_RES1(packet, -1); - PUT_PCK_RES2(packet, ERROR_INVALID_LOCK); - return; - } + if (k == 0) { + PUT_PCK_RES1 (packet, -1); + PUT_PCK_RES2 (packet, ERROR_INVALID_LOCK); + return; + } - if (mode > 0) - whence = SEEK_END; - if (mode < 0) - whence = SEEK_SET; + if (mode > 0) + whence = SEEK_END; + if (mode < 0) + whence = SEEK_SET; cur = k->file_pos; TRACE((_T("ACTION_SEEK(%s,%d,%d)=%lld\n"), k->aino->nname, pos, mode, cur)); - gui_flicker_led(UNIT_LED(unit), unit->unit, 1); + gui_flicker_led (UNIT_LED(unit), unit->unit, 1); filesize = key_filesize(k); - if (whence == SEEK_CUR) - temppos = cur + pos; - if (whence == SEEK_SET) - temppos = pos; - if (whence == SEEK_END) - temppos = filesize + pos; + if (whence == SEEK_CUR) + temppos = cur + pos; + if (whence == SEEK_SET) + temppos = pos; + if (whence == SEEK_END) + temppos = filesize + pos; if (filesize < temppos || temppos < 0) { - PUT_PCK_RES1(packet, -1); - PUT_PCK_RES2(packet, ERROR_SEEK_ERROR); - return; + PUT_PCK_RES1 (packet, -1); + PUT_PCK_RES2 (packet, ERROR_SEEK_ERROR); + return; } res = key_seek(k, pos, whence); - if (-1 == res || cur > MAXFILESIZE32) { - PUT_PCK_RES1(packet, -1); - PUT_PCK_RES2(packet, ERROR_SEEK_ERROR); + if (-1 == res || cur > MAXFILESIZE32) { + PUT_PCK_RES1 (packet, -1); + PUT_PCK_RES2 (packet, ERROR_SEEK_ERROR); key_seek(k, cur, SEEK_SET); - } - else { - PUT_PCK_RES1(packet, cur); + } else { + PUT_PCK_RES1 (packet, cur); k->file_pos = key_seek(k, 0, SEEK_CUR); - } + } } static void action_set_protect(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr lock = GET_PCK_ARG2(packet) << 2; - uaecptr name = GET_PCK_ARG3(packet) << 2; - uae_u32 mask = GET_PCK_ARG4(packet); - a_inode *a; - int err; + uaecptr lock = GET_PCK_ARG2 (packet) << 2; + uaecptr name = GET_PCK_ARG3 (packet) << 2; + uae_u32 mask = GET_PCK_ARG4 (packet); + a_inode *a; + int err; TRACE((_T("ACTION_SET_PROTECT(0x%x,\"%s\",0x%x)\n"), lock, bstr(ctx, unit, name), mask)); if (is_writeprotected(unit)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DISK_WRITE_PROTECTED); - return; - } + 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); - if (err != 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err); - return; - } + if (err != 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, err); + return; + } - a->amigaos_mode = mask; - if (!fsdb_cando(unit)) - a->amigaos_mode = fsdb_mode_supported(a); - err = fsdb_set_file_attrs(a); - if (err != 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err); - } - else { - PUT_PCK_RES1(packet, DOS_TRUE); - } + a->amigaos_mode = mask; + if (!fsdb_cando (unit)) + a->amigaos_mode = fsdb_mode_supported (a); + err = fsdb_set_file_attrs (a); + if (err != 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, err); + } else { + PUT_PCK_RES1 (packet, DOS_TRUE); + } notify_check(ctx, unit, a); - gui_flicker_led(UNIT_LED(unit), unit->unit, 2); + gui_flicker_led (UNIT_LED(unit), unit->unit, 2); } static void action_set_comment(TrapContext *ctx, Unit * unit, dpacket *packet) { - uaecptr lock = GET_PCK_ARG2(packet) << 2; - uaecptr name = GET_PCK_ARG3(packet) << 2; - uaecptr comment = GET_PCK_ARG4(packet) << 2; - TCHAR *commented = NULL; - a_inode *a; - int err; + uaecptr lock = GET_PCK_ARG2 (packet) << 2; + uaecptr name = GET_PCK_ARG3 (packet) << 2; + uaecptr comment = GET_PCK_ARG4 (packet) << 2; + TCHAR *commented = NULL; + a_inode *a; + int err; if (is_writeprotected(unit)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DISK_WRITE_PROTECTED); - return; - } + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); + return; + } - if (fsdb_cando(unit)) { + if (fsdb_cando (unit)) { commented = bstr(ctx, unit, comment); - if (_tcslen(commented) > 80) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_COMMENT_TOO_BIG); - return; - } - if (_tcslen(commented) > 0) { - TCHAR *p = commented; - commented = xmalloc(TCHAR, 81); - _tcsncpy(commented, p, 80); - commented[80] = 0; - } - else { - commented = NULL; - } - } - TRACE((_T("ACTION_SET_COMMENT(0x%x,\"%s\")\n"), lock, commented)); + if (_tcslen (commented) > 80) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_COMMENT_TOO_BIG); + return; + } + if (_tcslen (commented) > 0) { + TCHAR *p = commented; + commented = xmalloc (TCHAR, 81); + _tcsncpy (commented, p, 80); + commented[80] = 0; + } else { + commented = NULL; + } + } + TRACE ((_T("ACTION_SET_COMMENT(0x%x,\"%s\")\n"), lock, commented)); a = find_aino(ctx, unit, lock, bstr(ctx, unit, name), &err); - if (err != 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err); + if (err != 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, err); - maybe_free_and_out: - if (commented) - xfree(commented); - return; - } + maybe_free_and_out: + if (commented) + xfree (commented); + return; + } - PUT_PCK_RES1(packet, DOS_TRUE); - PUT_PCK_RES2(packet, 0); - if (a->comment == 0 && commented == 0) - goto maybe_free_and_out; - if (a->comment != 0 && commented != 0 && _tcscmp(a->comment, commented) == 0) - goto maybe_free_and_out; - if (a->comment) - xfree(a->comment); - a->comment = commented; - fsdb_set_file_attrs(a); + PUT_PCK_RES1 (packet, DOS_TRUE); + PUT_PCK_RES2 (packet, 0); + if (a->comment == 0 && commented == 0) + goto maybe_free_and_out; + if (a->comment != 0 && commented != 0 && _tcscmp (a->comment, commented) == 0) + goto maybe_free_and_out; + if (a->comment) + 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); + gui_flicker_led (UNIT_LED(unit), unit->unit, 2); } static void action_same_lock(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr lock1 = GET_PCK_ARG1(packet) << 2; - uaecptr lock2 = GET_PCK_ARG2(packet) << 2; + uaecptr lock1 = GET_PCK_ARG1 (packet) << 2; + uaecptr lock2 = GET_PCK_ARG2 (packet) << 2; TRACE((_T("ACTION_SAME_LOCK(0x%x,0x%x)\n"), lock1, lock2)); - DUMPLOCK(ctx, unit, lock1); DUMPLOCK(ctx, unit, lock2); + DUMPLOCK(ctx, unit, lock1); DUMPLOCK(ctx, 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); - } + 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); + } } static void action_change_mode(TrapContext *ctx, 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); - /* 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); - unsigned long uniq; - a_inode *a = NULL, *olda = NULL; - int err = 0; + /* will be CHANGE_FH or CHANGE_LOCK value */ + int 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); + unsigned long uniq; + a_inode *a = NULL, *olda = NULL; + int err = 0; TRACE((_T("ACTION_CHANGE_MODE(0x%x,%d,%d)\n"), object, type, mode)); - if (!object || (type != CHANGE_FH && type != CHANGE_LOCK)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_INVALID_LOCK); - return; - } + if (! object || (type != CHANGE_FH && type != CHANGE_LOCK)) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_INVALID_LOCK); + return; + } - if (type == CHANGE_LOCK) { + if (type == CHANGE_LOCK) { uniq = trap_get_long(ctx, object + 4); - } - else { - Key *k = lookup_key(unit, trap_get_long(ctx, object + 36)); - if (!k) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_NOT_AROUND); - return; - } - uniq = k->aino->uniq; - } - a = lookup_aino(unit, uniq); + } else { + Key *k = lookup_key (unit, trap_get_long(ctx, object + 36)); + if (!k) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND); + return; + } + uniq = k->aino->uniq; + } + a = lookup_aino (unit, uniq); - if (!a) { - err = ERROR_INVALID_LOCK; - } - else { - if (mode == -1) { - if (a->shlock > 1) { - err = ERROR_OBJECT_IN_USE; - } - else { - a->shlock = 0; - a->elock = 1; - } - } - else { /* Must be SHARED_LOCK == -2 */ - a->elock = 0; - a->shlock++; - } - } + if (! a) { + err = ERROR_INVALID_LOCK; + } else { + if (mode == -1) { + if (a->shlock > 1) { + err = ERROR_OBJECT_IN_USE; + } else { + a->shlock = 0; + a->elock = 1; + } + } else { /* Must be SHARED_LOCK == -2 */ + a->elock = 0; + a->shlock++; + } + } - if (err) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err); - return; - } - else { - de_recycle_aino(unit, a); - PUT_PCK_RES1(packet, DOS_TRUE); - } + if (err) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, err); + return; + } else { + de_recycle_aino (unit, a); + PUT_PCK_RES1 (packet, DOS_TRUE); + } } static void action_parent_common(TrapContext *ctx, Unit *unit, dpacket *packet, unsigned long uniq) { - a_inode *olda = lookup_aino(unit, uniq); - if (olda == 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_INVALID_LOCK); - return; - } + a_inode *olda = lookup_aino (unit, uniq); + if (olda == 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_INVALID_LOCK); + return; + } - if (olda->parent == 0) { - PUT_PCK_RES1(packet, 0); - PUT_PCK_RES2(packet, 0); - return; - } - if (olda->parent->elock) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_IN_USE); - return; - } - olda->parent->shlock++; - de_recycle_aino(unit, olda->parent); - PUT_PCK_RES1(packet, make_lock(ctx, unit, olda->parent->uniq, -2) >> 2); + if (olda->parent == 0) { + PUT_PCK_RES1 (packet, 0); + PUT_PCK_RES2 (packet, 0); + return; + } + if (olda->parent->elock) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_IN_USE); + return; + } + olda->parent->shlock++; + de_recycle_aino (unit, olda->parent); + PUT_PCK_RES1 (packet, make_lock (ctx, unit, olda->parent->uniq, -2) >> 2); } static void action_parent_fh(TrapContext *ctx, Unit *unit, dpacket *packet) { - Key *k = lookup_key(unit, GET_PCK_ARG1(packet)); - if (!k) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_NOT_AROUND); - return; - } - action_parent_common(ctx, unit, packet, k->aino->uniq); + Key *k = lookup_key (unit, GET_PCK_ARG1 (packet)); + if (!k) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND); + return; + } + action_parent_common (ctx, unit, packet, k->aino->uniq); } static void action_parent(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr lock = GET_PCK_ARG1(packet) << 2; + uaecptr lock = GET_PCK_ARG1 (packet) << 2; - TRACE((_T("ACTION_PARENT(0x%x)\n"), lock)); + TRACE((_T("ACTION_PARENT(0x%x)\n"),lock)); - if (!lock) { - PUT_PCK_RES1(packet, 0); - PUT_PCK_RES2(packet, 0); - } - else { + 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)); - } - TRACE((_T("=%x %d\n"), GET_PCK_RES1(packet), GET_PCK_RES2(packet))); + } + TRACE((_T("=%x %d\n"), GET_PCK_RES1 (packet), GET_PCK_RES2 (packet))); } static void action_create_dir(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr lock = GET_PCK_ARG1(packet) << 2; - uaecptr name = GET_PCK_ARG2(packet) << 2; - a_inode *aino; - int err; + uaecptr lock = GET_PCK_ARG1 (packet) << 2; + uaecptr name = GET_PCK_ARG2 (packet) << 2; + a_inode *aino; + int err; TRACE((_T("ACTION_CREATE_DIR(0x%x,\"%s\")\n"), lock, bstr(ctx, unit, name))); if (is_writeprotected(unit)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DISK_WRITE_PROTECTED); - return; - } + 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); - if (aino == 0 || (err != 0 && err != ERROR_OBJECT_NOT_AROUND)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err); - return; - } - if (err == 0) { - /* Object exists. */ - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_EXISTS); - return; - } - /* Object does not exist. aino points to containing directory. */ - aino = create_child_aino(unit, aino, my_strdup(bstr_cut(ctx, unit, name)), 1); - if (aino == 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DISK_IS_FULL); /* best we can do */ - return; - } + if (aino == 0 || (err != 0 && err != ERROR_OBJECT_NOT_AROUND)) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, err); + return; + } + if (err == 0) { + /* Object exists. */ + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_EXISTS); + return; + } + /* Object does not exist. aino points to containing directory. */ + aino = create_child_aino(unit, aino, my_strdup (bstr_cut(ctx, unit, name)), 1); + if (aino == 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_DISK_IS_FULL); /* best we can do */ + return; + } - if (my_mkdir(aino->nname) == -1) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, dos_errno()); - return; - } - aino->shlock = 1; - fsdb_set_file_attrs(aino); - de_recycle_aino(unit, aino); + if (my_mkdir (aino->nname) == -1) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, dos_errno()); + return; + } + aino->shlock = 1; + fsdb_set_file_attrs (aino); + de_recycle_aino (unit, aino); notify_check(ctx, unit, aino); - updatedirtime(aino, 0); + updatedirtime (aino, 0); PUT_PCK_RES1(packet, make_lock(ctx, unit, aino->uniq, -2) >> 2); - gui_flicker_led(UNIT_LED(unit), unit->unit, 2); + gui_flicker_led (UNIT_LED(unit), unit->unit, 2); } static void action_examine_fh(TrapContext *ctx, Unit *unit, dpacket *packet, bool largefilesize) { - Key *k; - a_inode *aino = 0; - uaecptr info = GET_PCK_ARG2(packet) << 2; + Key *k; + a_inode *aino = 0; + uaecptr info = GET_PCK_ARG2 (packet) << 2; TRACE((_T("ACTION_EXAMINE_FH(0x%x,0x%x,%d)\n"), - GET_PCK_ARG1(packet), GET_PCK_ARG2(packet), largefilesize)); + 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; + 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); } /* 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). */ + * 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) { - Key *k, *k1; - off_t offset = GET_PCK_ARG2(packet); - int mode = (uae_s32)GET_PCK_ARG3(packet); - int whence = SEEK_CUR; + Key *k, *k1; + off_t offset = GET_PCK_ARG2 (packet); + int mode = (uae_s32)GET_PCK_ARG3 (packet); + int whence = SEEK_CUR; - if (mode > 0) - whence = SEEK_END; - if (mode < 0) - whence = SEEK_SET; + if (mode > 0) + whence = SEEK_END; + if (mode < 0) + whence = SEEK_SET; - TRACE((_T("ACTION_SET_FILE_SIZE(0x%lx, %d, 0x%x)\n"), GET_PCK_ARG1(packet), offset, mode)); + 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); + 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); + 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) { - PUT_PCK_RES1(packet, DOS_TRUE); - PUT_PCK_RES2(packet, ERROR_BAD_NUMBER); /* ? */ - return; - } + PUT_PCK_RES1 (packet, DOS_TRUE); + PUT_PCK_RES2 (packet, ERROR_BAD_NUMBER); /* ? */ + return; + } - 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. */ - for (k1 = unit->keys; k1; k1 = k1->next) { - if (k != k1 && k->aino == k1->aino) { - if (k1->file_pos > offset) - offset = (off_t)k1->file_pos; - } - } + 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. */ + for (k1 = unit->keys; k1; k1 = k1->next) { + if (k != k1 && k->aino == k1->aino) { + if (k1->file_pos > offset) + offset = (off_t)k1->file_pos; + } + } - /* Write one then truncate: that should give the right size in all cases. */ - fs_lseek(k->fd, offset, whence); - offset = fs_lseek(k->fd, 0, SEEK_CUR); - fs_write(k->fd, /* whatever */(uae_u8*)&k1, 1); - if (k->file_pos > offset) - k->file_pos = offset; - fs_lseek(k->fd, (off_t)k->file_pos, SEEK_SET); + /* Write one then truncate: that should give the right size in all cases. */ + fs_lseek (k->fd, offset, whence); + offset = fs_lseek (k->fd, 0, SEEK_CUR); + fs_write (k->fd, /* whatever */(uae_u8*)&k1, 1); + if (k->file_pos > offset) + k->file_pos = offset; + fs_lseek (k->fd, (off_t)k->file_pos, SEEK_SET); - /* Brian: no bug here; the file _must_ be one byte too large after writing - * The write is supposed to guarantee that the file can't be smaller than - * the requested size, the truncate guarantees that it can't be larger. - * If we were to write one byte earlier we'd clobber file data. */ - if (my_truncate(k->aino->nname, offset) == -1) { - PUT_PCK_RES1(packet, DOS_TRUE); - PUT_PCK_RES2(packet, dos_errno()); - return; - } + /* Brian: no bug here; the file _must_ be one byte too large after writing + * The write is supposed to guarantee that the file can't be smaller than + * the requested size, the truncate guarantees that it can't be larger. + * If we were to write one byte earlier we'd clobber file data. */ + if (my_truncate (k->aino->nname, offset) == -1) { + PUT_PCK_RES1 (packet, DOS_TRUE); + PUT_PCK_RES2 (packet, dos_errno ()); + return; + } - PUT_PCK_RES1(packet, offset); - PUT_PCK_RES2(packet, 0); + PUT_PCK_RES1 (packet, offset); + PUT_PCK_RES2 (packet, 0); } static int relock_do(Unit *unit, a_inode *a1) { - Key *k1, *knext; - int wehavekeys = 0; + Key *k1, *knext; + int wehavekeys = 0; - for (k1 = unit->keys; k1; k1 = knext) { - knext = k1->next; - if (k1->aino == a1 && k1->fd) { - wehavekeys++; - fs_closefile(k1->fd); - write_log(_T("handle %p freed\n"), k1->fd); - } - } - return wehavekeys; + for (k1 = unit->keys; k1; k1 = knext) { + knext = k1->next; + if (k1->aino == a1 && k1->fd) { + wehavekeys++; + fs_closefile (k1->fd); + write_log (_T("handle %p freed\n"), k1->fd); + } + } + return wehavekeys; } static void relock_re(Unit *unit, a_inode *a1, a_inode *a2, int failed) { - Key *k1, *knext; + Key *k1, *knext; - for (k1 = unit->keys; k1; k1 = knext) { - knext = k1->next; - if (k1->aino == a1 && k1->fd) { - int mode = (k1->dosmode & A_FIBF_READ) == 0 ? O_WRONLY : (k1->dosmode & A_FIBF_WRITE) == 0 ? O_RDONLY : O_RDWR; - mode |= O_BINARY; - if (failed) { - /* rename still failed, restore fd */ - k1->fd = fs_openfile(unit, a1, mode); - write_log(_T("restoring old handle '%s' %d\n"), a1->nname, k1->dosmode); - } - else { - /* transfer fd to new name */ - if (a2) { - k1->aino = a2; - k1->fd = fs_openfile(unit, a2, mode); - write_log(_T("restoring new handle '%s' %d\n"), a2->nname, k1->dosmode); - } - else { - write_log(_T("no new handle, deleting old lock(s).\n")); - } - } - if (k1->fd == NULL) { - write_log(_T("relocking failed '%s' -> '%s'\n"), a1->nname, a2->nname); - free_key(unit, k1); - } - else { + for (k1 = unit->keys; k1; k1 = knext) { + knext = k1->next; + if (k1->aino == a1 && k1->fd) { + int mode = (k1->dosmode & A_FIBF_READ) == 0 ? O_WRONLY : (k1->dosmode & A_FIBF_WRITE) == 0 ? O_RDONLY : O_RDWR; + mode |= O_BINARY; + if (failed) { + /* rename still failed, restore fd */ + k1->fd = fs_openfile (unit, a1, mode); + write_log (_T("restoring old handle '%s' %d\n"), a1->nname, k1->dosmode); + } else { + /* transfer fd to new name */ + if (a2) { + k1->aino = a2; + k1->fd = fs_openfile (unit, a2, mode); + write_log (_T("restoring new handle '%s' %d\n"), a2->nname, k1->dosmode); + } else { + write_log (_T("no new handle, deleting old lock(s).\n")); + } + } + if (k1->fd == NULL) { + 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); - } - } - } + } + } + } } static void action_delete_object(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr lock = GET_PCK_ARG1(packet) << 2; - uaecptr name = GET_PCK_ARG2(packet) << 2; - a_inode *a; - int err; + uaecptr lock = GET_PCK_ARG1 (packet) << 2; + uaecptr name = GET_PCK_ARG2 (packet) << 2; + a_inode *a; + int err; TRACE((_T("ACTION_DELETE_OBJECT(0x%x,\"%s\")\n"), lock, bstr(ctx, unit, name))); if (is_writeprotected(unit)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DISK_WRITE_PROTECTED); - return; - } + 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); - if (err != 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err); - return; - } - if (a->amigaos_mode & A_FIBF_DELETE) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DELETE_PROTECTED); - return; - } - if (a->shlock > 0 || a->elock) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_IN_USE); - return; - } + if (err != 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, err); + return; + } + if (a->amigaos_mode & A_FIBF_DELETE) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_DELETE_PROTECTED); + return; + } + if (a->shlock > 0 || a->elock) { + PUT_PCK_RES1 (packet, DOS_FALSE); + 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; - } - } + 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); - updatedirtime(a, 1); - if (a->child != 0) { - write_log(_T("Serious error in action_delete_object.\n")); - a->deleted = 1; - } - else { - delete_aino(unit, a); - } - PUT_PCK_RES1(packet, DOS_TRUE); - gui_flicker_led(UNIT_LED(unit), unit->unit, 2); + updatedirtime (a, 1); + if (a->child != 0) { + write_log (_T("Serious error in action_delete_object.\n")); + a->deleted = 1; + } else { + delete_aino (unit, a); + } + PUT_PCK_RES1 (packet, DOS_TRUE); + gui_flicker_led (UNIT_LED(unit), unit->unit, 2); } static void action_set_date(TrapContext *ctx, 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; + 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; TRACE((_T("ACTION_SET_DATE(0x%x,\"%s\")\n"), lock, bstr(ctx, unit, name))); if (is_writeprotected(unit)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DISK_WRITE_PROTECTED); - return; - } + 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); if (err != 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err); + 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); + 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(); + if (!my_utime (a->nname, &tv)) + err = dos_errno (); } - if (err != 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err); + if (err != 0) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, err); return; - } - else { + } else { notify_check(ctx, unit, a); - PUT_PCK_RES1(packet, DOS_TRUE); - } - gui_flicker_led(UNIT_LED(unit), unit->unit, 2); + PUT_PCK_RES1 (packet, DOS_TRUE); + } + gui_flicker_led (UNIT_LED(unit), unit->unit, 2); } static void action_rename_object(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr lock1 = GET_PCK_ARG1(packet) << 2; - uaecptr name1 = GET_PCK_ARG2(packet) << 2; - uaecptr lock2 = GET_PCK_ARG3(packet) << 2; - uaecptr name2 = GET_PCK_ARG4(packet) << 2; - a_inode *a1, *a2; - int err1, err2; - Key *k1, *knext; - int wehavekeys = 0; + uaecptr lock1 = GET_PCK_ARG1 (packet) << 2; + uaecptr name1 = GET_PCK_ARG2 (packet) << 2; + uaecptr lock2 = GET_PCK_ARG3 (packet) << 2; + uaecptr name2 = GET_PCK_ARG4 (packet) << 2; + a_inode *a1, *a2; + int err1, err2; + Key *k1, *knext; + int wehavekeys = 0; TRACE((_T("ACTION_RENAME_OBJECT(0x%x,\"%s\","), lock1, bstr(ctx, unit, name1))); TRACE((_T("0x%x,\"%s\")\n"), lock2, bstr(ctx, unit, name2))); if (is_writeprotected(unit)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DISK_WRITE_PROTECTED); - return; - } + 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); - if (err1 != 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err1); - return; - } + 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; - if (k1->aino == a1 && k1->fd && k1->createmode == 2) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_IN_USE); - return; - } - } + /* rename always fails if file is open for writing */ + for (k1 = unit->keys; k1; k1 = knext) { + knext = k1->next; + if (k1->aino == a1 && k1->fd && k1->createmode == 2) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_IN_USE); + return; + } + } - /* See whether the other name already exists in the filesystem. */ + /* See whether the other name already exists in the filesystem. */ a2 = find_aino(ctx, unit, lock2, bstr(ctx, 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) { - /* Exact match -> do nothing. */ + if (a2 == a1) { + /* Renaming to the same name, but possibly different case. */ + if (_tcscmp (a1->aname, bstr_cut(ctx, unit, name2)) == 0) { + /* Exact match -> do nothing. */ notify_check(ctx, unit, a1); - updatedirtime(a1, 1); - PUT_PCK_RES1(packet, DOS_TRUE); - return; - } - a2 = a2->parent; - } - else if (a2 == 0 || err2 != ERROR_OBJECT_NOT_AROUND) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, err2 == 0 ? ERROR_OBJECT_EXISTS : err2); - return; - } + updatedirtime (a1, 1); + PUT_PCK_RES1 (packet, DOS_TRUE); + return; + } + a2 = a2->parent; + } else if (a2 == 0 || err2 != ERROR_OBJECT_NOT_AROUND) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, err2 == 0 ? ERROR_OBJECT_EXISTS : err2); + return; + } - a2 = create_child_aino(unit, a2, bstr_cut(ctx, 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; - } + a2 = create_child_aino (unit, a2, bstr_cut(ctx, 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); - a2->comment = a1->comment; - a1->comment = 0; - a2->amigaos_mode = a1->amigaos_mode; - a2->uniq = a1->uniq; - a2->elock = a1->elock; - a2->shlock = a1->shlock; - a2->has_dbentry = a1->has_dbentry; - a2->db_offset = a1->db_offset; - a2->dirty = 0; + a2->comment = a1->comment; + a1->comment = 0; + a2->amigaos_mode = a1->amigaos_mode; + a2->uniq = a1->uniq; + a2->elock = a1->elock; + a2->shlock = a1->shlock; + 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); - a2->dirty = 1; - if (a2->parent) - fsdb_dir_writeback(a2->parent); - updatedirtime(a2, 1); - fsdb_set_file_attrs(a2); - 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); + move_exkeys (unit, a1, a2); + move_aino_children (unit, a1, a2); + delete_aino (unit, a1); + a2->dirty = 1; + if (a2->parent) + fsdb_dir_writeback (a2->parent); + updatedirtime (a2, 1); + fsdb_set_file_attrs (a2); + 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); } static void action_current_volume(TrapContext *ctx, Unit *unit, dpacket *packet) { - if (filesys_isvolume(unit)) - PUT_PCK_RES1(packet, unit->volume >> 2); - else - PUT_PCK_RES1(packet, 0); + if (filesys_isvolume(unit)) + PUT_PCK_RES1 (packet, unit->volume >> 2); + else + PUT_PCK_RES1 (packet, 0); } static void action_rename_disk(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr name = GET_PCK_ARG1(packet) << 2; + uaecptr name = GET_PCK_ARG1 (packet) << 2; TRACE((_T("ACTION_RENAME_DISK(\"%s\")\n"), bstr(ctx, unit, name))); if (is_writeprotected(unit)) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_DISK_WRITE_PROTECTED); - return; - } + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_DISK_WRITE_PROTECTED); + return; + } - /* get volume name */ - xfree(unit->ui.volname); + /* get volume name */ + xfree (unit->ui.volname); unit->ui.volname = bstr1(ctx, name); - set_volume_name(unit, 0); + set_volume_name (unit, 0); - PUT_PCK_RES1(packet, DOS_TRUE); + PUT_PCK_RES1 (packet, DOS_TRUE); } static void action_is_filesystem(TrapContext *ctx, Unit *unit, dpacket *packet) { TRACE((_T("ACTION_IS_FILESYSTEM()\n"))); - PUT_PCK_RES1(packet, DOS_TRUE); + PUT_PCK_RES1 (packet, DOS_TRUE); } static void action_flush(TrapContext *ctx, Unit *unit, dpacket *packet) { TRACE((_T("ACTION_FLUSH()\n"))); - PUT_PCK_RES1(packet, DOS_TRUE); - flush_cache(unit, 0); + PUT_PCK_RES1 (packet, DOS_TRUE); + flush_cache(unit, 0); } static void action_more_cache(TrapContext *ctx, 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); + 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) { - PUT_PCK_RES1(packet, DOS_TRUE); - flush_cache(unit, 0); - unit->inhibited = GET_PCK_ARG1(packet) != 0; + 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) { TRACE((_T("ACTION_WRITE_PROTECT()\n"))); - PUT_PCK_RES1(packet, DOS_TRUE); - if (GET_PCK_ARG1(packet)) { - if (!unit->ui.locked) { - unit->ui.locked = true; - unit->lockkey = GET_PCK_ARG2(packet); - } - } - else { - if (unit->ui.locked) { - if (unit->lockkey == GET_PCK_ARG2(packet) || unit->lockkey == 0) { + PUT_PCK_RES1 (packet, DOS_TRUE); + if (GET_PCK_ARG1 (packet)) { + if (!unit->ui.locked) { + unit->ui.locked = true; + unit->lockkey = GET_PCK_ARG2 (packet); + } + } else { + if (unit->ui.locked) { + if (unit->lockkey == GET_PCK_ARG2 (packet) || unit->lockkey == 0) { unit->ui.locked = false; - } - else { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, 0); - } - } - } + } else { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, 0); + } + } + } } /* OS4 */ @@ -5446,37 +5356,37 @@ static void action_filesystem_attr(TrapContext *ctx, Unit *unit, dpacket *packet } uae_u32 retval = 0; bool doret = false; - switch (tag) + switch(tag) { - case 0x80002332: // FSA_MaxFileNameLengthR + case 0x80002332: // FSA_MaxFileNameLengthR retval = currprefs.filesys_max_name; doret = true; break; - case 0x80002334: // FSA_VersionNumberR + case 0x80002334: // FSA_VersionNumberR retval = (0 << 16) | (5 << 0); doret = true; break; - case 0x80002335: // FSA_DOSTypeR + case 0x80002335: // FSA_DOSTypeR retval = get_long(unit->volume + 32); doret = true; break; - case 0x80002336: // FSA_ActivityFlushTimeoutR - case 0x80002338: // FSA_InactivityFlushTimeoutR + case 0x80002336: // FSA_ActivityFlushTimeoutR + case 0x80002338: // FSA_InactivityFlushTimeoutR retval = 0; doret = true; break; - case 0x8000233a: // FSA_MaxRecycledEntriesR - case 0x8000233c: // FSA_HasRecycledEntriesR + case 0x8000233a: // FSA_MaxRecycledEntriesR + case 0x8000233c: // FSA_HasRecycledEntriesR retval = 0; doret = true; break; - case 0x8000233d: // FSA_VersionStringR + case 0x8000233d: // FSA_VersionStringR verbuffer = trap_get_long(ctx, tagp); break; - case 0x8000233e: // FSA_VersionStringR_BufSize + case 0x8000233e: // FSA_VersionStringR_BufSize versize = trap_get_long(ctx, tagp); break; - default: + 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); @@ -5484,7 +5394,7 @@ static void action_filesystem_attr(TrapContext *ctx, Unit *unit, dpacket *packet } if (doret) trap_put_long(ctx, trap_get_long(ctx, tagp), retval); - + } if (verbuffer && versize) { trap_put_string(ctx, UAEFS_VERSION, verbuffer, versize); @@ -5495,158 +5405,157 @@ static void action_filesystem_attr(TrapContext *ctx, Unit *unit, dpacket *packet static void action_change_file_position64(TrapContext *ctx, 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 whence = SEEK_CUR; - uae_s64 res, cur; + 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 whence = SEEK_CUR; + uae_s64 res, cur; - PUT_PCK64_RES0(packet, DP64_INIT); + PUT_PCK64_RES0 (packet, DP64_INIT); - if (k == 0) { - PUT_PCK64_RES1(packet, DOS_FALSE); - PUT_PCK64_RES2(packet, ERROR_INVALID_LOCK); - return; - } + if (k == 0) { + PUT_PCK64_RES1 (packet, DOS_FALSE); + PUT_PCK64_RES2 (packet, ERROR_INVALID_LOCK); + return; + } - if (mode > 0) - whence = SEEK_END; - if (mode < 0) - whence = SEEK_SET; + if (mode > 0) + whence = SEEK_END; + if (mode < 0) + whence = SEEK_SET; TRACE((_T("ACTION_CHANGE_FILE_POSITION64(%s,%lld,%d)\n"), k->aino->nname, pos, mode)); - gui_flicker_led(UNIT_LED(unit), unit->unit, 1); + gui_flicker_led (UNIT_LED(unit), unit->unit, 1); cur = k->file_pos; - { - uae_s64 temppos; + { + uae_s64 temppos; uae_s64 filesize = key_filesize(k); - if (whence == SEEK_CUR) - temppos = cur + pos; - if (whence == SEEK_SET) - temppos = pos; - if (whence == SEEK_END) - temppos = filesize + pos; - if (filesize < temppos) { - res = -1; - PUT_PCK64_RES1(packet, res); - PUT_PCK64_RES2(packet, ERROR_SEEK_ERROR); - return; - } - } + if (whence == SEEK_CUR) + temppos = cur + pos; + if (whence == SEEK_SET) + temppos = pos; + if (whence == SEEK_END) + temppos = filesize + pos; + if (filesize < temppos) { + res = -1; + PUT_PCK64_RES1 (packet, res); + PUT_PCK64_RES2 (packet, ERROR_SEEK_ERROR); + return; + } + } res = key_seek(k, pos, whence); - if (-1 == res) { - PUT_PCK64_RES1(packet, DOS_FALSE); - PUT_PCK64_RES2(packet, ERROR_SEEK_ERROR); - } - else { - PUT_PCK64_RES1(packet, TRUE); - PUT_PCK64_RES2(packet, 0); + if (-1 == res) { + PUT_PCK64_RES1 (packet, DOS_FALSE); + PUT_PCK64_RES2 (packet, ERROR_SEEK_ERROR); + } else { + PUT_PCK64_RES1 (packet, TRUE); + PUT_PCK64_RES2 (packet, 0); k->file_pos = key_seek(k, 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) { - Key *k = lookup_key(unit, GET_PCK64_ARG1(packet)); + Key *k = lookup_key (unit, GET_PCK64_ARG1 (packet)); - PUT_PCK64_RES0(packet, DP64_INIT); + PUT_PCK64_RES0 (packet, DP64_INIT); - if (k == 0) { - PUT_PCK64_RES1(packet, -1); - PUT_PCK64_RES2(packet, ERROR_INVALID_LOCK); - return; - } + if (k == 0) { + PUT_PCK64_RES1 (packet, -1); + 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); + PUT_PCK64_RES1 (packet, k->file_pos); + PUT_PCK64_RES2 (packet, 0); } static void action_change_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet) { - Key *k, *k1; - uae_s64 offset = GET_PCK64_ARG2(packet); - int mode = (uae_s32)GET_PCK64_ARG3(packet); - int whence = SEEK_CUR; + Key *k, *k1; + uae_s64 offset = GET_PCK64_ARG2 (packet); + int mode = (uae_s32)GET_PCK64_ARG3 (packet); + int whence = SEEK_CUR; - PUT_PCK64_RES0(packet, DP64_INIT); + PUT_PCK64_RES0 (packet, DP64_INIT); - if (mode > 0) - whence = SEEK_END; - if (mode < 0) - whence = SEEK_SET; + if (mode > 0) + whence = SEEK_END; + if (mode < 0) + whence = SEEK_SET; - TRACE((_T("ACTION_CHANGE_FILE_SIZE64(0x%x, %lld, 0x%x)\n"), GET_PCK64_ARG1(packet), offset, mode)); + TRACE((_T("ACTION_CHANGE_FILE_SIZE64(0x%x, %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); - PUT_PCK64_RES2(packet, ERROR_OBJECT_NOT_AROUND); - return; - } + k = lookup_key (unit, GET_PCK64_ARG1 (packet)); + if (k == 0) { + PUT_PCK64_RES1 (packet, DOS_FALSE); + PUT_PCK64_RES2 (packet, ERROR_OBJECT_NOT_AROUND); + return; + } - 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. */ - for (k1 = unit->keys; k1; k1 = k1->next) { - if (k != k1 && k->aino == k1->aino) { - if (k1->file_pos > offset) - offset = k1->file_pos; - } - } + 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. */ + for (k1 = unit->keys; k1; k1 = k1->next) { + if (k != k1 && k->aino == k1->aino) { + if (k1->file_pos > offset) + offset = k1->file_pos; + } + } - /* Write one then truncate: that should give the right size in all cases. */ - fs_lseek(k->fd, offset, whence); + /* 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); - fs_write(k->fd, /* whatever */(uae_u8*)&k1, 1); - if (k->file_pos > offset) - k->file_pos = offset; + 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); - if (my_truncate(k->aino->nname, offset) == -1) { - PUT_PCK64_RES1(packet, DOS_FALSE); - PUT_PCK64_RES2(packet, dos_errno()); - return; - } + if (my_truncate (k->aino->nname, offset) == -1) { + PUT_PCK64_RES1 (packet, DOS_FALSE); + PUT_PCK64_RES2 (packet, dos_errno ()); + return; + } - PUT_PCK64_RES1(packet, DOS_TRUE); - PUT_PCK64_RES2(packet, 0); + PUT_PCK64_RES1 (packet, DOS_TRUE); + PUT_PCK64_RES2 (packet, 0); } static void action_get_file_size64(TrapContext *ctx, Unit *unit, dpacket *packet) { - Key *k = lookup_key(unit, GET_PCK64_ARG1(packet)); + Key *k = lookup_key (unit, GET_PCK64_ARG1 (packet)); uae_s64 filesize; - PUT_PCK64_RES0(packet, DP64_INIT); + PUT_PCK64_RES0 (packet, DP64_INIT); - if (k == 0) { - PUT_PCK64_RES1(packet, -1); - PUT_PCK64_RES2(packet, ERROR_INVALID_LOCK); - return; - } + if (k == 0) { + PUT_PCK64_RES1 (packet, -1); + PUT_PCK64_RES2 (packet, ERROR_INVALID_LOCK); + return; + } TRACE((_T("ACTION_GET_FILE_SIZE64(%s)\n"), k->aino->nname)); filesize = key_filesize(k); 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); - return; - } - PUT_PCK64_RES1(packet, -1); - PUT_PCK64_RES2(packet, ERROR_SEEK_ERROR); + PUT_PCK64_RES1 (packet, filesize); + PUT_PCK64_RES2 (packet, 0); + return; + } + PUT_PCK64_RES1 (packet, -1); + PUT_PCK64_RES2 (packet, ERROR_SEEK_ERROR); } /* MOS */ static void action_examine_object64(TrapContext *ctx, Unit *unit, dpacket *packet) { - uaecptr lock = GET_PCK_ARG1(packet) << 2; - uaecptr info = GET_PCK_ARG2(packet) << 2; + uaecptr lock = GET_PCK_ARG1 (packet) << 2; + uaecptr info = GET_PCK_ARG2 (packet) << 2; a_inode *aino = 0; TRACE((_T("ACTION_EXAMINE_OBJECT(0x%x,0x%x)\n"), lock, info)); @@ -5663,8 +5572,8 @@ static void action_examine_object64(TrapContext *ctx, Unit *unit, dpacket *packe static void action_set_file_size64(TrapContext *ctx, 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(ctx, GET_PCK_ARG2 (packet)); + int mode = (uae_s32)GET_PCK_ARG3 (packet); int whence = SEEK_CUR; if (mode > 0) @@ -5672,16 +5581,16 @@ 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%x, %lld, 0x%x)\n"), GET_PCK_ARG1(packet), offset, mode)); + TRACE((_T("ACTION_SET_FILE_SIZE64(0x%x, %lld, 0x%x)\n"), GET_PCK_ARG1 (packet), offset, mode)); - k = lookup_key(unit, GET_PCK_ARG1(packet)); + k = lookup_key (unit, GET_PCK_ARG1 (packet)); if (k == 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_NOT_AROUND); + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_NOT_AROUND); 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. */ @@ -5693,20 +5602,20 @@ 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); + fs_lseek (k->fd, offset, whence); offset = key_seek(k, offset, whence); - fs_write(k->fd, /* whatever */(uae_u8*)&k1, 1); + 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); - if (my_truncate(k->aino->nname, offset) == -1) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, dos_errno()); + if (my_truncate (k->aino->nname, offset) == -1) { + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, dos_errno ()); return; } - PUT_PCK_RES1(packet, DOS_TRUE); + PUT_PCK_RES1 (packet, DOS_TRUE); set_quadp(ctx, GET_PCK_ARG4(packet), offset); } @@ -5719,8 +5628,8 @@ static void action_seek64(TrapContext *ctx, Unit *unit, dpacket *packet) uae_s64 res, cur; if (k == 0) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_INVALID_LOCK); + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_INVALID_LOCK); return; } @@ -5730,7 +5639,7 @@ static void action_seek64(TrapContext *ctx, Unit *unit, dpacket *packet) whence = SEEK_SET; TRACE((_T("ACTION_SEEK64(%s,%lld,%d)\n"), k->aino->nname, pos, mode)); - gui_flicker_led(UNIT_LED(unit), unit->unit, 1); + gui_flicker_led (UNIT_LED(unit), unit->unit, 1); cur = k->file_pos; { @@ -5745,19 +5654,18 @@ static void action_seek64(TrapContext *ctx, Unit *unit, dpacket *packet) temppos = filesize + pos; if (filesize < temppos) { res = -1; - PUT_PCK_RES1(packet, res); - PUT_PCK_RES2(packet, ERROR_SEEK_ERROR); + PUT_PCK_RES1 (packet, res); + PUT_PCK_RES2 (packet, ERROR_SEEK_ERROR); return; } } res = key_seek(k, pos, whence); if (-1 == res) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_SEEK_ERROR); - } - else { - PUT_PCK_RES1(packet, TRUE); + 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); } @@ -5774,34 +5682,33 @@ static int action_lock_record64(TrapContext *ctx, Unit *unit, dpacket *packet, u bool exclusive = mode == REC_EXCLUSIVE || mode == REC_EXCLUSIVE_IMMED; - write_log(_T("action_lock_record64('%s',%lld,%lld,%d,%d)\n"), k ? k->aino->nname : _T("null"), pos, len, mode, timeout); + write_log (_T("action_lock_record64('%s',%lld,%lld,%d,%d)\n"), k ? k->aino->nname : _T("null"), pos, len, mode, timeout); if (!k || mode > REC_SHARED_IMMED) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_WRONG_TYPE); + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_WRONG_TYPE); return 1; } if (mode == REC_EXCLUSIVE_IMMED || mode == REC_SHARED_IMMED) timeout = 0; - if (record_hit(unit, k, pos, len, mode)) { + if (record_hit (unit, k, pos, len, mode)) { if (timeout && msg) { // queue it and do not reply - struct lockrecord *lr = new_record(packet, pos, len, mode, timeout, msg); + struct lockrecord *lr = new_record (packet, pos, len, mode, timeout, msg); if (unit->waitingrecords) { lr->next = unit->waitingrecords; unit->waitingrecords = lr; - } - else { + } else { unit->waitingrecords = lr; } - write_log(_T("-> collision, timeout queued\n")); + write_log (_T("-> collision, timeout queued\n")); return -1; } - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_LOCK_COLLISION); - write_log(_T("-> ERROR_LOCK_COLLISION\n")); + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_LOCK_COLLISION); + write_log (_T("-> ERROR_LOCK_COLLISION\n")); return 1; } @@ -5809,12 +5716,11 @@ static int action_lock_record64(TrapContext *ctx, Unit *unit, dpacket *packet, u if (k->record) { lr->next = k->record; k->record = lr; - } - else { + } else { k->record = lr; } - PUT_PCK_RES1(packet, DOS_TRUE); - write_log(_T("-> OK\n")); + PUT_PCK_RES1 (packet, DOS_TRUE); + write_log (_T("-> OK\n")); return 1; } @@ -5822,13 +5728,13 @@ static void action_free_record64(TrapContext *ctx, 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 len = get_quadp(ctx, GET_PCK_ARG3 (packet)); - write_log(_T("action_free_record('%s',%lld,%lld)\n"), k ? k->aino->nname : _T("null"), pos, len); + write_log (_T("action_free_record('%s',%lld,%lld)\n"), k ? k->aino->nname : _T("null"), pos, len); if (!k) { - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_OBJECT_WRONG_TYPE); + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_OBJECT_WRONG_TYPE); return; } @@ -5839,246 +5745,246 @@ static void action_free_record64(TrapContext *ctx, Unit *unit, dpacket *packet) prev->next = lr->next; else k->record = lr->next; - xfree(lr); - write_log(_T("->OK\n")); + xfree (lr); + write_log (_T("->OK\n")); record_check_waiting(ctx, unit); - PUT_PCK_RES1(packet, DOS_TRUE); + PUT_PCK_RES1 (packet, DOS_TRUE); return; } } - write_log(_T("-> ERROR_RECORD_NOT_LOCKED\n")); - PUT_PCK_RES1(packet, DOS_FALSE); - PUT_PCK_RES2(packet, ERROR_RECORD_NOT_LOCKED); + write_log (_T("-> ERROR_RECORD_NOT_LOCKED\n")); + PUT_PCK_RES1 (packet, DOS_FALSE); + PUT_PCK_RES2 (packet, ERROR_RECORD_NOT_LOCKED); } /* We don't want multiple interrupts to be active at the same time. I don't -* know whether AmigaOS takes care of that, but this does. */ + * 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 *ctx) { - UnitInfo *uip = mountinfo.ui; - uaecptr port; + UnitInfo *uip = mountinfo.ui; + uaecptr port; int n = trap_get_dreg(ctx, 0); - static int unit_no; + static int unit_no; if (n == 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 - * code. - * Note that this is called from the main loop, unlike the other cases - * in this switch statement which are called from the interrupt handler. - */ + /* 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 + * code. + * Note that this is called from the main loop, unlike the other cases + * in this switch statement which are called from the interrupt handler. + */ #ifdef UAE_FILESYS_THREADS - { + { Unit *unit = find_unit(trap_get_areg(ctx, 5)); uaecptr msg = trap_get_areg(ctx, 4); - unit->cmds_complete = unit->cmds_acked; - while (comm_pipe_has_data(unit->ui.back_pipe)) { + unit->cmds_complete = unit->cmds_acked; + while (comm_pipe_has_data (unit->ui.back_pipe)) { uaecptr locks, lockend, lockv; - 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) { - write_log(_T("filesystem lock queue corrupted!\n")); - break; - } - lockend = lockv; - cnt++; - } + 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) { + write_log (_T("filesystem lock queue corrupted!\n")); + break; + } + lockend = lockv; + cnt++; + } TRACE3((_T("message_lock: %d %x %x %x\n"), cnt, locks, lockend, trap_get_areg(ctx, 3))); trap_put_long(ctx, lockend, trap_get_long(ctx, trap_get_areg(ctx, 3))); trap_put_long(ctx, trap_get_areg(ctx, 3), locks); - } - } + } + } #else - write_log(_T("exter_int_helper should not be called with arg 1!\n")); + 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. */ + 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; - } + return 0; + } + filesys_in_interrupt++; + unit_no = 0; + } if (n >= 10) { - /* Find work that needs to be done: - * return d0 = 0: none - * d0 = 1: PutMsg(), port in a0, message in a1 - * d0 = 2: Signal(), task in a1, signal set in d1 - * d0 = 3: ReplyMsg(), message in a1 - * d0 = 4: Cause(), interrupt in a1 - * d0 = 5: Send FileNofication message, port in a0, notifystruct in a1 - */ + /* Find work that needs to be done: + * return d0 = 0: none + * d0 = 1: PutMsg(), port in a0, message in a1 + * d0 = 2: Signal(), task in a1, signal set in d1 + * d0 = 3: ReplyMsg(), message in a1 + * d0 = 4: Cause(), interrupt in a1 + * d0 = 5: Send FileNofication message, port in a0, notifystruct in a1 + */ #ifdef SUPPORT_THREADS - /* First, check signals/messages */ - while (comm_pipe_has_data(&native2amiga_pending)) { - int cmd = read_comm_pipe_int_blocking(&native2amiga_pending); - switch (cmd) { - case 0: /* Signal() */ + /* First, check signals/messages */ + while (comm_pipe_has_data (&native2amiga_pending)) { + 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)); - return 2; + return 2; - case 1: /* PutMsg() */ + 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)); - return 1; + return 1; - case 2: /* ReplyMsg() */ + case 2: /* ReplyMsg() */ trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending)); - return 3; + return 3; - case 3: /* Cause() */ + case 3: /* Cause() */ trap_set_areg(ctx, 1, read_comm_pipe_u32_blocking(&native2amiga_pending)); - return 4; + return 4; - case 4: /* NotifyHack() */ + 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)); - return 5; + return 5; - default: - write_log(_T("exter_int_helper: unknown native action %X\n"), cmd); - break; - } - } + default: + write_log (_T("exter_int_helper: unknown native action %X\n"), cmd); + break; + } + } #endif - /* Find some unit that needs a message sent, and return its port, - * or zero if all are done. - * Take care not to dereference self for units that didn't have their - * startup packet sent. */ - for (;;) { - if (unit_no >= MAX_FILESYSTEM_UNITS) + /* Find some unit that needs a message sent, and return its port, + * or zero if all are done. + * Take care not to dereference self for units that didn't have their + * startup packet sent. */ + for (;;) { + if (unit_no >= MAX_FILESYSTEM_UNITS) goto end; if (uip[unit_no].open > 0 && uip[unit_no].self != 0 - && uip[unit_no].self->cmds_acked == uip[unit_no].self->cmds_complete - && uip[unit_no].self->cmds_acked != uip[unit_no].self->cmds_sent) - break; - unit_no++; - } - uip[unit_no].self->cmds_acked = uip[unit_no].self->cmds_sent; - port = uip[unit_no].self->port; - if (port) { + && uip[unit_no].self->cmds_acked == uip[unit_no].self->cmds_complete + && uip[unit_no].self->cmds_acked != uip[unit_no].self->cmds_sent) + break; + unit_no++; + } + 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); - unit_no++; - return 1; - } + unit_no++; + return 1; + } - end: - /* Exit the interrupt, and release the single-threading lock. */ - filesys_in_interrupt--; - uae_sem_post(&singlethread_int_sem); - } - return 0; +end: + /* Exit the interrupt, and release the single-threading lock. */ + filesys_in_interrupt--; + uae_sem_post (&singlethread_int_sem); + } + return 0; } static int handle_packet(TrapContext *ctx, Unit *unit, dpacket *pck, uae_u32 msg, int isvolume) { - uae_s32 type = GET_PCK_TYPE(pck); - PUT_PCK_RES2(pck, 0); + uae_s32 type = GET_PCK_TYPE (pck); + PUT_PCK_RES2 (pck, 0); TRACE((_T("unit=%p packet=%d\n"), unit, type)); if (unit->inhibited && isvolume - && type != ACTION_INHIBIT && type != ACTION_MORE_CACHE - && type != ACTION_DISK_INFO) { - PUT_PCK_RES1(pck, DOS_FALSE); - PUT_PCK_RES2(pck, ERROR_NOT_A_DOS_DISK); - return 1; - } - if (type != ACTION_INHIBIT && type != ACTION_CURRENT_VOLUME - && type != ACTION_IS_FILESYSTEM && type != ACTION_MORE_CACHE - && type != ACTION_WRITE_PROTECT && type != ACTION_DISK_INFO + && type != ACTION_INHIBIT && type != ACTION_MORE_CACHE + && type != ACTION_DISK_INFO) { + PUT_PCK_RES1 (pck, DOS_FALSE); + PUT_PCK_RES2 (pck, ERROR_NOT_A_DOS_DISK); + return 1; + } + 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) { - 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; - - /* 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; + 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; + + /* 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; /* 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_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; /* 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(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; - /* unsupported packets */ - case ACTION_MAKE_LINK: - case ACTION_READ_LINK: - case ACTION_FORMAT: - write_log(_T("FILESYS: UNSUPPORTED PACKET %x\n"), type); - return 0; - default: - write_log(_T("FILESYS: UNKNOWN PACKET %x\n"), type); - return 0; - } - return 1; + /* unsupported packets */ + case ACTION_MAKE_LINK: + case ACTION_READ_LINK: + case ACTION_FORMAT: + write_log (_T("FILESYS: UNSUPPORTED PACKET %x\n"), type); + return 0; + default: + write_log (_T("FILESYS: UNKNOWN PACKET %x\n"), type); + return 0; + } + return 1; } #ifdef UAE_FILESYS_THREADS @@ -6086,22 +5992,22 @@ static int handle_packet(TrapContext *ctx, Unit *unit, dpacket *pck, uae_u32 msg static int filesys_iteration(UnitInfo *ui) { uaecptr pck; - uaecptr msg; - uae_u32 morelocks; + 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); + 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); - if (ui->reset_state == FS_GO_DOWN) { - if (pck != 0) - return 1; - /* Death message received. */ - uae_sem_post(&ui->reset_sync_sem); - /* Die. */ - return 0; + if (ui->reset_state == FS_GO_DOWN) { + if (pck != 0) + return 1; + /* Death message received. */ + uae_sem_post (&ui->reset_sync_sem); + /* Die. */ + return 0; } dpacket packet; @@ -6110,11 +6016,11 @@ static int filesys_iteration(UnitInfo *ui) int isvolume = 0; #if TRAPMD trapmd md[] = { - { TRAPCMD_GET_LONG,{ morelocks }, 2, 0 }, - { TRAPCMD_GET_LONG,{ ui->self->locklist }, 2, 1 }, + { 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 } }, + { 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)); @@ -6131,15 +6037,15 @@ static int filesys_iteration(UnitInfo *ui) int ret = handle_packet(ctx, ui->self, &packet, msg, isvolume); if (!ret) { - PUT_PCK_RES1(&packet, DOS_FALSE); - PUT_PCK_RES2(&packet, ERROR_ACTION_NOT_KNOWN); + PUT_PCK_RES1 (&packet, DOS_FALSE); + PUT_PCK_RES2 (&packet, 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 } } + { TRAPCMD_PUT_LONG, { msg + 4, 0xffffffff } }, + { TRAPCMD_GET_LONG, { ui->self->locklist } }, + { TRAPCMD_PUT_LONG, { ui->self->locklist, 0 } } }; struct trapmd *mdp; int mdcnt; @@ -6147,15 +6053,14 @@ static int filesys_iteration(UnitInfo *ui) if (ret >= 0) { mdp = &md2[0]; mdcnt = 3; - /* Mark the packet as processed for the list scan in the assembly code. */ + /* Mark the packet as processed for the list scan in the assembly code. */ //trap_put_long(ctx, msg + 4, 0xffffffff); - } - else { + } else { mdp = &md2[1]; mdcnt = 2; } /* Acquire the message lock, so that we know we can safely send the message. */ - ui->self->cmds_sent++; + ui->self->cmds_sent++; /* Send back the locks. */ trap_multi(ctx, mdp, mdcnt); @@ -6163,19 +6068,19 @@ static int filesys_iteration(UnitInfo *ui) 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(); + do_uae_int_requested(); return 1; } -static void *filesys_thread(void *unit_v) +static void *filesys_thread (void *unit_v) { UnitInfo *ui = (UnitInfo *)unit_v; - uae_set_thread_priority(NULL, 1); + uae_set_thread_priority (NULL, 1); for (;;) { - if (!filesys_iteration(ui)) { + if (!filesys_iteration (ui)) { return 0; } } @@ -6184,7 +6089,7 @@ 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 *ctx) { bool packet_valid = false; Unit *unit = find_unit(trap_get_areg(ctx, 5)); @@ -6192,73 +6097,73 @@ static uae_u32 REGPARAM2 filesys_handler(TrapContext *ctx) uaecptr message_addr = trap_get_areg(ctx, 4); if (!trap_valid_address(ctx, packet_addr, 36) || !trap_valid_address(ctx, message_addr, 14)) { - write_log(_T("FILESYS: Bad address %x/%x passed for packet.\n"), packet_addr, message_addr); - goto error2; - } + write_log (_T("FILESYS: Bad address %x/%x passed for packet.\n"), packet_addr, message_addr); + goto error2; + } - if (!unit || !unit->volume) { - write_log(_T("FILESYS: was not initialized.\n")); - goto error; - } + if (!unit || !unit->volume) { + write_log (_T("FILESYS: was not initialized.\n")); + goto error; + } #ifdef UAE_FILESYS_THREADS - { - uae_u32 morelocks; - if (!unit->ui.unit_pipe) - goto error; - /* Get two more locks and hand them over to the other thread. */ + { + uae_u32 morelocks; + 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 }, + /* 0 */ { TRAPCMD_GET_LONG, { trap_get_areg(ctx, 3) }, 1, 0 }, // morelocksptr = trap_get_long(ctx, morelocks) - /* 1 */{ TRAPCMD_GET_LONG,{ 0 } }, + /* 1 */ { TRAPCMD_GET_LONG, { 0 } }, // result 1 to index 4 - /* 2 */{ TRAPCMD_NOP,{ 0 }, 4, 0 }, + /* 2 */ { TRAPCMD_NOP, { 0 }, 4, 0 }, // result 1 to index 6 - /* 3 */{ TRAPCMD_NOP,{ 0 }, 6, 0 }, + /* 3 */ { TRAPCMD_NOP, { 0 }, 6, 0 }, // trap_get_long(ctx, morelocksptr) - /* 4 */{ TRAPCMD_GET_LONG,{ 0 }, 5, 1 }, + /* 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) } }, + /* 5 */ { TRAPCMD_PUT_LONG, { trap_get_areg(ctx, 3) } }, // trap_put_long(ctx, morelocksptr, 0); - /* 6 */{ TRAPCMD_PUT_LONG,{ 0, 0 } }, + /* 6 */ { TRAPCMD_PUT_LONG, { 0, 0 } }, // trap_put_long(ctx, message_addr + 4, 0); - /* 7 */{ TRAPCMD_PUT_LONG,{ 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); + 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); - /* The packet wasn't processed yet. */ - trap_put_long(ctx, message_addr + 4, 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); - 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); - /* Don't reply yet. */ - return 1; - } + 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); + /* Don't reply yet. */ + return 1; + } #endif dpacket packet; readdpacket(ctx, &packet, packet_addr); packet_valid = true; - if (!handle_packet(ctx, unit, &packet, 0, filesys_isvolume(unit))) { - error: + if (! handle_packet(ctx, unit, &packet, 0, filesys_isvolume(unit))) { + 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, DOS_FALSE); + PUT_PCK_RES2 (&packet, ERROR_ACTION_NOT_KNOWN); + } TRACE((_T("reply: %08x, %d\n"), GET_PCK_RES1(&packet), GET_PCK_RES2(&packet))); writedpacket(ctx, &packet); @@ -6266,112 +6171,112 @@ static uae_u32 REGPARAM2 filesys_handler(TrapContext *ctx) error2: trap_put_long(ctx, message_addr + 4, 0xffffffff); - return 0; + return 0; } -void filesys_start_threads(void) +void filesys_start_threads (void) { - int i; + int i; - filesys_in_interrupt = 0; - for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { - UnitInfo *ui = &mountinfo.ui[i]; + filesys_in_interrupt = 0; + for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { + UnitInfo *ui = &mountinfo.ui[i]; if (ui->open <= 0) - continue; - filesys_start_thread(ui, i); - } + continue; + filesys_start_thread (ui, i); + } } void filesys_free_handles(void) { - Unit *u, *u1; - for (u = units; u; u = u1) { - Key *k1, *knext; - u1 = u->next; - for (k1 = u->keys; k1; k1 = knext) { - knext = k1->next; - if (k1->fd) - fs_closefile(k1->fd); - xfree(k1); - } - u->keys = NULL; + Unit *u, *u1; + for (u = units; u; u = u1) { + Key *k1, *knext; + u1 = u->next; + for (k1 = u->keys; k1; k1 = knext) { + knext = k1->next; + if (k1->fd) + fs_closefile (k1->fd); + xfree(k1); + } + u->keys = NULL; struct lockrecord *lrnext; for (struct lockrecord *lr = u->waitingrecords; lr; lr = lrnext) { lrnext = lr->next; - xfree(lr); + xfree (lr); } u->waitingrecords = NULL; - free_all_ainos(u, &u->rootnode); - u->rootnode.next = u->rootnode.prev = &u->rootnode; - u->aino_cache_size = 0; - xfree(u->newrootdir); - xfree(u->newvolume); - u->newrootdir = NULL; - u->newvolume = NULL; - } + free_all_ainos (u, &u->rootnode); + u->rootnode.next = u->rootnode.prev = &u->rootnode; + u->aino_cache_size = 0; + xfree(u->newrootdir); + xfree(u->newvolume); + u->newrootdir = NULL; + u->newvolume = NULL; + } } -static void filesys_reset2(void) +static void filesys_reset2 (void) { - Unit *u, *u1; + Unit *u, *u1; - filesys_free_handles(); - for (u = units; u; u = u1) { - u1 = u->next; - xfree(u); - } - units = 0; - key_uniq = 0; - a_uniq = 0; - free_mountinfo(); + filesys_free_handles(); + for (u = units; u; u = u1) { + u1 = u->next; + xfree (u); + } + units = 0; + key_uniq = 0; + a_uniq = 0; + free_mountinfo (); } -void filesys_reset(void) +void filesys_reset (void) { - if (isrestore()) - return; + if (isrestore ()) + return; load_injected_icons(); - filesys_reset2(); - initialize_mountinfo(); + filesys_reset2 (); + initialize_mountinfo(); } -static void filesys_prepare_reset2(void) +static void filesys_prepare_reset2 (void) { - UnitInfo *uip; - int i; + UnitInfo *uip; + int i; - uip = mountinfo.ui; + uip = mountinfo.ui; #ifdef UAE_FILESYS_THREADS - for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { - if (uip[i].open > 0 && uip[i].unit_pipe != 0) { - uae_sem_init(&uip[i].reset_sync_sem, 0, 0); - uip[i].reset_state = FS_GO_DOWN; - /* send death message */ + for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) { + if (uip[i].open > 0 && uip[i].unit_pipe != 0) { + 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); - xfree(uip[i].unit_pipe); - uip[i].unit_pipe = 0; - destroy_comm_pipe(uip[i].back_pipe); - xfree(uip[i].back_pipe); - uip[i].back_pipe = 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); + xfree(uip[i].unit_pipe); + uip[i].unit_pipe = 0; + destroy_comm_pipe(uip[i].back_pipe); + xfree(uip[i].back_pipe); + uip[i].back_pipe = 0; + } + } #endif - filesys_free_handles(); + filesys_free_handles(); } -void filesys_prepare_reset(void) +void filesys_prepare_reset (void) { - if (isrestore()) - return; - filesys_prepare_reset2(); + if (isrestore ()) + return; + filesys_prepare_reset2 (); } /* don't forget filesys.asm! */ @@ -6429,8 +6334,8 @@ static uae_u32 REGPARAM2 filesys_putmsg(TrapContext *ctx) 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); +// 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; @@ -6478,13 +6383,13 @@ static uae_u32 REGPARAM2 filesys_doio(TrapContext *ctx) case 9: // TD_MOTOR trap_put_long(ctx, ioreq + 32, trackdisk_hack_state < 0 ? 0 : 1); trackdisk_hack_state = len ? 1 : -1; - break; + break; case 13: // TD_CHANGENUM trap_put_long(ctx, ioreq + 32, 1); // io_Actual - break; + break; case 14: // TD_CHANGESTATE trap_put_long(ctx, ioreq + 32, 0); - break; + break; } return 0; } @@ -6526,8 +6431,7 @@ static uaecptr add_resident(TrapContext *ctx, uaecptr resaddr, uaecptr myres) } if (prevjmp) { trap_put_long(ctx, prevjmp, 0x80000000 | resaddr); - } - else { + } else { trap_put_long(ctx, reslist, 0x80000000 | resaddr); } trap_put_long(ctx, resaddr, myres); @@ -6537,7 +6441,7 @@ static uaecptr add_resident(TrapContext *ctx, uaecptr resaddr, uaecptr myres) return resaddr; } -static uae_u32 REGPARAM2 filesys_diagentry(TrapContext *ctx) +static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *ctx) { UnitInfo *uip = mountinfo.ui; uaecptr resaddr = trap_get_areg(ctx, 2); @@ -6561,12 +6465,12 @@ static uae_u32 REGPARAM2 filesys_diagentry(TrapContext *ctx) native2amiga_startup(); - write_log(_T("filesystem: diagentry %08x configdev %08x\n"), resaddr, filesys_configdev); + 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 */ + 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 */ @@ -6575,16 +6479,16 @@ static uae_u32 REGPARAM2 filesys_diagentry(TrapContext *ctx) 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; + } + 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 + 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 */ @@ -6600,18 +6504,18 @@ static uae_u32 REGPARAM2 filesys_diagentry(TrapContext *ctx) resaddr += 0x1A; } - resaddr = uaeres_startup(ctx, resaddr); + 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 */ + /* 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; @@ -6628,8 +6532,7 @@ static uae_u32 REGPARAM2 filesys_diagentry(TrapContext *ctx) resaddr += 2 * 22; trackdisk_hack_state = -1; putmsg_hack_filesystemtask = 1; - } - else { + } else { resaddr += 1 * 22; } } @@ -6712,41 +6615,40 @@ static uae_u32 REGPARAM2 filesys_diagentry(TrapContext *ctx) resaddr = resaddr_tmp; } - trap_set_areg(ctx, 0, last_resident); + 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 { + } else { tmp += 2; } } - return 1; + return 1; } -static uae_u32 REGPARAM2 filesys_dev_bootfilesys(TrapContext *ctx) +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 fsnode; - uae_u32 dostype, dostype2; + uaecptr fsnode; + uae_u32 dostype, dostype2; int no = trap_get_dreg(ctx, 6) & 0x7fffffff; - int unit_no = no & 65535; + int unit_no = no & 65535; UnitInfo *uip = &mountinfo.ui[unit_no]; - int type; + int type; - type = is_hardfile(unit_no); + type = is_hardfile (unit_no); - if (type == FILESYS_VIRTUAL) { + if (type == FILESYS_VIRTUAL) { if (!trap_get_long(ctx, devicenode + 16)) trap_put_long(ctx, devicenode + 16, fshandlername); - return 0; - } + return 0; + } if (trap_get_long(ctx, parmpacket + PP_FSPTR) && !trap_get_long(ctx, parmpacket + PP_ADDTOFSRES)) { uaecptr fsptr = trap_get_long(ctx, parmpacket + PP_FSPTR); @@ -6765,25 +6667,25 @@ static uae_u32 REGPARAM2 filesys_dev_bootfilesys(TrapContext *ctx) trap_put_long(ctx, devicenode + 4 + 7 * 4, seglist); return 1; } - dostype = trap_get_long(ctx, parmpacket + 80); - fsnode = trap_get_long(ctx, fsres + 18); - while (trap_get_long(ctx, fsnode)) { - dostype2 = trap_get_long(ctx, fsnode + 14); - if (dostype2 == dostype) { + dostype = trap_get_long(ctx, parmpacket + 80); + fsnode = trap_get_long(ctx, fsres + 18); + while (trap_get_long(ctx, fsnode)) { + dostype2 = trap_get_long(ctx, fsnode + 14); + if (dostype2 == dostype) { uae_u32 pf = trap_get_long(ctx, 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 + // 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); } - } - return 1; - } + } + return 1; + } fsnode = trap_get_long(ctx, fsnode); } if (type == FILESYS_HARDFILE) { @@ -6793,7 +6695,7 @@ static uae_u32 REGPARAM2 filesys_dev_bootfilesys(TrapContext *ctx) trap_put_long(ctx, devicenode + 4 + i * 4, trap_get_long(ctx, parmpacket + PP_FSHDSTART + 8 + 4 + i * 4)); } trap_put_long(ctx, 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) { @@ -6811,7 +6713,7 @@ static uae_u32 REGPARAM2 filesys_dev_bootfilesys(TrapContext *ctx) } } - return 0; + return 0; } // called from bcplwrapper @@ -6847,35 +6749,35 @@ static uae_u32 REGPARAM2 filesys_bcpl_wrapper(TrapContext *ctx) return 0; } -static uae_u32 REGPARAM2 filesys_init_storeinfo(TrapContext *ctx) +static uae_u32 REGPARAM2 filesys_init_storeinfo (TrapContext *ctx) { - int ret = -1; + int ret = -1; switch (trap_get_dreg(ctx, 1)) - { + { case 1: mountertask = trap_get_areg(ctx, 1); #ifdef PICASSO96 - picasso96_alloc(ctx); + picasso96_alloc (ctx); #endif - break; + break; case 2: - ret = automountunit; - automountunit = -1; - break; + ret = automountunit; + automountunit = -1; + break; case 3: - return 0; - } - return ret; + return 0; + } + return ret; } /* 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) + * which unit a given startup message belongs to. */ +static uae_u32 REGPARAM2 filesys_dev_remember (TrapContext *ctx) { int no = trap_get_dreg(ctx, 6) & 0x7fffffff; - int unit_no = no & 65535; - int sub_no = no >> 16; - UnitInfo *uip = &mountinfo.ui[unit_no]; + 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 fssize; @@ -6891,16 +6793,16 @@ static uae_u32 REGPARAM2 filesys_dev_remember(TrapContext *ctx) trap_put_bytes(ctx, fs, addr, fssize); } - xfree(fs); + 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); - return devicenode; + return devicenode; } -static int legalrdbblock(UnitInfo *uip, int block) +static int legalrdbblock (UnitInfo *uip, int block) { if (block <= 0) return 0; @@ -6909,38 +6811,38 @@ static int legalrdbblock(UnitInfo *uip, int block) return 1; } -static uae_u32 rl(uae_u8 *p) +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) +static int rdb_checksum (const uae_char *id, uae_u8 *p, int block) { uae_u32 sum = 0; int i, blocksize; - if (memcmp(id, p, 4)) + if (memcmp (id, p, 4)) return 0; - blocksize = rl(p + 4); + blocksize = rl (p + 4); if (blocksize < 1 || blocksize * 4 > FILESYS_MAX_BLOCKSIZE) return 0; for (i = 0; i < blocksize; i++) - sum += rl(p + i * 4); + sum += rl (p + i * 4); sum = -sum; if (sum) { - TCHAR *s = au(id); - write_log(_T("RDB: block %d ('%s') checksum error\n"), block, s); - xfree(s); + TCHAR *s = au (id); + write_log (_T("RDB: block %d ('%s') checksum error\n"), block, s); + xfree (s); return 0; } return 1; } -static int device_isdup(TrapContext *ctx, uaecptr expbase, TCHAR *devname) +static int device_isdup (TrapContext *ctx, uaecptr expbase, TCHAR *devname) { - uaecptr bnode, dnode, name; - int len, i; - TCHAR dname[256]; + uaecptr bnode, dnode, name; + int len, i; + TCHAR dname[256]; if (!expbase) return 0; @@ -6949,36 +6851,35 @@ static int device_isdup(TrapContext *ctx, uaecptr expbase, TCHAR *devname) 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); - for (i = 0; i < len; i++) + for (i = 0; i < len; i++) dname[i] = trap_get_byte(ctx, name + 1 + i); - dname[len] = 0; - if (!_tcsicmp(devname, dname)) - return 1; + dname[len] = 0; + if (!_tcsicmp (devname, dname)) + return 1; bnode = trap_get_long(ctx, bnode); - } - return 0; + } + return 0; } -static TCHAR *device_dupfix(TrapContext *ctx, uaecptr expbase, TCHAR *devname) +static TCHAR *device_dupfix (TrapContext *ctx, uaecptr expbase, TCHAR *devname) { - int modified; - TCHAR newname[256]; + int modified; + TCHAR newname[256]; - _tcscpy(newname, devname); - modified = 1; - while (modified) { - modified = 0; - if (device_isdup(ctx, expbase, newname)) { - if (_tcslen(newname) > 2 && newname[_tcslen(newname) - 2] == '_') { - newname[_tcslen(newname) - 1]++; - } - else { - _tcscat(newname, _T("_0")); - } - modified = 1; + _tcscpy (newname, devname); + modified = 1; + while (modified) { + modified = 0; + if (device_isdup (ctx, expbase, newname)) { + if (_tcslen (newname) > 2 && newname[_tcslen (newname) - 2] == '_') { + newname[_tcslen (newname) - 1]++; + } else { + _tcscat (newname, _T("_0")); + } + modified = 1; } - } - return my_strdup(newname); + } + return my_strdup (newname); } static const TCHAR *dostypes(TCHAR *dt, uae_u32 dostype) @@ -6990,11 +6891,10 @@ static const TCHAR *dostypes(TCHAR *dt, uae_u32 dostype) uae_u8 c = dostype >> ((3 - i) * 8); if (c >= ' ' && c <= 'z') { dt[j++] = c; - } - else { + } else { dt[j++] = '\\'; - _stprintf(&dt[j], _T("%d"), c); - j += _tcslen(&dt[j]); + _stprintf (&dt[j], _T("%d"), c); + j += _tcslen (&dt[j]); } } dt[j] = 0; @@ -7003,7 +6903,7 @@ 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 (TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacket) { int lastblock = 63, blocksize, readblocksize, badblock, driveinitblock; TCHAR dt[32]; @@ -7019,78 +6919,78 @@ static int rdb_mount(TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum, int newversion, newrevision; TCHAR *s; - write_log(_T("%s:\n"), uip->rootdir); + write_log (_T("%s:\n"), uip->rootdir); if (hfd->drive_empty) { rdbmnt - write_log(_T("ignored, drive is empty\n")); + write_log (_T("ignored, drive is empty\n")); return -2; } if (hfd->ci.blocksize == 0) { rdbmnt - write_log(_T("failed, blocksize == 0\n")); + write_log (_T("failed, blocksize == 0\n")); return -1; } if (lastblock * hfd->ci.blocksize > hfd->virtsize) { rdbmnt - write_log(_T("failed, too small (%d*%d > %llu)\n"), lastblock, hfd->ci.blocksize, hfd->virtsize); + write_log (_T("failed, too small (%d*%d > %llu)\n"), lastblock, hfd->ci.blocksize, hfd->virtsize); return -2; } for (rdblock = 0; rdblock < lastblock; rdblock++) { - hdf_read_rdb(hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize); - if (rdb_checksum("RDSK", bufrdb, rdblock)) + hdf_read_rdb (hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize); + if (rdb_checksum ("RDSK", bufrdb, rdblock)) break; - if (rdb_checksum("CDSK", bufrdb, rdblock)) + if (rdb_checksum ("CDSK", bufrdb, rdblock)) break; - hdf_read_rdb(hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize); - if (!memcmp("RDSK", bufrdb, 4)) { + hdf_read_rdb (hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize); + if (!memcmp ("RDSK", bufrdb, 4)) { bufrdb[0xdc] = 0; bufrdb[0xdd] = 0; bufrdb[0xde] = 0; bufrdb[0xdf] = 0; - if (rdb_checksum("RDSK", bufrdb, rdblock)) { - write_log(_T("Windows 95/98/ME trashed RDB detected, fixing..\n")); - hdf_write(hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize); + if (rdb_checksum ("RDSK", bufrdb, rdblock)) { + write_log (_T("Windows 95/98/ME trashed RDB detected, fixing..\n")); + hdf_write (hfd, bufrdb, rdblock * hfd->ci.blocksize, hfd->ci.blocksize); break; } } } if (rdblock == lastblock) { rdbmnt - write_log(_T("failed, no RDB detected\n")); + write_log (_T("failed, no RDB detected\n")); return -2; } - blocksize = rl(bufrdb + 16); + blocksize = rl (bufrdb + 16); readblocksize = blocksize > hfd->ci.blocksize ? blocksize : hfd->ci.blocksize; - badblock = rl(bufrdb + 24); + badblock = rl (bufrdb + 24); if (badblock != -1) { - write_log(_T("RDB: badblock list %08x\n"), badblock); + write_log (_T("RDB: badblock list %08x\n"), badblock); } - driveinitblock = rl(bufrdb + 36); + driveinitblock = rl (bufrdb + 36); if (driveinitblock != -1) { - write_log(_T("RDB: driveinit = %08x\n"), driveinitblock); + write_log (_T("RDB: driveinit = %08x\n"), driveinitblock); } - hfd->rdbcylinders = rl(bufrdb + 64); - hfd->rdbsectors = rl(bufrdb + 68); - hfd->rdbheads = rl(bufrdb + 72); - fileblock = rl(bufrdb + 32); + hfd->rdbcylinders = rl (bufrdb + 64); + hfd->rdbsectors = rl (bufrdb + 68); + hfd->rdbheads = rl (bufrdb + 72); + fileblock = rl (bufrdb + 32); - buf = xmalloc(uae_u8, readblocksize); + buf = xmalloc (uae_u8, readblocksize); for (i = 0; i <= partnum; i++) { if (i == 0) - partblock = rl(bufrdb + 28); + partblock = rl (bufrdb + 28); else - partblock = rl(buf + 4 * 4); - if (!legalrdbblock(uip, partblock)) { + partblock = rl (buf + 4 * 4); + if (!legalrdbblock (uip, partblock)) { err = -2; goto error; } - memset(buf, 0, readblocksize); - hdf_read(hfd, buf, partblock * hfd->ci.blocksize, readblocksize); - if (!rdb_checksum("PART", buf, partblock)) { + memset (buf, 0, readblocksize); + 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; @@ -7098,10 +6998,10 @@ static int rdb_mount(TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum, } rdbmnt - flags = rl(buf + 20); + flags = rl (buf + 20); if ((flags & 2) || uip->bootpri <= -129) { /* do not mount */ err = -1; - write_log(_T("RDB: Automount disabled, not mounting\n")); + write_log (_T("RDB: Automount disabled, not mounting\n")); goto error; } @@ -7109,9 +7009,9 @@ static int rdb_mount(TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum, trap_set_dreg(ctx, 7, trap_get_dreg(ctx, 7) & ~1); buf[37 + buf[36]] = 0; /* zero terminate BSTR */ - s = au((char*)buf + 37); + s = au ((char*)buf + 37); uip->rdb_devname_amiga[partnum] = ds(device_dupfix(ctx, trap_get_long(ctx, parmpacket + PP_EXPLIB), s)); - xfree(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); @@ -7122,23 +7022,23 @@ static int rdb_mount(TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum, uip->rdb_dostype = dostype; if (dostype == 0) { - write_log(_T("RDB: mount failed, dostype=0\n")); + write_log (_T("RDB: mount failed, dostype=0\n")); err = -1; goto error; } if (dostype == 0xffffffff) { - write_log(_T("RDB: WARNING: dostype = 0xFFFFFFFF. FFS bug can report partition in \"no disk inserted\" state!!\n")); + write_log (_T("RDB: WARNING: dostype = 0xFFFFFFFF. FFS bug can report partition in \"no disk inserted\" state!!\n")); } err = 2; /* load custom filesystems if needed */ - if (fileblock == -1 || !legalrdbblock(uip, fileblock)) + if (fileblock == -1 || !legalrdbblock (uip, fileblock)) goto error; fsres = trap_get_long(ctx, parmpacket + PP_FSRES); if (!fsres) { - write_log(_T("RDB: FileSystem.resource not found, this shouldn't happen!\n")); + write_log (_T("RDB: FileSystem.resource not found, this shouldn't happen!\n")); goto error; } fsnode = trap_get_long(ctx, fsres + 18); @@ -7151,41 +7051,40 @@ static int rdb_mount(TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum, if (trap_get_long(ctx, fsnode)) { oldversion = trap_get_word(ctx, fsnode + 18); oldrevision = trap_get_word(ctx, fsnode + 20); - } - else { + } else { fsnode = 0; } 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 (dt, dostype)); goto error; } - if (!legalrdbblock(uip, fileblock)) { - write_log(_T("RDB: corrupt FSHD pointer %d\n"), fileblock); + if (!legalrdbblock (uip, fileblock)) { + write_log (_T("RDB: corrupt FSHD pointer %d\n"), fileblock); goto error; } - memset(buf, 0, readblocksize); - hdf_read(hfd, buf, fileblock * hfd->ci.blocksize, readblocksize); - if (!rdb_checksum("FSHD", buf, fileblock)) { - write_log(_T("RDB: checksum error in FSHD block %d\n"), fileblock); + memset (buf, 0, readblocksize); + hdf_read (hfd, buf, fileblock * hfd->ci.blocksize, readblocksize); + if (!rdb_checksum ("FSHD", buf, fileblock)) { + write_log (_T("RDB: checksum error in FSHD block %d\n"), fileblock); goto error; } - fileblock = rl(buf + 16); - uae_u32 rdbdostype = rl(buf + 32); + 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)) 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 (dt, 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 (dt, 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")); + write_log (_T("RDB: FS in FileSystem.resource is newer or same, ignoring RDB filesystem\n")); goto error; } @@ -7193,43 +7092,43 @@ static int rdb_mount(TrapContext *ctx, UnitInfo *uip, int unit_no, int partnum, trap_put_byte(ctx, parmpacket + PP_FSHDSTART + i, buf[32 + i]); trap_put_long(ctx, parmpacket + PP_FSHDSTART, dostype); /* we found required FSHD block */ - fsmem = xmalloc(uae_u8, 262144); - lsegblock = rl(buf + 72); + fsmem = xmalloc (uae_u8, 262144); + lsegblock = rl (buf + 72); i = 0; for (;;) { int pb = lsegblock; - if (!legalrdbblock(uip, 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)) { + 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); goto error; } - lsegblock = rl(buf + 16); + lsegblock = rl (buf + 16); if (lsegblock == pb) goto error; if ((i + 1) * (blocksize - 20) >= 262144) goto error; - memcpy(fsmem + i * (blocksize - 20), buf + 20, blocksize - 20); + memcpy (fsmem + i * (blocksize - 20), buf + 20, blocksize - 20); i++; if (lsegblock == -1) break; } - write_log(_T("RDB: Filesystem loaded, %d bytes\n"), i * (blocksize - 20)); + write_log (_T("RDB: Filesystem loaded, %d bytes\n"), i * (blocksize - 20)); trap_put_long(ctx, parmpacket + PP_FSSIZE, i * (blocksize - 20)); /* RDB filesystem size hack */ trap_put_long(ctx, parmpacket + PP_ADDTOFSRES, -1); uip->rdb_filesysstore = fsmem; uip->rdb_filesyssize = i * (blocksize - 20); - xfree(buf); + xfree (buf); return 2; error: - xfree(buf); - xfree(fsmem); + xfree (buf); + xfree (fsmem); return err; } -static void addfakefilesys(TrapContext *ctx, uaecptr parmpacket, uae_u32 dostype, int ver, int rev, struct uaedev_config_info *ci) +static void addfakefilesys (TrapContext *ctx, uaecptr parmpacket, uae_u32 dostype, int ver, int rev, struct uaedev_config_info *ci) { int i; uae_u32 flags; @@ -7240,7 +7139,7 @@ static void addfakefilesys(TrapContext *ctx, uaecptr parmpacket, uae_u32 dostype if (dostype) { trap_put_long(ctx, parmpacket + 80, dostype); trap_put_long(ctx, parmpacket + PP_FSHDSTART, dostype); - } + } if (ver >= 0 && rev >= 0) trap_put_long(ctx, parmpacket + PP_FSHDSTART + 4, (ver << 16) | rev); @@ -7252,20 +7151,20 @@ static void addfakefilesys(TrapContext *ctx, uaecptr parmpacket, uae_u32 dostype flags |= 0x20; } trap_put_long(ctx, parmpacket + PP_FSHDSTART + 12 + 8 * 4, dostype == DISK_TYPE_DOS || bcplonlydos() ? 0 : -1); // globvec - // if OFS = seglist -> NULL + // if OFS = seglist -> NULL if (dostype == DISK_TYPE_DOS) flags &= ~0x080; trap_put_long(ctx, parmpacket + PP_FSHDSTART + 8, flags); // patchflags } -static uaecptr getfakefilesysseg(UnitInfo *uip) +static uaecptr getfakefilesysseg (UnitInfo *uip) { - if (uip->filesysdir && _tcslen(uip->filesysdir) > 0) { + if (uip->filesysdir && _tcslen (uip->filesysdir) > 0) { for (int i = 0; &mountinfo.ui[i] != uip; i++) { UnitInfo *uip2 = &mountinfo.ui[i]; if (!uip2->filesysdir) continue; - if (_tcsicmp(uip2->filesysdir, uip->filesysdir) != 0) + if (_tcsicmp (uip2->filesysdir, uip->filesysdir) != 0) continue; if (uip2->filesysseg) return uip2->filesysseg; @@ -7274,7 +7173,7 @@ static uaecptr getfakefilesysseg(UnitInfo *uip) return 0; } -static int dofakefilesys(TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, struct uaedev_config_info *ci) +static int dofakefilesys (TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, struct uaedev_config_info *ci) { int i, size; TCHAR tmp[MAX_DPATH]; @@ -7287,23 +7186,22 @@ static int dofakefilesys(TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, st // we already have custom filesystem loaded for earlier hardfile? if (!ci->forceload) { - uaecptr seg = getfakefilesysseg(uip); + 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); - write_log(_T("RDB: faked RDB filesystem '%s' reused\n"), uip->filesysdir); + write_log (_T("RDB: faked RDB filesystem '%s' reused\n"), uip->filesysdir); return FILESYS_HARDFILE; } } if (!ci->dostype) { - memset(buf, 0, 4); - hdf_read(&uip->hf, buf, 0, 512); - dostype = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; - } - else { + memset (buf, 0, 4); + hdf_read (&uip->hf, buf, 0, 512); + dostype = (buf[0] << 24) | (buf[1] << 16) |(buf[2] << 8) | buf[3]; + } else { dostype = ci->dostype; } if (dostype == 0) { @@ -7311,35 +7209,34 @@ static int dofakefilesys(TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, st return FILESYS_HARDFILE; } if (dostype == DISK_TYPE_DOS && (!uip->filesysdir || !uip->filesysdir[0])) { - write_log(_T("RDB: OFS, using ROM default FS.\n")); + write_log (_T("RDB: OFS, using ROM default FS.\n")); return FILESYS_HARDFILE; } tmp[0] = 0; - if (uip->filesysdir && _tcslen(uip->filesysdir) > 0) { - _tcscpy(tmp, uip->filesysdir); - } - else if ((dostype & 0xffffff00) == DISK_TYPE_DOS) { - _tcscpy(tmp, currprefs.romfile); - i = _tcslen(tmp); + if (uip->filesysdir && _tcslen (uip->filesysdir) > 0) { + _tcscpy (tmp, uip->filesysdir); + } else if ((dostype & 0xffffff00) == DISK_TYPE_DOS) { + _tcscpy (tmp, currprefs.romfile); + i = _tcslen (tmp); while (i > 0 && tmp[i - 1] != '/' && tmp[i - 1] != '\\') i--; - _tcscpy(tmp + i, _T("FastFileSystem")); + _tcscpy (tmp + i, _T("FastFileSystem")); 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); + 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) return FILESYS_HARDFILE; - write_log(_T("RDB: mounted without filesys\n")); + 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)); - zf = zfile_fopen(tmp, _T("rb"), ZFD_NORMAL); + write_log (_T("RDB: fakefilesys, trying to load '%s', dostype 0x%08X (%s)\n"), tmp, dostype, dostypes (dt, dostype)); + zf = zfile_fopen (tmp, _T("rb"), ZFD_NORMAL); if (!zf) { addfakefilesys(ctx, parmpacket, dostype, ver, rev, ci); - write_log(_T("RDB: filesys not found, mounted without forced filesys\n")); + write_log (_T("RDB: filesys not found, mounted without forced filesys\n")); return FILESYS_HARDFILE; } @@ -7353,25 +7250,25 @@ static int dofakefilesys(TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, st 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); + write_log (_T("RDB: %08X (%s) in FileSystem.resource version %d.%d\n"), dostype, dostypes(dt, dostype), oldversion, oldrevision); break; } fsnode = trap_get_long(ctx, fsnode); } // if automatically found FastFileSystem, do not replace matching FileSystem.resource FS if (autofs && oldversion >= 0) { - zfile_fclose(zf); + zfile_fclose (zf); addfakefilesys(ctx, parmpacket, dostype, ver, rev, ci); - write_log(_T("RDB: not replacing FileSystem.resource\n")); + write_log (_T("RDB: not replacing FileSystem.resource\n")); return FILESYS_HARDFILE; } - zfile_fseek(zf, 0, SEEK_END); - size = zfile_ftell(zf); + zfile_fseek (zf, 0, SEEK_END); + size = zfile_ftell (zf); if (size > 0) { - zfile_fseek(zf, 0, SEEK_SET); - uip->rdb_filesysstore = xmalloc(uae_u8, size); - zfile_fread(uip->rdb_filesysstore, size, 1, zf); + zfile_fseek (zf, 0, SEEK_SET); + uip->rdb_filesysstore = xmalloc (uae_u8, size); + zfile_fread (uip->rdb_filesysstore, size, 1, zf); for (i = 0; i < size - 6; i++) { uae_u8 *p = uip->rdb_filesysstore + i; if (p[0] == 'V' && p[1] == 'E' && p[2] == 'R' && p[3] == ':' && p[4] == ' ') { @@ -7384,7 +7281,7 @@ static int dofakefilesys(TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, st while (*p && (ver < 0 || rev < 0)) { if (*p == ' ') { p++; - ver = atol((char*)p); + ver = atol ((char*)p); if (ver < 0) ver = 0; while (*p) { @@ -7392,17 +7289,15 @@ static int dofakefilesys(TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, st break; if (*p == '.') { p++; - rev = atol((char*)p); + rev = atol ((char*)p); if (rev < 0) rev = 0; - } - else { + } else { p++; } } break; - } - else { + } else { p++; } } @@ -7411,7 +7306,7 @@ static int dofakefilesys(TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, st } } } - zfile_fclose(zf); + zfile_fclose (zf); uip->rdb_filesyssize = size; // DOS\0 is not in fs.resource and fs.resource already existed? @@ -7419,45 +7314,44 @@ static int dofakefilesys(TrapContext *ctx, UnitInfo *uip, uaecptr parmpacket, st 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); + 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); 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 (TrapContext *ctx, int type, uaecptr parmpacket, TCHAR **devname, uaecptr *devname_amiga, int unit_no) { - TCHAR buffer[80]; + TCHAR buffer[80]; uaecptr expbase = trap_get_long(ctx, 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)) - break; - } - } - else { - _tcscpy(buffer, *devname); - } - *devname_amiga = ds(device_dupfix(ctx, expbase, buffer)); - if (type == FILESYS_VIRTUAL) - write_log(_T("FS: mounted virtual unit %s (%s)\n"), buffer, mountinfo.ui[unit_no].rootdir); - else - write_log(_T("FS: mounted HDF unit %s (%04x-%08x, %s)\n"), buffer, - (uae_u32)(mountinfo.ui[unit_no].hf.virtsize >> 32), - (uae_u32)(mountinfo.ui[unit_no].hf.virtsize), - mountinfo.ui[unit_no].rootdir); + if (*devname == 0 || _tcslen (*devname) == 0) { + int un = unit_no; + for (;;) { + _stprintf (buffer, _T("DH%d"), un++); + if (!device_isdup(ctx, expbase, buffer)) + break; + } + } else { + _tcscpy (buffer, *devname); + } + *devname_amiga = ds (device_dupfix(ctx, expbase, buffer)); + if (type == FILESYS_VIRTUAL) + write_log (_T("FS: mounted virtual unit %s (%s)\n"), buffer, mountinfo.ui[unit_no].rootdir); + else + write_log (_T("FS: mounted HDF unit %s (%04x-%08x, %s)\n"), buffer, + (uae_u32)(mountinfo.ui[unit_no].hf.virtsize >> 32), + (uae_u32)(mountinfo.ui[unit_no].hf.virtsize), + mountinfo.ui[unit_no].rootdir); } /* 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 *ctx) { - UnitInfo *uip = mountinfo.ui; + UnitInfo *uip = mountinfo.ui; int no = trap_get_dreg(ctx, 6) & 0x7fffffff; - int unit_no = no & 65535; - int sub_no = no >> 16; - int type; + int unit_no = no & 65535; + int sub_no = no >> 16; + int type; uaecptr parmpacket = trap_get_areg(ctx, 0); struct uaedev_config_info *ci = &uip[unit_no].hf.ci; @@ -7468,18 +7362,18 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo(TrapContext *ctx) trap_put_long(ctx, parmpacket + PP_ADDTOFSRES, 0); trap_put_long(ctx, parmpacket + PP_FSSIZE, 0); - gui_flicker_led(LED_HD, unit_no, 0); - type = is_hardfile(unit_no); + gui_flicker_led (LED_HD, unit_no, 0); + type = is_hardfile (unit_no); if (type == FILESYS_HARDFILE_RDB) { /* RDB hardfile */ uip[unit_no].devno = unit_no; - return rdb_mount(ctx, &uip[unit_no], unit_no, sub_no, parmpacket); + return rdb_mount (ctx, &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); + 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; + 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 */ @@ -7493,23 +7387,22 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo(TrapContext *ctx) trap_put_long(ctx, parmpacket + 72, 0xFFFFFFFE); /* dma mask */ trap_put_long(ctx, parmpacket + 76, uip[unit_no].bootpri); /* bootPri */ 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; + // 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 */ @@ -7518,9 +7411,8 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo(TrapContext *ctx) 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 { + 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 */ @@ -7539,9 +7431,8 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo(TrapContext *ctx) 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); + } 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); } @@ -7555,76 +7446,61 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo(TrapContext *ctx) buf[i + 128] = trap_get_byte(ctx, 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 (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; } -static uae_u32 REGPARAM2 mousehack_done(TrapContext *ctx) +static uae_u32 REGPARAM2 mousehack_done (TrapContext *ctx) { int mode = trap_get_dreg(ctx, 1); - if (mode < 10) { + 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)); - } - else if (mode == 10) { - } - else if (mode == 11) { - } - else if (mode == 12) { + } else if (mode == 10) { + } else if (mode == 11) { + } else if (mode == 12) { return 0; - } - else if (mode == 13) { + } else if (mode == 13) { return 0; - } - else if (mode == 14) { - } - else if (mode == 15) { - } - else if (mode == 16) { + } else if (mode == 14) { + } else if (mode == 15) { + } else if (mode == 16) { uaecptr a2 = trap_get_areg(ctx, 2); - input_mousehack_mouseoffset(a2); - } - else if (mode == 17) { + input_mousehack_mouseoffset (a2); + } else if (mode == 17) { return 0; - } - else if (mode == 18) { + } 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) { + } else if (mode == 19) { // boot rom copy // d2 = ram address return 0; - } - else if (mode == 20) { + } else if (mode == 20) { // boot rom copy done return 0; - } - else if (mode == 21) { - // keymap hook (nur für Retroplatform relevant) + } else if (mode == 21) { + // keymap hook (nur für Retroplatform relevant) return 1; - } - else if (mode == 101) { - } - else if (mode == 102) { - } - else { - write_log(_T("Unknown mousehack hook %d\n"), mode); - } - return 1; + } else if (mode == 101) { + } else if (mode == 102) { + } else { + write_log (_T("Unknown mousehack hook %d\n"), mode); + } + return 1; } -void filesys_vsync(void) +void filesys_vsync (void) { TrapContext *ctx = NULL; - Unit *u; + Unit *u; if (uae_boot_rom_type <= 0) return; @@ -7633,68 +7509,68 @@ void filesys_vsync(void) } heartbeat = get_long_host(rtarea_bank.baseaddr + RTAREA_HEARTBEAT); - for (u = units; u; u = u->next) { - if (u->reinsertdelay > 0) { - u->reinsertdelay--; - if (u->reinsertdelay == 0) { - filesys_insert(u->unit, u->newvolume, u->newrootdir, u->newreadonly, u->newflags); - xfree(u->newvolume); - u->newvolume = NULL; - xfree(u->newrootdir); - u->newrootdir = NULL; - } - } - record_timeout(ctx, u); + for (u = units; u; u = u->next) { + if (u->reinsertdelay > 0) { + u->reinsertdelay--; + if (u->reinsertdelay == 0) { + filesys_insert (u->unit, u->newvolume, u->newrootdir, u->newreadonly, u->newflags); + xfree (u->newvolume); + u->newvolume = NULL; + xfree (u->newrootdir); + u->newrootdir = NULL; + } + } + record_timeout (ctx, u); } for (int i = 0; i < currprefs.mountitems; i++) { - struct hardfiledata *hfd = get_hardfile_data(currprefs.mountconfig[i].configoffset); + struct hardfiledata *hfd = get_hardfile_data (currprefs.mountconfig[i].configoffset); if (!hfd) continue; if (hfd->reinsertdelay > 0) { hfd->reinsertdelay--; if (hfd->reinsertdelay == 0) { hfd->reinsertdelay = -1; - hardfile_media_change(hfd, &hfd->delayedci, true, true); + hardfile_media_change (hfd, &hfd->delayedci, true, true); } } } } -void filesys_cleanup(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; + 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_install(void) +void filesys_install (void) { - uaecptr loop; + uaecptr loop; - TRACEI((_T("Installing filesystem\n"))); + TRACEI ((_T("Installing filesystem\n"))); - uae_sem_init(&singlethread_int_sem, 0, 1); + 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 ("UAEfs.resource"); + ROM_filesys_resid = ds_ansi (UAEFS_VERSION); - fsdevname = ds_ansi("uae.device"); /* does not really exist */ - fshandlername = ds_bstr_ansi("uaefs"); + 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_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); @@ -7706,49 +7582,49 @@ void filesys_install(void) ROM_filesys_putmsg_return = here(); calltrap(deftrap2(filesys_putmsg_return, 0, _T("filesys_putmsg_return"))); dw(RTS); - - loop = here(); - - org(rtarea_base + RTAREA_HEARTBEAT); - dl(0); + + loop = here (); + + org (rtarea_base + RTAREA_HEARTBEAT); + dl (0); heartbeat = 0; - org(rtarea_base + 0xFF18); - calltrap(deftrap2(filesys_dev_bootfilesys, 0, _T("filesys_dev_bootfilesys"))); - dw(RTS); + org (rtarea_base + 0xFF18); + calltrap (deftrap2 (filesys_dev_bootfilesys, 0, _T("filesys_dev_bootfilesys"))); + dw (RTS); + + /* Special trap for the assembly make_dev routine */ + org (rtarea_base + 0xFF20); + calltrap (deftrap2 (filesys_dev_remember, 0, _T("filesys_dev_remember"))); + dw (RTS); - /* Special trap for the assembly make_dev routine */ - org(rtarea_base + 0xFF20); - calltrap(deftrap2(filesys_dev_remember, 0, _T("filesys_dev_remember"))); - dw(RTS); + org (rtarea_base + 0xFF28); + calltrap (deftrap2 (filesys_dev_storeinfo, 0, _T("filesys_dev_storeinfo"))); + dw (RTS); - org(rtarea_base + 0xFF28); - calltrap(deftrap2(filesys_dev_storeinfo, 0, _T("filesys_dev_storeinfo"))); - dw(RTS); + org (rtarea_base + 0xFF30); + calltrap (deftrap2 (filesys_handler, 0, _T("filesys_handler"))); + dw (RTS); - org(rtarea_base + 0xFF30); - calltrap(deftrap2(filesys_handler, 0, _T("filesys_handler"))); - dw(RTS); + org (rtarea_base + 0xFF38); + calltrap (deftrap2 (mousehack_done, 0, _T("mousehack_done"))); + dw (RTS); - org(rtarea_base + 0xFF38); - calltrap(deftrap2(mousehack_done, 0, _T("mousehack_done"))); - dw(RTS); + org (rtarea_base + 0xFF40); + calltrap (deftrap2 (startup_handler, 0, _T("startup_handler"))); + dw (RTS); - org(rtarea_base + 0xFF40); - calltrap(deftrap2(startup_handler, 0, _T("startup_handler"))); - dw(RTS); + org (rtarea_base + 0xFF48); + calltrap (deftrap2 (filesys_init_storeinfo, TRAPFLAG_EXTRA_STACK, _T("filesys_init_storeinfo"))); + dw (RTS); - org(rtarea_base + 0xFF48); - calltrap(deftrap2(filesys_init_storeinfo, TRAPFLAG_EXTRA_STACK, _T("filesys_init_storeinfo"))); - dw(RTS); + org (rtarea_base + 0xFF50); + calltrap (deftrap2 (exter_int_helper, 0, _T("exter_int_helper"))); + dw (RTS); - org(rtarea_base + 0xFF50); - calltrap(deftrap2(exter_int_helper, 0, _T("exter_int_helper"))); - dw(RTS); - - org(rtarea_base + 0xFF58); - calltrap(deftrap2(fsmisc_helper, 0, _T("fsmisc_helper"))); - dw(RTS); + org (rtarea_base + 0xFF58); + calltrap (deftrap2 (fsmisc_helper, 0, _T("fsmisc_helper"))); + dw (RTS); org(rtarea_base + 0xFF68); calltrap(deftrap2(filesys_bcpl_wrapper, 0, _T("filesys_bcpl_wrapper"))); @@ -7758,7 +7634,7 @@ void filesys_install(void) calltrap(deftrap2(debugger_helper, 0, _T("debugger_helper"))); dw(RTS); - org(loop); + org (loop); } uaecptr filesys_get_entry(int index) @@ -7766,708 +7642,696 @@ uaecptr filesys_get_entry(int index) return bootrom_start + dlg(bootrom_start + bootrom_header + index * 4 - 4) + bootrom_header - 4; } -void filesys_install_code(void) +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; + filesys_initcode = bootrom_start + dlg (b) + bootrom_header - 4; afterdos_initcode = filesys_get_entry(8); } -#ifdef _WIN32_ +#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) +static a_inode *restore_filesys_get_base (Unit *u, TCHAR *npath) { - TCHAR *path, *p, *p2; - a_inode *a; - int cnt, err, i; + TCHAR *path, *p, *p2; + a_inode *a; + int cnt, err, i; - /* no '/' = parent is root */ - if (!_tcschr(npath, '/')) - return &u->rootnode; + /* no '/' = parent is root */ + if (!_tcschr (npath, '/')) + return &u->rootnode; - /* iterate from root to last to previous path part, - * create ainos if not already created. - */ - path = xcalloc(TCHAR, _tcslen(npath) + 2); - cnt = 1; - for (;;) { - _tcscpy(path, npath); - p = path; - for (i = 0; i < cnt; i++) { - if (i > 0) - p++; - while (*p != '/' && *p != 0) - p++; - } - if (*p) { - *p = 0; - err = 0; - get_aino(u, &u->rootnode, path, &err); - if (err) { - write_log(_T("*** FS: missing path '%s'!\n"), path); - return NULL; - } - cnt++; - } - else { - break; - } - } + /* iterate from root to last to previous path part, + * create ainos if not already created. + */ + path = xcalloc(TCHAR, _tcslen (npath) + 2); + cnt = 1; + for (;;) { + _tcscpy (path, npath); + p = path; + for (i = 0; i < cnt ;i++) { + if (i > 0) + p++; + while (*p != '/' && *p != 0) + p++; + } + if (*p) { + *p = 0; + err = 0; + get_aino (u, &u->rootnode, path, &err); + if (err) { + write_log (_T("*** FS: missing path '%s'!\n"), path); + return NULL; + } + cnt++; + } else { + break; + } + } - /* find base (parent) of last path part */ - _tcscpy(path, npath); - p = path; - a = u->rootnode.child; - for (;;) { - if (*p == 0) { - write_log(_T("*** FS: base aino NOT found '%s' ('%s')\n"), a->nname, npath); - xfree(path); - return NULL; - } - p2 = p; - while (*p2 != '/' && *p2 != '\\' && *p2 != 0) - p2++; - *p2 = 0; - while (a) { - if (!same_aname(p, a->aname)) { - a = a->sibling; - continue; - } - p = p2 + 1; - if (*p == 0) { - write_log(_T("FS: base aino found '%s' ('%s')\n"), a->nname, npath); - xfree(path); - return a; - } - a = a->child; - break; - } - if (!a) { - write_log(_T("*** FS: path part '%s' not found ('%s')\n"), p, npath); - xfree(path); - return NULL; - } - } + /* find base (parent) of last path part */ + _tcscpy (path, npath); + p = path; + a = u->rootnode.child; + for (;;) { + if (*p == 0) { + write_log (_T("*** FS: base aino NOT found '%s' ('%s')\n"), a->nname, npath); + xfree (path); + return NULL; + } + p2 = p; + while(*p2 != '/' && *p2 != '\\' && *p2 != 0) + p2++; + *p2 = 0; + while (a) { + if (!same_aname(p, a->aname)) { + a = a->sibling; + continue; + } + p = p2 + 1; + if (*p == 0) { + write_log (_T("FS: base aino found '%s' ('%s')\n"), a->nname, npath); + xfree (path); + return a; + } + a = a->child; + break; + } + if (!a) { + write_log (_T("*** FS: path part '%s' not found ('%s')\n"), p, npath); + xfree (path); + return NULL; + } + } } -static TCHAR *makenativepath(UnitInfo *ui, TCHAR *apath) +static TCHAR *makenativepath (UnitInfo *ui, TCHAR *apath) { - int i; - TCHAR *pn; - /* create native path. FIXME: handle 'illegal' characters */ - pn = xcalloc(TCHAR, _tcslen(apath) + 1 + _tcslen(ui->rootdir) + 1); - _stprintf(pn, _T("%s/%s"), ui->rootdir, apath); - if (FSDB_DIR_SEPARATOR != '/') { - for (i = 0; i < _tcslen(pn); i++) { - if (pn[i] == '/') - pn[i] = FSDB_DIR_SEPARATOR; - } - } - return pn; + int i; + TCHAR *pn; + /* create native path. FIXME: handle 'illegal' characters */ + pn = xcalloc (TCHAR, _tcslen (apath) + 1 + _tcslen (ui->rootdir) + 1); + _stprintf (pn, _T("%s/%s"), ui->rootdir, apath); + if (FSDB_DIR_SEPARATOR != '/') { + for (i = 0; i < _tcslen (pn); i++) { + if (pn[i] == '/') + pn[i] = FSDB_DIR_SEPARATOR; + } + } + return pn; } static uae_u8 *restore_aino(UnitInfo *ui, Unit *u, uae_u8 *src) { - TCHAR *p, *p2, *pn; - uae_u32 flags; - int missing; - a_inode *base, *a; + TCHAR *p, *p2, *pn; + uae_u32 flags; + int missing; + a_inode *base, *a; - missing = 0; - a = xcalloc(a_inode, 1); - a->uniq = restore_u64(); - a->locked_children = restore_u32(); - a->exnext_count = restore_u32(); - a->shlock = restore_u32(); - flags = restore_u32(); - if (flags & 1) - a->elock = 1; + missing = 0; + a = xcalloc (a_inode, 1); + a->uniq = restore_u64 (); + a->locked_children = restore_u32 (); + a->exnext_count = restore_u32 (); + a->shlock = restore_u32 (); + flags = restore_u32 (); + if (flags & 1) + a->elock = 1; if (flags & 4) - a->uniq_external = restore_u64(); - /* full Amiga-side path without drive, eg. "C/SetPatch" */ - p = restore_string(); - /* root (p = volume label) */ - if (a->uniq == 0) { - a->nname = my_strdup(ui->rootdir); - a->aname = p; - a->dir = 1; - if (ui->volflags < 0) { - write_log(_T("FS: Volume '%s' ('%s') missing!\n"), a->aname, a->nname); - } - else { - a->volflags = ui->volflags; - recycle_aino(u, a); - write_log(_T("FS: Lock (root) '%s' ('%s')\n"), a->aname, a->nname); - } - return src; - } - p2 = _tcsrchr(p, '/'); - if (p2) - p2++; - else - p2 = p; - pn = makenativepath(ui, p); - a->nname = pn; - a->aname = my_strdup(p2); + a->uniq_external = restore_u64 (); + /* full Amiga-side path without drive, eg. "C/SetPatch" */ + p = restore_string (); + /* root (p = volume label) */ + if (a->uniq == 0) { + a->nname = my_strdup(ui->rootdir); + a->aname = p; + a->dir = 1; + if (ui->volflags < 0) { + write_log (_T("FS: Volume '%s' ('%s') missing!\n"), a->aname, a->nname); + } else { + a->volflags = ui->volflags; + recycle_aino (u, a); + write_log (_T("FS: Lock (root) '%s' ('%s')\n"), a->aname, a->nname); + } + return src; + } + p2 = _tcsrchr(p, '/'); + if (p2) + p2++; + else + p2 = p; + pn = makenativepath(ui, p); + a->nname = pn; + a->aname = my_strdup(p2); /* create path to parent dir */ - if (p2 != p) + if (p2 != p) p2[0] = 0; - /* find parent of a->aname (Already restored previously. I hope..) */ - base = restore_filesys_get_base(u, p); - xfree(p); - if (flags & 2) { - a->dir = 1; - if (!my_existsdir(a->nname)) - write_log(_T("*** FS: Directory '%s' missing!\n"), a->nname); - else - fsdb_clean_dir(a); - } - else { - if (!my_existsfile(a->nname)) - write_log(_T("*** FS: File '%s' missing!\n"), a->nname); - } - if (base) { - fill_file_attrs(u, base, a); - init_child_aino_tree(u, base, a); - } - else { - write_log(_T("*** FS: parent directory missing '%s' ('%s')\n"), a->aname, a->nname); - missing = 1; - } - if (missing) { - write_log(_T("*** FS: Lock restore failed '%s' ('%s')\n"), a->aname, a->nname); - xfree(a->nname); - xfree(a->aname); - xfree(a); - } - else { - write_log(_T("FS: Lock '%s' ('%s')\n"), a->aname, a->nname); - recycle_aino(u, a); - } - return src; + /* find parent of a->aname (Already restored previously. I hope..) */ + base = restore_filesys_get_base(u, p); + xfree(p); + if (flags & 2) { + a->dir = 1; + if (!my_existsdir(a->nname)) + write_log (_T("*** FS: Directory '%s' missing!\n"), a->nname); + else + fsdb_clean_dir (a); + } else { + if (!my_existsfile(a->nname)) + write_log (_T("*** FS: File '%s' missing!\n"), a->nname); + } + if (base) { + fill_file_attrs (u, base, a); + init_child_aino_tree (u, base, a); + } else { + write_log (_T("*** FS: parent directory missing '%s' ('%s')\n"), a->aname, a->nname); + missing = 1; + } + if (missing) { + write_log (_T("*** FS: Lock restore failed '%s' ('%s')\n"), a->aname, a->nname); + xfree (a->nname); + xfree (a->aname); + xfree (a); + } else { + write_log (_T("FS: Lock '%s' ('%s')\n"), a->aname, a->nname); + recycle_aino (u, a); + } + return src; } static uae_u8 *restore_key(UnitInfo *ui, Unit *u, uae_u8 *src) { - int uniq; - TCHAR *p, *pn; - mode_t openmode; - int err; - int missing; - a_inode *a; - Key *k; + int uniq; + TCHAR *p, *pn; + mode_t openmode; + int err; + int missing; + a_inode *a; + Key *k; uae_u64 savedsize, size, pos; - missing = 0; - k = xcalloc(Key, 1); - k->uniq = restore_u64(); - k->file_pos = restore_u32(); - k->createmode = restore_u32(); - k->dosmode = restore_u32(); - savedsize = restore_u32(); - uniq = restore_u64(); - p = restore_string(); - pos = restore_u64(); - size = restore_u64(); + missing = 0; + k = xcalloc(Key, 1); + k->uniq = restore_u64(); + k->file_pos = restore_u32(); + k->createmode = restore_u32(); + k->dosmode = restore_u32(); + savedsize = restore_u32(); + uniq = restore_u64(); + p = restore_string(); + pos = restore_u64 (); + size = restore_u64 (); if (size) { savedsize = size; k->file_pos = pos; } - pn = makenativepath(ui, p); - openmode = ((k->dosmode & A_FIBF_READ) == 0 ? O_WRONLY - : (k->dosmode & A_FIBF_WRITE) == 0 ? O_RDONLY - : O_RDWR); - write_log(_T("FS: open file '%s' ('%s'), pos=%llu\n"), p, pn, k->file_pos); - a = get_aino(u, &u->rootnode, p, &err); - if (!a) - write_log(_T("*** FS: Open file aino creation failed '%s'\n"), p); - missing = 1; - if (a) { - missing = 0; - k->aino = a; - if (a->uniq != uniq) - write_log(_T("*** FS: Open file '%s' aino id %d != %d\n"), p, uniq, a->uniq); - if (!my_existsfile(pn)) { - write_log(_T("*** FS: Open file '%s' is missing, creating dummy file!\n"), p); + pn = makenativepath (ui, p); + openmode = ((k->dosmode & A_FIBF_READ) == 0 ? O_WRONLY + : (k->dosmode & A_FIBF_WRITE) == 0 ? O_RDONLY + : O_RDWR); + write_log (_T("FS: open file '%s' ('%s'), pos=%llu\n"), p, pn, k->file_pos); + a = get_aino (u, &u->rootnode, p, &err); + if (!a) + write_log (_T("*** FS: Open file aino creation failed '%s'\n"), p); + missing = 1; + if (a) { + missing = 0; + k->aino = a; + if (a->uniq != uniq) + write_log (_T("*** FS: Open file '%s' aino id %d != %d\n"), p, uniq, a->uniq); + if (!my_existsfile(pn)) { + write_log(_T("*** FS: Open file '%s' is missing, creating dummy file!\n"), p); if (savedsize < 10 * 1024 * 1024) { - k->fd = fs_openfile(u, a, openmode | O_CREAT | O_BINARY); - if (k->fd) { - uae_u8 *buf = xcalloc(uae_u8, 10000); + k->fd = fs_openfile (u, a, openmode | O_CREAT |O_BINARY); + if (k->fd) { + uae_u8 *buf = xcalloc (uae_u8, 10000); uae_u64 sp = savedsize; - while (sp) { + while (sp) { uae_u32 s = sp >= 10000 ? 10000 : sp; - fs_write(k->fd, buf, s); - sp -= s; - } - xfree(buf); - write_log(_T("*** FS: dummy file created\n")); - } - else { - write_log(_T("*** FS: Open file '%s', couldn't create dummy file!\n"), p); - } - } - else { - write_log(_T("*** FS: Too big, ignored\n")); - } - } - else { - k->fd = fs_openfile(u, a, openmode | O_BINARY); - } - if (!k->fd) { - write_log(_T("*** FS: Open file '%s' failed to open!\n"), p); - missing = 1; - } - else { - uae_s64 s; + fs_write(k->fd, buf, s); + sp -= s; + } + xfree(buf); + write_log (_T("*** FS: dummy file created\n")); + } else { + write_log (_T("*** FS: Open file '%s', couldn't create dummy file!\n"), p); + } + } else { + write_log (_T("*** FS: Too big, ignored\n")); + } + } else { + k->fd = fs_openfile (u, a, openmode | O_BINARY); + } + if (!k->fd) { + write_log (_T("*** FS: Open file '%s' failed to open!\n"), p); + missing = 1; + } else { + uae_s64 s; s = key_filesize(k); - 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; - } + 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); - } - } - xfree(p); - if (missing) { - xfree(k); - } - else { - k->next = u->keys; - u->keys = k; - } - return src; + } + } + xfree (p); + if (missing) { + xfree(k); + } else { + k->next = u->keys; + u->keys = k; + } + return src; } static uae_u8 *restore_notify(UnitInfo *ui, Unit *u, uae_u8 *src) { - Notify *n = xcalloc(Notify, 1); - uae_u32 hash; - TCHAR *s; + Notify *n = xcalloc (Notify, 1); + uae_u32 hash; + TCHAR *s; - n->notifyrequest = restore_u32(); - s = restore_string(); - n->fullname = xmalloc(TCHAR, _tcslen(ui->volname) + 2 + _tcslen(s) + 1); - _stprintf(n->fullname, _T("%s:%s"), ui->volname, s); - xfree(s); - s = _tcsrchr(n->fullname, '/'); - if (s) - s++; - else - s = n->fullname; - n->partname = my_strdup(s); - hash = notifyhash(n->fullname); - n->next = u->notifyhash[hash]; - u->notifyhash[hash] = n; - write_log(_T("FS: notify %08X '%s' '%s'\n"), n->notifyrequest, n->fullname, n->partname); - return src; + n->notifyrequest = restore_u32(); + s = restore_string(); + n->fullname = xmalloc (TCHAR, _tcslen (ui->volname) + 2 + _tcslen (s) + 1); + _stprintf (n->fullname, _T("%s:%s"), ui->volname, s); + xfree(s); + s = _tcsrchr (n->fullname, '/'); + if (s) + s++; + else + s = n->fullname; + n->partname = my_strdup(s); + hash = notifyhash (n->fullname); + n->next = u->notifyhash[hash]; + u->notifyhash[hash] = n; + write_log (_T("FS: notify %08X '%s' '%s'\n"), n->notifyrequest, n->fullname, n->partname); + return src; } static uae_u8 *restore_exkey(UnitInfo *ui, Unit *u, uae_u8 *src) { - restore_u64(); - restore_u64(); - restore_u64(); - return src; + restore_u64(); + restore_u64(); + restore_u64(); + return src; } -static uae_u8 *restore_filesys_virtual(UnitInfo *ui, uae_u8 *src, int num) +static uae_u8 *restore_filesys_virtual (UnitInfo *ui, uae_u8 *src, int num) { - Unit *u = startup_create_unit(NULL, ui, num); - int cnt; + Unit *u = startup_create_unit (NULL, ui, num); + int cnt; - u->dosbase = restore_u32(); - u->volume = restore_u32(); - u->port = restore_u32(); - u->locklist = restore_u32(); - u->dummy_message = restore_u32(); - u->cmds_sent = restore_u64(); - u->cmds_complete = restore_u64(); - u->cmds_acked = restore_u64(); - u->next_exkey = restore_u32(); - u->total_locked_ainos = restore_u32(); - u->volflags = ui->volflags; + u->dosbase = restore_u32 (); + u->volume = restore_u32 (); + u->port = restore_u32 (); + u->locklist = restore_u32 (); + u->dummy_message = restore_u32 (); + u->cmds_sent = restore_u64 (); + u->cmds_complete = restore_u64 (); + u->cmds_acked = restore_u64 (); + u->next_exkey = restore_u32 (); + u->total_locked_ainos = restore_u32 (); + u->volflags = ui->volflags; - cnt = restore_u32(); - write_log(_T("FS: restoring %d locks\n"), cnt); - while (cnt-- > 0) - src = restore_aino(ui, u, src); + cnt = restore_u32 (); + write_log (_T("FS: restoring %d locks\n"), cnt); + while (cnt-- > 0) + src = restore_aino(ui, u, src); - cnt = restore_u32(); - write_log(_T("FS: restoring %d open files\n"), cnt); - while (cnt-- > 0) - src = restore_key(ui, u, src); + cnt = restore_u32 (); + write_log (_T("FS: restoring %d open files\n"), cnt); + while (cnt-- > 0) + src = restore_key(ui, u, src); - cnt = restore_u32(); - write_log(_T("FS: restoring %d notifications\n"), cnt); - while (cnt-- > 0) - src = restore_notify(ui, u, src); + cnt = restore_u32 (); + write_log (_T("FS: restoring %d notifications\n"), cnt); + while (cnt-- > 0) + src = restore_notify (ui, u, src); - cnt = restore_u32(); - write_log(_T("FS: restoring %d exkeys\n"), cnt); - while (cnt-- > 0) - src = restore_exkey(ui, u, src); + cnt = restore_u32 (); + write_log (_T("FS: restoring %d exkeys\n"), cnt); + while (cnt-- > 0) + src = restore_exkey (ui, u, src); - return src; + return src; } static TCHAR *getfullaname(a_inode *a) { - TCHAR *p; - int first = 1; + TCHAR *p; + int first = 1; - p = xcalloc(TCHAR, MAX_DPATH); - while (a) { - int len = _tcslen(a->aname); - memmove(p + len + 1, p, (_tcslen(p) + 1) * sizeof(TCHAR)); - memcpy(p, a->aname, len * sizeof(TCHAR)); - if (!first) - p[len] = '/'; - first = 0; - a = a->parent; - if (a && a->uniq == 0) - return p; - } - return p; + p = xcalloc (TCHAR, MAX_DPATH); + while (a) { + int len = _tcslen (a->aname); + memmove (p + len + 1, p, (_tcslen (p) + 1) * sizeof (TCHAR)); + memcpy (p, a->aname, len * sizeof (TCHAR)); + if (!first) + p[len] = '/'; + first = 0; + a = a->parent; + if (a && a->uniq == 0) + return p; + } + return p; } /* scan and save all Lock()'d files */ -static int recurse_aino(UnitInfo *ui, a_inode *a, int cnt, uae_u8 **dstp) +static int recurse_aino (UnitInfo *ui, a_inode *a, int cnt, uae_u8 **dstp) { - uae_u8 *dst = NULL; - int dirty = 0; - a_inode *a2 = a; + uae_u8 *dst = NULL; + int dirty = 0; + a_inode *a2 = a; - if (dstp) - dst = *dstp; - while (a) { + if (dstp) + dst = *dstp; + while (a) { //write_log("recurse '%s' '%s' %d %08x\n", a->aname, a->nname, a->uniq, a->parent); - if (a->elock || a->shlock || a->uniq == 0) { - if (dst) { - TCHAR *fn = NULL; - write_log(_T("uniq=%d %lld s=%d e=%d d=%d '%s' '%s'\n"), a->uniq, a->uniq_external, a->shlock, a->elock, a->dir, a->aname, a->nname); + if (a->elock || a->shlock || a->uniq == 0) { + if (dst) { + TCHAR *fn = NULL; + write_log (_T("uniq=%d %lld s=%d e=%d d=%d '%s' '%s'\n"), a->uniq, a->uniq_external, a->shlock, a->elock, a->dir, a->aname, a->nname); if (a->aname) { - fn = getfullaname(a); - write_log(_T("->'%s'\n"), fn); + fn = getfullaname(a); + write_log (_T("->'%s'\n"), fn); } - save_u64(a->uniq); - save_u32(a->locked_children); - save_u32(a->exnext_count); - save_u32(a->shlock); - save_u32((a->elock ? 1 : 0) | (a->dir ? 2 : 0) | 4); - save_u64(a->uniq_external); - save_string(fn); - xfree(fn); - } - cnt++; - } - if (a->dirty) - dirty = 1; - if (a->child) - cnt = recurse_aino(ui, a->child, cnt, &dst); - a = a->sibling; - } - if (dirty && a2->parent) - fsdb_dir_writeback(a2->parent); - if (dst) - *dstp = dst; - return cnt; + save_u64 (a->uniq); + save_u32 (a->locked_children); + save_u32 (a->exnext_count); + save_u32 (a->shlock); + save_u32 ((a->elock ? 1 : 0) | (a->dir ? 2 : 0) | 4); + save_u64 (a->uniq_external); + save_string (fn); + xfree(fn); + } + cnt++; + } + if (a->dirty) + dirty = 1; + if (a->child) + cnt = recurse_aino (ui, a->child, cnt, &dst); + a = a->sibling; + } + if (dirty && a2->parent) + fsdb_dir_writeback (a2->parent); + if (dst) + *dstp = dst; + return cnt; } static uae_u8 *save_key(uae_u8 *dst, Key *k) { - TCHAR *fn = getfullaname(k->aino); - uae_u64 size; - save_u64(k->uniq); - save_u32((uae_u32)k->file_pos); - save_u32(k->createmode); - save_u32(k->dosmode); - size = fs_fsize(k->fd); - save_u32((uae_u32)size); - save_u64(k->aino->uniq); - save_string(fn); - save_u64(k->file_pos); - save_u64(size); - write_log(_T("'%s' uniq=%d size=%lld seekpos=%lld mode=%d dosmode=%d\n"), - fn, k->uniq, size, k->file_pos, k->createmode, k->dosmode); - xfree(fn); - return dst; + TCHAR *fn = getfullaname(k->aino); + uae_u64 size; + save_u64 (k->uniq); + save_u32 ((uae_u32)k->file_pos); + save_u32 (k->createmode); + save_u32 (k->dosmode); + size = fs_fsize (k->fd); + save_u32 ((uae_u32)size); + save_u64 (k->aino->uniq); + save_string (fn); + save_u64 (k->file_pos); + save_u64 (size); + write_log (_T("'%s' uniq=%d size=%lld seekpos=%lld mode=%d dosmode=%d\n"), + fn, k->uniq, size, k->file_pos, k->createmode, k->dosmode); + xfree(fn); + return dst; } -static uae_u8 *save_notify(UnitInfo *ui, uae_u8 *dst, Notify *n) +static uae_u8 *save_notify (UnitInfo *ui, uae_u8 *dst, Notify *n) { - TCHAR *s; - save_u32(n->notifyrequest); - s = n->fullname; - if (_tcslen(s) >= _tcslen(ui->volname) && !_tcsncmp(n->fullname, ui->volname, _tcslen(ui->volname))) - s = n->fullname + _tcslen(ui->volname) + 1; - save_string(s); - write_log(_T("FS: notify %08X '%s'\n"), n->notifyrequest, n->fullname); - return dst; + TCHAR *s; + save_u32(n->notifyrequest); + s = n->fullname; + if (_tcslen (s) >= _tcslen (ui->volname) && !_tcsncmp (n->fullname, ui->volname, _tcslen (ui->volname))) + s = n->fullname + _tcslen (ui->volname) + 1; + save_string(s); + write_log (_T("FS: notify %08X '%s'\n"), n->notifyrequest, n->fullname); + return dst; } -static uae_u8 *save_exkey(uae_u8 *dst, ExamineKey *ek) +static uae_u8 *save_exkey (uae_u8 *dst, ExamineKey *ek) { - save_u64(ek->uniq); - save_u64(ek->aino->uniq); - save_u64(ek->curr_file->uniq); - return dst; + save_u64(ek->uniq); + save_u64(ek->aino->uniq); + save_u64(ek->curr_file->uniq); + return dst; } -static uae_u8 *save_filesys_virtual(UnitInfo *ui, uae_u8 *dst) +static uae_u8 *save_filesys_virtual (UnitInfo *ui, uae_u8 *dst) { - Unit *u = ui->self; - Key *k; - int cnt, i, j; + Unit *u = ui->self; + Key *k; + int cnt, i, j; - write_log(_T("FSSAVE: '%s'\n"), ui->devname); - save_u32(u->dosbase); - save_u32(u->volume); - save_u32(u->port); - save_u32(u->locklist); - save_u32(u->dummy_message); - save_u64(u->cmds_sent); - save_u64(u->cmds_complete); - save_u64(u->cmds_acked); - save_u32(u->next_exkey); - save_u32(u->total_locked_ainos); - cnt = recurse_aino(ui, &u->rootnode, 0, NULL); - save_u32(cnt); - write_log(_T("%d open locks\n"), cnt); - cnt = recurse_aino(ui, &u->rootnode, 0, &dst); - cnt = 0; - for (k = u->keys; k; k = k->next) - cnt++; - save_u32(cnt); - write_log(_T("%d open files\n"), cnt); - for (k = u->keys; k; k = k->next) - dst = save_key(dst, k); - for (j = 0; j < 2; j++) { - cnt = 0; - for (i = 0; i < NOTIFY_HASH_SIZE; i++) { - Notify *n = u->notifyhash[i]; - while (n) { - if (j > 0) - dst = save_notify(ui, dst, n); - cnt++; - n = n->next; - } - } - if (j == 0) { - save_u32(cnt); - write_log(_T("%d notify requests\n"), cnt); - } - } - for (j = 0; j < 2; j++) { - cnt = 0; - for (i = 0; i < EXKEYS; i++) { - ExamineKey *ek = &u->examine_keys[i]; - if (ek->uniq) { - cnt++; - if (j > 0) - dst = save_exkey(dst, ek); - } - } - if (j == 0) { - save_u32(cnt); - write_log(_T("%d exkeys\n"), cnt); - } - } - write_log(_T("END\n")); - return dst; + write_log (_T("FSSAVE: '%s'\n"), ui->devname); + save_u32 (u->dosbase); + save_u32 (u->volume); + save_u32 (u->port); + save_u32 (u->locklist); + save_u32 (u->dummy_message); + save_u64 (u->cmds_sent); + save_u64 (u->cmds_complete); + save_u64 (u->cmds_acked); + save_u32 (u->next_exkey); + save_u32 (u->total_locked_ainos); + cnt = recurse_aino (ui, &u->rootnode, 0, NULL); + save_u32 (cnt); + write_log (_T("%d open locks\n"), cnt); + cnt = recurse_aino (ui, &u->rootnode, 0, &dst); + cnt = 0; + for (k = u->keys; k; k = k->next) + cnt++; + save_u32 (cnt); + write_log (_T("%d open files\n"), cnt); + for (k = u->keys; k; k = k->next) + dst = save_key (dst, k); + for (j = 0; j < 2; j++) { + cnt = 0; + for (i = 0; i < NOTIFY_HASH_SIZE; i++) { + Notify *n = u->notifyhash[i]; + while (n) { + if (j > 0) + dst = save_notify (ui, dst, n); + cnt++; + n = n->next; + } + } + if (j == 0) { + save_u32 (cnt); + write_log (_T("%d notify requests\n"), cnt); + } + } + for (j = 0; j < 2; j++) { + cnt = 0; + for (i = 0; i < EXKEYS; i++) { + ExamineKey *ek = &u->examine_keys[i]; + if (ek->uniq) { + cnt++; + if (j > 0) + dst = save_exkey (dst, ek); + } + } + if (j == 0) { + save_u32 (cnt); + write_log (_T("%d exkeys\n"), cnt); + } + } + write_log (_T("END\n")); + return dst; } -uae_u8 *save_filesys_common(int *len) +uae_u8 *save_filesys_common (int *len) { - uae_u8 *dstbak, *dst; - if (nr_units() == 0) - return NULL; - dstbak = dst = xmalloc(uae_u8, 1000); - save_u32(2); - save_u64(a_uniq); - save_u64(key_uniq); - *len = dst - dstbak; - return dstbak; + uae_u8 *dstbak, *dst; + if (nr_units() == 0) + return NULL; + dstbak = dst = xmalloc (uae_u8, 1000); + save_u32 (2); + save_u64 (a_uniq); + save_u64 (key_uniq); + *len = dst - dstbak; + return dstbak; } -uae_u8 *restore_filesys_common(uae_u8 *src) +uae_u8 *restore_filesys_common (uae_u8 *src) { - if (restore_u32() != 2) - return src; - filesys_prepare_reset2(); - filesys_reset2(); - a_uniq = restore_u64(); - key_uniq = restore_u64(); - return src; + if (restore_u32 () != 2) + return src; + filesys_prepare_reset2 (); + filesys_reset2 (); + a_uniq = restore_u64 (); + key_uniq = restore_u64 (); + return src; } -uae_u8 *save_filesys(int num, int *len) +uae_u8 *save_filesys (int num, int *len) { - uae_u8 *dstbak, *dst; - UnitInfo *ui; - int type = is_hardfile(num); + uae_u8 *dstbak, *dst; + UnitInfo *ui; + int type = is_hardfile (num); - ui = &mountinfo.ui[num]; + ui = &mountinfo.ui[num]; if (ui->open <= 0) - return NULL; - /* not initialized yet, do not save */ + return NULL; + /* not initialized yet, do not save */ if ((type == FILESYS_VIRTUAL) && ui->self == NULL) - return NULL; - write_log(_T("FS_FILESYS: '%s' '%s'\n"), ui->devname, ui->volname ? ui->volname : _T("")); - dstbak = dst = xmalloc(uae_u8, 100000); - save_u32(2); /* version */ - save_u32(ui->devno); - save_u16(type); + return NULL; + write_log (_T("FS_FILESYS: '%s' '%s'\n"), ui->devname, ui->volname ? ui->volname : _T("")); + dstbak = dst = xmalloc (uae_u8, 100000); + save_u32 (2); /* version */ + save_u32 (ui->devno); + save_u16 (type); if (type == FILESYS_VIRTUAL) - save_path(ui->rootdir, SAVESTATE_PATH_VDIR); + save_path (ui->rootdir, SAVESTATE_PATH_VDIR); else if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB) - save_path(ui->rootdir, SAVESTATE_PATH_HDF); + save_path (ui->rootdir, SAVESTATE_PATH_HDF); else - save_path(ui->rootdir, SAVESTATE_PATH); - save_string(ui->devname); - save_string(ui->volname); - save_path(ui->filesysdir, SAVESTATE_PATH); - save_u8(ui->bootpri); - save_u8(ui->readonly); - save_u32(ui->startup); - save_u32(filesys_configdev); - if (type == FILESYS_VIRTUAL) - dst = save_filesys_virtual(ui, dst); - if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB) - dst = save_filesys_hardfile(ui, dst); - *len = dst - dstbak; - return dstbak; + save_path (ui->rootdir, SAVESTATE_PATH); + save_string (ui->devname); + save_string (ui->volname); + save_path (ui->filesysdir, SAVESTATE_PATH); + save_u8 (ui->bootpri); + save_u8 (ui->readonly); + save_u32 (ui->startup); + save_u32 (filesys_configdev); + if (type == FILESYS_VIRTUAL) + dst = save_filesys_virtual (ui, dst); + if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB) + dst = save_filesys_hardfile (ui, dst); + *len = dst - dstbak; + return dstbak; } -uae_u8 *restore_filesys(uae_u8 *src) +uae_u8 *restore_filesys (uae_u8 *src) { - int type, devno; - UnitInfo *ui; - TCHAR *devname = 0, *volname = 0, *rootdir = 0, *filesysdir = 0; + int type, devno; + UnitInfo *ui; + TCHAR *devname = 0, *volname = 0, *rootdir = 0, *filesysdir = 0; uae_u32 startup; struct uaedev_config_info *ci; - if (restore_u32() != 2) - return src; - devno = restore_u32(); + if (restore_u32 () != 2) + return src; + devno = restore_u32 (); ui = &mountinfo.ui[devno]; ci = &ui->hf.ci; - uci_set_defaults(ci, false); - type = restore_u16(); + uci_set_defaults (ci, false); + type = restore_u16 (); if (type == FILESYS_VIRTUAL) { - rootdir = restore_path(SAVESTATE_PATH_VDIR); - } - else if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB) { - rootdir = restore_path(SAVESTATE_PATH_HDF); - } - else { - rootdir = restore_path(SAVESTATE_PATH); - } - devname = restore_string(); - volname = restore_string(); - filesysdir = restore_path(SAVESTATE_PATH); - ci->bootpri = restore_u8(); - ci->readonly = restore_u8() != 0; - startup = restore_u32(); - filesys_configdev = restore_u32(); + rootdir = restore_path (SAVESTATE_PATH_VDIR); + } else if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB) { + rootdir = restore_path (SAVESTATE_PATH_HDF); + } else { + rootdir = restore_path (SAVESTATE_PATH); + } + devname = restore_string (); + volname = restore_string (); + filesysdir = restore_path (SAVESTATE_PATH); + ci->bootpri = restore_u8 (); + ci->readonly = restore_u8 () != 0; + startup = restore_u32 (); + filesys_configdev = restore_u32 (); if (type == FILESYS_HARDFILE || type == FILESYS_HARDFILE_RDB) { - src = restore_filesys_hardfile(ui, src); - xfree(volname); - volname = NULL; - } - _tcscpy(ci->rootdir, rootdir); - _tcscpy(ci->devname, devname); - _tcscpy(ci->volname, volname ? volname : _T("")); - _tcscpy(ci->filesys, filesysdir); + src = restore_filesys_hardfile(ui, src); + xfree (volname); + volname = NULL; + } + _tcscpy (ci->rootdir, rootdir); + _tcscpy (ci->devname, devname); + _tcscpy (ci->volname, volname ? volname : _T("")); + _tcscpy (ci->filesys, filesysdir); - if (set_filesys_unit(devno, ci) < 0) { - write_log(_T("filesys '%s' failed to restore\n"), rootdir); - goto end; - } + if (set_filesys_unit (devno, ci) < 0) { + write_log (_T("filesys '%s' failed to restore\n"), rootdir); + goto end; + } ui->devno = devno; ui->startup = startup; - if (type == FILESYS_VIRTUAL) - src = restore_filesys_virtual(ui, src, devno); - write_log(_T("'%s' restored\n"), rootdir); + if (type == FILESYS_VIRTUAL) + src = restore_filesys_virtual (ui, src, devno); + write_log (_T("'%s' restored\n"), rootdir); end: - xfree(rootdir); - xfree(devname); - xfree(volname); - xfree(filesysdir); - return src; + xfree (rootdir); + xfree (devname); + xfree (volname); + xfree (filesysdir); + return src; } int save_filesys_cando(void) { - if (nr_units() == 0) - return -1; - return filesys_in_interrupt ? 0 : 1; + if (nr_units() == 0) + return -1; + return filesys_in_interrupt ? 0 : 1; } diff --git a/src/filesys.sh b/src/filesys.sh new file mode 100644 index 00000000..e07c14ac --- /dev/null +++ b/src/filesys.sh @@ -0,0 +1,14 @@ +#! /bin/sh +# Script to convert an Amiga executable named filesys into a series of +# dw(...) statements. +# This assumes that the first four lines only contain hunk information. +# +# Befehle auf der Amigaseite mit HD0: +# DH0: +# cd asm +# PhxAss/PhxAss filesys.asm TO fs.out OPT 0 +# blink FROM fs.out TO filesys +# delete fs.out +# +# That is what you get if you assemble/link with a68k/blink +od -v -t xC -w8 filesys |tail -n +5 | sed -e "s,^.......,," -e "s,[0123456789abcdefABCDEF][0123456789abcdefABCDEF],db(0x&);,g" > filesys_bootrom.cpp diff --git a/src/fsdb.cpp b/src/fsdb.cpp index 680c5743..4c081a0c 100644 --- a/src/fsdb.cpp +++ b/src/fsdb.cpp @@ -45,7 +45,7 @@ TCHAR *nname_begin (TCHAR *nname) return nname; } -#ifndef _WIN32_ +#ifndef _WIN32 /* Find the name REL in directory DIRNAME. If we find a file that * has exactly the same name, return REL. If we find a file that * has the same name when compared case-insensitively, return a diff --git a/src/fsdb_unix.cpp b/src/fsdb_unix.cpp index 49c89bd3..1f4a4412 100644 --- a/src/fsdb_unix.cpp +++ b/src/fsdb_unix.cpp @@ -85,8 +85,9 @@ int fsdb_fill_file_attrs (a_inode *base, a_inode *aino) | (S_IWUSR & statbuf.st_mode ? 0 : A_FIBF_WRITE) | (S_IRUSR & statbuf.st_mode ? 0 : A_FIBF_READ)); -#if defined(WIN32) || defined(ANDROIDSDL) +#if defined(WIN32) || defined(ANDROIDSDL) || defined(RASPBERRY) // Always give execute & read permission + // Temporary do this for raspberry... aino->amigaos_mode &= ~A_FIBF_EXECUTE; aino->amigaos_mode &= ~A_FIBF_READ; #endif diff --git a/src/include/bsdsocket.h b/src/include/bsdsocket.h index 61e0f368..a8783bdb 100644 --- a/src/include/bsdsocket.h +++ b/src/include/bsdsocket.h @@ -29,7 +29,7 @@ extern void deinit_socket_layer (void); #define MAXADDRLEN 256 -#ifdef _WIN32_ +#ifdef _WIN32 #define SOCKET_TYPE SOCKET #else #define SOCKET_TYPE int @@ -70,7 +70,7 @@ struct socketbase { unsigned int *mtable; /* window messages allocated for asynchronous event notification */ /* host-specific fields below */ -#ifdef _WIN32_ +#ifdef _WIN32 SOCKET_TYPE sockAbort; /* for aborting WinSock2 select() (damn Microsoft) */ SOCKET_TYPE sockAsync; /* for aborting WSBAsyncSelect() in window message handler */ int needAbort; /* abort flag */ diff --git a/src/include/clipboard.h b/src/include/clipboard.h deleted file mode 100644 index d2b3994a..00000000 --- a/src/include/clipboard.h +++ /dev/null @@ -1,9 +0,0 @@ - -extern int amiga_clipboard_want_data (void); -extern void amiga_clipboard_got_data (uaecptr data, uae_u32 size, uae_u32 actual); -extern void amiga_clipboard_die (void); -extern void amiga_clipboard_init (void); -extern uaecptr amiga_clipboard_proc_start (void); -extern void amiga_clipboard_task_start (uaecptr); -extern void clipboard_disable (bool); -extern void clipboard_vsync (void); \ No newline at end of file diff --git a/src/include/debug.h b/src/include/debug.h deleted file mode 100644 index 2048d2ad..00000000 --- a/src/include/debug.h +++ /dev/null @@ -1,53 +0,0 @@ - /* - * NO Debugger - */ - -#ifndef DEBUG_H -#define DEBUG_H - -#if defined(DEBUG) && DEBUG -#define DUNUSED(x) -#else -#define DUNUSED(x) ((void)x) -#endif -#ifndef UNUSED -#define UNUSED(x) ((void)x) -#endif - -/* - * debug.h - Debugging utilities - * - * Basilisk II (C) 1997-2000 Christian Bauer - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define bug printf -#define panicbug printf - -#if defined(DEBUG) && DEBUG -#define D(x) (x); -#else -#define D(x) ; -#endif - -#if defined(DEBUG) && DEBUG > 1 -#define D2(x) (x); -#else -#define D2(x) ; -#endif - -#define infoprint bug -#endif diff --git a/src/include/drawing.h b/src/include/drawing.h index acfe7861..6e263cbc 100644 --- a/src/include/drawing.h +++ b/src/include/drawing.h @@ -106,19 +106,11 @@ STATIC_INLINE uae_u16 CONVERT_RGB_16(uae_u32 c) return ret; } #else -/* warning: this is still ugly, but now works with either byte order */ -#ifdef WORDS_BIGENDIAN -# define CONVERT_RGB(c) \ - ( xbluecolors[((uae_u8*)(&c))[3]] | xgreencolors[((uae_u8*)(&c))[2]] | xredcolors[((uae_u8*)(&c))[1]] ) -# define CONVERT_RGB_16(c) \ - ( xbluecolors[((uae_u8*)(&c))[3]] | xgreencolors[((uae_u8*)(&c))[2]] | xredcolors[((uae_u8*)(&c))[1]] ) -#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]] ) #endif -#endif STATIC_INLINE xcolnr getxcolor (int c) { @@ -240,7 +232,6 @@ 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 partial_draw_frame(void); extern void halt_draw_frame(void); extern void vsync_handle_redraw (void); extern bool vsync_handle_check (void); diff --git a/src/include/ersatz.h b/src/include/ersatz.h deleted file mode 100644 index 2833e4ba..00000000 --- a/src/include/ersatz.h +++ /dev/null @@ -1,12 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * A "replacement" for a missing Kickstart - * - * (c) 1995 Bernd Schmidt - */ - -extern void init_ersatz_rom (uae_u8 *data); -extern void ersatz_chipcopy (void); -extern void ersatz_perform (uae_u16); -extern void DISK_ersatz_read (int,int, uaecptr); diff --git a/src/include/fpp-ieee-be.h b/src/include/fpp-ieee-be.h deleted file mode 100644 index 81e67b7b..00000000 --- a/src/include/fpp-ieee-be.h +++ /dev/null @@ -1,64 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * MC68881 emulation - * Support functions for IEEE compatible host CPUs. - * These functions use a GCC extension (type punning through unions) and - * should only be compiled with compilers that support this. - * - * Copyright 1999 Sam Jordan - */ - -STATIC_INLINE double to_single (uae_u32 value) -{ - union { - float f; - uae_u32 u; - } val; - - val.u = value; - return val.f; -} - -STATIC_INLINE uae_u32 from_single (double src) -{ - union { - float f; - uae_u32 u; - } val; - - val.f = src; - return val.u; -} - -STATIC_INLINE double to_double(uae_u32 wrd1, uae_u32 wrd2) -{ - union { - double d; - uae_u32 u[2]; - } val; - - val.u[0] = wrd1; - val.u[1] = wrd2; - return val.d; -} - -STATIC_INLINE void from_double(double src, uae_u32 * wrd1, uae_u32 * wrd2) -{ - union { - double d; - uae_u32 u[2]; - } val; - - val.d = src; - *wrd1 = val.u[0]; - *wrd2 = val.u[1]; -} - -#define HAVE_from_double -#define HAVE_to_double -#define HAVE_from_single -#define HAVE_to_single - -/* Get the rest of the conversion functions defined. */ -#include "fpp-unknown.h" diff --git a/src/include/fpp-unknown.h b/src/include/fpp-unknown.h deleted file mode 100644 index 26d5e1ff..00000000 --- a/src/include/fpp-unknown.h +++ /dev/null @@ -1,139 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * MC68881 emulation - * - * Conversion routines for hosts with unknown floating point format. - * - * Copyright 1996 Herman ten Brugge - */ - -#ifndef HAVE_to_single -STATIC_INLINE double to_single (uae_u32 value) -{ - double frac; - - if ((value & 0x7fffffff) == 0) - return (0.0); - frac = (double) ((value & 0x7fffff) | 0x800000) / 8388608.0; - if (value & 0x80000000) - frac = -frac; - return (ldexp (frac, ((value >> 23) & 0xff) - 127)); -} -#endif - -#ifndef HAVE_from_single -STATIC_INLINE uae_u32 from_single (double src) -{ - int expon; - uae_u32 tmp; - double frac; - - if (src == 0.0) - return 0; - if (src < 0) { - tmp = 0x80000000; - src = -src; - } else { - tmp = 0; - } - frac = frexp (src, &expon); - frac += 0.5 / 16777216.0; - if (frac >= 1.0) { - frac /= 2.0; - expon++; - } - return (tmp | (((expon + 127 - 1) & 0xff) << 23) | - (((int) (frac * 16777216.0)) & 0x7fffff)); -} -#endif - -#ifndef HAVE_to_exten -STATIC_INLINE double to_exten(uae_u32 wrd1, uae_u32 wrd2, uae_u32 wrd3) -{ - double frac; - - if ((wrd1 & 0x7fff0000) == 0 && wrd2 == 0 && wrd3 == 0) - return 0.0; - frac = (double) wrd2 / 2147483648.0 + - (double) wrd3 / 9223372036854775808.0; - if (wrd1 & 0x80000000) - frac = -frac; - return ldexp (frac, ((wrd1 >> 16) & 0x7fff) - 16383); -} -#endif - -#ifndef HAVE_from_exten -STATIC_INLINE void from_exten(double src, uae_u32 * wrd1, uae_u32 * wrd2, uae_u32 * wrd3) -{ - int expon; - double frac; - - if (src == 0.0) { - *wrd1 = 0; - *wrd2 = 0; - *wrd3 = 0; - return; - } - if (src < 0) { - *wrd1 = 0x80000000; - src = -src; - } else { - *wrd1 = 0; - } - frac = frexp (src, &expon); - frac += 0.5 / 18446744073709551616.0; - if (frac >= 1.0) { - frac /= 2.0; - expon++; - } - *wrd1 |= (((expon + 16383 - 1) & 0x7fff) << 16); - *wrd2 = (uae_u32) (frac * 4294967296.0); - *wrd3 = (uae_u32) (frac * 18446744073709551616.0 - *wrd2 * 4294967296.0); -} -#endif - -#ifndef HAVE_to_double -STATIC_INLINE double to_double(uae_u32 wrd1, uae_u32 wrd2) -{ - double frac; - - if ((wrd1 & 0x7fffffff) == 0 && wrd2 == 0) - return 0.0; - frac = (double) ((wrd1 & 0xfffff) | 0x100000) / 1048576.0 + - (double) wrd2 / 4503599627370496.0; - if (wrd1 & 0x80000000) - frac = -frac; - return ldexp (frac, ((wrd1 >> 20) & 0x7ff) - 1023); -} -#endif - -#ifndef HAVE_from_double -STATIC_INLINE void from_double(double src, uae_u32 * wrd1, uae_u32 * wrd2) -{ - int expon; - int tmp; - double frac; - - if (src == 0.0) { - *wrd1 = 0; - *wrd2 = 0; - return; - } - if (src < 0) { - *wrd1 = 0x80000000; - src = -src; - } else { - *wrd1 = 0; - } - frac = frexp (src, &expon); - frac += 0.5 / 9007199254740992.0; - if (frac >= 1.0) { - frac /= 2.0; - expon++; - } - tmp = (uae_u32) (frac * 2097152.0); - *wrd1 |= (((expon + 1023 - 1) & 0x7ff) << 20) | (tmp & 0xfffff); - *wrd2 = (uae_u32) (frac * 9007199254740992.0 - tmp * 4294967296.0); -} -#endif diff --git a/src/include/gui.h b/src/include/gui.h index ff1ece0c..4d561afc 100644 --- a/src/include/gui.h +++ b/src/include/gui.h @@ -42,7 +42,8 @@ extern bool no_gui; #define LED_CPU 10 #define LED_SND 11 #define LED_MD 12 -#define LED_MAX 13 +#define LED_NET 13 +#define LED_MAX 14 struct gui_info { diff --git a/src/include/options.h b/src/include/options.h index 0248000f..ff4b5051 100644 --- a/src/include/options.h +++ b/src/include/options.h @@ -42,8 +42,6 @@ struct strlist { #define MAX_INPUT_SUB_EVENT_ALL 9 #define SPARE_SUB_EVENT 8 -#define INTERNALEVENT_COUNT 1 - struct uae_input_device { TCHAR *name; TCHAR *configname; @@ -290,11 +288,9 @@ struct uae_prefs 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; int sound_volume_cd; int cachesize; @@ -416,7 +412,15 @@ struct uae_prefs TCHAR quit_amiberry[256]; #endif - int statecapturerate, statecapturebuffersize; +#ifdef PANDORA +int pandora_vertical_offset; + int pandora_cpu_speed; + int pandora_hide_idle_led; + + int pandora_tapDelay; + int pandora_customControls; +#endif + /* input */ diff --git a/src/include/osemu.h b/src/include/osemu.h deleted file mode 100644 index acd536b6..00000000 --- a/src/include/osemu.h +++ /dev/null @@ -1,19 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * OS emulation prototypes - * - * Copyright 1996 Bernd Schmidt - */ - -STATIC_INLINE char *raddr(uaecptr p) -{ - return p == 0 ? NULL : (char *)get_real_address(p); -} - -extern void gfxlib_install(void); - -/* graphics.library */ - -extern int GFX_WritePixel(uaecptr rp, int x, int y); - diff --git a/src/include/scsidev.h b/src/include/scsidev.h deleted file mode 100644 index 2e77ec93..00000000 --- a/src/include/scsidev.h +++ /dev/null @@ -1,27 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * a SCSI device - * - * (c) 1995 Bernd Schmidt (hardfile.c) - * (c) 1999 Patrick Ohly - * (c) 2001-2005 Toni Wilen - */ - -uaecptr scsidev_startup (uaecptr resaddr); -void scsidev_install (void); -void scsidev_reset (void); -void scsidev_start_threads (void); -int scsi_do_disk_change (int unitnum, int insert, int *pollmode); -int scsi_do_disk_device_change (void); -uae_u32 scsi_get_cd_drive_mask (void); -uae_u32 scsi_get_cd_drive_media_mask (void); - -extern int log_scsi; - -#ifdef _WIN32_ -#define UAESCSI_CDEMU 0 -#define UAESCSI_SPTI 1 -#define UAESCSI_SPTISCAN 2 -#define UAESCSI_LAST 2 -#endif \ No newline at end of file diff --git a/src/include/sysdeps.h b/src/include/sysdeps.h index c6976f9a..df2dd33a 100644 --- a/src/include/sysdeps.h +++ b/src/include/sysdeps.h @@ -205,6 +205,7 @@ 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); /* 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. */ @@ -361,7 +362,11 @@ extern void gui_message(const TCHAR *, ...); #endif #ifndef STATIC_INLINE -#if __GNUC__ - 1 > 1 && __GNUC_MINOR__ - 1 >= 0 +#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 @@ -408,14 +413,7 @@ extern void gui_message(const TCHAR *, ...); * Byte-swapping functions */ -/* 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 +#ifdef ARMV6_ASSEMBLY STATIC_INLINE uae_u32 do_byteswap_32(uae_u32 v) { __asm__( "rev %0, %0" @@ -430,6 +428,14 @@ STATIC_INLINE uae_u32 do_byteswap_16(uae_u32 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 /* Else, if using SDL, try SDL's endian functions. */ # ifdef USE_SDL @@ -468,4 +474,4 @@ STATIC_INLINE uae_u32 do_byteswap_16(uae_u32 v) { #define NOWARN_UNUSED(x) x #endif -#endif /* UAE_SYSDEPS_H */ \ No newline at end of file +#endif /* UAE_SYSDEPS_H */ diff --git a/src/include/xwin.h b/src/include/xwin.h index f642ed97..f9d31563 100644 --- a/src/include/xwin.h +++ b/src/include/xwin.h @@ -65,20 +65,6 @@ extern unsigned int doMask256(int p, int bits, int shift); extern void alloc_colors64k(int, int, int, int, int, int, int); extern void alloc_colors_picasso(int rw, int gw, int bw, int rs, int gs, int bs, int rgbfmt); -/* The graphics code has a choice whether it wants to use a large buffer -* for the whole display, or only a small buffer for a single line. -* If you use a large buffer: -* - set bufmem to point at it -* - set linemem to 0 -* - if memcpy within bufmem would be very slow, i.e. because bufmem is -* in graphics card memory, also set emergmem to point to a buffer -* that is large enough to hold a single line. -* - implement flush_line to be a no-op. -* If you use a single line buffer: -* - set bufmem and emergmem to 0 -* - set linemem to point at your buffer -* - implement flush_line to copy a single line to the screen -*/ struct vidbuffer { uae_u8 *bufmem; @@ -98,4 +84,4 @@ struct vidbuf_description extern struct vidbuf_description gfxvidinfo; -#endif /* UAE_XWIN_H */ \ No newline at end of file +#endif /* UAE_XWIN_H */ diff --git a/src/inputevents.def b/src/inputevents.def index 088b970c..68ea2021 100644 --- a/src/inputevents.def +++ b/src/inputevents.def @@ -163,6 +163,7 @@ DEFEVENT(KEY_TAB,_T("Tab"),AM_K,0,0,AK_TAB) DEFEVENT(KEY_CTRL,_T("CTRL"),AM_K,0,0,AK_CTRL) DEFEVENT(KEY_CAPS_LOCK,_T("Caps Lock"),AM_K,0,0,AK_CAPSLOCK) DEFEVENT(KEY_SHIFT_LEFT,_T("Left Shift"),AM_K,0,0,AK_LSH) +DEFEVENT(KEY_LTGT,_T("Lower Greater"),AM_K,0,0,AK_LTGT) DEFEVENT(KEY_ALT_LEFT,_T("Left Alt"),AM_K,0,0,AK_LALT) DEFEVENT(KEY_AMIGA_LEFT,_T("Left Amiga"),AM_K,0,0,AK_LAMI) DEFEVENT(KEY_AMIGA_RIGHT,_T("Right Amiga"),AM_K,0,0,AK_RAMI) diff --git a/src/jit/compemu_support.cpp b/src/jit/compemu_support.cpp index 8421eac6..2cc6ae69 100644 --- a/src/jit/compemu_support.cpp +++ b/src/jit/compemu_support.cpp @@ -168,7 +168,7 @@ static blockinfo* hold_bi[MAX_HOLD_BI]; blockinfo* active; blockinfo* dormant; -#ifdef AMIBERRY +#ifndef WIN32 #include void cache_free (uae_u8 *cache, int size) diff --git a/src/machdep/md-fpp.h b/src/machdep/md-fpp.h deleted file mode 100644 index a7faec17..00000000 --- a/src/machdep/md-fpp.h +++ /dev/null @@ -1,131 +0,0 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * MC68881 emulation - * Support functions for IEEE 754-compatible host CPUs. - * These functions use a GCC extension (type punning through unions) and - * should only be compiled with compilers that support this. - * - * Copyright 1999 Sam Jordan - * Copyright 2007 Richard Drummond - */ - -#define FPCR_ROUNDING_MODE 0x00000030 -#define FPCR_ROUND_NEAR 0x00000000 -#define FPCR_ROUND_ZERO 0x00000010 -#define FPCR_ROUND_MINF 0x00000020 -#define FPCR_ROUND_PINF 0x00000030 - -#define FPCR_ROUNDING_PRECISION 0x000000c0 -#define FPCR_PRECISION_SINGLE 0x00000040 -#define FPCR_PRECISION_DOUBLE 0x00000080 -#define FPCR_PRECISION_EXTENDED 0x00000000 - -STATIC_INLINE void exten_zeronormalize(uae_u32 *pwrd1, uae_u32 *pwrd2, uae_u32 *pwrd3) -{ - uae_u32 wrd1 = *pwrd1; - uae_u32 wrd2 = *pwrd2; - uae_u32 wrd3 = *pwrd3; - int exp = (wrd1 >> 16) & 0x7fff; - // Force zero if mantissa is zero but exponent is non-zero - // M68k FPU automatically convert them to plain zeros. - // x86 FPU considers them invalid values - if (exp != 0 && exp != 0x7fff && !wrd2 && !wrd3) { - *pwrd1 = (wrd1 & 0x80000000); - } -} - -STATIC_INLINE double to_single (uae_u32 value) -{ - union { - float f; - uae_u32 u; - } val; - - val.u = value; - return val.f; -} - -STATIC_INLINE uae_u32 from_single (double src) -{ - union { - float f; - uae_u32 u; - } val; - - val.f = (float) src; - return val.u; -} - -STATIC_INLINE double to_double (uae_u32 wrd1, uae_u32 wrd2) -{ - union { - double d; - uae_u32 u[2]; - } val; - - val.u[0] = wrd2; // little endian - val.u[1] = wrd1; - return val.d; -} - -STATIC_INLINE void from_double (double src, uae_u32 * wrd1, uae_u32 * wrd2) -{ - uae_u32 *longarray = (uae_u32 *)&src; - - *wrd1 = longarray[1]; // little endian - *wrd2 = longarray[0]; -} - -static const double twoto32 = 4294967296.0; -STATIC_INLINE void to_exten(fpdata *fpd, uae_u32 wrd1, uae_u32 wrd2, uae_u32 wrd3) -{ - double frac; - - exten_zeronormalize(&wrd1, &wrd2, &wrd3); - if ((wrd1 & 0x7fff0000) == 0 && wrd2 == 0 && wrd3 == 0) { - fpd->fp = (wrd1 & 0x80000000) ? -0.0 : +0.0; - return; - } - frac = ((double)wrd2 + ((double)wrd3 / twoto32)) / 2147483648.0; - if (wrd1 & 0x80000000) - frac = -frac; - fpd->fp = ldexp (frac, ((wrd1 >> 16) & 0x7fff) - 16383); -} - -STATIC_INLINE void from_exten(fpdata *fpd, uae_u32 * wrd1, uae_u32 * wrd2, uae_u32 * wrd3) -{ - int expon; - double frac; - fptype v; - - v = fpd->fp; - if (v == 0.0) { - *wrd1 = signbit(v) ? 0x80000000 : 0; - *wrd2 = 0; - *wrd3 = 0; - return; - } - if (v < 0) { - *wrd1 = 0x80000000; - v = -v; - } else { - *wrd1 = 0; - } - frac = frexp (v, &expon); - frac += 0.5 / (twoto32 * twoto32); - if (frac >= 1.0) { - frac /= 2.0; - expon++; - } - *wrd1 |= (((expon + 16383 - 1) & 0x7fff) << 16); - *wrd2 = (uae_u32) (frac * twoto32); - *wrd3 = (uae_u32) ((frac * twoto32 - *wrd2) * twoto32); -} - -#define HAVE_from_double -#define HAVE_to_double -#define HAVE_from_exten -#define HAVE_to_exten -#define HAVE_from_single -#define HAVE_to_single diff --git a/src/main.cpp b/src/main.cpp index 2a0b4127..c7f2d1cf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -472,7 +472,34 @@ static TCHAR *parsetextpath(const TCHAR *s) return s3; } -static void parse_cmdline(int argc, TCHAR **argv) +void print_usage() +{ + 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); +} + +static void parse_cmdline (int argc, TCHAR **argv) { static bool started; bool firstconfig = true; @@ -715,6 +742,9 @@ static int real_main2 (int argc, TCHAR **argv) } else { +#ifdef PANDORA + setCpuSpeed(); +#endif update_display(&currprefs); } memset(&gui_data, 0, sizeof gui_data); diff --git a/src/osdep/amiberry.cpp b/src/osdep/amiberry.cpp index d4046f2c..a0b6ef46 100644 --- a/src/osdep/amiberry.cpp +++ b/src/osdep/amiberry.cpp @@ -41,6 +41,7 @@ extern FILE *debugfile; int quickstart_start = 1; int quickstart_model = 0; int quickstart_conf = 0; +bool host_poweroff = false; extern void signal_segv(int signum, siginfo_t* info, void*ptr); extern void signal_buserror(int signum, siginfo_t* info, void*ptr); @@ -714,9 +715,17 @@ uae_u32 emulib_target_getcpurate(uae_u32 v, uae_u32 *low) return 0; } +static void target_shutdown(void) +{ + system("sudo poweroff"); +} int main(int argc, char* argv[]) { struct sigaction action; + +#ifdef AMIBERRY + printf("Amiberry-SDL2 v2.5b, by Dimitris (MiDWaN) Panokostas and TomB\n"); +#endif max_uae_width = 1920; max_uae_height = 1080; @@ -762,7 +771,6 @@ int main(int argc, char* argv[]) alloc_AmigaMem(); RescanROMs(); - keyboard_settrans(); #ifdef CAPSLOCK_DEBIAN_WORKAROUND // set capslock state based upon current "real" state @@ -800,6 +808,8 @@ int main(int argc, char* argv[]) logging_cleanup(); + if(host_poweroff) + target_shutdown(); return 0; } @@ -823,6 +833,11 @@ int handle_msgpump() int got = 0; SDL_Event rEvent; int keycode; + if(delayed_mousebutton) { + --delayed_mousebutton; + if(delayed_mousebutton == 0) + setmousebuttonstate (0, 0, 1); + } if (currprefs.customControls) PopulateCustomControlMap(); diff --git a/src/osdep/bsdsocket_host.cpp b/src/osdep/bsdsocket_host.cpp index b51a6e1a..9c118180 100644 --- a/src/osdep/bsdsocket_host.cpp +++ b/src/osdep/bsdsocket_host.cpp @@ -1,32 +1,32 @@ /* -* UAE - The Un*x Amiga Emulator -* -* bsdsocket.library emulation - Unix -* -* Copyright 2000-2001 Carl Drougge -* Copyright 2003-2005 Richard Drummond -* Copyright 2004 Jeff Shepherd -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ + * UAE - The Un*x Amiga Emulator + * + * bsdsocket.library emulation - Unix + * + * Copyright 2000-2001 Carl Drougge + * Copyright 2003-2005 Richard Drummond + * Copyright 2004 Jeff Shepherd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ #include "sysconfig.h" #include "sysdeps.h" #include "options.h" -#include "memory.h" +#include "include/memory.h" #include "newcpu.h" #include "custom.h" #include "autoconf.h" @@ -39,7 +39,8 @@ volatile int bsd_int_requested; -void bsdsock_fake_int_handler(void) { +void bsdsock_fake_int_handler(void) +{ } #else @@ -72,8 +73,8 @@ void bsdsock_fake_int_handler(void) { #endif /* Sigqueue is unsafe on SMP machines. -* Temporary work-around. -*/ + * Temporary work-around. + */ //#define SETSIGNAL addtosigqueue (sb, 0) #define SETSIGNAL \ do { \ @@ -87,1656 +88,1635 @@ void bsdsock_fake_int_handler(void) { /* BSD-systems don't seem to have MSG_NOSIGNAL.. -@@@ We need to catch SIGPIPE on those systems! (?) */ + @@@ We need to catch SIGPIPE on those systems! (?) */ #ifndef MSG_NOSIGNAL #define MSG_NOSIGNAL 0 #endif #define S_GL_result(res) sb->resultval = (res) -uae_u32 bsdthr_Accept_2(SB); -uae_u32 bsdthr_Recv_2(SB); -uae_u32 bsdthr_blockingstuff(uae_u32(*tryfunc)(SB), SB); -uae_u32 bsdthr_SendRecvAcceptConnect(uae_u32(*tryfunc)(SB), SB); -uae_u32 bsdthr_Send_2(SB); -uae_u32 bsdthr_Connect_2(SB); -uae_u32 bsdthr_WaitSelect(SB); -uae_u32 bsdthr_Wait(SB); -void clearsockabort(SB); +uae_u32 bsdthr_Accept_2 (SB); +uae_u32 bsdthr_Recv_2 (SB); +uae_u32 bsdthr_blockingstuff (uae_u32 (*tryfunc)(SB), SB); +uae_u32 bsdthr_SendRecvAcceptConnect (uae_u32 (*tryfunc)(SB), SB); +uae_u32 bsdthr_Send_2 (SB); +uae_u32 bsdthr_Connect_2 (SB); +uae_u32 bsdthr_WaitSelect (SB); +uae_u32 bsdthr_Wait (SB); +void clearsockabort (SB); static uae_sem_t sem_queue = 0; /** -** Helper functions -**/ + ** Helper functions + **/ /* -* Map host errno to amiga errno -*/ -static int mapErrno(int e) + * Map host errno to amiga errno + */ +static int mapErrno (int e) { - switch (e) { - case EINTR: e = 4; break; - case EDEADLK: e = 11; break; - case EAGAIN: e = 35; break; - case EINPROGRESS: e = 36; break; - case EALREADY: e = 37; break; - case ENOTSOCK: e = 38; break; - case EDESTADDRREQ: e = 39; break; - case EMSGSIZE: e = 40; break; - case EPROTOTYPE: e = 41; break; - case ENOPROTOOPT: e = 42; break; - case EPROTONOSUPPORT: e = 43; break; - case ESOCKTNOSUPPORT: e = 44; break; - case EOPNOTSUPP: e = 45; break; - case EPFNOSUPPORT: e = 46; break; - case EAFNOSUPPORT: e = 47; break; - case EADDRINUSE: e = 48; break; - case EADDRNOTAVAIL: e = 49; break; - case ENETDOWN: e = 50; break; - case ENETUNREACH: e = 51; break; - case ENETRESET: e = 52; break; - case ECONNABORTED: e = 53; break; - case ECONNRESET: e = 54; break; - case ENOBUFS: e = 55; break; - case EISCONN: e = 56; break; - case ENOTCONN: e = 57; break; - case ESHUTDOWN: e = 58; break; - case ETOOMANYREFS: e = 59; break; - case ETIMEDOUT: e = 60; break; - case ECONNREFUSED: e = 61; break; - case ELOOP: e = 62; break; - case ENAMETOOLONG: e = 63; break; - default: break; - } - return e; + switch (e) { + case EINTR: e = 4; break; + case EDEADLK: e = 11; break; + case EAGAIN: e = 35; break; + case EINPROGRESS: e = 36; break; + case EALREADY: e = 37; break; + case ENOTSOCK: e = 38; break; + case EDESTADDRREQ: e = 39; break; + case EMSGSIZE: e = 40; break; + case EPROTOTYPE: e = 41; break; + case ENOPROTOOPT: e = 42; break; + case EPROTONOSUPPORT: e = 43; break; + case ESOCKTNOSUPPORT: e = 44; break; + case EOPNOTSUPP: e = 45; break; + case EPFNOSUPPORT: e = 46; break; + case EAFNOSUPPORT: e = 47; break; + case EADDRINUSE: e = 48; break; + case EADDRNOTAVAIL: e = 49; break; + case ENETDOWN: e = 50; break; + case ENETUNREACH: e = 51; break; + case ENETRESET: e = 52; break; + case ECONNABORTED: e = 53; break; + case ECONNRESET: e = 54; break; + case ENOBUFS: e = 55; break; + case EISCONN: e = 56; break; + case ENOTCONN: e = 57; break; + case ESHUTDOWN: e = 58; break; + case ETOOMANYREFS: e = 59; break; + case ETIMEDOUT: e = 60; break; + case ECONNREFUSED: e = 61; break; + case ELOOP: e = 62; break; + case ENAMETOOLONG: e = 63; break; + default: break; + } + return e; } /* -* Map amiga (s|g)etsockopt level into native one -*/ -static int mapsockoptlevel(int level) + * Map amiga (s|g)etsockopt level into native one + */ +static int mapsockoptlevel (int level) { - switch (level) { - case 0xffff: - return SOL_SOCKET; - case 0: - return IPPROTO_IP; - case 1: - return IPPROTO_ICMP; - case 2: - return IPPROTO_IGMP; + switch (level) { + case 0xffff: + return SOL_SOCKET; + case 0: + return IPPROTO_IP; + case 1: + return IPPROTO_ICMP; + case 2: + return IPPROTO_IGMP; #ifdef IPPROTO_IPIP - case 4: - return IPPROTO_IPIP; + case 4: + return IPPROTO_IPIP; #endif - case 6: - return IPPROTO_TCP; - case 8: - return IPPROTO_EGP; - case 12: - return IPPROTO_PUP; - case 17: - return IPPROTO_UDP; - case 22: - return IPPROTO_IDP; + case 6: + return IPPROTO_TCP; + case 8: + return IPPROTO_EGP; + case 12: + return IPPROTO_PUP; + case 17: + return IPPROTO_UDP; + case 22: + return IPPROTO_IDP; #ifdef IPPROTO_TP - case 29: - return IPPROTO_TP; + case 29: + return IPPROTO_TP; #endif - case 98: - return IPPROTO_ENCAP; - default: - DEBUG_LOG("Unknown sockopt level %d\n", level); - return level; - } + case 98: + return IPPROTO_ENCAP; + default: + DEBUG_LOG ("Unknown sockopt level %d\n", level); + return level; + } } /* -* Map amiga (s|g)etsockopt optname into native one -*/ -static int mapsockoptname(int level, int optname) + * Map amiga (s|g)etsockopt optname into native one + */ +static int mapsockoptname (int level, int optname) { - switch (level) { + switch (level) { - case SOL_SOCKET: - switch (optname) { - case 0x0001: - return SO_DEBUG; - case 0x0002: - return SO_ACCEPTCONN; - case 0x0004: - return SO_REUSEADDR; - case 0x0008: - return SO_KEEPALIVE; - case 0x0010: - return SO_DONTROUTE; - case 0x0020: - return SO_BROADCAST; + case SOL_SOCKET: + switch (optname) { + case 0x0001: + return SO_DEBUG; + case 0x0002: + return SO_ACCEPTCONN; + case 0x0004: + return SO_REUSEADDR; + case 0x0008: + return SO_KEEPALIVE; + case 0x0010: + return SO_DONTROUTE; + case 0x0020: + return SO_BROADCAST; #ifdef SO_USELOOPBACK - case 0x0040: - return SO_USELOOPBACK; + case 0x0040: + return SO_USELOOPBACK; #endif - case 0x0080: - return SO_LINGER; - case 0x0100: - return SO_OOBINLINE; + case 0x0080: + return SO_LINGER; + case 0x0100: + return SO_OOBINLINE; #ifdef SO_REUSEPORT - case 0x0200: - return SO_REUSEPORT; + case 0x0200: + return SO_REUSEPORT; #endif - case 0x1001: - return SO_SNDBUF; - case 0x1002: - return SO_RCVBUF; - case 0x1003: - return SO_SNDLOWAT; - case 0x1004: - return SO_RCVLOWAT; - case 0x1005: - return SO_SNDTIMEO; - case 0x1006: - return SO_RCVTIMEO; - case 0x1007: - return SO_ERROR; - case 0x1008: - return SO_TYPE; + case 0x1001: + return SO_SNDBUF; + case 0x1002: + return SO_RCVBUF; + case 0x1003: + return SO_SNDLOWAT; + case 0x1004: + return SO_RCVLOWAT; + case 0x1005: + return SO_SNDTIMEO; + case 0x1006: + return SO_RCVTIMEO; + case 0x1007: + return SO_ERROR; + case 0x1008: + return SO_TYPE; - default: - DEBUG_LOG("Invalid setsockopt option 0x%x for level %d\n", - optname, level); - return -1; - } - break; + default: + DEBUG_LOG("Invalid setsockopt option 0x%x for level %d\n", + optname, level); + return -1; + } + break; - case IPPROTO_IP: - switch (optname) { - case 1: - return IP_OPTIONS; - case 2: - return IP_HDRINCL; - case 3: - return IP_TOS; - case 4: - return IP_TTL; - case 5: - return IP_RECVOPTS; - case 6: - return IP_RECVRETOPTS; - case 8: - return IP_RETOPTS; - case 9: - return IP_MULTICAST_IF; - case 10: - return IP_MULTICAST_TTL; - case 11: - return IP_MULTICAST_LOOP; - case 12: - return IP_ADD_MEMBERSHIP; + case IPPROTO_IP: + switch (optname) { + case 1: + return IP_OPTIONS; + case 2: + return IP_HDRINCL; + case 3: + return IP_TOS; + case 4: + return IP_TTL; + case 5: + return IP_RECVOPTS; + case 6: + return IP_RECVRETOPTS; + case 8: + return IP_RETOPTS; + case 9: + return IP_MULTICAST_IF; + case 10: + return IP_MULTICAST_TTL; + case 11: + return IP_MULTICAST_LOOP; + case 12: + return IP_ADD_MEMBERSHIP; + + default: + DEBUG_LOG ("Invalid setsockopt option 0x%x for level %d\n", + optname, level); + return -1; + } + break; - default: - DEBUG_LOG("Invalid setsockopt option 0x%x for level %d\n", - optname, level); - return -1; - } - break; + case IPPROTO_TCP: + switch (optname) { + case 1: + return TCP_NODELAY; + case 2: + return TCP_MAXSEG; - case IPPROTO_TCP: - switch (optname) { - case 1: - return TCP_NODELAY; - case 2: - return TCP_MAXSEG; + default: + DEBUG_LOG ("Invalid setsockopt option 0x%x for level %d\n", + optname, level); + return -1; + } + break; - default: - DEBUG_LOG("Invalid setsockopt option 0x%x for level %d\n", - optname, level); - return -1; - } - break; - - default: - DEBUG_LOG("Unknown level %d\n", level); - return -1; - } + default: + DEBUG_LOG ("Unknown level %d\n", level); + return -1; + } } /* -* Map amiga (s|g)etsockopt return value into the correct form -*/ + * Map amiga (s|g)etsockopt return value into the correct form + */ static void mapsockoptreturn(TrapContext *ctx, int level, int optname, uae_u32 optval, void *buf) { - switch (level) { + switch (level) { - case SOL_SOCKET: - switch (optname) { - case SO_DEBUG: - case SO_ACCEPTCONN: - case SO_REUSEADDR: - case SO_KEEPALIVE: - case SO_DONTROUTE: - case SO_BROADCAST: + case SOL_SOCKET: + switch (optname) { + case SO_DEBUG: + case SO_ACCEPTCONN: + case SO_REUSEADDR: + case SO_KEEPALIVE: + case SO_DONTROUTE: + case SO_BROADCAST: #ifdef SO_USELOOPBACK - case SO_USELOOPBACK: + case SO_USELOOPBACK: #endif - case SO_LINGER: - case SO_OOBINLINE: + case SO_LINGER: + case SO_OOBINLINE: #ifdef SO_REUSEPORT - case SO_REUSEPORT: + case SO_REUSEPORT: #endif - case SO_SNDBUF: - case SO_RCVBUF: - case SO_SNDLOWAT: - case SO_RCVLOWAT: - case SO_SNDTIMEO: - case SO_RCVTIMEO: - case SO_TYPE: - trap_put_long(ctx, optval, *(int *)buf); - break; + case SO_SNDBUF: + case SO_RCVBUF: + case SO_SNDLOWAT: + case SO_RCVLOWAT: + case SO_SNDTIMEO: + case SO_RCVTIMEO: + case SO_TYPE: + trap_put_long (ctx, optval, *static_cast(buf)); + break; - case SO_ERROR: - DEBUG_LOG("New errno is %d\n", mapErrno(*(int *)buf)); - trap_put_long(ctx, optval, mapErrno(*(int *)buf)); - break; - default: - break; - } - break; + case SO_ERROR: + DEBUG_LOG("New errno is %d\n", mapErrno(*(int *)buf)); + trap_put_long (ctx, optval, mapErrno(*static_cast(buf))); + break; + default: + break; + } + break; - case IPPROTO_IP: - switch (optname) { - case IP_OPTIONS: - case IP_HDRINCL: - case IP_TOS: - case IP_TTL: - case IP_RECVOPTS: - //case IP_RECVRETOPTS: - //case IP_RETOPTS: - case IP_MULTICAST_IF: - case IP_MULTICAST_TTL: - case IP_MULTICAST_LOOP: - case IP_ADD_MEMBERSHIP: - trap_put_long(ctx, optval, *(int *)buf); - break; + case IPPROTO_IP: + switch (optname) { + case IP_OPTIONS: + case IP_HDRINCL: + case IP_TOS: + case IP_TTL: + case IP_RECVOPTS: + //case IP_RECVRETOPTS: + //case IP_RETOPTS: + case IP_MULTICAST_IF: + case IP_MULTICAST_TTL: + case IP_MULTICAST_LOOP: + case IP_ADD_MEMBERSHIP: + trap_put_long (ctx, optval, *static_cast(buf)); + break; - default: - break; - } - break; + default: + break; + } + break; - case IPPROTO_TCP: - switch (optname) { - case TCP_NODELAY: - case TCP_MAXSEG: - trap_put_long(ctx, optval, *(int *)buf); - break; + case IPPROTO_TCP: + switch (optname) { + case TCP_NODELAY: + case TCP_MAXSEG: + trap_put_long (ctx, optval,*static_cast(buf)); + break; - default: - break; - } - break; + default: + break; + } + break; - default: - break; - } + default: + break; + } } /* -* Map amiga (s|g)etsockopt value from amiga to the appropriate value -*/ + * Map amiga (s|g)etsockopt value from amiga to the appropriate value + */ static void mapsockoptvalue(TrapContext *ctx, int level, int optname, uae_u32 optval, void *buf) { - switch (level) { + switch (level) { - case SOL_SOCKET: - switch (optname) { - case SO_DEBUG: - case SO_ACCEPTCONN: - case SO_REUSEADDR: - case SO_KEEPALIVE: - case SO_DONTROUTE: - case SO_BROADCAST: + case SOL_SOCKET: + switch (optname) { + case SO_DEBUG: + case SO_ACCEPTCONN: + case SO_REUSEADDR: + case SO_KEEPALIVE: + case SO_DONTROUTE: + case SO_BROADCAST: #ifdef SO_USELOOPBACK - case SO_USELOOPBACK: + case SO_USELOOPBACK: #endif - case SO_LINGER: - case SO_OOBINLINE: + case SO_LINGER: + case SO_OOBINLINE: #ifdef SO_REUSEPORT - case SO_REUSEPORT: + case SO_REUSEPORT: #endif - case SO_SNDBUF: - case SO_RCVBUF: - case SO_SNDLOWAT: - case SO_RCVLOWAT: - case SO_SNDTIMEO: - case SO_RCVTIMEO: - case SO_TYPE: - case SO_ERROR: - *((int *)buf) = trap_get_long(ctx, optval); - break; - default: - break; - } - break; + case SO_SNDBUF: + case SO_RCVBUF: + case SO_SNDLOWAT: + case SO_RCVLOWAT: + case SO_SNDTIMEO: + case SO_RCVTIMEO: + case SO_TYPE: + case SO_ERROR: + *static_cast(buf) = trap_get_long (ctx, optval); + break; + default: + break; + } + break; - case IPPROTO_IP: - switch (optname) { - case IP_OPTIONS: - case IP_HDRINCL: - case IP_TOS: - case IP_TTL: - case IP_RECVOPTS: - //case IP_RECVRETOPTS: - //case IP_RETOPTS: - case IP_MULTICAST_IF: - case IP_MULTICAST_TTL: - case IP_MULTICAST_LOOP: - case IP_ADD_MEMBERSHIP: - *((int *)buf) = trap_get_long(ctx, optval); - break; + case IPPROTO_IP: + switch (optname) { + case IP_OPTIONS: + case IP_HDRINCL: + case IP_TOS: + case IP_TTL: + case IP_RECVOPTS: + //case IP_RECVRETOPTS: + //case IP_RETOPTS: + case IP_MULTICAST_IF: + case IP_MULTICAST_TTL: + case IP_MULTICAST_LOOP: + case IP_ADD_MEMBERSHIP: + *static_cast(buf) = trap_get_long (ctx, optval); + break; - default: - break; - } - break; + default: + break; + } + break; - case IPPROTO_TCP: - switch (optname) { - case TCP_NODELAY: - case TCP_MAXSEG: - *((int *)buf) = trap_get_long(ctx, optval); - break; + case IPPROTO_TCP: + switch (optname) { + case TCP_NODELAY: + case TCP_MAXSEG: + *static_cast(buf) = trap_get_long (ctx, optval); + break; - default: - break; - } - break; + default: + break; + } + break; - default: - break; - } + default: + break; + } } -STATIC_INLINE void fd_zero(TrapContext *ctx, uae_u32 fdset, uae_u32 nfds) +STATIC_INLINE void fd_zero (TrapContext *ctx, uae_u32 fdset, uae_u32 nfds) { - unsigned int i; + unsigned int i; - for (i = 0; i < nfds; i += 32, fdset += 4) - trap_put_long(ctx, fdset, 0); + for (i = 0; i < nfds; i += 32, fdset += 4) + trap_put_long(ctx, fdset, 0); } -STATIC_INLINE int bsd_amigaside_FD_ISSET(TrapContext *ctx, int n, uae_u32 set) +STATIC_INLINE int bsd_amigaside_FD_ISSET (TrapContext *ctx, int n, uae_u32 set) { - uae_u32 foo = trap_get_long(ctx, set + (n / 32)); - if (foo & (1 << (n % 32))) + uae_u32 foo = trap_get_long(ctx, set + (n / 32)); + if (foo & (1 << (n % 32))) return 1; - return 0; + return 0; } -STATIC_INLINE void bsd_amigaside_FD_ZERO(TrapContext *ctx, uae_u32 set) +STATIC_INLINE void bsd_amigaside_FD_ZERO (TrapContext *ctx, uae_u32 set) { - trap_put_long(ctx, set, 0); - trap_put_long(ctx, set + 4, 0); + trap_put_long(ctx, set, 0); + trap_put_long(ctx, set + 4, 0); } -STATIC_INLINE void bsd_amigaside_FD_SET(TrapContext *ctx, int n, uae_u32 set) +STATIC_INLINE void bsd_amigaside_FD_SET (TrapContext *ctx, int n, uae_u32 set) { - set = set + (n / 32); - trap_put_long(ctx, set, trap_get_long(ctx, set) | (1 << (n % 32))); + set = set + (n / 32); + trap_put_long(ctx, set, trap_get_long(ctx, set) | (1 << (n % 32))); } #ifdef DEBUG_BSDSOCKET -static void printSockAddr(struct sockaddr_in *in) +static void printSockAddr (struct sockaddr_in *in) { - DEBUG_LOG("Family %d, ", in->sin_family); - DEBUG_LOG("Port %d,", ntohs(in->sin_port)); - DEBUG_LOG("Address %s,", inet_ntoa(in->sin_addr)); + DEBUG_LOG ("Family %d, ", in->sin_family); + DEBUG_LOG ("Port %d,", ntohs (in->sin_port)); + DEBUG_LOG ("Address %s,", inet_ntoa (in->sin_addr)); } #else #define printSockAddr(sockAddr) #endif /* -* Copy a sockaddr object from amiga space to native space -*/ -static int copysockaddr_a2n(TrapContext *ctx, struct sockaddr_in *addr, uae_u32 a_addr, unsigned int len) + * Copy a sockaddr object from amiga space to native space + */ +static int copysockaddr_a2n (TrapContext *ctx, struct sockaddr_in *addr, uae_u32 a_addr, unsigned int len) { - if ((len > sizeof(struct sockaddr_in)) || (len < 8)) - return 1; + if ((len > sizeof (struct sockaddr_in)) || (len < 8)) + return 1; - if (a_addr == 0) + if (a_addr == 0) return 0; - addr->sin_family = trap_get_byte(ctx, a_addr + 1); - addr->sin_port = htons(trap_get_word(ctx, a_addr + 2)); - addr->sin_addr.s_addr = htonl(trap_get_long(ctx, a_addr + 4)); + addr->sin_family = trap_get_byte (ctx, a_addr + 1); + addr->sin_port = htons (trap_get_word (ctx, a_addr + 2)); + addr->sin_addr.s_addr = htonl (trap_get_long (ctx, a_addr + 4)); - if (len > 8) - memcpy(&addr->sin_zero, get_real_address(a_addr + 8), len - 8); /* Pointless? */ - - return 0; + if (len > 8) + memcpy (&addr->sin_zero, get_real_address (a_addr + 8), len - 8); /* Pointless? */ + + return 0; } /* -* Copy a sockaddr object from native space to amiga space -*/ -static int copysockaddr_n2a(TrapContext *ctx, uae_u32 a_addr, const struct sockaddr_in *addr, unsigned int len) + * Copy a sockaddr object from native space to amiga space + */ +static int copysockaddr_n2a (TrapContext *ctx, uae_u32 a_addr, const struct sockaddr_in *addr, unsigned int len) { - if (len < 8) + if (len < 8) return 1; - if (a_addr == 0) + if (a_addr == 0) return 0; - trap_put_byte(ctx, a_addr, 0); /* Anyone use this field? */ - trap_put_byte(ctx, a_addr + 1, addr->sin_family); - trap_put_word(ctx, a_addr + 2, ntohs(addr->sin_port)); - trap_put_long(ctx, a_addr + 4, ntohl(addr->sin_addr.s_addr)); + trap_put_byte (ctx, a_addr, 0); /* Anyone use this field? */ + trap_put_byte (ctx, a_addr + 1, addr->sin_family); + trap_put_word (ctx, a_addr + 2, ntohs (addr->sin_port)); + trap_put_long (ctx, a_addr + 4, ntohl (addr->sin_addr.s_addr)); - if (len > 8) - memset(get_real_address(a_addr + 8), 0, len - 8); + if (len > 8) + memset (get_real_address (a_addr + 8), 0, len - 8); - return 0; + return 0; } /* -* Copy a hostent object from native space to amiga space -*/ -static void copyHostent(const struct hostent *hostent, SB) + * Copy a hostent object from native space to amiga space + */ +static void copyHostent (const struct hostent *hostent, SB) { - int size = 28; - int i; - int numaddr = 0; - int numaliases = 0; - uae_u32 aptr; + int size = 28; + int i; + int numaddr = 0; + int numaliases = 0; + uae_u32 aptr; - if (hostent->h_name != NULL) - size += strlen(hostent->h_name) + 1; + if (hostent->h_name != NULL) + size += strlen(hostent->h_name)+1; - if (hostent->h_aliases != NULL) - while (hostent->h_aliases[numaliases]) - size += strlen(hostent->h_aliases[numaliases++]) + 5; + if (hostent->h_aliases != NULL) + while (hostent->h_aliases[numaliases]) + size += strlen(hostent->h_aliases[numaliases++]) + 5; - if (hostent->h_addr_list != NULL) { - while (hostent->h_addr_list[numaddr]) - numaddr++; - size += numaddr*(hostent->h_length + 4); - } + if (hostent->h_addr_list != NULL) { + while (hostent->h_addr_list[numaddr]) + numaddr++; + size += numaddr*(hostent->h_length+4); + } - aptr = sb->hostent + 28 + numaliases * 4 + numaddr * 4; + aptr = sb->hostent + 28 + numaliases * 4 + numaddr * 4; - // transfer hostent to Amiga memory - trap_put_long(sb->context, sb->hostent + 4, sb->hostent + 20); - trap_put_long(sb->context, sb->hostent + 8, hostent->h_addrtype); - trap_put_long(sb->context, sb->hostent + 12, hostent->h_length); - trap_put_long(sb->context, sb->hostent + 16, sb->hostent + 24 + numaliases * 4); + // transfer hostent to Amiga memory + trap_put_long (sb->context, sb->hostent + 4, sb->hostent + 20); + trap_put_long (sb->context, sb->hostent + 8, hostent->h_addrtype); + trap_put_long (sb->context, sb->hostent + 12, hostent->h_length); + trap_put_long (sb->context, sb->hostent + 16, sb->hostent + 24 + numaliases*4); - for (i = 0; i < numaliases; i++) - trap_put_long(sb->context, sb->hostent + 20 + i * 4, addstr(sb->context, &aptr, hostent->h_aliases[i])); - trap_put_long(sb->context, sb->hostent + 20 + numaliases * 4, 0); + for (i = 0; i < numaliases; i++) + trap_put_long (sb->context, sb->hostent + 20 + i * 4, addstr (sb->context, &aptr, hostent->h_aliases[i])); + trap_put_long (sb->context, sb->hostent + 20 + numaliases * 4, 0); - for (i = 0; i < numaddr; i++) { - trap_put_long(sb->context, sb->hostent + 24 + (numaliases + i) * 4, addmem(sb->context, &aptr, hostent->h_addr_list[i], hostent->h_length)); - } - trap_put_long(sb->context, sb->hostent + 24 + numaliases * 4 + numaddr * 4, 0); - trap_put_long(sb->context, sb->hostent, aptr); - addstr(sb->context, &aptr, hostent->h_name); + for (i = 0; i < numaddr; i++) { + trap_put_long (sb->context, sb->hostent + 24 + (numaliases + i) * 4, addmem (sb->context, &aptr, hostent->h_addr_list[i], hostent->h_length)); + } + trap_put_long (sb->context, sb->hostent + 24 + numaliases * 4 + numaddr * 4, 0); + trap_put_long (sb->context, sb->hostent, aptr); + addstr (sb->context, &aptr, hostent->h_name); - BSDTRACE(("OK (%s)\n", hostent->h_name)); - bsdsocklib_seterrno(sb->context, sb, 0); + BSDTRACE (("OK (%s)\n",hostent->h_name)); + bsdsocklib_seterrno (sb->context, sb, 0); } /* -* Copy a protoent object from native space to Amiga space -*/ -static void copyProtoent(TrapContext *ctx, SB, const struct protoent *p) + * Copy a protoent object from native space to Amiga space + */ +static void copyProtoent (TrapContext *ctx, SB, const struct protoent *p) { - size_t size = 16; - int numaliases = 0; - int i; - uae_u32 aptr; + size_t size = 16; + int numaliases = 0; + int i; + uae_u32 aptr; - // compute total size of protoent - if (p->p_name != NULL) - size += strlen(p->p_name) + 1; + // compute total size of protoent + if (p->p_name != NULL) + size += strlen (p->p_name) + 1; - if (p->p_aliases != NULL) - while (p->p_aliases[numaliases]) - size += strlen(p->p_aliases[numaliases++]) + 5; + if (p->p_aliases != NULL) + while (p->p_aliases[numaliases]) + size += strlen (p->p_aliases[numaliases++]) + 5; - if (sb->protoent) { - uae_FreeMem(ctx, sb->protoent, sb->protoentsize, sb->sysbase); - } + if (sb->protoent) { + uae_FreeMem (ctx, sb->protoent, sb->protoentsize, sb->sysbase); + } - sb->protoent = uae_AllocMem(ctx, size, 0, sb->sysbase); + sb->protoent = uae_AllocMem (ctx, size, 0, sb->sysbase); - if (!sb->protoent) { - write_log("BSDSOCK: WARNING - copyProtoent() ran out of Amiga memory (couldn't allocate %d bytes)\n", size); - bsdsocklib_seterrno(ctx, sb, 12); // ENOMEM + if (!sb->protoent) { + write_log ("BSDSOCK: WARNING - copyProtoent() ran out of Amiga memory (couldn't allocate %d bytes)\n", size); + bsdsocklib_seterrno (ctx, sb, 12); // ENOMEM return; - } + } - sb->protoentsize = size; + sb->protoentsize = size; - aptr = sb->protoent + 16 + numaliases * 4; + aptr = sb->protoent + 16 + numaliases * 4; - // transfer protoent to Amiga memory - trap_put_long(ctx, sb->protoent + 4, sb->protoent + 12); - trap_put_long(ctx, sb->protoent + 8, p->p_proto); + // transfer protoent to Amiga memory + trap_put_long (ctx, sb->protoent + 4, sb->protoent + 12); + trap_put_long (ctx, sb->protoent + 8, p->p_proto); - for (i = 0; i < numaliases; i++) - trap_put_long(ctx, sb->protoent + 12 + i * 4, addstr(ctx, &aptr, p->p_aliases[i])); - trap_put_long(ctx, sb->protoent + 12 + numaliases * 4, 0); - trap_put_long(ctx, sb->protoent, aptr); - addstr(ctx, &aptr, p->p_name); - bsdsocklib_seterrno(ctx, sb, 0); + for (i = 0; i < numaliases; i++) + trap_put_long (ctx, sb->protoent + 12 + i * 4, addstr (ctx, &aptr, p->p_aliases[i])); + trap_put_long (ctx, sb->protoent + 12 + numaliases * 4, 0); + trap_put_long (ctx, sb->protoent, aptr); + addstr (ctx, &aptr, p->p_name); + bsdsocklib_seterrno(ctx, sb, 0); } -uae_u32 bsdthr_WaitSelect(SB) +uae_u32 bsdthr_WaitSelect (SB) { - fd_set sets[3]; - int i, s, set, a_s, max; - uae_u32 a_set; - struct timeval tv; - int r; + fd_set sets [3]; + int i, s, set, a_s, max; + uae_u32 a_set; + struct timeval tv; + int r; - DEBUG_LOG("WaitSelect: %d 0x%x 0x%x 0x%x 0x%x 0x%x\n", sb->nfds, sb->sets[0], sb->sets[1], sb->sets[2], sb->timeout, sb->sigmp); + DEBUG_LOG ("WaitSelect: %d 0x%x 0x%x 0x%x 0x%x 0x%x\n", sb->nfds, sb->sets [0], sb->sets [1], sb->sets [2], sb->timeout, sb->sigmp); - if (sb->timeout) - DEBUG_LOG("WaitSelect: timeout %d %d\n", trap_get_long(sb->context, sb->timeout), trap_get_long(sb->context, sb->timeout + 4)); + if (sb->timeout) + DEBUG_LOG ("WaitSelect: timeout %d %d\n", trap_get_long (sb->context, sb->timeout), trap_get_long (sb->context, sb->timeout + 4)); - FD_ZERO(&sets[0]); - FD_ZERO(&sets[1]); - FD_ZERO(&sets[2]); + FD_ZERO (&sets [0]); + FD_ZERO (&sets [1]); + FD_ZERO (&sets [2]); - /* Set up the abort socket */ - FD_SET(sb->sockabort[0], &sets[0]); - FD_SET(sb->sockabort[0], &sets[2]); - max = sb->sockabort[0]; + /* Set up the abort socket */ + FD_SET (sb->sockabort[0], &sets[0]); + FD_SET (sb->sockabort[0], &sets[2]); + max = sb->sockabort[0]; - for (set = 0; set < 3; set++) { - if (sb->sets[set] != 0) { - a_set = sb->sets[set]; - for (i = 0; i < sb->nfds; i++) { - if (bsd_amigaside_FD_ISSET(sb->context, i, a_set)) { - s = getsock(sb->context, sb, i + 1); - DEBUG_LOG("WaitSelect: AmigaSide %d set. NativeSide %d.\n", i, s); - if (s == -1) { - write_log("BSDSOCK: WaitSelect() called with invalid descriptor %d in set %d.\n", i, set); - } - else { - FD_SET(s, &sets[set]); - if (max < s) max = s; - } - } - } + for (set = 0; set < 3; set++) { + if (sb->sets [set] != 0) { + a_set = sb->sets [set]; + for (i = 0; i < sb->nfds; i++) { + if (bsd_amigaside_FD_ISSET (sb->context, i, a_set)) { + s = getsock (sb->context, sb, i + 1); + DEBUG_LOG ("WaitSelect: AmigaSide %d set. NativeSide %d.\n", i, s); + if (s == -1) { + write_log ("BSDSOCK: WaitSelect() called with invalid descriptor %d in set %d.\n", i, set); + } else { + FD_SET (s, &sets [set]); + if (max < s) max = s; + } + } + } } - } + } - max++; + max++; - if (sb->timeout) { - tv.tv_sec = trap_get_long(sb->context, sb->timeout); - tv.tv_usec = trap_get_long(sb->context, sb->timeout + 4); - } + if (sb->timeout) { + tv.tv_sec = trap_get_long (sb->context, sb->timeout); + tv.tv_usec = trap_get_long (sb->context, sb->timeout + 4); + } - DEBUG_LOG("Select going to select\n"); - r = select(max, &sets[0], &sets[1], &sets[2], (sb->timeout == 0) ? NULL : &tv); - DEBUG_LOG("Select returns %d, errno is %d\n", r, errno); - if (r > 0) { + DEBUG_LOG("Select going to select\n"); + r = select (max, &sets [0], &sets [1], &sets [2], (sb->timeout == 0) ? NULL : &tv); + DEBUG_LOG("Select returns %d, errno is %d\n", r, errno); + if( r > 0 ) { /* Socket told us to abort */ - if (FD_ISSET(sb->sockabort[0], &sets[0])) { - /* read from the pipe to reset it */ - DEBUG_LOG("WaitSelect aborted from signal\n"); - r = 0; - for (set = 0; set < 3; set++) - if (sb->sets[set] != 0) - bsd_amigaside_FD_ZERO(sb->context, sb->sets[set]); - clearsockabort(sb); + if (FD_ISSET (sb->sockabort[0], &sets[0])) { + /* read from the pipe to reset it */ + DEBUG_LOG ("WaitSelect aborted from signal\n"); + r = 0; + for (set = 0; set < 3; set++) + if (sb->sets [set] != 0) + bsd_amigaside_FD_ZERO (sb->context, sb->sets [set]); + clearsockabort (sb); } - else - /* This is perhaps slightly inefficient, but I don't care.. */ - for (set = 0; set < 3; set++) { - a_set = sb->sets[set]; - if (a_set != 0) { - bsd_amigaside_FD_ZERO(sb->context, a_set); - for (i = 0; i < sb->nfds; i++) { - a_s = getsock(sb->context, sb, i + 1); - if (a_s != -1) { - if (FD_ISSET(a_s, &sets[set])) { - DEBUG_LOG("WaitSelect: NativeSide %d set. AmigaSide %d.\n", a_s, i); + else + /* This is perhaps slightly inefficient, but I don't care.. */ + for (set = 0; set < 3; set++) { + a_set = sb->sets [set]; + if (a_set != 0) { + bsd_amigaside_FD_ZERO (sb->context, a_set); + for (i = 0; i < sb->nfds; i++) { + a_s = getsock (sb->context, sb, i + 1); + if (a_s != -1) { + if (FD_ISSET (a_s, &sets [set])) { + DEBUG_LOG ("WaitSelect: NativeSide %d set. AmigaSide %d.\n", a_s, i); - bsd_amigaside_FD_SET(sb->context, i, a_set); - } - } - } - } - } - } - else if (r == 0) { /* Timeout. I think we're supposed to clear the sets.. */ + bsd_amigaside_FD_SET (sb->context, i, a_set); + } + } + } + } + } + } else if (r == 0) { /* Timeout. I think we're supposed to clear the sets.. */ for (set = 0; set < 3; set++) - if (sb->sets[set] != 0) - bsd_amigaside_FD_ZERO(sb->context, sb->sets[set]); - } - DEBUG_LOG("WaitSelect: r=%d errno=%d\n", r, errno); - return r; + if (sb->sets [set] != 0) + bsd_amigaside_FD_ZERO (sb->context, sb->sets [set]); + } + DEBUG_LOG ("WaitSelect: r=%d errno=%d\n", r, errno); + return r; } -uae_u32 bsdthr_Accept_2(SB) +uae_u32 bsdthr_Accept_2 (SB) { - int foo, s, s2; - long flags; - struct sockaddr_in addr; - socklen_t hlen = sizeof(struct sockaddr_in); + int foo, s, s2; + long flags; + struct sockaddr_in addr; + socklen_t hlen = sizeof (struct sockaddr_in); - if ((s = accept(sb->s, (struct sockaddr *)&addr, &hlen)) >= 0) { - if ((flags = fcntl(s, F_GETFL)) == -1) - flags = 0; - fcntl(s, F_SETFL, flags & ~O_NONBLOCK); /* @@@ Don't do this if it's supposed to stay nonblocking... */ - s2 = getsd(sb->context, sb, s); - sb->ftable[s2 - 1] = sb->ftable[sb->len]; /* new socket inherits the old socket's properties */ - DEBUG_LOG("Accept: AmigaSide %d, NativeSide %d, len %d(%d)", sb->resultval, s, hlen, trap_get_long(sb->context, sb->a_addrlen)); - printSockAddr(&addr); - foo = trap_get_long(sb->context, sb->a_addrlen); - if (foo > 16) - trap_put_long(sb->context, sb->a_addrlen, 16); - copysockaddr_n2a(sb->context, sb->a_addr, &addr, foo); - return s2 - 1; - } - else { + if ((s = accept (sb->s, reinterpret_cast(&addr), &hlen)) >= 0) { + if ((flags = fcntl (s, F_GETFL)) == -1) + flags = 0; + fcntl (s, F_SETFL, flags & ~O_NONBLOCK); /* @@@ Don't do this if it's supposed to stay nonblocking... */ + s2 = getsd (sb->context, sb, s); + sb->ftable[s2-1] = sb->ftable[sb->len]; /* new socket inherits the old socket's properties */ + DEBUG_LOG ("Accept: AmigaSide %d, NativeSide %d, len %d(%d)", sb->resultval, s, hlen, trap_get_long (sb->context, sb->a_addrlen)); + printSockAddr (&addr); + foo = trap_get_long (sb->context, sb->a_addrlen); + if (foo > 16) + trap_put_long (sb->context, sb->a_addrlen, 16); + copysockaddr_n2a (sb->context, sb->a_addr, &addr, foo); + return s2 - 1; + } else { return -1; - } + } } -uae_u32 bsdthr_Recv_2(SB) +uae_u32 bsdthr_Recv_2 (SB) { - int foo; - if (sb->from == 0) { - foo = recv(sb->s, sb->buf, sb->len, sb->flags /*| MSG_NOSIGNAL*/); - DEBUG_LOG("recv2, recv returns %d, errno is %d\n", foo, errno); - } - else { - struct sockaddr_in addr; - socklen_t l = sizeof(struct sockaddr_in); - int i = trap_get_long(sb->context, sb->fromlen); - copysockaddr_a2n(sb->context, &addr, sb->from, i); - foo = recvfrom(sb->s, sb->buf, sb->len, sb->flags | MSG_NOSIGNAL, (struct sockaddr *)&addr, &l); - DEBUG_LOG("recv2, recvfrom returns %d, errno is %d\n", foo, errno); - if (foo >= 0) { - copysockaddr_n2a(sb->context, sb->from, &addr, l); - trap_put_long(sb->context, sb->fromlen, l); - } - } - return foo; + int foo; + if (sb->from == 0) { + foo = recv (sb->s, sb->buf, sb->len, sb->flags /*| MSG_NOSIGNAL*/); + DEBUG_LOG ("recv2, recv returns %d, errno is %d\n", foo, errno); + } else { + struct sockaddr_in addr; + socklen_t l = sizeof (struct sockaddr_in); + int i = trap_get_long (sb->context, sb->fromlen); + copysockaddr_a2n (sb->context, &addr, sb->from, i); + foo = recvfrom (sb->s, sb->buf, sb->len, sb->flags | MSG_NOSIGNAL, (struct sockaddr *)&addr, &l); + DEBUG_LOG ("recv2, recvfrom returns %d, errno is %d\n", foo, errno); + if (foo >= 0) { + copysockaddr_n2a (sb->context, sb->from, &addr, l); + trap_put_long (sb->context, sb->fromlen, l); + } + } + return foo; } -uae_u32 bsdthr_Send_2(SB) +uae_u32 bsdthr_Send_2 (SB) { - if (sb->to == 0) { - return send(sb->s, sb->buf, sb->len, sb->flags | MSG_NOSIGNAL); - } - else { + if (sb->to == 0) { + return send (sb->s, sb->buf, sb->len, sb->flags | MSG_NOSIGNAL); + } else { struct sockaddr_in addr; - int l = sizeof(struct sockaddr_in); - copysockaddr_a2n(sb->context, &addr, sb->to, sb->tolen); - return sendto(sb->s, sb->buf, sb->len, sb->flags | MSG_NOSIGNAL, (struct sockaddr *)&addr, l); - } + int l = sizeof (struct sockaddr_in); + copysockaddr_a2n (sb->context, &addr, sb->to, sb->tolen); + return sendto (sb->s, sb->buf, sb->len, sb->flags | MSG_NOSIGNAL, (struct sockaddr *)&addr, l); + } } -uae_u32 bsdthr_Connect_2(SB) +uae_u32 bsdthr_Connect_2 (SB) { - if (sb->action == 1) { + if (sb->action == 1) { struct sockaddr_in addr; - int len = sizeof(struct sockaddr_in); + int len = sizeof (struct sockaddr_in); int retval; - copysockaddr_a2n(sb->context, &addr, sb->a_addr, sb->a_addrlen); - retval = connect(sb->s, (struct sockaddr *)&addr, len); - DEBUG_LOG("Connect returns %d, errno is %d\n", retval, errno); + copysockaddr_a2n (sb->context, &addr, sb->a_addr, sb->a_addrlen); + retval = connect (sb->s, reinterpret_cast(&addr), len); + DEBUG_LOG ("Connect returns %d, errno is %d\n", retval, errno); /* Hack: I need to set the action to something other than - * 1 but I know action == 2 does the correct thing - */ + * 1 but I know action == 2 does the correct thing + */ sb->action = 2; if (retval == 0) { - errno = 0; + errno = 0; } return retval; - } - else { + } else { int foo; socklen_t bar; - bar = sizeof(foo); - if (getsockopt(sb->s, SOL_SOCKET, SO_ERROR, &foo, &bar) == 0) { - errno = foo; - DEBUG_LOG("Connect status is %d\n", foo); - return (foo == 0) ? 0 : -1; + bar = sizeof (foo); + if (getsockopt (sb->s, SOL_SOCKET, SO_ERROR, &foo, &bar) == 0) { + errno = foo; + DEBUG_LOG("Connect status is %d\n", foo); + return (foo == 0) ? 0 : -1; } - return -1; - } + return -1; + } } -uae_u32 bsdthr_SendRecvAcceptConnect(uae_u32(*tryfunc)(SB), SB) +uae_u32 bsdthr_SendRecvAcceptConnect (uae_u32 (*tryfunc)(SB), SB) { - return bsdthr_blockingstuff(tryfunc, sb); + return bsdthr_blockingstuff (tryfunc, sb); } -uae_u32 bsdthr_blockingstuff(uae_u32(*tryfunc)(SB), SB) +uae_u32 bsdthr_blockingstuff (uae_u32 (*tryfunc)(SB), SB) { - int done = 0, foo; - long flags; - int nonblock; - if ((flags = fcntl(sb->s, F_GETFL)) == -1) - flags = 0; - nonblock = (flags & O_NONBLOCK); - fcntl(sb->s, F_SETFL, flags | O_NONBLOCK); - while (!done) { - done = 1; - foo = tryfunc(sb); - if (foo < 0 && !nonblock) { - if ((errno == EAGAIN) || (errno == EWOULDBLOCK) || (errno == EINPROGRESS)) { - fd_set readset, writeset, exceptset; - int maxfd = (sb->s > sb->sockabort[0]) ? sb->s : sb->sockabort[0]; - int num; + int done = 0, foo; + long flags; + int nonblock; + if ((flags = fcntl (sb->s, F_GETFL)) == -1) + flags = 0; + nonblock = (flags & O_NONBLOCK); + fcntl (sb->s, F_SETFL, flags | O_NONBLOCK); + while (!done) { + done = 1; + foo = tryfunc (sb); + if (foo < 0 && !nonblock) { + if ((errno == EAGAIN) || (errno == EWOULDBLOCK) || (errno == EINPROGRESS)) { + fd_set readset, writeset, exceptset; + int maxfd = (sb->s > sb->sockabort[0]) ? sb->s : sb->sockabort[0]; + int num; + + FD_ZERO (&readset); + FD_ZERO (&writeset); + FD_ZERO (&exceptset); - FD_ZERO(&readset); - FD_ZERO(&writeset); - FD_ZERO(&exceptset); + if (sb->action == 3 || sb->action == 6) + FD_SET (sb->s, &readset); + if (sb->action == 2 || sb->action == 1 || sb->action == 4) + FD_SET (sb->s, &writeset); + FD_SET (sb->sockabort[0], &readset); - if (sb->action == 3 || sb->action == 6) - FD_SET(sb->s, &readset); - if (sb->action == 2 || sb->action == 1 || sb->action == 4) - FD_SET(sb->s, &writeset); - FD_SET(sb->sockabort[0], &readset); + num = select (maxfd + 1, &readset, &writeset, &exceptset, NULL); + if (num == -1) { + DEBUG_LOG ("Blocking select(%d) returns -1,errno is %d\n", sb->sockabort[0],errno); + fcntl (sb->s, F_SETFL, flags); + return -1; + } - num = select(maxfd + 1, &readset, &writeset, &exceptset, NULL); - if (num == -1) { - DEBUG_LOG("Blocking select(%d) returns -1,errno is %d\n", sb->sockabort[0], errno); - fcntl(sb->s, F_SETFL, flags); - return -1; - } + if (FD_ISSET (sb->sockabort[0], &readset) || FD_ISSET (sb->sockabort[0], &writeset)) { + /* reset sock abort pipe */ + /* read from the pipe to reset it */ + DEBUG_LOG ("select aborted from signal\n"); - if (FD_ISSET(sb->sockabort[0], &readset) || FD_ISSET(sb->sockabort[0], &writeset)) { - /* reset sock abort pipe */ - /* read from the pipe to reset it */ - DEBUG_LOG("select aborted from signal\n"); - - clearsockabort(sb); - DEBUG_LOG("Done read\n"); - errno = EINTR; - done = 1; - } - else { - done = 0; - } - } - else if (errno == EINTR) - done = 1; - } - } - fcntl(sb->s, F_SETFL, flags); - return foo; + clearsockabort (sb); + DEBUG_LOG ("Done read\n"); + errno = EINTR; + done = 1; + } else { + done = 0; + } + } else if (errno == EINTR) + done = 1; + } + } + fcntl (sb->s, F_SETFL, flags); + return foo; } -static void *bsdlib_threadfunc(void *arg) +static void *bsdlib_threadfunc (void *arg) { - struct socketbase *sb = (struct socketbase *) arg; + struct socketbase *sb = static_cast(arg); - DEBUG_LOG("THREAD_START\n"); + DEBUG_LOG ("THREAD_START\n"); - while (1) { - uae_sem_wait(&sb->sem); - TrapContext *ctx = sb->context; + while (1) { + uae_sem_wait (&sb->sem); + TrapContext *ctx = sb->context; - DEBUG_LOG("Socket thread got action %d (sb=0x%08x)\n", sb->action, sb); + DEBUG_LOG ("Socket thread got action %d (sb=0x%08x)\n", sb->action, sb); - switch (sb->action) { - case 0: /* kill thread (CloseLibrary) */ - DEBUG_LOG("THREAD_END\n"); - uae_sem_destroy(&sb->sem); - return NULL; + switch (sb->action) { + case 0: /* kill thread (CloseLibrary) */ + DEBUG_LOG ("THREAD_END\n"); + uae_sem_destroy (&sb->sem); + return NULL; - case 1: /* Connect */ - sb->resultval = bsdthr_SendRecvAcceptConnect(bsdthr_Connect_2, sb); - break; + case 1: /* Connect */ + sb->resultval = bsdthr_SendRecvAcceptConnect (bsdthr_Connect_2, sb); + break; - /* @@@ Should check (from|to)len so it's 16.. */ - case 2: /* Send[to] */ - sb->resultval = bsdthr_SendRecvAcceptConnect(bsdthr_Send_2, sb); - break; + /* @@@ Should check (from|to)len so it's 16.. */ + case 2: /* Send[to] */ + sb->resultval = bsdthr_SendRecvAcceptConnect (bsdthr_Send_2, sb); + break; - case 3: /* Recv[from] */ - sb->resultval = bsdthr_SendRecvAcceptConnect(bsdthr_Recv_2, sb); - break; + case 3: /* Recv[from] */ + sb->resultval = bsdthr_SendRecvAcceptConnect (bsdthr_Recv_2, sb); + break; - case 4: { /* Gethostbyname */ - struct hostent *tmphostent = gethostbyname((char *)get_real_address(sb->name)); - if (tmphostent) { - copyHostent(tmphostent, sb); - bsdsocklib_setherrno(ctx, sb, 0); - } - else - SETHERRNO; + case 4: /* Gethostbyname */ + { + struct hostent *tmphostent = gethostbyname (reinterpret_cast(get_real_address(sb->name))); + if (tmphostent) { + copyHostent (tmphostent, sb); + bsdsocklib_setherrno (ctx, sb, 0); + } else + SETHERRNO; - break; - } + break; + } - case 5: /* WaitSelect */ - sb->resultval = bsdthr_WaitSelect(sb); - break; + case 5: /* WaitSelect */ + sb->resultval = bsdthr_WaitSelect (sb); + break; - case 6: /* Accept */ - sb->resultval = bsdthr_SendRecvAcceptConnect(bsdthr_Accept_2, sb); - break; + case 6: /* Accept */ + sb->resultval = bsdthr_SendRecvAcceptConnect (bsdthr_Accept_2, sb); + break; - case 7: { - struct hostent *tmphostent = gethostbyaddr(get_real_address(sb->name), sb->a_addrlen, sb->flags); + case 7: + { + struct hostent *tmphostent = gethostbyaddr (reinterpret_cast(get_real_address(sb->name)), sb->a_addrlen, sb->flags); - if (tmphostent) { - copyHostent(tmphostent, sb); - bsdsocklib_setherrno(ctx, sb, 0); - } - else - SETHERRNO; + if (tmphostent) { + copyHostent (tmphostent, sb); + bsdsocklib_setherrno (ctx, sb, 0); + } else + SETHERRNO; - break; - } - } - SETERRNO; - SETSIGNAL; - } + break; + } + } + SETERRNO; + SETSIGNAL; + } - return NULL; /* Just to keep GCC happy.. */ + return NULL; /* Just to keep GCC happy.. */ } -void host_connect(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) +void host_connect (TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) { - sb->s = getsock(ctx, sb, sd + 1); - if (sb->s == -1) { + sb->s = getsock (ctx, sb, sd + 1); + if (sb->s == -1) { sb->resultval = -1; - bsdsocklib_seterrno(ctx, sb, 9); /* EBADF */ + bsdsocklib_seterrno (ctx, sb, 9); /* EBADF */ return; - } - sb->a_addr = name; - sb->a_addrlen = namelen; - sb->action = 1; - sb->context = ctx; + } + sb->a_addr = name; + sb->a_addrlen = namelen; + sb->action = 1; + sb->context = ctx; + + uae_sem_post (&sb->sem); - uae_sem_post(&sb->sem); - - WAITSIGNAL; + WAITSIGNAL; } -void host_sendto(TrapContext *ctx, SB, uae_u32 sd, uae_u32 msg, uae_u8* hmsg, uae_u32 len, uae_u32 flags, uae_u32 to, uae_u32 tolen) +void host_sendto (TrapContext *ctx, SB, uae_u32 sd, uae_u32 msg, uae_u8* hmsg, uae_u32 len, uae_u32 flags, uae_u32 to, uae_u32 tolen) { - sb->s = getsock(ctx, sb, sd + 1); - if (sb->s == -1) { + sb->s = getsock (ctx, sb, sd + 1); + if (sb->s == -1) { sb->resultval = -1; - bsdsocklib_seterrno(ctx, sb, 9); /* EBADF */ + bsdsocklib_seterrno (ctx, sb, 9); /* EBADF */ return; - } - if (hmsg == NULL) - sb->buf = get_real_address(msg); - else - sb->buf = hmsg; - sb->len = len; - sb->flags = flags; - sb->to = to; - sb->tolen = tolen; - sb->action = 2; - sb->context = ctx; + } + if(hmsg == NULL) + sb->buf = get_real_address (msg); + else + sb->buf = hmsg; + sb->len = len; + sb->flags = flags; + sb->to = to; + sb->tolen = tolen; + sb->action = 2; + sb->context = ctx; - uae_sem_post(&sb->sem); + uae_sem_post (&sb->sem); - WAITSIGNAL; + WAITSIGNAL; } -void host_recvfrom(TrapContext *ctx, SB, uae_u32 sd, uae_u32 msg, uae_u8* hmsg, uae_u32 len, uae_u32 flags, uae_u32 addr, uae_u32 addrlen) +void host_recvfrom (TrapContext *ctx, SB, uae_u32 sd, uae_u32 msg, uae_u8* hmsg, uae_u32 len, uae_u32 flags, uae_u32 addr, uae_u32 addrlen) { - int s = getsock(ctx, sb, sd + 1); + int s = getsock (ctx, sb, sd + 1); - DEBUG_LOG("Recv[from](%p, %x, %x, %d, %x, %x, %u)\n", - sb, sd, msg, len, flags, addr, addrlen); + DEBUG_LOG ("Recv[from](%p, %x, %x, %d, %x, %x, %u)\n", + sb, sd, msg, len, flags, addr, addrlen); - if (s == -1) { + if (s == -1) { sb->resultval = -1; - bsdsocklib_seterrno(ctx, sb, 9); /* EBADF */; + bsdsocklib_seterrno (ctx, sb, 9); /* EBADF */ return; - } + } - sb->s = s; - if (hmsg == NULL) - sb->buf = get_real_address(msg); - else - sb->buf = hmsg; - sb->len = len; - sb->flags = flags; - sb->from = addr; - sb->fromlen = addrlen; - sb->action = 3; - sb->context = ctx; + sb->s = s; + if(hmsg == NULL) + sb->buf = get_real_address (msg); + else + sb->buf = hmsg; + sb->len = len; + sb->flags = flags; + sb->from = addr; + sb->fromlen= addrlen; + sb->action = 3; + sb->context = ctx; - uae_sem_post(&sb->sem); + uae_sem_post (&sb->sem); - WAITSIGNAL; + WAITSIGNAL; } -void host_setsockopt(TrapContext *ctx, SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 optval, uae_u32 optlen) +void host_setsockopt (TrapContext *ctx, SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 optval, uae_u32 optlen) { - int s = getsock(ctx, sb, sd + 1); - int nativelevel = mapsockoptlevel(level); - int nativeoptname = mapsockoptname(nativelevel, optname); - void *buf; - if (s == -1) { + int s = getsock (ctx, sb, sd + 1); + int nativelevel = mapsockoptlevel (level); + int nativeoptname = mapsockoptname(nativelevel, optname); + void *buf; + if (s == -1) { sb->resultval = -1; - bsdsocklib_seterrno(ctx, sb, 9); /* EBADF */; + bsdsocklib_seterrno (ctx, sb, 9); /* EBADF */ return; - } + } - if (optval) { + if (optval) { buf = malloc(optlen); mapsockoptvalue(ctx, nativelevel, nativeoptname, optval, buf); - } - else { + } else { buf = NULL; - } - sb->resultval = setsockopt(s, nativelevel, nativeoptname, buf, optlen); - if (buf) - free(buf); - SETERRNO; + } + sb->resultval = setsockopt (s, nativelevel, nativeoptname, buf, optlen); + if (buf) + free(buf); + SETERRNO; - DEBUG_LOG("setsockopt: sock %d, level %d, 'name' %d(%d), len %d -> %d, %d\n", - s, level, optname, nativeoptname, optlen, - sb->resultval, errno); + DEBUG_LOG ("setsockopt: sock %d, level %d, 'name' %d(%d), len %d -> %d, %d\n", + s, level, optname, nativeoptname, optlen, + sb->resultval, errno); } -uae_u32 host_getsockname(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) +uae_u32 host_getsockname (TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) { - int s; - socklen_t len = sizeof(struct sockaddr_in); - struct sockaddr_in addr; + int s; + socklen_t len = sizeof (struct sockaddr_in); + struct sockaddr_in addr; - DEBUG_LOG("getsockname(%u, 0x%x, %u) -> ", sd, name, len); + DEBUG_LOG ("getsockname(%u, 0x%x, %u) -> ", sd, name, len); - s = getsock(ctx, sb, sd + 1); + s = getsock (ctx, sb, sd + 1); - if (s != -1) { - if (getsockname(s, (struct sockaddr *)&addr, &len)) { + if (s != -1) { + if (getsockname (s, (struct sockaddr *)&addr, &len)) { SETERRNO; - DEBUG_LOG("failed (%d)\n", sb->sb_errno); - } - else { + DEBUG_LOG ("failed (%d)\n", sb->sb_errno); + } else { int a_nl; - DEBUG_LOG("okay\n"); - a_nl = trap_get_long(ctx, namelen); - if (!trap_valid_address(ctx, name, a_nl)) - return -1; - copysockaddr_n2a(ctx, name, &addr, a_nl); + DEBUG_LOG ("okay\n"); + a_nl = trap_get_long (ctx, namelen); + if (!trap_valid_address(ctx, name, a_nl)) + return -1; + copysockaddr_n2a (ctx, name, &addr, a_nl); if (a_nl > 16) - trap_put_long(ctx, namelen, 16); - return 0; - } + trap_put_long (ctx, namelen, 16); + return 0; + } } return -1; } -uae_u32 host_getpeername(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) +uae_u32 host_getpeername (TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) { - int s; - socklen_t len = sizeof(struct sockaddr_in); - struct sockaddr_in addr; + int s; + socklen_t len = sizeof (struct sockaddr_in); + struct sockaddr_in addr; - DEBUG_LOG("getpeername(%u, 0x%x, %u) -> ", sd, name, len); + DEBUG_LOG ("getpeername(%u, 0x%x, %u) -> ", sd, name, len); - s = getsock(ctx, sb, sd + 1); + s = getsock (ctx, sb, sd + 1); - if (s != -1) { - if (getpeername(s, (struct sockaddr *)&addr, &len)) { + if (s != -1) { + if (getpeername (s, (struct sockaddr *)&addr, &len)) { SETERRNO; - DEBUG_LOG("failed (%d)\n", sb->sb_errno); + DEBUG_LOG ("failed (%d)\n", sb->sb_errno); + } else { + int a_nl; + DEBUG_LOG ("okay\n"); + a_nl = trap_get_long (ctx, namelen); + if (!trap_valid_address(ctx, name, a_nl)) + return -1; + copysockaddr_n2a (ctx, name, &addr, a_nl); + if (a_nl > 16) + trap_put_long (ctx, namelen, 16); + return 0; } - else { - int a_nl; - DEBUG_LOG("okay\n"); - a_nl = trap_get_long(ctx, namelen); - if (!trap_valid_address(ctx, name, a_nl)) - return -1; - copysockaddr_n2a(ctx, name, &addr, a_nl); - if (a_nl > 16) - trap_put_long(ctx, namelen, 16); - return 0; - } - } + } - return -1; + return -1; } -void host_gethostbynameaddr(TrapContext *ctx, SB, uae_u32 name, uae_u32 namelen, long addrtype) +void host_gethostbynameaddr (TrapContext *ctx, SB, uae_u32 name, uae_u32 namelen, long addrtype) { - sb->name = name; - sb->a_addrlen = namelen; - sb->flags = addrtype; - if (addrtype == -1) - sb->action = 4; - else - sb->action = 7; - sb->context = ctx; + sb->name = name; + sb->a_addrlen = namelen; + sb->flags = addrtype; + if (addrtype == -1) + sb->action = 4; + else + sb->action = 7; + sb->context = ctx; - uae_sem_post(&sb->sem); + uae_sem_post (&sb->sem); - WAITSIGNAL; + WAITSIGNAL; } -void host_WaitSelect(TrapContext *ctx, SB, uae_u32 nfds, uae_u32 readfds, uae_u32 writefds, uae_u32 exceptfds, - uae_u32 timeout, uae_u32 sigmp) +void host_WaitSelect (TrapContext *ctx, SB, uae_u32 nfds, uae_u32 readfds, uae_u32 writefds, uae_u32 exceptfds, + uae_u32 timeout, uae_u32 sigmp) { - uae_u32 wssigs = (sigmp) ? trap_get_long(ctx, sigmp) : 0; - uae_u32 sigs; + uae_u32 wssigs = (sigmp) ? trap_get_long (ctx, sigmp) : 0; + uae_u32 sigs; - if (wssigs) { - trap_call_add_dreg(ctx, 0, 0); - trap_call_add_dreg(ctx, 1, wssigs); - sigs = trap_call_lib(ctx, trap_get_long(ctx, 4), -0x132) & wssigs; // SetSignal() + if (wssigs) { + trap_call_add_dreg (ctx, 0, 0); + trap_call_add_dreg (ctx, 1, wssigs); + sigs = trap_call_lib (ctx, trap_get_long (ctx, 4), -0x132) & wssigs; // SetSignal() if (sigs) { - DEBUG_LOG("WaitSelect preempted by signals 0x%08x\n", sigs & wssigs); - trap_put_long(ctx, sigmp, sigs); - // Check for zero address -> otherwise WinUAE crashes - if (readfds) fd_zero(ctx, readfds, nfds); - if (writefds) fd_zero(ctx, writefds, nfds); - if (exceptfds) fd_zero(ctx, exceptfds, nfds); - sb->resultval = 0; - bsdsocklib_seterrno(ctx, sb, 0); - return; + DEBUG_LOG ("WaitSelect preempted by signals 0x%08x\n", sigs & wssigs); + trap_put_long (ctx, sigmp, sigs); + // Check for zero address -> otherwise WinUAE crashes + if (readfds) fd_zero (ctx, readfds, nfds); + if (writefds) fd_zero (ctx, writefds, nfds); + if (exceptfds) fd_zero (ctx, exceptfds, nfds); + sb->resultval = 0; + bsdsocklib_seterrno (ctx, sb, 0); + return; } - } + } - if (nfds == 0) { + if (nfds == 0) { /* No sockets - Just wait on signals */ - trap_call_add_dreg(ctx, 0, wssigs); - sigs = trap_call_lib(ctx, trap_get_long(ctx, 4), -0x13e); // Wait() + trap_call_add_dreg (ctx, 0, wssigs); + sigs = trap_call_lib (ctx, trap_get_long (ctx, 4), -0x13e); // Wait() if (sigmp) - trap_put_long(ctx, sigmp, sigs & wssigs); + trap_put_long (ctx, sigmp, sigs & wssigs); - if (readfds) fd_zero(ctx, readfds, nfds); - if (writefds) fd_zero(ctx, writefds, nfds); - if (exceptfds) fd_zero(ctx, exceptfds, nfds); + if (readfds) fd_zero (ctx, readfds, nfds); + if (writefds) fd_zero (ctx, writefds, nfds); + if (exceptfds) fd_zero (ctx, exceptfds, nfds); sb->resultval = 0; return; - } + } - sb->nfds = nfds; - sb->sets[0] = readfds; - sb->sets[1] = writefds; - sb->sets[2] = exceptfds; - sb->timeout = timeout; - sb->sigmp = wssigs; - sb->action = 5; - sb->context = ctx; + sb->nfds = nfds; + sb->sets [0] = readfds; + sb->sets [1] = writefds; + sb->sets [2] = exceptfds; + sb->timeout = timeout; + sb->sigmp = wssigs; + sb->action = 5; + sb->context = ctx; - uae_sem_post(&sb->sem); + uae_sem_post (&sb->sem); - trap_call_add_dreg(ctx, 0, (((uae_u32)1) << sb->signal) | sb->eintrsigs | wssigs); - sigs = trap_call_lib(ctx, trap_get_long(ctx, 4), -0x13e); // Wait() + trap_call_add_dreg (ctx, 0, (((uae_u32)1) << sb->signal) | sb->eintrsigs | wssigs); + sigs = trap_call_lib (ctx, trap_get_long (ctx, 4), -0x13e); // Wait() - if (sigmp) - trap_put_long(ctx, sigmp, sigs & (sb->eintrsigs | wssigs)); + if (sigmp) + trap_put_long (ctx, sigmp, sigs & (sb->eintrsigs | wssigs)); - if (sigs & wssigs) { + if (sigs & wssigs) { /* Received the signals we were waiting on */ - DEBUG_LOG("WaitSelect: got signal(s) %x\n", sigs); + DEBUG_LOG ("WaitSelect: got signal(s) %x\n", sigs); if (!(sigs & (((uae_u32)1) << sb->signal))) { - sockabort(sb); - WAITSIGNAL; + sockabort (sb); + WAITSIGNAL; } sb->resultval = 0; - if (readfds) fd_zero(ctx, readfds, nfds); - if (writefds) fd_zero(ctx, writefds, nfds); - if (exceptfds) fd_zero(ctx, exceptfds, nfds); + if (readfds) fd_zero (ctx, readfds, nfds); + if (writefds) fd_zero (ctx, writefds, nfds); + if (exceptfds) fd_zero (ctx, exceptfds, nfds); - bsdsocklib_seterrno(ctx, sb, 0); - } - else if (sigs & sb->eintrsigs) { + bsdsocklib_seterrno (ctx, sb, 0); + } else if (sigs & sb->eintrsigs) { /* Wait select was interrupted */ - DEBUG_LOG("WaitSelect: interrupted\n"); + DEBUG_LOG ("WaitSelect: interrupted\n"); if (!(sigs & (((uae_u32)1) << sb->signal))) { - sockabort(sb); - WAITSIGNAL; + sockabort (sb); + WAITSIGNAL; } sb->resultval = -1; - bsdsocklib_seterrno(ctx, sb, mapErrno(EINTR)); - } - clearsockabort(sb); + bsdsocklib_seterrno (ctx, sb, mapErrno (EINTR)); + } + clearsockabort(sb); } -void host_accept(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) +void host_accept (TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) { - sb->s = getsock(ctx, sb, sd + 1); - if (sb->s == -1) { + sb->s = getsock (ctx, sb, sd + 1); + if (sb->s == -1) { sb->resultval = -1; - bsdsocklib_seterrno(ctx, sb, 9); /* EBADF */ + bsdsocklib_seterrno (ctx, sb, 9); /* EBADF */ return; - } + } if (name != 0) { if (!trap_valid_address(ctx, name, sizeof(struct sockaddr)) || !trap_valid_address(ctx, namelen, 4)) return; - } + } - DEBUG_LOG("accept(%d, %x, %x)\n", sb->s, name, namelen); - sb->a_addr = name; - sb->a_addrlen = namelen; - sb->action = 6; - sb->len = sd; - sb->context = ctx; + DEBUG_LOG ("accept(%d, %x, %x)\n", sb->s, name, namelen); + sb->a_addr = name; + sb->a_addrlen = namelen; + sb->action = 6; + sb->len = sd; + sb->context = ctx; - uae_sem_post(&sb->sem); + uae_sem_post (&sb->sem); - WAITSIGNAL; - DEBUG_LOG("Accept returns %d\n", sb->resultval); + WAITSIGNAL; + DEBUG_LOG ("Accept returns %d\n", sb->resultval); } -int host_socket(TrapContext *ctx, SB, int af, int type, int protocol) +int host_socket (TrapContext *ctx, SB, int af, int type, int protocol) { - int sd; - int s; + int sd; + int s; - DEBUG_LOG("socket(%s,%s,%d) -> ", af == AF_INET ? "AF_INET" : "AF_other", - type == SOCK_STREAM ? "SOCK_STREAM" : type == SOCK_DGRAM ? - "SOCK_DGRAM " : "SOCK_RAW", protocol); + DEBUG_LOG ("socket(%s,%s,%d) -> ",af == AF_INET ? "AF_INET" : "AF_other", + type == SOCK_STREAM ? "SOCK_STREAM" : type == SOCK_DGRAM ? + "SOCK_DGRAM " : "SOCK_RAW", protocol); - if ((s = socket(af, type, protocol)) == -1) { + if ((s = socket (af, type, protocol)) == -1) { SETERRNO; - DEBUG_LOG("failed (%d)\n", sb->sb_errno); + DEBUG_LOG ("failed (%d)\n", sb->sb_errno); return -1; - } - else { + } else { int arg = 1; - sd = getsd(ctx, sb, s); - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)); - } + sd = getsd (ctx, sb, s); + setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)); + } - sb->ftable[sd - 1] = SF_BLOCKING; - DEBUG_LOG("socket returns Amiga %d, NativeSide %d\n", sd - 1, s); - return sd - 1; + sb->ftable[sd-1] = SF_BLOCKING; + DEBUG_LOG ("socket returns Amiga %d, NativeSide %d\n", sd - 1, s); + return sd - 1; } -uae_u32 host_bind(TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) +uae_u32 host_bind (TrapContext *ctx, SB, uae_u32 sd, uae_u32 name, uae_u32 namelen) { - uae_u32 success = 0; - struct sockaddr_in addr; - int len = sizeof(struct sockaddr_in); - int s; + uae_u32 success = 0; + struct sockaddr_in addr; + int len = sizeof (struct sockaddr_in); + int s; - s = getsock(ctx, sb, sd + 1); - if (s == -1) { + s = getsock (ctx, sb, sd + 1); + if (s == -1) { sb->resultval = -1; - bsdsocklib_seterrno(ctx, sb, 9); /* EBADF */ + bsdsocklib_seterrno (ctx, sb, 9); /* EBADF */ return -1; - } + } - DEBUG_LOG("bind(%u[%d], 0x%x, %u) -> ", sd, s, name, namelen); - copysockaddr_a2n(ctx, &addr, name, namelen); - printSockAddr(&addr); - if ((success = bind(s, (struct sockaddr *)&addr, len)) != 0) { + DEBUG_LOG ("bind(%u[%d], 0x%x, %u) -> ", sd, s, name, namelen); + copysockaddr_a2n (ctx, &addr, name, namelen); + printSockAddr (&addr); + if ((success = bind (s, reinterpret_cast(&addr), len)) != 0) { SETERRNO; - DEBUG_LOG("failed (%d)\n", sb->sb_errno); - } - else { - DEBUG_LOG("OK\n"); - } - return success; + DEBUG_LOG ("failed (%d)\n",sb->sb_errno); + } else { + DEBUG_LOG ("OK\n"); + } + return success; } -uae_u32 host_listen(TrapContext *ctx, SB, uae_u32 sd, uae_u32 backlog) +uae_u32 host_listen (TrapContext *ctx, SB, uae_u32 sd, uae_u32 backlog) { - int s; - uae_u32 success = -1; + int s; + uae_u32 success = -1; - DEBUG_LOG("listen(%d,%d) -> ", sd, backlog); - s = getsock(ctx, sb, sd + 1); + DEBUG_LOG ("listen(%d,%d) -> ", sd, backlog); + s = getsock (ctx, sb, sd + 1); - if (s == -1) { - bsdsocklib_seterrno(ctx, sb, 9); + if (s == -1) { + bsdsocklib_seterrno (ctx, sb, 9); return -1; - } + } - if ((success = listen(s, backlog)) != 0) { + if ((success = listen (s, backlog)) != 0) { SETERRNO; - DEBUG_LOG("failed (%d)\n", sb->sb_errno); - } - else { - DEBUG_LOG("OK\n"); - } - return success; + DEBUG_LOG ("failed (%d)\n", sb->sb_errno); + } else { + DEBUG_LOG ("OK\n"); + } + return success; } -void host_getprotobyname(TrapContext *ctx, SB, uae_u32 name) +void host_getprotobyname (TrapContext *ctx, SB, uae_u32 name) { - struct protoent *p = getprotobyname((char *)get_real_address(name)); + struct protoent *p = getprotobyname (reinterpret_cast(get_real_address(name))); - DEBUG_LOG("Getprotobyname(%s) = %p\n", get_real_address(name), p); + DEBUG_LOG ("Getprotobyname(%s) = %p\n", get_real_address (name), p); - if (p == NULL) { + if (p == NULL) { SETERRNO; return; - } + } - copyProtoent(ctx, sb, p); - BSDTRACE(("OK (%s, %d)\n", p->p_name, p->p_proto)); + copyProtoent (ctx, sb, p); + BSDTRACE (("OK (%s, %d)\n", p->p_name, p->p_proto)); } -void host_getprotobynumber(TrapContext *ctx, SB, uae_u32 number) +void host_getprotobynumber (TrapContext *ctx, SB, uae_u32 number) { - struct protoent *p = getprotobynumber(number); - DEBUG_LOG("getprotobynumber(%d) = %p\n", number, p); + struct protoent *p = getprotobynumber(number); + DEBUG_LOG("getprotobynumber(%d) = %p\n", number, p); - if (p == NULL) { + if (p == NULL) { SETERRNO; return; - } + } - copyProtoent(ctx, sb, p); - BSDTRACE(("OK (%s, %d)\n", p->p_name, p->p_proto)); + copyProtoent (ctx, sb, p); + BSDTRACE (("OK (%s, %d)\n", p->p_name, p->p_proto)); } -void host_getservbynameport(TrapContext *ctx, SB, uae_u32 name, uae_u32 proto, uae_u32 type) +void host_getservbynameport (TrapContext *ctx, SB, uae_u32 name, uae_u32 proto, uae_u32 type) { - uae_char protobuf[256]; - uae_char namebuf[256]; + uae_char protobuf[256]; + uae_char namebuf[256]; if (proto) { if (trap_valid_address(ctx, proto, 1)) { trap_get_string(ctx, protobuf, proto, sizeof protobuf); } } - if (!type) { + if(!type) { if (trap_valid_address(ctx, name, 1)) { trap_get_string(ctx, namebuf, name, sizeof namebuf); } - } + } + + struct servent *s = (type) ? + getservbyport (name, protobuf) : + getservbyname (namebuf, protobuf); + size_t size = 20; + int numaliases = 0; + uae_u32 aptr; + int i; - struct servent *s = (type) ? - getservbyport(name, protobuf) : - getservbyname(namebuf, protobuf); - size_t size = 20; - int numaliases = 0; - uae_u32 aptr; - int i; + if (type) { + DEBUG_LOG("Getservbyport(%d, %s) = %p\n", name, protobuf, s); + } else { + DEBUG_LOG("Getservbyname(%s, %s) = %p\n", namebuf, protobuf, s); + } - if (type) { - DEBUG_LOG("Getservbyport(%d, %s) = %p\n", name, protobuf, s); - } - else { - DEBUG_LOG("Getservbyname(%s, %s) = %p\n", namebuf, protobuf, s); - } + if (s == NULL) { + SETERRNO; + return; + } - if (s == NULL) { - SETERRNO; + // compute total size of servent + if (s->s_name != NULL) + size += strlen (s->s_name) + 1; + + if (s->s_proto != NULL) + size += strlen (s->s_proto) + 1; + + if (s->s_aliases != NULL) + while (s->s_aliases[numaliases]) + size += strlen (s->s_aliases[numaliases++]) + 5; + + if (sb->servent) { + uae_FreeMem (ctx, sb->servent, sb->serventsize, sb->sysbase); + } + + sb->servent = uae_AllocMem (ctx, size, 0, sb->sysbase); + + if (!sb->servent) { + write_log ("BSDSOCK: WARNING - getservby%s() ran out of Amiga memory (couldn't allocate %d bytes)\n",type ? "port" : "name", size); + bsdsocklib_seterrno (ctx, sb, 12); // ENOMEM return; - } + } - // compute total size of servent - if (s->s_name != NULL) - size += strlen(s->s_name) + 1; + sb->serventsize = size; - if (s->s_proto != NULL) - size += strlen(s->s_proto) + 1; + aptr = sb->servent + 20 + numaliases * 4; - if (s->s_aliases != NULL) - while (s->s_aliases[numaliases]) - size += strlen(s->s_aliases[numaliases++]) + 5; + // transfer servent to Amiga memory + trap_put_long (ctx, sb->servent + 4, sb->servent + 16); + trap_put_long (ctx, sb->servent + 8, (unsigned short)htons (s->s_port)); - if (sb->servent) { - uae_FreeMem(ctx, sb->servent, sb->serventsize, sb->sysbase); - } + for (i = 0; i < numaliases; i++) + trap_put_long (ctx, sb->servent + 16 + i * 4, addstr (ctx, &aptr, s->s_aliases[i])); + trap_put_long (ctx, sb->servent + 16 + numaliases * 4, 0); + trap_put_long (ctx, sb->servent, aptr); + addstr (ctx, &aptr, s->s_name); + trap_put_long (ctx, sb->servent + 12, aptr); + addstr (ctx, &aptr, s->s_proto); - sb->servent = uae_AllocMem(ctx, size, 0, sb->sysbase); - - if (!sb->servent) { - write_log("BSDSOCK: WARNING - getservby%s() ran out of Amiga memory (couldn't allocate %d bytes)\n", type ? "port" : "name", size); - bsdsocklib_seterrno(ctx, sb, 12); // ENOMEM - return; - } - - sb->serventsize = size; - - aptr = sb->servent + 20 + numaliases * 4; - - // transfer servent to Amiga memory - trap_put_long(ctx, sb->servent + 4, sb->servent + 16); - trap_put_long(ctx, sb->servent + 8, (unsigned short)htons(s->s_port)); - - for (i = 0; i < numaliases; i++) - trap_put_long(ctx, sb->servent + 16 + i * 4, addstr(ctx, &aptr, s->s_aliases[i])); - trap_put_long(ctx, sb->servent + 16 + numaliases * 4, 0); - trap_put_long(ctx, sb->servent, aptr); - addstr(ctx, &aptr, s->s_name); - trap_put_long(ctx, sb->servent + 12, aptr); - addstr(ctx, &aptr, s->s_proto); - - BSDTRACE(("OK (%s, %d)\n", s->s_name, (unsigned short)htons(s->s_port))); - bsdsocklib_seterrno(ctx, sb, 0); + BSDTRACE (("OK (%s, %d)\n", s->s_name, (unsigned short)htons (s->s_port))); + bsdsocklib_seterrno (ctx, sb,0); } -int host_sbinit(TrapContext *ctx, SB) +int host_sbinit (TrapContext *ctx, SB) { - if (pipe(sb->sockabort) < 0) { + if (pipe (sb->sockabort) < 0) { return 0; - } + } - if (fcntl(sb->sockabort[0], F_SETFL, O_NONBLOCK) < 0) { - write_log("Set nonblock failed %d\n", errno); - } + if (fcntl (sb->sockabort[0], F_SETFL, O_NONBLOCK) < 0) { + write_log ("Set nonblock failed %d\n", errno); + } - if (uae_sem_init(&sb->sem, 0, 0)) { - write_log("BSDSOCK: Failed to create semaphore.\n"); - close(sb->sockabort[0]); - close(sb->sockabort[1]); + if (uae_sem_init (&sb->sem, 0, 0)) { + write_log ("BSDSOCK: Failed to create semaphore.\n"); + close (sb->sockabort[0]); + close (sb->sockabort[1]); return 0; - } + } - /* Alloc hostent buffer */ - sb->hostent = uae_AllocMem(ctx, 1024, 0, sb->sysbase); - sb->hostentsize = 1024; + /* Alloc hostent buffer */ + sb->hostent = uae_AllocMem (ctx, 1024, 0, sb->sysbase); + sb->hostentsize = 1024; - /* @@@ The thread should be PTHREAD_CREATE_DETACHED */ - if (uae_start_thread("bsdsocket", bsdlib_threadfunc, (void *)sb, &sb->thread) == BAD_THREAD) { - write_log("BSDSOCK: Failed to create thread.\n"); - uae_sem_destroy(&sb->sem); - close(sb->sockabort[0]); - close(sb->sockabort[1]); + /* @@@ The thread should be PTHREAD_CREATE_DETACHED */ + if (uae_start_thread ("bsdsocket", bsdlib_threadfunc, static_cast(sb), &sb->thread) == BAD_THREAD) { + write_log ("BSDSOCK: Failed to create thread.\n"); + uae_sem_destroy (&sb->sem); + close (sb->sockabort[0]); + close (sb->sockabort[1]); return 0; - } - return 1; + } + return 1; } -void host_sbcleanup(SB) +void host_sbcleanup (SB) { - int i; + int i; - if (!sb) { - return; - } + if (!sb) { + return; + } - uae_thread_id thread = sb->thread; - close(sb->sockabort[0]); - close(sb->sockabort[1]); - for (i = 0; i < sb->dtablesize; i++) { + uae_thread_id thread = sb->thread; + close (sb->sockabort[0]); + close (sb->sockabort[1]); + for (i = 0; i < sb->dtablesize; i++) { if (sb->dtable[i] != -1) { - close(sb->dtable[i]); + close(sb->dtable[i]); } - } - sb->action = 0; + } + sb->action = 0; - uae_sem_post(&sb->sem); /* destroy happens on socket thread */ + uae_sem_post (&sb->sem); /* destroy happens on socket thread */ - /* We need to join with the socket thread to allow the thread to die - * and clean up resources when the underlying thread layer is pthreads. - * Ideally, this shouldn't be necessary, but, for example, when SDL uses - * pthreads, it always creates joinable threads - and we can't do anything - * about that. */ - uae_wait_thread(thread); + /* We need to join with the socket thread to allow the thread to die + * and clean up resources when the underlying thread layer is pthreads. + * Ideally, this shouldn't be necessary, but, for example, when SDL uses + * pthreads, it always creates joinable threads - and we can't do anything + * about that. */ + uae_wait_thread (thread); } -void host_sbreset(void) +void host_sbreset (void) { - /* TODO */ + /* TODO */ } -uae_u32 host_Inet_NtoA(TrapContext *ctx, SB, uae_u32 in) +uae_u32 host_Inet_NtoA (TrapContext *ctx, SB, uae_u32 in) { - char *addr; - struct in_addr ina; - uae_u32 buf; + char *addr; + struct in_addr ina; + uae_u32 buf; - *(uae_u32 *)&ina = htonl(in); + *reinterpret_cast(&ina) = htonl (in); - BSDTRACE(("Inet_NtoA(%x) -> ", in)); + BSDTRACE (("Inet_NtoA(%x) -> ", in)); - if ((addr = inet_ntoa(ina)) != NULL) { - buf = trap_get_areg(ctx, 6) + offsetof(struct UAEBSDBase, scratchbuf); + if ((addr = inet_ntoa(ina)) != NULL) { + buf = trap_get_areg(ctx, 6) + offsetof (struct UAEBSDBase, scratchbuf); strncpyha(ctx, buf, addr, SCRATCHBUFSIZE); - BSDTRACE(("%s\n", addr)); + BSDTRACE (("%s\n", addr)); return buf; - } - else + } else SETERRNO; - BSDTRACE(("failed (%d)\n", sb->sb_errno)); + BSDTRACE (("failed (%d)\n", sb->sb_errno)); - return 0; + return 0; } -uae_u32 host_inet_addr(TrapContext *ctx, uae_u32 cp) +uae_u32 host_inet_addr (TrapContext *ctx, uae_u32 cp) { - uae_u32 addr; - char *cp_rp; + uae_u32 addr; + char *cp_rp; if (!trap_valid_address(ctx, cp, 4)) return 0; - cp_rp = trap_get_alloc_string(ctx, cp, 256); + cp_rp = trap_get_alloc_string(ctx, cp, 256); - addr = htonl(inet_addr(cp_rp)); + addr = htonl (inet_addr (cp_rp)); - BSDTRACE(("inet_addr(%s) -> 0x%08x\n", cp_rp, addr)); - xfree(cp_rp); + BSDTRACE (("inet_addr(%s) -> 0x%08x\n", cp_rp, addr)); + xfree(cp_rp); - return addr; + return addr; } -uae_u32 host_shutdown(TrapContext *ctx, SB, uae_u32 sd, uae_u32 how) +uae_u32 host_shutdown (TrapContext *ctx, SB, uae_u32 sd, uae_u32 how) { - SOCKET s; + SOCKET s; - BSDTRACE(("shutdown(%d,%d) -> ", sd, how)); - s = getsock(ctx, sb, sd + 1); + BSDTRACE (("shutdown(%d,%d) -> ", sd, how)); + s = getsock (ctx, sb, sd + 1); - if (s != -1) { - if (shutdown(s, how)) { - SETERRNO; - BSDTRACE(("failed (%d)\n", sb->sb_errno)); + if (s != -1) { + if (shutdown (s, how)) { + SETERRNO; + BSDTRACE (("failed (%d)\n", sb->sb_errno)); + } else { + BSDTRACE (("OK\n")); + return 0; } - else { - BSDTRACE(("OK\n")); - return 0; - } - } + } - return -1; + return -1; } -int host_dup2socket(TrapContext *ctx, SB, int fd1, int fd2) +int host_dup2socket (TrapContext *ctx, SB, int fd1, int fd2) { - int s1, s2; + int s1, s2; - BSDTRACE(("dup2socket(%d,%d) -> ", fd1, fd2)); - fd1++; + BSDTRACE (("dup2socket(%d,%d) -> ", fd1, fd2)); + fd1++; - s1 = getsock(ctx, sb, fd1); - if (s1 != -1) { + s1 = getsock (ctx, sb, fd1); + if (s1 != -1) { if (fd2 != -1) { - if ((unsigned int)(fd2) >= (unsigned int)sb->dtablesize) { - BSDTRACE(("Bad file descriptor (%d)\n", fd2)); - bsdsocklib_seterrno(ctx, sb, 9); /* EBADF */ - } - fd2++; - s2 = getsock(ctx, sb, fd2); - if (s2 != -1) { - close(s2); - } - setsd(ctx, sb, fd2, dup(s1)); - BSDTRACE(("0(%d)\n", getsock(ctx, sb, fd2))); - return 0; - } - else { - fd2 = getsd(ctx, sb, 1); + if (static_cast(fd2) >= static_cast(sb->dtablesize)) { + BSDTRACE (("Bad file descriptor (%d)\n", fd2)); + bsdsocklib_seterrno (ctx, sb, 9); /* EBADF */ + } + fd2++; + s2 = getsock (ctx, sb, fd2); + if (s2 != -1) { + close (s2); + } + setsd (ctx, sb, fd2, dup (s1)); + BSDTRACE (("0(%d)\n", getsock (ctx, sb, fd2))); + return 0; + } else { + fd2 = getsd (ctx, sb, 1); if (fd2 != -1) { - setsd(ctx, sb, fd2, dup(s1)); - BSDTRACE(("%d(%d)\n", fd2, getsock(ctx, sb, fd2))); - return (fd2 - 1); - } - else { + setsd (ctx, sb, fd2, dup (s1)); + BSDTRACE (("%d(%d)\n", fd2, getsock (ctx, sb, fd2))); + return (fd2 - 1); + } else { BSDTRACE(("-1\n")); return -1; } } - } - BSDTRACE(("-1\n")); - return -1; + } + BSDTRACE (("-1\n")); + return -1; } -uae_u32 host_getsockopt(TrapContext *ctx, SB, uae_u32 sd, uae_u32 level, uae_u32 optname, +uae_u32 host_getsockopt (TrapContext *ctx, SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 optval, uae_u32 optlen) { - socklen_t len = 0; - int r; - int s; - int nativelevel = mapsockoptlevel(level); - int nativeoptname = mapsockoptname(nativelevel, optname); - void *buf = NULL; - s = getsock(ctx, sb, sd + 1); + socklen_t len = 0; + int r; + int s; + int nativelevel = mapsockoptlevel(level); + int nativeoptname = mapsockoptname(nativelevel, optname); + void *buf = NULL; + s = getsock (ctx, sb, sd + 1); - if (s == -1) { + if (s == -1) { bsdsocklib_seterrno(ctx, sb, 9); /* EBADF */ return -1; - } + } - if (optlen) { - len = trap_get_long(ctx, optlen); + if (optlen) { + len = trap_get_long (ctx, optlen); buf = malloc(len); if (buf == NULL) { - return -1; + return -1; } - } + } - r = getsockopt(s, nativelevel, nativeoptname, - optval ? buf : NULL, optlen ? &len : NULL); + r = getsockopt (s, nativelevel, nativeoptname, + optval ? buf : NULL, optlen ? &len : NULL); - if (optlen) - trap_put_long(ctx, optlen, len); + if (optlen) + trap_put_long (ctx, optlen, len); - SETERRNO; - DEBUG_LOG("getsockopt: sock AmigaSide %d NativeSide %d, level %d, 'name' %x(%d), len %d -> %d, %d\n", - sd, s, level, optname, nativeoptname, len, r, errno); + SETERRNO; + DEBUG_LOG ("getsockopt: sock AmigaSide %d NativeSide %d, level %d, 'name' %x(%d), len %d -> %d, %d\n", + sd, s, level, optname, nativeoptname, len, r, errno); - if (optval) { + if (optval) { if (r == 0) { - mapsockoptreturn(ctx, nativelevel, nativeoptname, optval, buf); + mapsockoptreturn(ctx, nativelevel, nativeoptname, optval, buf); } - } + } - if (buf != NULL) + if (buf != NULL) free(buf); - return r; + return r; } -uae_u32 host_IoctlSocket(TrapContext *ctx, SB, uae_u32 sd, uae_u32 request, uae_u32 arg) +uae_u32 host_IoctlSocket (TrapContext *ctx, SB, uae_u32 sd, uae_u32 request, uae_u32 arg) { - int sock = getsock(ctx, sb, sd + 1); - int r, argval = trap_get_long(ctx, arg); - long flags; + int sock = getsock (ctx, sb, sd + 1); + int r, argval = trap_get_long (ctx, arg); + long flags; - if (sock == -1) { + if (sock == -1) { sb->resultval = -1; - bsdsocklib_seterrno(ctx, sb, 9); /* EBADF */ + bsdsocklib_seterrno (ctx, sb, 9); /* EBADF */ return -1; - } + } - if ((flags = fcntl(sock, F_GETFL)) == -1) { + if ((flags = fcntl (sock, F_GETFL)) == -1) { SETERRNO; return -1; - } + } - DEBUG_LOG("Ioctl code is %x, flags are %ld\n", request, flags); + DEBUG_LOG ("Ioctl code is %x, flags are %ld\n", request, flags); - switch (request) { - case 0x8004667B: /* FIOGETOWN */ - sb->ownertask = trap_get_long(ctx, arg); - return 0; + switch (request) { + case 0x8004667B: /* FIOGETOWN */ + sb->ownertask = trap_get_long (ctx, arg); + return 0; - case 0x8004667C: /* FIOSETOWN */ - trap_put_long(ctx, arg, sb->ownertask); - return 0; - case 0x8004667D: /* FIOASYNC */ + case 0x8004667C: /* FIOSETOWN */ + trap_put_long (ctx, arg, sb->ownertask); + return 0; + case 0x8004667D: /* FIOASYNC */ # ifdef O_ASYNC - r = fcntl(sock, F_SETFL, argval ? flags | O_ASYNC : flags & ~O_ASYNC); - return r; + r = fcntl (sock, F_SETFL, argval ? flags | O_ASYNC : flags & ~O_ASYNC); + return r; # else - /* O_ASYNC is only available on Linux and BSD systems */ - return fcntl(sock, F_GETFL); + /* O_ASYNC is only available on Linux and BSD systems */ + return fcntl (sock, F_GETFL); # endif - case 0x8004667E: /* FIONBIO */ - r = fcntl(sock, F_SETFL, argval ? - flags | O_NONBLOCK : flags & ~O_NONBLOCK); - if (argval) { - DEBUG_LOG("nonblocking\n"); - sb->ftable[sd] &= ~SF_BLOCKING; - } - else { - DEBUG_LOG("blocking\n"); - sb->ftable[sd] |= SF_BLOCKING; - } - return r; + case 0x8004667E: /* FIONBIO */ + r = fcntl (sock, F_SETFL, argval ? + flags | O_NONBLOCK : flags & ~O_NONBLOCK); + if (argval) { + DEBUG_LOG ("nonblocking\n"); + sb->ftable[sd] &= ~SF_BLOCKING; + } else { + DEBUG_LOG ("blocking\n"); + sb->ftable[sd] |= SF_BLOCKING; + } + return r; - case 0x4004667F: /* FIONREAD */ - r = ioctl(sock, FIONREAD, &flags); - if (r >= 0) { - trap_put_long(ctx, arg, flags); - } - return r; + case 0x4004667F: /* FIONREAD */ + r = ioctl (sock, FIONREAD, &flags); + if (r >= 0) { + trap_put_long (ctx, arg, flags); + } + return r; - } /* end switch */ + } /* end switch */ - bsdsocklib_seterrno(ctx, sb, EINVAL); - return -1; + bsdsocklib_seterrno (ctx, sb, EINVAL); + return -1; } -int host_CloseSocket(TrapContext *ctx, SB, int sd) +int host_CloseSocket (TrapContext *ctx, SB, int sd) { - int s = getsock(ctx, sb, sd + 1); - int retval; + int s = getsock (ctx, sb, sd + 1); + int retval; - if (s == -1) { - bsdsocklib_seterrno(ctx, sb, 9); /* EBADF */ + if (s == -1) { + bsdsocklib_seterrno (ctx, sb, 9); /* EBADF */ return -1; - } + } - /* - if (checksd (sb, sd + 1) == 1) { - return 0; - } - */ - DEBUG_LOG("CloseSocket Amiga: %d, NativeSide %d\n", sd, s); - retval = close(s); - SETERRNO; - releasesock(ctx, sb, sd + 1); - return retval; + /* + if (checksd (sb, sd + 1) == 1) { + return 0; + } + */ + DEBUG_LOG ("CloseSocket Amiga: %d, NativeSide %d\n", sd, s); + retval = close (s); + SETERRNO; + releasesock (ctx, sb, sd + 1); + return retval; } -void host_closesocketquick(int s) +void host_closesocketquick (int s) { - struct linger l; - l.l_onoff = 0; - l.l_linger = 0; - if (s != -1) { - setsockopt(s, SOL_SOCKET, SO_LINGER, &l, sizeof(l)); - close(s); - } + struct linger l; + l.l_onoff = 0; + l.l_linger = 0; + if(s != -1) { + setsockopt (s, SOL_SOCKET, SO_LINGER, &l, sizeof(l)); + close (s); + } } -uae_u32 host_gethostname(TrapContext *ctx, uae_u32 name, uae_u32 namelen) +uae_u32 host_gethostname (TrapContext *ctx, uae_u32 name, uae_u32 namelen) { if (!trap_valid_address(ctx, name, namelen)) return -1; @@ -1749,47 +1729,47 @@ int init_socket_layer(void) { int result = 0; - if (sem_queue != 0) { - uae_sem_destroy(&sem_queue); - sem_queue = 0; + if(sem_queue != 0) { + uae_sem_destroy(&sem_queue); + sem_queue = 0; } if (currprefs.socket_emu) { - if (uae_sem_init(&sem_queue, 0, 1) < 0) { - DEBUG_LOG("Can't create sem %d\n", errno); - return 0; - } - result = 1; - } + if (uae_sem_init(&sem_queue, 0, 1) < 0) { + DEBUG_LOG("Can't create sem %d\n", errno); + return 0; + } + result = 1; + } - return result; + return result; } -void clearsockabort(SB) +void clearsockabort (SB) { - int chr; - int num; + int chr; + int num; - while ((num = read(sb->sockabort[0], &chr, sizeof(chr))) >= 0) { - DEBUG_LOG("Sockabort got %d bytes\n", num); - } + while ((num = read (sb->sockabort[0], &chr, sizeof(chr))) >= 0) { + DEBUG_LOG ("Sockabort got %d bytes\n", num); + } } -void sockabort(SB) +void sockabort (SB) { - int chr = 1; - DEBUG_LOG("Sock abort!!\n"); - write(sb->sockabort[1], &chr, sizeof(chr)); + int chr = 1; + DEBUG_LOG ("Sock abort!!\n"); + write (sb->sockabort[1], &chr, sizeof (chr)); } -void locksigqueue(void) +void locksigqueue (void) { - uae_sem_wait(&sem_queue); + uae_sem_wait(&sem_queue); } -void unlocksigqueue(void) +void unlocksigqueue (void) { - uae_sem_post(&sem_queue); + uae_sem_post(&sem_queue); } #endif diff --git a/src/osdep/gui/CreateFilesysHardfile.cpp b/src/osdep/gui/CreateFilesysHardfile.cpp index 3e54690d..f339adc4 100644 --- a/src/osdep/gui/CreateFilesysHardfile.cpp +++ b/src/osdep/gui/CreateFilesysHardfile.cpp @@ -1,7 +1,7 @@ #include -#include "SDL.h" +#include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" @@ -11,6 +11,9 @@ #include "sysdeps.h" #include "config.h" #include "options.h" +#include "include/memory.h" +#include "uae.h" +#include "autoconf.h" #include "filesys.h" #include "gui.h" #include "gui_handling.h" diff --git a/src/osdep/gui/EditFilesysHardfile.cpp b/src/osdep/gui/EditFilesysHardfile.cpp index 988de986..0fdaf533 100644 --- a/src/osdep/gui/EditFilesysHardfile.cpp +++ b/src/osdep/gui/EditFilesysHardfile.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" @@ -11,6 +11,8 @@ #include "sysdeps.h" #include "config.h" #include "options.h" +#include "memory.h" +#include "uae.h" #include "autoconf.h" #include "filesys.h" #include "gui.h" diff --git a/src/osdep/gui/EditFilesysVirtual.cpp b/src/osdep/gui/EditFilesysVirtual.cpp index 0cac93f1..011ff1fc 100644 --- a/src/osdep/gui/EditFilesysVirtual.cpp +++ b/src/osdep/gui/EditFilesysVirtual.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" @@ -11,6 +11,8 @@ #include "sysdeps.h" #include "config.h" #include "options.h" +#include "memory.h" +#include "uae.h" #include "autoconf.h" #include "filesys.h" #include "gui.h" diff --git a/src/osdep/gui/InGameMessage.cpp b/src/osdep/gui/InGameMessage.cpp index d58a738b..f0f3f051 100644 --- a/src/osdep/gui/InGameMessage.cpp +++ b/src/osdep/gui/InGameMessage.cpp @@ -1,12 +1,18 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "sysconfig.h" #include "sysdeps.h" #include "config.h" +#include "options.h" +#include "uae.h" +#include "custom.h" +#include "xwin.h" +#include "drawing.h" +#include "gui.h" #include "gui_handling.h" #include "amiberry_gfx.h" diff --git a/src/osdep/gui/Navigation.cpp b/src/osdep/gui/Navigation.cpp index 1e28e7a8..506afa1f 100644 --- a/src/osdep/gui/Navigation.cpp +++ b/src/osdep/gui/Navigation.cpp @@ -1,12 +1,12 @@ #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" #include "sysconfig.h" #include "sysdeps.h" - +#include "config.h" #include "gui_handling.h" typedef struct @@ -42,62 +42,62 @@ static NavigationMap navMap[] = { "Help", "Quit", "Start", "Savestates", "Paths" }, {"Start", "Quit", "Reset", "Savestates", "Paths"}, - // PanelPaths - {"SystemROMs", "Paths", "Paths", "RescanROMs", "ConfigPath"}, - {"ConfigPath", "Paths", "Paths", "SystemROMs", "RescanROMs"}, - {"RescanROMs", "Paths", "Paths", "ConfigPath", "SystemROMs"}, +// PanelPaths + { "SystemROMs", "Paths", "Paths", "RescanROMs", "ConfigPath" }, + { "ConfigPath", "Paths", "Paths", "SystemROMs", "RescanROMs" }, + { "RescanROMs", "Paths", "Paths", "ConfigPath", "SystemROMs" }, - // active move left move right move up move down - // PanelQuickstart - { "AModel", "Quickstart", "qsNTSC", "qsMode", "AConfig" }, - { "qsNTSC", "AModel", "Quickstart", "qsMode", "AConfig" }, - { "AConfig", "Quickstart", "Quickstart", "AModel", "qscmdSel0" }, - { "qsDF0", "Quickstart", "qsWP0", "AConfig", "qscboDisk0" }, - { "qsWP0", "qsDF0", "qscmdEject0", "AConfig", "qscboDisk0" }, - // { "qsInfo0", "Quickstart", "", "", "" }, - { "qscmdEject0", "qsWP0", "qscmdSel0", "AConfig", "qscboDisk0" }, - { "qscmdSel0", "qscmdEject0", "Quickstart", "AConfig", "qscboDisk0" }, - { "qscboDisk0", "Quickstart", "Quickstart", "qscmdSel0", "qscmdSel1" }, - { "qsDF1", "Quickstart", "qsWP1", "qscboDisk0", "qscboDisk1" }, - { "qsWP1", "qsDF1", "qscmdEject1", "qscboDisk0", "qscboDisk1" }, - // { "qsInfo1", "Quickstart", "", "", "" }, - { "qscmdEject1", "qsWP1", "qscmdSel1", "qscboDisk0", "qscboDisk1" }, - { "qscmdSel1", "qscmdEject1", "Quickstart", "qscboDisk0", "qscboDisk1" }, - { "qscboDisk1", "Quickstart", "Quickstart", "qsDF1", "qsCDSelect" }, - { "qsCD drive", "Quickstart", "qscdEject", "qscboDisk1", "qscboCD" }, - { "qscdEject", "qsCD drive", "qsCDSelect", "qscboDisk1", "qscboCD" }, - { "qsCDSelect", "qscdEject", "Quickstart", "qscboDisk1", "qscboCD" }, - { "qscboCD", "Quickstart", "Quickstart", "qsCDSelect", "qsMode" }, - { "qsMode", "Quickstart", "Quickstart", "qscboCD", "qsNTSC" }, +// active move left move right move up move down +// PanelQuickstart + { "AModel", "Quickstart", "qsNTSC", "qsMode", "AConfig" }, + { "qsNTSC", "AModel", "Quickstart", "qsMode", "AConfig" }, + { "AConfig", "Quickstart", "Quickstart", "AModel", "qscmdSel0" }, + { "qsDF0", "Quickstart", "qsWP0", "AConfig", "qscboDisk0" }, + { "qsWP0", "qsDF0", "qscmdEject0", "AConfig", "qscboDisk0" }, +// { "qsInfo0", "Quickstart", "", "", "" }, + { "qscmdEject0", "qsWP0", "qscmdSel0", "AConfig", "qscboDisk0" }, + { "qscmdSel0", "qscmdEject0", "Quickstart", "AConfig", "qscboDisk0" }, + { "qscboDisk0", "Quickstart", "Quickstart", "qscmdSel0", "qscmdSel1" }, + { "qsDF1", "Quickstart", "qsWP1", "qscboDisk0", "qscboDisk1" }, + { "qsWP1", "qsDF1", "qscmdEject1", "qscboDisk0", "qscboDisk1" }, +// { "qsInfo1", "Quickstart", "", "", "" }, + { "qscmdEject1", "qsWP1", "qscmdSel1", "qscboDisk0", "qscboDisk1" }, + { "qscmdSel1", "qscmdEject1", "Quickstart", "qscboDisk0", "qscboDisk1" }, + { "qscboDisk1", "Quickstart", "Quickstart", "qsDF1", "qsCDSelect" }, + { "qsCD drive", "Quickstart", "qscdEject", "qscboDisk1", "qscboCD" }, + { "qscdEject", "qsCD drive", "qsCDSelect", "qscboDisk1", "qscboCD" }, + { "qsCDSelect", "qscdEject", "Quickstart", "qscboDisk1", "qscboCD" }, + { "qscboCD", "Quickstart", "Quickstart", "qsCDSelect", "qsMode" }, + { "qsMode", "Quickstart", "Quickstart", "qscboCD", "qsNTSC" }, - // PanelConfig - {"ConfigList", "Configurations", "ConfigName", "", ""}, - {"ConfigName", "Configurations", "Configurations", "ConfigList", "ConfigDesc"}, - {"ConfigDesc", "Configurations", "Configurations", "ConfigName", "ConfigLoad"}, - {"ConfigLoad", "Configurations", "ConfigSave", "ConfigDesc", "ConfigList"}, - {"ConfigSave", "ConfigLoad", "CfgDelete", "ConfigDesc", "ConfigList"}, - {"CfgDelete", "ConfigSave", "Configurations", "ConfigDesc", "ConfigList"}, +// PanelConfig + { "ConfigList", "Configurations", "ConfigName", "", "" }, + { "ConfigName", "Configurations", "Configurations", "ConfigList", "ConfigDesc" }, + { "ConfigDesc", "Configurations", "Configurations", "ConfigName", "ConfigLoad" }, + { "ConfigLoad", "Configurations", "ConfigSave", "ConfigDesc", "ConfigList" }, + { "ConfigSave", "ConfigLoad", "CfgDelete", "ConfigDesc", "ConfigList" }, + { "CfgDelete", "ConfigSave", "Configurations", "ConfigDesc", "ConfigList" }, - // active move left move right move up move down - // PanelCPU - { "68000", "CPU and FPU", "FPUnone", "JIT", "68010" }, - { "68010", "CPU and FPU", "68881", "68000", "68020" }, - { "68020", "CPU and FPU", "68882", "68010", "68030" }, - { "68030", "CPU and FPU", "CPU internal", "68020", "68040" }, - { "68040", "CPU and FPU", "FPUstrict", "68030", "CPU24Bit" }, - { "CPU24Bit", "CPU and FPU", "SoftFloat", "68040", "CPUComp" }, - { "CPUComp", "CPU and FPU", "SoftFloat", "CPU24Bit", "JIT" }, - { "JIT", "CPU and FPU", "SoftFloat", "CPUComp", "68000" }, - { "FPUnone", "68000", "7 Mhz", "SoftFloat", "68881" }, - { "68881", "68010", "14 Mhz", "FPUnone", "68882" }, - { "68882", "68020", "25 Mhz", "68881", "CPU internal" }, - { "CPU internal", "68030", "Fastest", "68882", "FPUstrict" }, - { "FPUstrict", "68040", "Fastest", "CPU internal", "SoftFloat" }, - { "SoftFloat", "CPU24Bit", "Fastest", "FPUstrict", "FPUnone" }, - { "7 Mhz", "FPUnone", "CPU and FPU", "Fastest", "14 Mhz" }, - { "14 Mhz", "68881", "CPU and FPU", "7 Mhz", "25 Mhz" }, - { "25 Mhz", "68882", "CPU and FPU", "14 Mhz", "Fastest" }, - { "Fastest", "CPU internal", "CPU and FPU", "25 Mhz", "7 Mhz" }, +// active move left move right move up move down +// PanelCPU + { "68000", "CPU and FPU", "FPUnone", "JIT", "68010" }, + { "68010", "CPU and FPU", "68881", "68000", "68020" }, + { "68020", "CPU and FPU", "68882", "68010", "68030" }, + { "68030", "CPU and FPU", "CPU internal", "68020", "68040" }, + { "68040", "CPU and FPU", "FPUstrict", "68030", "CPU24Bit" }, + { "CPU24Bit", "CPU and FPU", "SoftFloat", "68040", "CPUComp" }, + { "CPUComp", "CPU and FPU", "SoftFloat", "CPU24Bit", "JIT" }, + { "JIT", "CPU and FPU", "SoftFloat", "CPUComp", "68000" }, + { "FPUnone", "68000", "7 Mhz", "SoftFloat", "68881" }, + { "68881", "68010", "14 Mhz", "FPUnone", "68882" }, + { "68882", "68020", "25 Mhz", "68881", "CPU internal" }, + { "CPU internal", "68030", "Fastest", "68882", "FPUstrict" }, + { "FPUstrict", "68040", "Fastest", "CPU internal", "SoftFloat" }, + { "SoftFloat", "CPU24Bit", "Fastest", "FPUstrict", "FPUnone" }, + { "7 Mhz", "FPUnone", "CPU and FPU", "Fastest", "14 Mhz" }, + { "14 Mhz", "68881", "CPU and FPU", "7 Mhz", "25 Mhz" }, + { "25 Mhz", "68882", "CPU and FPU", "14 Mhz", "Fastest" }, + { "Fastest", "CPU internal", "CPU and FPU", "25 Mhz", "7 Mhz" }, // PanelChipset {"OCS", "Chipset", "BlitNormal", "CollFull", "ECS Agnus"}, @@ -113,57 +113,57 @@ static NavigationMap navMap[] = {"CollPlay", "Chipset", "Chipset", "Sprites only", "CollFull"}, {"CollFull", "Chipset", "Chipset", "CollPlay", "OCS"}, - // active move left move right move up move down - // PanelROM +// active move left move right move up move down +// PanelROM #ifdef ACTION_REPLAY - { "cboMainROM", "ROM", "MainROM", "cboCartROM", "cboExtROM" }, - { "MainROM", "cboMainROM", "ROM", "CartROM", "ExtROM" }, - { "cboExtROM", "ROM", "ExtROM", "cboMainROM", "cboCartROM" }, - { "ExtROM", "cboExtROM", "ROM", "MainROM", "CartROM" }, - { "cboCartROM", "ROM", "CartROM", "cboExtROM", "cboMainROM" }, - { "CartROM", "cboCartROM", "ROM", "ExtROM", "MainROM" }, + { "cboMainROM", "ROM", "MainROM", "cboCartROM", "cboExtROM" }, + { "MainROM", "cboMainROM", "ROM", "CartROM", "ExtROM" }, + { "cboExtROM", "ROM", "ExtROM", "cboMainROM", "cboCartROM" }, + { "ExtROM", "cboExtROM", "ROM", "MainROM", "CartROM" }, + { "cboCartROM", "ROM", "CartROM", "cboExtROM", "cboMainROM" }, + { "CartROM", "cboCartROM", "ROM", "ExtROM", "MainROM" }, #else - { "cboMainROM", "ROM", "MainROM", "cboExtROM", "cboExtROM" }, - { "MainROM", "cboMainROM", "ROM", "ExtROM", "ExtROM" }, - { "cboExtROM", "ROM", "ExtROM", "cboMainROM", "cboMainROM" }, - { "ExtROM", "cboExtROM", "ROM", "MainROM", "MainROM" }, + { "cboMainROM", "ROM", "MainROM", "cboExtROM", "cboExtROM" }, + { "MainROM", "cboMainROM", "ROM", "ExtROM", "ExtROM" }, + { "cboExtROM", "ROM", "ExtROM", "cboMainROM", "cboMainROM" }, + { "ExtROM", "cboExtROM", "ROM", "MainROM", "MainROM" }, #endif - //PanelRAM - { "Chipmem", "", "", "RAM", "Slowmem" }, - { "Slowmem", "", "", "Chipmem", "Fastmem" }, - { "Fastmem", "", "", "Slowmem", "Z3mem" }, - { "Z3mem", "", "", "Fastmem", "Gfxmem" }, - { "Gfxmem", "", "", "Z3mem", "A3000Low" }, - { "A3000Low", "", "", "Gfxmem", "A3000High" }, - { "A3000High", "", "", "A3000Low", "RAM" }, +//PanelRAM + { "Chipmem", "", "", "RAM", "Slowmem" }, + { "Slowmem", "", "", "Chipmem", "Fastmem" }, + { "Fastmem", "", "", "Slowmem", "Z3mem" }, + { "Z3mem", "", "", "Fastmem", "Gfxmem" }, + { "Gfxmem", "", "", "Z3mem", "A3000Low" }, + { "A3000Low", "", "", "Gfxmem", "A3000High" }, + { "A3000High", "", "", "A3000Low", "RAM" }, - //PanelFloppy - {"DF0:", "Floppy drives", "cboType0", "SaveForDisk", "cboDisk0"}, - {"cboType0", "DF0:", "cmdEject0", "SaveForDisk", "cboDisk0"}, - {"cmdEject0", "cboType0", "cmdSel0", "CreateHD", "cboDisk0"}, - {"cmdSel0", "cmdEject0", "Floppy drives", "CreateHD", "cboDisk0"}, - {"cboDisk0", "Floppy drives", "Floppy drives", "DF0:", "LoadDiskCfg"}, - {"LoadDiskCfg", "Floppy drives", "Floppy drives", "cboDisk0", "DF1:"}, - {"DF1:", "Floppy drives", "cboType1", "LoadDiskCfg", "cboDisk1"}, - {"cboType1", "DF1:", "cmdEject1", "LoadDiskCfg", "cboDisk1"}, - {"cmdEject1", "cboType1", "cmdSel1", "LoadDiskCfg", "cboDisk1"}, - {"cmdSel1", "cmdEject1", "Floppy drives", "LoadDiskCfg", "cboDisk1"}, - {"cboDisk1", "Floppy drives", "Floppy drives", "DF1:", "DF2:"}, - {"DF2:", "Floppy drives", "cboType2", "cboDisk1", "cboDisk2"}, - {"cboType2", "DF2:", "cmdEject2", "cboDisk1", "cboDisk2"}, - {"cmdEject2", "cboType2", "cmdSel2", "cboDisk1", "cboDisk2"}, - {"cmdSel2", "cmdEject2", "Floppy drives", "cboDisk1", "cboDisk2"}, - {"cboDisk2", "Floppy drives", "Floppy drives", "DF2:", "DF3:"}, - {"DF3:", "Floppy drives", "cboType3", "cboDisk2", "cboDisk3"}, - {"cboType3", "DF3:", "cmdEject3", "cboDisk2", "cboDisk3"}, - {"cmdEject3", "cboType3", "cmdSel3", "cboDisk2", "cboDisk3"}, - {"cmdSel3", "cmdEject3", "Floppy drives", "cboDisk2", "cboDisk3"}, - {"cboDisk3", "Floppy drives", "Floppy drives", "DF3:", "DriveSpeed"}, - {"DriveSpeed", "", "", "cboDisk3", "CreateDD"}, - {"SaveForDisk", "Floppy drives", "CreateDD", "DriveSpeed", "DF0:"}, - {"CreateDD", "SaveForDisk", "CreateHD", "DriveSpeed", "cboType0"}, - {"CreateHD", "CreateDD", "Floppy drives", "DriveSpeed", "cmdEject0"}, +//PanelFloppy + { "DF0:", "Floppy drives", "cboType0", "SaveForDisk", "cboDisk0" }, + { "cboType0", "DF0:", "cmdEject0", "SaveForDisk", "cboDisk0" }, + { "cmdEject0", "cboType0", "cmdSel0", "CreateHD", "cboDisk0" }, + { "cmdSel0", "cmdEject0", "Floppy drives", "CreateHD", "cboDisk0" }, + { "cboDisk0", "Floppy drives", "Floppy drives", "DF0:", "LoadDiskCfg" }, + { "LoadDiskCfg", "Floppy drives", "Floppy drives", "cboDisk0", "DF1:" }, + { "DF1:", "Floppy drives", "cboType1", "LoadDiskCfg", "cboDisk1" }, + { "cboType1", "DF1:", "cmdEject1", "LoadDiskCfg", "cboDisk1" }, + { "cmdEject1", "cboType1", "cmdSel1", "LoadDiskCfg", "cboDisk1" }, + { "cmdSel1", "cmdEject1", "Floppy drives", "LoadDiskCfg", "cboDisk1" }, + { "cboDisk1", "Floppy drives", "Floppy drives", "DF1:", "DF2:" }, + { "DF2:", "Floppy drives", "cboType2", "cboDisk1", "cboDisk2" }, + { "cboType2", "DF2:", "cmdEject2", "cboDisk1", "cboDisk2" }, + { "cmdEject2", "cboType2", "cmdSel2", "cboDisk1", "cboDisk2" }, + { "cmdSel2", "cmdEject2", "Floppy drives", "cboDisk1", "cboDisk2" }, + { "cboDisk2", "Floppy drives", "Floppy drives", "DF2:", "DF3:" }, + { "DF3:", "Floppy drives", "cboType3", "cboDisk2", "cboDisk3" }, + { "cboType3", "DF3:", "cmdEject3", "cboDisk2", "cboDisk3" }, + { "cmdEject3", "cboType3", "cmdSel3", "cboDisk2", "cboDisk3" }, + { "cmdSel3", "cmdEject3", "Floppy drives", "cboDisk2", "cboDisk3" }, + { "cboDisk3", "Floppy drives", "Floppy drives", "DF3:", "DriveSpeed" }, + { "DriveSpeed", "", "", "cboDisk3", "CreateDD" }, + { "SaveForDisk", "Floppy drives", "CreateDD", "DriveSpeed", "DF0:" }, + { "CreateDD", "SaveForDisk", "CreateHD", "DriveSpeed", "cboType0" }, + { "CreateHD", "CreateDD", "Floppy drives", "DriveSpeed", "cmdEject0" }, // active move left move right move up move down // PanelHD @@ -177,10 +177,11 @@ static NavigationMap navMap[] = {"cmdDel3", "cmdProp3", "Hard drives/CD", "cmdDel2", "cmdDel4"}, {"cmdProp4", "Hard drives/CD", "cmdDel4", "cmdProp3", "cmdAddDir"}, {"cmdDel4", "cmdProp4", "Hard drives/CD", "cmdDel3", "cmdAddHDF"}, - {"cmdAddDir", "Hard drives/CD", "cmdAddHDF", "cmdProp4", "CD drive"}, - {"cmdAddHDF", "cmdAddDir", "cmdCreateHDF", "cmdDel4", "CD drive"}, - {"cmdCreateHDF", "cmdAddHDF", "Hard drives/CD", "cmdDel4", "CD drive"}, - {"CD drive", "Hard drives/CD", "cdEject", "cmdAddDir", "cboCD"}, + {"cmdAddDir", "Hard drives/CD", "cmdAddHDF", "cmdProp4", "chkHDRO"}, + {"cmdAddHDF", "cmdAddDir", "cmdCreateHDF", "cmdDel4", "chkHDRO"}, + {"cmdCreateHDF", "cmdAddHDF", "Hard drives/CD", "cmdDel4", "chkHDRO"}, + { "chkHDRO", "Hard drives/CD", "Hard drives/CD", "cmdAddDir", "CD drive" }, + {"CD drive", "Hard drives/CD", "cdEject", "chkHDRO", "cboCD"}, {"cdEject", "CD drive", "CDSelect", "cmdCreateHDF", "cboCD"}, {"CDSelect", "cdEject", "Hard drives/CD", "cmdCreateHDF", "cboCD"}, {"cboCD", "Hard drives/CD", "Hard drives/CD", "CD drive", "CDVol"}, @@ -192,38 +193,38 @@ static NavigationMap navMap[] = { "Nearest Neighbor (pixelated)", "Display", "Display", "Auto", "Linear (smooth)"}, {"Linear (smooth)", "Display", "Display", "Nearest Neighbor (pixelated)", "Frameskip"}, - //PanelSound - {"sndDisable", "Sound", "Mono", "sldStereoDelay", "sndDisEmu"}, - {"sndDisEmu", "Sound", "Stereo", "sndDisable", "sndEmulate"}, - {"sndEmulate", "Sound", "Stereo", "sndDisEmu", "sndEmuBest"}, - {"sndEmuBest", "Sound", "Stereo", "sndEmulate", "cboFrequency"}, - {"Mono", "sndDisable", "Sound", "sldStereoDelay", "Stereo"}, - {"Stereo", "sndDisEmu", "Sound", "Mono", "cboFrequency"}, - {"cboFrequency", "Sound", "Sound", "sndEmuBest", "cboInterpol"}, - {"cboInterpol", "Sound", "Sound", "cboFrequency", "cboFilter"}, - {"cboFilter", "Sound", "Sound", "cboInterpol", "sldSeparation"}, - {"sldSeparation", "", "", "cboFilter", "sldStereoDelay"}, - {"sldStereoDelay", "", "", "sldSeparation", "sndDisable"}, - - // active move left move right move up move down - // PanelInput - {"cboPort0", "Input", "Input", "cboLeft", "cboPort1"}, - {"cboPort1", "Input", "cboAutofire", "cboPort0", "MouseSpeed"}, - {"cboAutofire", "cboPort1", "Input", "cboPort0", "cboTapDelay"}, - {"MouseSpeed", "", "", "cboPort1", "MouseHack"}, - {"MouseHack", "Input", "cboTapDelay", "MouseSpeed", "CustomCtrl"}, - {"cboTapDelay", "MouseHack", "Input", "cboAutofire", "cboB"}, - {"CustomCtrl", "Input", "Input", "MouseHack", "cboA"}, - {"cboA", "Input", "cboB", "CustomCtrl", "cboX"}, - {"cboB", "cboA", "Input", "cboTapDelay", "cboY"}, - {"cboX", "Input", "cboY", "cboA", "cboL"}, - {"cboY", "cboX", "Input", "cboB", "cboR"}, - {"cboL", "Input", "cboR", "cboX", "cboUp"}, - {"cboR", "cboL", "Input", "cboY", "cboDown"}, - {"cboUp", "Input", "cboDown", "cboL", "cboLeft"}, - {"cboDown", "cboUp", "Input", "cboR", "cboRight"}, - {"cboLeft", "Input", "cboRight", "cboUp", "cboPort0"}, - {"cboRight", "cboLeft", "Input", "cboDown", "cboPort0"}, +//PanelSound + { "sndDisable", "Sound", "Mono", "sldStereoDelay", "sndDisEmu" }, + { "sndDisEmu", "Sound", "Stereo", "sndDisable", "sndEmulate" }, + { "sndEmulate", "Sound", "Stereo", "sndDisEmu", "sndEmuBest" }, + { "sndEmuBest", "Sound", "Stereo", "sndEmulate", "cboFrequency" }, + { "Mono", "sndDisable", "Sound", "sldStereoDelay", "Stereo" }, + { "Stereo", "sndDisEmu", "Sound", "Mono", "cboFrequency" }, + { "cboFrequency", "Sound", "Sound", "sndEmuBest", "cboInterpol" }, + { "cboInterpol", "Sound", "Sound", "cboFrequency", "cboFilter" }, + { "cboFilter", "Sound", "Sound", "cboInterpol", "sldSeparation" }, + { "sldSeparation", "", "", "cboFilter", "sldStereoDelay" }, + { "sldStereoDelay", "", "", "sldSeparation", "sndDisable" }, + +// active move left move right move up move down +// PanelInput + { "cboPort0", "Input", "Input", "cboLeft", "cboPort1" }, + { "cboPort1", "Input", "cboAutofire", "cboPort0", "MouseSpeed" }, + { "cboAutofire", "cboPort1", "Input", "cboPort0", "cboTapDelay" }, + { "MouseSpeed", "", "", "cboPort1", "MouseHack" }, + { "MouseHack", "Input", "cboTapDelay", "MouseSpeed", "CustomCtrl" }, + { "cboTapDelay", "MouseHack", "Input", "cboAutofire", "cboB" }, + { "CustomCtrl", "Input", "Input", "MouseHack", "cboA" }, + { "cboA", "Input", "cboB", "CustomCtrl", "cboX" }, + { "cboB", "cboA", "Input", "cboTapDelay", "cboY" }, + { "cboX", "Input", "cboY", "cboA", "cboL" }, + { "cboY", "cboX", "Input", "cboB", "cboR" }, + { "cboL", "Input", "cboR", "cboX", "cboUp" }, + { "cboR", "cboL", "Input", "cboY", "cboDown" }, + { "cboUp", "Input", "cboDown", "cboL", "cboLeft" }, + { "cboDown", "cboUp", "Input", "cboR", "cboRight" }, + { "cboLeft", "Input", "cboRight", "cboUp", "cboPort0" }, + { "cboRight", "cboLeft", "Input", "cboDown", "cboPort0" }, // PanelMisc {"StatusLine", "Miscellaneous", "Miscellaneous", "MasterWP", "HideIdle"}, @@ -254,29 +255,29 @@ static NavigationMap navMap[] = {"virtOK", "virtCancel", "virtCancel", "virtPath", "virtRW"}, {"virtCancel", "virtOK", "virtOK", "virtPath", "virtRW"}, - // EditFilesysHardfile - { "hdfDev", "hdfBootPri", "hdfRW", "hdfOK", "hdfPath" }, - { "hdfRW", "hdfDev", "hdfAutoboot", "hdfOK", "hdfPath" }, - { "hdfAutoboot", "hdfRW", "hdfBootPri", "hdfOK", "hdfPath" }, - { "hdfBootPri", "hdfAutoboot", "hdfDev", "hdfCancel", "hdfPath" }, - { "hdfSurface", "hdfReserved", "hdfReserved", "hdfPath", "hdfSectors" }, - { "hdfReserved", "hdfSurface", "hdfSurface", "hdfPath", "hdfBlocksize" }, - { "hdfSectors", "hdfBlocksize", "hdfBlocksize", "hdfSurface", "hdfController" }, - { "hdfBlocksize", "hdfSectors", "hdfSectors", "hdfReserved", "hdfUnit" }, - { "hdfPath", "", "", "hdfBootPri", "hdfReserved" }, - { "hdfController", "hdfUnit", "hdfUnit", "hdfSectors", "hdfOK" }, - { "hdfUnit", "hdfController", "hdfController", "hdfBlocksize", "hdfOK" }, - { "hdfOK", "hdfCancel", "hdfCancel", "hdfUnit", "hdfBootPri" }, - { "hdfCancel", "hdfOK", "hdfOK", "hdfUnit", "hdfBootPri" }, +// EditFilesysHardfile + { "hdfDev", "hdfBootPri", "hdfRW", "hdfOK", "hdfPath" }, + { "hdfRW", "hdfDev", "hdfAutoboot", "hdfOK", "hdfPath" }, + { "hdfAutoboot", "hdfRW", "hdfBootPri", "hdfOK", "hdfPath" }, + { "hdfBootPri", "hdfAutoboot", "hdfDev", "hdfCancel", "hdfPath" }, + { "hdfSurface", "hdfReserved", "hdfReserved", "hdfPath", "hdfSectors" }, + { "hdfReserved", "hdfSurface", "hdfSurface", "hdfPath", "hdfBlocksize" }, + { "hdfSectors", "hdfBlocksize", "hdfBlocksize", "hdfSurface", "hdfController" }, + { "hdfBlocksize", "hdfSectors", "hdfSectors", "hdfReserved", "hdfUnit" }, + { "hdfPath", "", "", "hdfBootPri", "hdfReserved" }, + { "hdfController", "hdfUnit", "hdfUnit", "hdfSectors", "hdfOK" }, + { "hdfUnit", "hdfController", "hdfController", "hdfBlocksize", "hdfOK" }, + { "hdfOK", "hdfCancel", "hdfCancel", "hdfUnit", "hdfBootPri" }, + { "hdfCancel", "hdfOK", "hdfOK", "hdfUnit", "hdfBootPri" }, - // CreateFilesysHardfile - {"createHdfDev", "createHdfBootPri", "createHdfAutoboot", "createHdfOK", "createHdfPath"}, - {"createHdfAutoboot", "createHdfDev", "createHdfBootPri", "createHdfOK", "createHdfPath"}, - {"createHdfBootPri", "createHdfAutoboot", "createHdfDev", "createHdfOK", "createHdfPath"}, - {"createHdfSize", "", "", "createHdfPath", "createHdfOK"}, - {"createHdfPath", "", "", "createHdfBootPri", "createHdfSize"}, - {"createHdfOK", "createHdfCancel", "createHdfCancel", "createHdfSize", "createHdfBootPri"}, - {"createHdfCancel", "createHdfOK", "createHdfOK", "createHdfSize", "createHdfBootPri"}, +// CreateFilesysHardfile + { "createHdfDev", "createHdfBootPri", "createHdfAutoboot", "createHdfOK", "createHdfPath" }, + { "createHdfAutoboot", "createHdfDev", "createHdfBootPri", "createHdfOK", "createHdfPath" }, + { "createHdfBootPri", "createHdfAutoboot", "createHdfDev", "createHdfOK", "createHdfPath" }, + { "createHdfSize", "", "", "createHdfPath", "createHdfOK" }, + { "createHdfPath", "", "", "createHdfBootPri", "createHdfSize" }, + { "createHdfOK", "createHdfCancel", "createHdfCancel", "createHdfSize", "createHdfBootPri" }, + { "createHdfCancel", "createHdfOK", "createHdfOK", "createHdfSize", "createHdfBootPri" }, {"END", "", "", "", ""} }; @@ -346,7 +347,7 @@ bool HandleNavigation(int direction) if (focusTarget != nullptr) { - if (!activeWidget->getId().substr(0, 3).compare("cbo")) + if (!activeWidget->getId().substr(0, 3).compare("cbo") || !activeWidget->getId().substr(0, 5).compare("qscbo")) { gcn::UaeDropDown* dropdown = static_cast(activeWidget); if (dropdown->isDroppedDown() && (direction == DIRECTION_UP || direction == DIRECTION_DOWN)) diff --git a/src/osdep/gui/PanelCPU.cpp b/src/osdep/gui/PanelCPU.cpp index d4afbb15..487fc840 100644 --- a/src/osdep/gui/PanelCPU.cpp +++ b/src/osdep/gui/PanelCPU.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeCheckBox.hpp" @@ -428,4 +428,4 @@ bool HelpPanelCPU(std::vector &helptext) helptext.push_back("cycles for the opcodes are based on 68020. The different cycles for 68030 and 68040 may come in a later"); helptext.push_back("version."); return true; -} \ No newline at end of file +} diff --git a/src/osdep/gui/PanelChipset.cpp b/src/osdep/gui/PanelChipset.cpp index 72a48353..df3431eb 100644 --- a/src/osdep/gui/PanelChipset.cpp +++ b/src/osdep/gui/PanelChipset.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeCheckBox.hpp" @@ -30,6 +30,8 @@ static gcn::Window* grpBlitter; static gcn::UaeRadioButton* optBlitNormal; static gcn::UaeRadioButton* optBlitImmed; static gcn::UaeRadioButton* optBlitWait; +static gcn::Window *grpCopper; +static gcn::UaeCheckBox* chkFastCopper; static gcn::Window* grpCollisionLevel; static gcn::UaeRadioButton* optCollNone; static gcn::UaeRadioButton* optCollSprites; @@ -133,12 +135,24 @@ public: changed_prefs.ntscmode = false; changed_prefs.chipset_refreshrate = 50; } + RefreshPanelQuickstart(); } }; static NTSCButtonActionListener* ntscButtonActionListener; +class FastCopperActionListener : public gcn::ActionListener +{ + public: + void action(const gcn::ActionEvent& actionEvent) + { + changed_prefs.fast_copper = chkFastCopper->isSelected(); + } +}; +static FastCopperActionListener* fastCopperActionListener; + + class BlitterButtonActionListener : public gcn::ActionListener { public: @@ -212,7 +226,7 @@ void InitPanelChipset(const struct _ConfigCategory& category) grpChipset->add(cboChipset, 115 + lblChipset->getWidth() + 8, 10); grpChipset->setMovable(false); - grpChipset->setSize(120, 185); + grpChipset->setSize(255, 185); grpChipset->setBaseColor(gui_baseCol); category.panel->add(grpChipset); @@ -241,6 +255,20 @@ void InitPanelChipset(const struct _ConfigCategory& category) category.panel->add(grpBlitter); + fastCopperActionListener = new FastCopperActionListener(); + + chkFastCopper = new gcn::UaeCheckBox("Fast copper"); + chkFastCopper->addActionListener(fastCopperActionListener); + + grpCopper = new gcn::Window("Copper"); + grpCopper->setPosition(DISTANCE_BORDER + grpChipset->getWidth() + DISTANCE_NEXT_X, grpBlitter->getY() + grpBlitter->getHeight() + DISTANCE_NEXT_Y); + grpCopper->add(chkFastCopper, 5, 10); + grpCopper->setMovable(false); + grpCopper->setSize(120, 55); + grpCopper->setBaseColor(gui_baseCol); + + category.panel->add(grpCopper); + collisionButtonActionListener = new CollisionButtonActionListener(); optCollNone = new gcn::UaeRadioButton("None", "radioccollisiongroup"); @@ -294,6 +322,9 @@ void ExitPanelChipset() delete grpBlitter; delete blitterButtonActionListener; + delete chkFastCopper; + delete grpCopper; + delete fastCopperActionListener; delete optCollNone; delete optCollSprites; delete optCollPlayfield; @@ -334,6 +365,8 @@ void RefreshPanelChipset() else optBlitNormal->setSelected(true); + chkFastCopper->setSelected(changed_prefs.fast_copper); + if (changed_prefs.collision_level == 0) optCollNone->setSelected(true); else if (changed_prefs.collision_level == 1) @@ -362,4 +395,4 @@ bool HelpPanelChipset(std::vector &helptext) helptext.push_back(""); helptext.push_back("For \"Collision Level\", select \"Sprites and Sprites vs. Playfield\" which is fine for nearly all games."); return true; -} \ No newline at end of file +} diff --git a/src/osdep/gui/PanelConfig.cpp b/src/osdep/gui/PanelConfig.cpp index 7e810003..db375784 100644 --- a/src/osdep/gui/PanelConfig.cpp +++ b/src/osdep/gui/PanelConfig.cpp @@ -1,16 +1,18 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeListBox.hpp" #include "sysconfig.h" #include "sysdeps.h" +#include "config.h" #include "options.h" +#include "uae.h" +#include "blkdev.h" #include "gui.h" #include "gui_handling.h" -#include "uae.h" static char last_active_config[MAX_DPATH] = {'\0'}; static int ensureVisible = -1; @@ -33,6 +35,9 @@ bool LoadConfigByName(const char* name) ConfigFileInfo* config = SearchConfigInList(name); if (config != nullptr) { + if(emulating) { + uae_restart(-1, config->FullPath); + } else { txtName->setText(config->Name); txtDesc->setText(config->Description); target_cfgfile_load(&changed_prefs, config->FullPath, 0, 0); @@ -359,4 +364,4 @@ bool HelpPanelConfig(std::vector &helptext) helptext.push_back(""); helptext.push_back("\"Delete\" will delete the selected configuration."); return true; -} \ No newline at end of file +} diff --git a/src/osdep/gui/PanelDisplay.cpp b/src/osdep/gui/PanelDisplay.cpp index fa949fed..2d637fb6 100644 --- a/src/osdep/gui/PanelDisplay.cpp +++ b/src/osdep/gui/PanelDisplay.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" @@ -9,7 +9,10 @@ #include "sysconfig.h" #include "sysdeps.h" +#include "config.h" #include "options.h" +#include "include/memory.h" +#include "uae.h" #include "gui.h" #include "gui_handling.h" @@ -124,4 +127,4 @@ bool HelpPanelDisplay(std::vector &helptext) helptext.push_back("When you activate \"Frameskip\", only every second frame is drawn. This will improve performance and some"); helptext.push_back("more games are playable."); return true; -} \ No newline at end of file +} diff --git a/src/osdep/gui/PanelFloppy.cpp b/src/osdep/gui/PanelFloppy.cpp index f70440a1..9a6f6b5c 100644 --- a/src/osdep/gui/PanelFloppy.cpp +++ b/src/osdep/gui/PanelFloppy.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" @@ -9,8 +9,11 @@ #include "sysconfig.h" #include "sysdeps.h" +#include "config.h" #include "options.h" +#include "include/memory.h" #include "disk.h" +#include "uae.h" #include "gui.h" #include "gui_handling.h" @@ -40,7 +43,8 @@ static bool bIgnoreListChange = false; class DriveTypeListModel : public gcn::ListModel { - vector types; +private: + std::vector types; public: DriveTypeListModel() @@ -245,7 +249,7 @@ public: { if (diskfileList.getElementAt(idx).compare(changed_prefs.floppyslots[i].df)) { - strcpy(changed_prefs.floppyslots[i].df, diskfileList.getElementAt(idx).c_str()); + strncpy(changed_prefs.floppyslots[i].df, diskfileList.getElementAt(idx).c_str(), sizeof(changed_prefs.floppyslots[i].df)); disk_insert(i, changed_prefs.floppyslots[i].df); lstMRUDiskList.erase(lstMRUDiskList.begin() + idx); lstMRUDiskList.insert(lstMRUDiskList.begin(), changed_prefs.floppyslots[i].df); @@ -394,6 +398,8 @@ void InitPanelFloppy(const struct _ConfigCategory& category) chkDFxWriteProtect[i] = new gcn::UaeCheckBox("Write-protected"); chkDFxWriteProtect[i]->addActionListener(dfxCheckActionListener); + snprintf(tmp, 20, "chkWP%d", i); + chkDFxWriteProtect[i]->setId(tmp); cmdDFxInfo[i] = new gcn::Button("?"); cmdDFxInfo[i]->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT); @@ -614,4 +620,4 @@ bool HelpPanelFloppy(std::vector &helptext) helptext.push_back(""); helptext.push_back("With the buttons \"Create 3.5'' DD disk\" and \"Create 3.5'' HD disk\" you can create a new and empty disk."); return true; -} \ No newline at end of file +} diff --git a/src/osdep/gui/PanelHD.cpp b/src/osdep/gui/PanelHD.cpp index 40e30148..0d1af61b 100644 --- a/src/osdep/gui/PanelHD.cpp +++ b/src/osdep/gui/PanelHD.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" @@ -648,4 +648,4 @@ bool HelpPanelHD(std::vector &helptext) helptext.push_back(""); helptext.push_back("In current version, WAV, MP3 and FLAC is supported for audio tracks."); return true; -} \ No newline at end of file +} diff --git a/src/osdep/gui/PanelInput.cpp b/src/osdep/gui/PanelInput.cpp index a8c24dd3..a825cf22 100644 --- a/src/osdep/gui/PanelInput.cpp +++ b/src/osdep/gui/PanelInput.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" @@ -9,7 +9,12 @@ #include "sysconfig.h" #include "sysdeps.h" +#include "config.h" #include "options.h" +#include "include/memory.h" +#include "uae.h" +#include "autoconf.h" +#include "filesys.h" #include "gui.h" #include "gui_handling.h" #include "keyboard.h" @@ -28,7 +33,10 @@ static gcn::UaeDropDown* cboAutofire; static gcn::Label* lblMouseSpeed; static gcn::Label* lblMouseSpeedInfo; static gcn::Slider* sldMouseSpeed; - +static gcn::Label *lblTapDelay; +static gcn::UaeDropDown* cboTapDelay; +static gcn::UaeCheckBox* chkMouseHack; + static gcn::UaeCheckBox* chkCustomCtrl; static gcn::Label* lblA; static gcn::TextField* txtA; @@ -76,7 +84,8 @@ static gcn::Button* cmdPlay; class StringListModel : public gcn::ListModel { - vector values; + private: + std::vector values; public: StringListModel(const char* entries[], int count) { @@ -109,6 +118,8 @@ StringListModel ctrlPortList(inputport_list, 5); const char* autofireValues[] = {"Off", "Slow", "Medium", "Fast"}; StringListModel autofireList(autofireValues, 4); +const char *tapDelayValues[] = { "Normal", "Short", "None" }; +StringListModel tapDelayList(tapDelayValues, 3); const char* mappingValues[] = { "CD32 rwd", "CD32 ffw", "CD32 play", "CD32 yellow", "CD32 green", @@ -249,6 +260,20 @@ public: RefreshPanelInput(); } + else if (actionEvent.getSource() == cboTapDelay) + { + if(cboTapDelay->getSelected() == 0) + changed_prefs.pandora_tapDelay = 10; + else if (cboTapDelay->getSelected() == 1) + changed_prefs.pandora_tapDelay = 5; + else + changed_prefs.pandora_tapDelay = 2; + } + + else if (actionEvent.getSource() == chkMouseHack) + { + changed_prefs.input_tablet = chkMouseHack->isSelected() ? TABLET_MOUSEHACK : TABLET_OFF; + } else if (actionEvent.getSource() == chkCustomCtrl) changed_prefs.customControls = chkCustomCtrl->isSelected(); @@ -432,6 +457,18 @@ void InitPanelInput(const struct _ConfigCategory& category) sldMouseSpeed->addActionListener(inputActionListener); lblMouseSpeedInfo = new gcn::Label(".25"); + lblTapDelay = new gcn::Label("Tap Delay:"); + lblTapDelay->setSize(100, LABEL_HEIGHT); + lblTapDelay->setAlignment(gcn::Graphics::RIGHT); + cboTapDelay = new gcn::UaeDropDown(&tapDelayList); + cboTapDelay->setSize(80, DROPDOWN_HEIGHT); + cboTapDelay->setBaseColor(gui_baseCol); + cboTapDelay->setId("cboTapDelay"); + cboTapDelay->addActionListener(inputActionListener); + + chkMouseHack = new gcn::UaeCheckBox("Enable mousehack"); + chkMouseHack->setId("MouseHack"); + chkMouseHack->addActionListener(inputActionListener); chkCustomCtrl = new gcn::UaeCheckBox("Custom Control"); chkCustomCtrl->setId("CustomCtrl"); chkCustomCtrl->addActionListener(inputActionListener); @@ -596,6 +633,11 @@ void InitPanelInput(const struct _ConfigCategory& category) category.panel->add(lblMouseSpeedInfo, sldMouseSpeed->getX() + sldMouseSpeed->getWidth() + 12, posY); posY += sldMouseSpeed->getHeight() + DISTANCE_NEXT_Y * 2; + category.panel->add(chkMouseHack, DISTANCE_BORDER + lblA->getWidth() + 8, posY); + category.panel->add(lblTapDelay, 300, posY); + category.panel->add(cboTapDelay, 300 + lblTapDelay->getWidth() + 8, posY); + posY += cboTapDelay->getHeight() + DISTANCE_NEXT_Y; + category.panel->add(chkCustomCtrl, DISTANCE_BORDER + lblA->getWidth() + 8, posY); posY += chkCustomCtrl->getHeight() + DISTANCE_NEXT_Y; category.panel->add(lblA, DISTANCE_BORDER, posY); @@ -645,6 +687,9 @@ void ExitPanelInput() delete lblMouseSpeed; delete sldMouseSpeed; delete lblMouseSpeedInfo; + delete lblTapDelay; + delete cboTapDelay; + delete chkMouseHack; delete chkCustomCtrl; delete lblA; @@ -740,6 +785,14 @@ void RefreshPanelInput() } } +if (changed_prefs.pandora_tapDelay == 10) + cboTapDelay->setSelected(0); + else if (changed_prefs.pandora_tapDelay == 5) + cboTapDelay->setSelected(1); + else + cboTapDelay->setSelected(2); + chkMouseHack->setSelected(changed_prefs.input_tablet == TABLET_MOUSEHACK); + chkCustomCtrl->setSelected(changed_prefs.customControls); txtA->setText(changed_prefs.custom_a); @@ -762,8 +815,14 @@ bool HelpPanelInput(std::vector &helptext) helptext.push_back(""); helptext.push_back("Set the emulated mouse speed to .25x, .5x, 1x, 2x and 4x to slow down or speed up the mouse."); helptext.push_back(""); + helptext.push_back("When \"Enable mousehack\" is activated, you can use the stylus to set the mouse pointer to the exact position."); + helptext.push_back("This works very well on Workbench, but many games using there own mouse handling and will not profit from"); + helptext.push_back("this code."); + helptext.push_back(""); + helptext.push_back("\"Tap Delay\" specifies the time between taping the screen and an emulated mouse button click."); + helptext.push_back(""); helptext.push_back("When you activate \"Custom Control\", you can define which Amiga key should be emulated by pressing one of the"); helptext.push_back("ABXY- or D-pad buttons. Useful to setup controls for pinball games. During emulation, you can switch between"); helptext.push_back("regular buttons and custom settings by pressing left shoulder button and 'c'."); return true; -} \ No newline at end of file +} diff --git a/src/osdep/gui/PanelMisc.cpp b/src/osdep/gui/PanelMisc.cpp index f255ab62..28214239 100644 --- a/src/osdep/gui/PanelMisc.cpp +++ b/src/osdep/gui/PanelMisc.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" @@ -9,7 +9,12 @@ #include "sysconfig.h" #include "sysdeps.h" +#include "config.h" #include "options.h" +#include "include/memory.h" +#include "uae.h" +#include "autoconf.h" +#include "filesys.h" #include "gui.h" #include "gui_handling.h" @@ -17,6 +22,11 @@ static gcn::UaeCheckBox* chkStatusLine; static gcn::UaeCheckBox* chkHideIdleLed; static gcn::UaeCheckBox* chkShowGUI; +#ifdef PANDORA +static gcn::Label* lblPandoraSpeed; +static gcn::Label* lblPandoraSpeedInfo; +static gcn::Slider* sldPandoraSpeed; +#endif static gcn::UaeCheckBox* chkBSDSocket; static gcn::UaeCheckBox* chkMasterWP; @@ -66,7 +76,10 @@ public: { if (actionEvent.getSource() == chkStatusLine) changed_prefs.leds_on_screen = chkStatusLine->isSelected(); - +#ifdef PANDORA + else if (actionEvent.getSource() == chkHideIdleLed) + changed_prefs.pandora_hide_idle_led = chkHideIdleLed->isSelected(); +#endif else if (actionEvent.getSource() == chkShowGUI) changed_prefs.start_gui = chkShowGUI->isSelected(); @@ -98,6 +111,18 @@ public: strcpy(changed_prefs.quit_amiberry, key); } } +#ifdef PANDORA + else if (actionEvent.getSource() == sldPandoraSpeed) + { + int newspeed = (int) sldPandoraSpeed->getValue(); + newspeed = newspeed - (newspeed % 20); + if(changed_prefs.pandora_cpu_speed != newspeed) + { + changed_prefs.pandora_cpu_speed = newspeed; + RefreshPanelMisc(); + } + } +#endif else if (actionEvent.getSource() == cboKBDLed_num) changed_prefs.kbd_led_num = cboKBDLed_num->getSelected(); @@ -126,6 +151,19 @@ void InitPanelMisc(const struct _ConfigCategory& category) chkShowGUI->setId("ShowGUI"); chkShowGUI->addActionListener(miscActionListener); +#ifdef PANDORA + lblPandoraSpeed = new gcn::Label("Pandora Speed:"); + lblPandoraSpeed->setSize(110, LABEL_HEIGHT); + lblPandoraSpeed->setAlignment(gcn::Graphics::RIGHT); + sldPandoraSpeed = new gcn::Slider(500, 1260); + sldPandoraSpeed->setSize(200, SLIDER_HEIGHT); + sldPandoraSpeed->setBaseColor(gui_baseCol); + sldPandoraSpeed->setMarkerLength(20); + sldPandoraSpeed->setStepLength(20); + sldPandoraSpeed->setId("PandSpeed"); + sldPandoraSpeed->addActionListener(miscActionListener); + lblPandoraSpeedInfo = new gcn::Label("1000 MHz"); +#endif chkBSDSocket = new gcn::UaeCheckBox("bsdsocket.library"); chkBSDSocket->setId("BSDSocket"); chkBSDSocket->addActionListener(miscActionListener); @@ -185,7 +223,12 @@ void InitPanelMisc(const struct _ConfigCategory& category) posY += chkHideIdleLed->getHeight() + DISTANCE_NEXT_Y; category.panel->add(chkShowGUI, DISTANCE_BORDER, posY); posY += chkShowGUI->getHeight() + DISTANCE_NEXT_Y; - +#ifdef PANDORA + category.panel->add(lblPandoraSpeed, DISTANCE_BORDER, posY); + category.panel->add(sldPandoraSpeed, DISTANCE_BORDER + lblPandoraSpeed->getWidth() + 8, posY); + category.panel->add(lblPandoraSpeedInfo, sldPandoraSpeed->getX() + sldPandoraSpeed->getWidth() + 12, posY); + posY += sldPandoraSpeed->getHeight() + DISTANCE_NEXT_Y; +#endif category.panel->add(chkBSDSocket, DISTANCE_BORDER, posY); posY += chkBSDSocket->getHeight() + DISTANCE_NEXT_Y * 2; @@ -213,6 +256,11 @@ void ExitPanelMisc() delete chkStatusLine; delete chkHideIdleLed; delete chkShowGUI; +#ifdef PANDORA + delete lblPandoraSpeed; + delete sldPandoraSpeed; + delete lblPandoraSpeedInfo; +#endif delete chkBSDSocket; delete chkMasterWP; @@ -233,7 +281,15 @@ void ExitPanelMisc() void RefreshPanelMisc() { chkStatusLine->setSelected(changed_prefs.leds_on_screen); +#ifdef PANDORA + chkHideIdleLed->setSelected(changed_prefs.pandora_hide_idle_led); +#endif chkShowGUI->setSelected(changed_prefs.start_gui); +#ifdef PANDORA + sldPandoraSpeed->setValue(changed_prefs.pandora_cpu_speed); + snprintf(tmp, 20, "%d MHz", changed_prefs.pandora_cpu_speed); + lblPandoraSpeedInfo->setCaption(tmp); +#endif chkBSDSocket->setSelected(changed_prefs.socket_emu); chkMasterWP->setSelected(changed_prefs.floppy_read_only); @@ -256,8 +312,13 @@ bool HelpPanelMisc(std::vector &helptext) helptext.push_back("When you deactivate the option \"Show GUI on startup\" and use this configuration by specifying it with the"); helptext.push_back("command line parameter \"-config=\", the emulation starts directly without showing the GUI."); helptext.push_back(""); +#ifdef PANDORA + helptext.push_back("Set the speed for the Pandora CPU to overclock it for games which need more power. Be careful with this"); + helptext.push_back("parameter."); + helptext.push_back(""); +#endif helptext.push_back("\"bsdsocket.library\" enables network functions (i.e. for web browsers in OS3.9)."); helptext.push_back(""); helptext.push_back("\"Master floppy drive protection\" will disable all write access to floppy disks."); return true; -} \ No newline at end of file +} diff --git a/src/osdep/gui/PanelPaths.cpp b/src/osdep/gui/PanelPaths.cpp index 6aff73a4..ca8356d6 100644 --- a/src/osdep/gui/PanelPaths.cpp +++ b/src/osdep/gui/PanelPaths.cpp @@ -1,11 +1,13 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "sysconfig.h" #include "sysdeps.h" +#include "config.h" +#include "options.h" #include "uae.h" #include "gui.h" #include "gui_handling.h" @@ -156,4 +158,4 @@ bool HelpPanelPaths(std::vector &helptext) helptext.push_back("After changing the location of the kickstart roms, click on \"Rescan ROMS\" to refresh the list of the available"); helptext.push_back("ROMs."); return true; -} \ No newline at end of file +} diff --git a/src/osdep/gui/PanelQuickstart.cpp b/src/osdep/gui/PanelQuickstart.cpp index 8b51ec8b..cdc1e29e 100644 --- a/src/osdep/gui/PanelQuickstart.cpp +++ b/src/osdep/gui/PanelQuickstart.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" @@ -11,7 +11,7 @@ #include "sysdeps.h" #include "config.h" #include "options.h" -#include "memory.h" +#include "include/memory.h" #include "disk.h" #include "uae.h" #include "autoconf.h" @@ -48,42 +48,42 @@ struct amigamodels { char configs[8][128]; }; static struct amigamodels amodels[] = { - { 4, "Amiga 500",{ - "1.3 ROM, OCS, 512 KB Chip + 512 KB Slow RAM (most common)", - "1.3 ROM, ECS Agnus, 512 KB Chip RAM + 512 KB Slow RAM", - "1.3 ROM, ECS Agnus, 1 MB Chip RAM", - "1.3 ROM, OCS Agnus, 512 KB Chip RAM", - "1.2 ROM, OCS Agnus, 512 KB Chip RAM", - "1.2 ROM, OCS Agnus, 512 KB Chip RAM + 512 KB Slow RAM", - "\0" } }, - { 4, "Amiga 500+",{ - "Basic non-expanded configuration", - "2 MB Chip RAM expanded configuration", - "MB Fast RAM expanded configuration\n", - "\0" } }, - { 4, "Amiga 600",{ - "Basic non-expanded configuration", - "2 MB Chip RAM expanded configuration", - "n MB Fast RAM expanded configuration", - "\0" } }, - { 4, "Amiga 1200",{ - "Basic non-expanded configuration", - "4 MB Fast RAM expanded configuration", - "\0" } }, - // { 2, "Amiga 3000", { - // "1.4 ROM, 2MB Chip + 8MB Fast", - // "2.04 ROM, 2MB Chip + 8MB Fast", - // "3.1 ROM, 2MB Chip + 8MB Fast", - // "\0" } }, - { 1, "Amiga 4000",{ - "68030, 3.1 ROM, 2MB Chip + 8MB Fast", - "68040, 3.1 ROM, 2MB Chip + 8MB Fast", - "\0" } }, - { 3, "CD32",{ - "CD32", - "CD32 with Full Motion Video cartridge", - "\0" } }, - { -1 } + { 4, "Amiga 500", { + "1.3 ROM, OCS, 512 KB Chip + 512 KB Slow RAM (most common)", + "1.3 ROM, ECS Agnus, 512 KB Chip RAM + 512 KB Slow RAM", + "1.3 ROM, ECS Agnus, 1 MB Chip RAM", + "1.3 ROM, OCS Agnus, 512 KB Chip RAM", + "1.2 ROM, OCS Agnus, 512 KB Chip RAM", + "1.2 ROM, OCS Agnus, 512 KB Chip RAM + 512 KB Slow RAM", + "\0" } }, + { 4, "Amiga 500+", { + "Basic non-expanded configuration", + "2 MB Chip RAM expanded configuration", + "MB Fast RAM expanded configuration\n", + "\0" } }, + { 4, "Amiga 600", { + "Basic non-expanded configuration", + "2 MB Chip RAM expanded configuration", + "n MB Fast RAM expanded configuration", + "\0" } }, + { 4, "Amiga 1200", { + "Basic non-expanded configuration", + "4 MB Fast RAM expanded configuration", + "\0" } }, +// { 2, "Amiga 3000", { +// "1.4 ROM, 2MB Chip + 8MB Fast", +// "2.04 ROM, 2MB Chip + 8MB Fast", +// "3.1 ROM, 2MB Chip + 8MB Fast", +// "\0" } }, + { 1, "Amiga 4000", { + "68030, 3.1 ROM, 2MB Chip + 8MB Fast", + "68040, 3.1 ROM, 2MB Chip + 8MB Fast", + "\0" } }, + { 3, "CD32", { + "CD32", + "CD32 with Full Motion Video cartridge", + "\0" } }, + { -1 } }; static const int numModels = 6; diff --git a/src/osdep/gui/PanelRAM.cpp b/src/osdep/gui/PanelRAM.cpp index 11e4f70f..219c0566 100644 --- a/src/osdep/gui/PanelRAM.cpp +++ b/src/osdep/gui/PanelRAM.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" @@ -9,11 +9,13 @@ #include "sysconfig.h" #include "sysdeps.h" +#include "config.h" #include "options.h" #include "include/memory.h" +#include "uae.h" +#include "gfxboard.h" #include "gui.h" #include "gui_handling.h" -#include "gfxboard.h" static const char *ChipMem_list[] = { "512 K", "1 MB", "2 MB", "4 MB", "8 MB" }; diff --git a/src/osdep/gui/PanelROM.cpp b/src/osdep/gui/PanelROM.cpp index 8e0962a1..035930d9 100644 --- a/src/osdep/gui/PanelROM.cpp +++ b/src/osdep/gui/PanelROM.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeDropDown.hpp" @@ -9,8 +9,11 @@ #include "sysconfig.h" #include "sysdeps.h" +#include "config.h" #include "options.h" +#include "include/memory.h" #include "rommgr.h" +#include "uae.h" #include "gui.h" #include "gui_handling.h" @@ -63,7 +66,7 @@ public: idxToAvailableROMs.clear(); int currIdx = -1; - if (ROMType & (ROMTYPE_EXTCDTV | ROMTYPE_EXTCD32)) + if (ROMType & (ROMTYPE_ALL_EXT | ROMTYPE_ALL_CART)) { roms.push_back(""); idxToAvailableROMs.push_back(-1); @@ -209,8 +212,8 @@ void InitPanelROM(const struct _ConfigCategory& category) cartROMActionListener = new CartROMActionListener(); #endif romButtonActionListener = new ROMButtonActionListener(); - mainROMList = new ROMListModel(ROMTYPE_KICK | ROMTYPE_KICKCD32); - extROMList = new ROMListModel(ROMTYPE_EXTCDTV | ROMTYPE_EXTCD32); + mainROMList = new ROMListModel(ROMTYPE_ALL_KICK); + extROMList = new ROMListModel(ROMTYPE_ALL_EXT); #ifdef ACTION_REPLAY cartROMList = new ROMListModel(ROMTYPE_ALL_CART); #endif @@ -306,7 +309,6 @@ void ExitPanelROM() #endif delete romButtonActionListener; - // delete chkMapROM; } @@ -334,4 +336,4 @@ bool HelpPanelROM(std::vector &helptext) helptext.push_back("In \"Cartridge ROM File\", you can select the CD32 FMV module to activate video playback in CD32."); helptext.push_back("There are also some Action Replay and Freezer cards and the built in HRTMon available."); return true; -} \ No newline at end of file +} diff --git a/src/osdep/gui/PanelSavestate.cpp b/src/osdep/gui/PanelSavestate.cpp index 88c7fdd9..c4ac6b10 100644 --- a/src/osdep/gui/PanelSavestate.cpp +++ b/src/osdep/gui/PanelSavestate.cpp @@ -2,14 +2,23 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeCheckBox.hpp" #include "sysconfig.h" #include "sysdeps.h" +#include "config.h" +#include "options.h" +#include "include/memory.h" +#include "newcpu.h" +#include "custom.h" +#include "xwin.h" +#include "drawing.h" +#include "uae.h" #include "gui.h" +#include "autoconf.h" #include "savestate.h" #include "gui_handling.h" @@ -76,7 +85,7 @@ public: savestate_initsave(savestate_fname, 2, 0, false); save_state(savestate_fname, "..."); savestate_state = STATE_DOSAVE; // Just to create the screenshot - delay_savestate_frame = 1; + delay_savestate_frame = 2; gui_running = false; } else @@ -224,6 +233,7 @@ void RefreshPanelSavestate() target.h = rect.height; SDL_SoftStretch(loadedImage, &source, scaled, &target); SDL_FreeSurface(loadedImage); + loadedImage = nullptr; imgSavestate = new gcn::SDLImage(scaled, true); icoSavestate = new gcn::Icon(imgSavestate); wndScreenshot->add(icoSavestate); @@ -249,4 +259,4 @@ bool HelpPanelSavestate(std::vector &helptext) helptext.push_back(""); helptext.push_back("Note: Savestates will not work with HDDs."); return true; -} \ No newline at end of file +} diff --git a/src/osdep/gui/PanelSound.cpp b/src/osdep/gui/PanelSound.cpp index 271ba1a6..80c4586a 100644 --- a/src/osdep/gui/PanelSound.cpp +++ b/src/osdep/gui/PanelSound.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "UaeRadioButton.hpp" #include "UaeCheckBox.hpp" @@ -9,8 +9,13 @@ #include "sysconfig.h" #include "sysdeps.h" +#include "config.h" #include "options.h" +#include "uae.h" #include "gui.h" +#include "include/memory.h" +#include "newcpu.h" +#include "custom.h" #include "gui_handling.h" #include "sounddep/sound.h" @@ -474,4 +479,4 @@ bool HelpPanelSound(std::vector &helptext) helptext.push_back("are mixed to the left and right channels of your device. A value of 70% for separation and no delay is a good"); helptext.push_back("start."); return true; -} \ No newline at end of file +} diff --git a/src/osdep/gui/SelectFile.cpp b/src/osdep/gui/SelectFile.cpp index 5ab31b15..42aa054a 100644 --- a/src/osdep/gui/SelectFile.cpp +++ b/src/osdep/gui/SelectFile.cpp @@ -4,7 +4,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "sysconfig.h" @@ -308,6 +308,7 @@ static void SelectFileLoop() lstFiles->requestFocus(); else if (activeWidget == txtFilename) lstFiles->requestFocus(); + continue; } break; @@ -326,6 +327,7 @@ static void SelectFileLoop() lstFiles->requestFocus(); else if (activeWidget == cmdOK) cmdCancel->requestFocus(); + continue; } break; diff --git a/src/osdep/gui/SelectFolder.cpp b/src/osdep/gui/SelectFolder.cpp index ccf022c7..41dbba04 100644 --- a/src/osdep/gui/SelectFolder.cpp +++ b/src/osdep/gui/SelectFolder.cpp @@ -4,7 +4,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "sysconfig.h" diff --git a/src/osdep/gui/SelectorEntry.hpp b/src/osdep/gui/SelectorEntry.hpp index 219e2c3f..07e77e48 100644 --- a/src/osdep/gui/SelectorEntry.hpp +++ b/src/osdep/gui/SelectorEntry.hpp @@ -1,9 +1,9 @@ #ifndef GCN_SELECTORENTRY_HPP #define GCN_SELECTORENTRY_HPP -#include "guisan/basiccontainer.hpp" -#include "guisan/platform.hpp" -#include "guisan/widgetlistener.hpp" +#include +#include +#include #include namespace gcn diff --git a/src/osdep/gui/ShowHelp.cpp b/src/osdep/gui/ShowHelp.cpp index eaa36ef0..e98d64b4 100644 --- a/src/osdep/gui/ShowHelp.cpp +++ b/src/osdep/gui/ShowHelp.cpp @@ -4,7 +4,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "sysconfig.h" diff --git a/src/osdep/gui/ShowMessage.cpp b/src/osdep/gui/ShowMessage.cpp index c716ca93..24001da4 100644 --- a/src/osdep/gui/ShowMessage.cpp +++ b/src/osdep/gui/ShowMessage.cpp @@ -4,7 +4,7 @@ #include #include #include -#include "guisan/sdl/sdltruetypefont.hpp" +#include #include "SelectorEntry.hpp" #include "sysconfig.h" @@ -169,6 +169,7 @@ static void ShowMessageLoop() cmdOK->requestFocus(); else if (activeWidget == cmdOK) cmdCancel->requestFocus(); + continue; } break; diff --git a/src/osdep/gui/UaeCheckBox.cpp b/src/osdep/gui/UaeCheckBox.cpp index debd1fe8..43de0fe2 100644 --- a/src/osdep/gui/UaeCheckBox.cpp +++ b/src/osdep/gui/UaeCheckBox.cpp @@ -1,6 +1,6 @@ #include "UaeCheckBox.hpp" -#include "guisan/widgets/checkbox.hpp" -#include "guisan/graphics.hpp" +#include +#include namespace gcn diff --git a/src/osdep/gui/UaeCheckBox.hpp b/src/osdep/gui/UaeCheckBox.hpp index 4773d85a..d31a53af 100644 --- a/src/osdep/gui/UaeCheckBox.hpp +++ b/src/osdep/gui/UaeCheckBox.hpp @@ -4,9 +4,9 @@ #include #include -#include "guisan/platform.hpp" -#include "guisan/widget.hpp" -#include "guisan/widgets/checkbox.hpp" +#include +#include +#include namespace gcn diff --git a/src/osdep/gui/UaeDropDown.cpp b/src/osdep/gui/UaeDropDown.cpp index 85a713af..a376e9d3 100644 --- a/src/osdep/gui/UaeDropDown.cpp +++ b/src/osdep/gui/UaeDropDown.cpp @@ -1,6 +1,6 @@ #include "UaeDropDown.hpp" -#include "guisan/widgets/dropdown.hpp" -#include "guisan/key.hpp" +#include +#include namespace gcn { diff --git a/src/osdep/gui/UaeDropDown.hpp b/src/osdep/gui/UaeDropDown.hpp index b5b1d4bc..4c11720f 100644 --- a/src/osdep/gui/UaeDropDown.hpp +++ b/src/osdep/gui/UaeDropDown.hpp @@ -3,10 +3,10 @@ #include -#include "guisan/keylistener.hpp" -#include "guisan/platform.hpp" -#include "guisan/widget.hpp" -#include "guisan/widgets/dropdown.hpp" +#include +#include +#include +#include namespace gcn diff --git a/src/osdep/gui/UaeListBox.cpp b/src/osdep/gui/UaeListBox.cpp index aec49d71..6c4d40e1 100644 --- a/src/osdep/gui/UaeListBox.cpp +++ b/src/osdep/gui/UaeListBox.cpp @@ -1,9 +1,9 @@ #include "UaeListBox.hpp" -#include "guisan/widgets/listbox.hpp" -#include "guisan/basiccontainer.hpp" -#include "guisan/font.hpp" -#include "guisan/graphics.hpp" -#include "guisan/listmodel.hpp" +#include +#include +#include +#include +#include namespace gcn { diff --git a/src/osdep/gui/UaeListBox.hpp b/src/osdep/gui/UaeListBox.hpp index 79394947..2b97418b 100644 --- a/src/osdep/gui/UaeListBox.hpp +++ b/src/osdep/gui/UaeListBox.hpp @@ -3,10 +3,10 @@ #include -#include "guisan/listmodel.hpp" -#include "guisan/platform.hpp" -#include "guisan/widget.hpp" -#include "guisan/widgets/listbox.hpp" +#include +#include +#include +#include namespace gcn diff --git a/src/osdep/gui/UaeRadioButton.cpp b/src/osdep/gui/UaeRadioButton.cpp index 1d4fab8c..f60d7eff 100644 --- a/src/osdep/gui/UaeRadioButton.cpp +++ b/src/osdep/gui/UaeRadioButton.cpp @@ -1,6 +1,6 @@ #include "UaeRadioButton.hpp" -#include "guisan/widgets/radiobutton.hpp" -#include "guisan/graphics.hpp" +#include +#include namespace gcn { diff --git a/src/osdep/gui/UaeRadioButton.hpp b/src/osdep/gui/UaeRadioButton.hpp index f10a4ada..ddd2c0c7 100644 --- a/src/osdep/gui/UaeRadioButton.hpp +++ b/src/osdep/gui/UaeRadioButton.hpp @@ -4,9 +4,9 @@ #include #include -#include "guisan/platform.hpp" -#include "guisan/widget.hpp" -#include "guisan/widgets/radiobutton.hpp" +#include +#include +#include namespace gcn diff --git a/src/osdep/gui/main_window.cpp b/src/osdep/gui/main_window.cpp index d2b0d8be..02bf4a78 100644 --- a/src/osdep/gui/main_window.cpp +++ b/src/osdep/gui/main_window.cpp @@ -97,7 +97,7 @@ namespace widgets /* Flag for changes in rtarea: Bit 0: any HD in config? -Bit 1: force because add/remove HD was clicked +Bit 1: force because add/remove HD was clicked or new config loaded Bit 2: socket_emu on Bit 3: mousehack on Bit 4: rtgmem on diff --git a/src/osdep/keyboard_amiberry.cpp b/src/osdep/keyboard.cpp similarity index 99% rename from src/osdep/keyboard_amiberry.cpp rename to src/osdep/keyboard.cpp index 36b8acf0..2ed94390 100644 --- a/src/osdep/keyboard_amiberry.cpp +++ b/src/osdep/keyboard.cpp @@ -3,7 +3,7 @@ #include "config.h" #include "options.h" #include "uae.h" -#include "memory.h" +#include "include/memory.h" #include "newcpu.h" #include "custom.h" #include "xwin.h" @@ -409,4 +409,4 @@ int target_checkcapslock(int scancode, int *state) if (scancode == SDLK_SCROLLLOCK) *state = host_scrolllockstate; return 1; -} \ No newline at end of file +} diff --git a/src/osdep/menu/menu_config.cpp b/src/osdep/menu/menu_config.cpp deleted file mode 100644 index a64ba9ff..00000000 --- a/src/osdep/menu/menu_config.cpp +++ /dev/null @@ -1,336 +0,0 @@ -#define _MENU_CONFIG_CPP - -#include "sysconfig.h" -#include "sysdeps.h" -#include "config.h" -#include "autoconf.h" -#include "options.h" -#include "gui.h" -#include "sounddep/sound.h" -#include "memory.h" -#include "newcpu.h" -#include "custom.h" -#include "uae.h" -#include "disk.h" -#include - -static int kickstart; - -static void SetDefaultMenuSettings(struct uae_prefs* p) -{ - kickstart = 1; -} - -static void replace(char* str, char replace, char toreplace) -{ - while (*str) - { - if (*str == toreplace) *str = replace; - str++; - } -} - -int create_configfilename(char *dest, char *basename, int fromDir) -{ - char *p; - p = basename + strlen(basename) - 1; - while (*p != '/') - p--; - p++; - if (fromDir == 0) - { - int len = strlen(p) + 1; - char filename[MAX_DPATH]; - strcpy(filename, p); - char *pch = &filename[len]; - while (pch != filename && *pch != '.') - pch--; - if (pch) - { - *pch = '\0'; - snprintf(dest, MAX_DPATH, "%s/conf/%s.uae", start_path_data, filename); - return 1; - } - } - else - { - snprintf(dest, MAX_DPATH, "%s/conf/%s.uae", start_path_data, p); - return 1; - } - - return 0; -} - -const char *kickstarts_rom_names[] = { "kick12.rom\0", "kick13.rom\0", "kick20.rom\0", "kick31.rom\0", "aros-amiga-m68k-rom.bin\0" }; -const char *extended_rom_names[] = { "\0", "\0", "\0", "\0", "aros-amiga-m68k-ext.bin\0" }; -const char *kickstarts_names[] = { "KS ROM v1.2\0", "KS ROM v1.3\0", "KS ROM v2.05\0", "KS ROM v3.1\0", "\0" }; -#ifdef ANDROIDSDL -const char *af_kickstarts_rom_names[] = { "amiga-os-120.rom\0", "amiga-os-130.rom\0", "amiga-os-204.rom\0", "amiga-os-310-a1200.rom\0" }; -#endif - -static bool CheckKickstart(struct uae_prefs *p) -{ - char kickpath[MAX_DPATH]; - int i; - - // Search via filename - fetch_rompath(kickpath, MAX_DPATH); - strncat(kickpath, kickstarts_rom_names[kickstart], MAX_DPATH); - for (i = 0; iPath, kickpath)) - { - // Found it - strncpy(p->romfile, kickpath, sizeof(p->romfile)); - return true; - } - } - - // Search via name - if (strlen(kickstarts_names[kickstart]) > 0) - { - for (i = 0; iName, kickstarts_names[kickstart], strlen(kickstarts_names[kickstart]))) - { - // Found it - strncpy(p->romfile, lstAvailableROMs[i]->Path, sizeof(p->romfile)); - return true; - } - } - } - - return false; -} - - -// In this procedure, we use changed_prefs -int loadconfig_old(struct uae_prefs* p, const char* orgpath) -{ - char path[MAX_PATH]; - int cpu_level; - - strcpy(path, orgpath); - char* ptr = strstr(path, ".uae"); - if (ptr > nullptr) - { - *(ptr + 1) = '\0'; - strcat(path, "conf"); - } - - FILE* f = fopen(path, "rt"); - if (!f) - { - write_log("No config file %s!\n", path); - return 0; - } - // Set everthing to default and clear HD settings - default_prefs(p, 0); - SetDefaultMenuSettings(p); - - char filebuffer[MAX_PATH]; - int dummy; - - fscanf(f, "kickstart=%d\n", &kickstart); -#if defined(AMIBERRY) || defined(ANDROIDSDL) - fscanf(f, "scaling=%d\n", &dummy); -#else - fscanf(f, "scaling=%d\n", &mainMenu_enableHWscaling); -#endif - fscanf(f, "showstatus=%d\n", &p->leds_on_screen); - fscanf(f, "mousemultiplier=%d\n", &p->input_joymouse_multiplier); - p->input_joymouse_multiplier *= 10; -#if defined(AMIBERRY) || defined(ANDROIDSDL) - fscanf(f, "systemclock=%d\n", &dummy); // mainMenu_throttle never changes -> removed - fscanf(f, "syncthreshold=%d\n", &dummy); // timeslice_mode never changes -> removed -#else - fscanf(f, "systemclock=%d\n", &mainMenu_throttle); - fscanf(f, "syncthreshold=%d\n", ×lice_mode); -#endif - fscanf(f, "frameskip=%d\n", &p->gfx_framerate); - fscanf(f, "sound=%d\n", &p->produce_sound); - if (p->produce_sound >= 10) - { - p->sound_stereo = 1; - p->produce_sound -= 10; - if (p->produce_sound > 0) - p->produce_sound += 1; - } - else - p->sound_stereo = 0; - fscanf(f, "soundrate=%d\n", &p->sound_freq); - fscanf(f, "autosave=%d\n", &dummy); - int joybuffer = 0; - fscanf(f, "joyconf=%d\n", &joybuffer); - fscanf(f, "autofireRate=%d\n", &p->input_autofire_linecnt); - p->input_autofire_linecnt = p->input_autofire_linecnt * 312; - fscanf(f, "autofire=%d\n", &dummy); - fscanf(f, "stylusOffset=%d\n", &dummy); - fscanf(f, "scanlines=%d\n", &dummy); -#if defined(AMIBERRY) || defined(ANDROIDSDL) - fscanf(f, "ham=%d\n", &dummy); -#else - fscanf(f, "ham=%d\n", &mainMenu_ham); -#endif - fscanf(f, "enableScreenshots=%d\n", &dummy); - fscanf(f, "floppyspeed=%d\n", &p->floppy_speed); - fscanf(f, "drives=%d\n", &p->nr_floppies); - fscanf(f, "videomode=%d\n", &p->ntscmode); - if (p->ntscmode) - p->chipset_refreshrate = 60; - else - p->chipset_refreshrate = 50; - fscanf(f, "displayedLines=%d\n", &p->gfx_size.height); - fscanf(f, "screenWidth=%d\n", &p->gfx_size.width); - fscanf(f, "amiberry.custom_controls=%d\n", &p->customControls); - fscanf(f, "amiberry.custom_up=%d\n", &p->custom_up); - fscanf(f, "amiberry.custom_down=%d\n", &p->custom_down); - fscanf(f, "amiberry.custom_left=%d\n", &p->custom_left); - fscanf(f, "amiberry.custom_right=%d\n", &p->custom_right); - fscanf(f, "amiberry.custom_a=%d\n", &p->custom_a); - fscanf(f, "amiberry.custom_b=%d\n", &p->custom_b); - fscanf(f, "amiberry.custom_x=%d\n", &p->custom_x); - fscanf(f, "amiberry.custom_y=%d\n", &p->custom_y); - fscanf(f, "amiberry.custom_l=%d\n", &p->custom_l); - fscanf(f, "amiberry.custom_r=%d\n", &p->custom_r); - fscanf(f, "amiberry.custom_play=%d\n", &p->custom_play); - fscanf(f, "cpu=%d\n", &cpu_level); - if (cpu_level > 0) // M68000 - // Was old format - cpu_level = 2; // M68020 - fscanf(f, "chipset=%d\n", &p->chipset_mask); - p->immediate_blits = (p->chipset_mask & 0x100) == 0x100; - switch (p->chipset_mask & 0xff) - { - case 1: - p->chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE; - break; - case 2: - p->chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE | CSMASK_AGA; - break; - default: - p->chipset_mask = CSMASK_ECS_AGNUS; - break; - } - fscanf(f, "cpu=%d\n", &p->m68k_speed); - if (p->m68k_speed < 0) - { - // New version of this option - p->m68k_speed = -p->m68k_speed; - } - else - { - // Old version (500 5T 1200 12T 12T2) - if (p->m68k_speed >= 2) - { - // 1200: set to 68020 with 14 MHz - cpu_level = 2; // M68020 - p->m68k_speed--; - if (p->m68k_speed > 2) - p->m68k_speed = 2; - } - } - if (p->m68k_speed == 1) - p->m68k_speed = M68K_SPEED_14MHZ_CYCLES; - if (p->m68k_speed == 2) - p->m68k_speed = M68K_SPEED_25MHZ_CYCLES; - p->cachesize = 0; - p->cpu_compatible = false; - switch (cpu_level) - { - case 0: - p->cpu_model = 68000; - p->fpu_model = 0; - break; - case 1: - p->cpu_model = 68010; - p->fpu_model = 0; - break; - case 2: - p->cpu_model = 68020; - p->fpu_model = 0; - break; - case 3: - p->cpu_model = 68020; - p->fpu_model = 68881; - break; - case 4: - p->cpu_model = 68040; - p->fpu_model = 68881; - break; - } - - disk_eject(0); - disk_eject(1); - disk_eject(2); - disk_eject(3); - fscanf(f, "df0=%s\n", &filebuffer); - replace(filebuffer, ' ', '|'); - if (DISK_validate_filename(p, filebuffer, 0, nullptr, nullptr, nullptr)) - strcpy(p->floppyslots[0].df, filebuffer); - else - p->floppyslots[0].df[0] = 0; - disk_insert(0, filebuffer); - if (p->nr_floppies > 1) - { - memset(filebuffer, 0, 256); - fscanf(f, "df1=%s\n", &filebuffer); - replace(filebuffer, ' ', '|'); - if (DISK_validate_filename(p, filebuffer, 0, nullptr, nullptr, nullptr)) - strcpy(p->floppyslots[1].df, filebuffer); - else - p->floppyslots[1].df[0] = 0; - disk_insert(1, filebuffer); - } - if (p->nr_floppies > 2) - { - memset(filebuffer, 0, 256); - fscanf(f, "df2=%s\n", &filebuffer); - replace(filebuffer, ' ', '|'); - if (DISK_validate_filename(p, filebuffer, 0, nullptr, nullptr, nullptr)) - strcpy(p->floppyslots[2].df, filebuffer); - else - p->floppyslots[2].df[0] = 0; - disk_insert(2, filebuffer); - } - if (p->nr_floppies > 3) - { - memset(filebuffer, 0, sizeof filebuffer); - fscanf(f, "df3=%s\n", &filebuffer); - replace(filebuffer, ' ', '|'); - if (DISK_validate_filename(p, filebuffer, 0, nullptr, nullptr, nullptr)) - strcpy(p->floppyslots[3].df, filebuffer); - else - p->floppyslots[3].df[0] = 0; - disk_insert(3, filebuffer); - } - - for (int i = 0; i < 4; ++i) - { - if (i < p->nr_floppies) - p->floppyslots[i].dfxtype = DRV_35_DD; - else - p->floppyslots[i].dfxtype = DRV_NONE; - } - - fscanf(f, "chipmemory=%d\n", &p->chipmem_size); - if (p->chipmem_size < 10) - // Was saved in old format - p->chipmem_size = 0x80000 << p->chipmem_size; - fscanf(f, "slowmemory=%d\n", &p->bogomem_size); - if (p->bogomem_size > 0 && p->bogomem_size < 10) - // Was saved in old format - p->bogomem_size = - (p->bogomem_size <= 2) ? 0x080000 << p->bogomem_size : - (p->bogomem_size == 3) ? 0x180000 : 0x1c0000; - fscanf(f, "fastmemory=%d\n", &p->fastmem_size); - if (p->fastmem_size > 0 && p->fastmem_size < 10) - // Was saved in old format - p->fastmem_size = 0x080000 << p->fastmem_size; - - fclose(f); - - CheckKickstart(p); - - return 1; -} diff --git a/src/osdep/picasso96.cpp b/src/osdep/picasso96.cpp index 7438b76b..a38935cf 100644 --- a/src/osdep/picasso96.cpp +++ b/src/osdep/picasso96.cpp @@ -67,6 +67,12 @@ #define NOBLITTER_BLIT 0 #define NOBLITTER_ALL 0 +#ifdef RASPBERRY +static const int defaultHz = 50; +#else +static const int defaultHz = 60; +#endif + static int picasso96_BT = BT_uaegfx; static int picasso96_GCT = GCT_Unknown; static int picasso96_PCT = PCT_Unknown; @@ -178,113 +184,110 @@ STATIC_INLINE void endianswap(uae_u32 *vp, int bpp) /* * Debugging dumps */ -static void DumpModeInfoStructure(uaecptr amigamodeinfoptr) +static void DumpModeInfoStructure(TrapContext *ctx, uaecptr amigamodeinfoptr) { write_log (_T("ModeInfo Structure Dump:\n")); - write_log (_T(" Node.ln_Succ = 0x%x\n"), get_long (amigamodeinfoptr)); - write_log (_T(" Node.ln_Pred = 0x%x\n"), get_long (amigamodeinfoptr + 4)); - write_log (_T(" Node.ln_Type = 0x%x\n"), get_byte (amigamodeinfoptr + 8)); - write_log (_T(" Node.ln_Pri = %d\n"), get_byte (amigamodeinfoptr + 9)); -/*write_log (_T(" Node.ln_Name = %s\n"), uaememptr->Node.ln_Name); */ - write_log (_T(" OpenCount = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_OpenCount)); - write_log (_T(" Active = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_Active)); - write_log (_T(" Width = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_Width)); - write_log (_T(" Height = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_Height)); - write_log (_T(" Depth = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_Depth)); - write_log (_T(" Flags = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_Flags)); - write_log (_T(" HorTotal = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_HorTotal)); - write_log (_T(" HorBlankSize = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_HorBlankSize)); - write_log (_T(" HorSyncStart = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncStart)); - write_log (_T(" HorSyncSize = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSize)); - write_log (_T(" HorSyncSkew = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSkew)); - write_log (_T(" HorEnableSkew = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorEnableSkew)); - write_log (_T(" VerTotal = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_VerTotal)); - write_log (_T(" VerBlankSize = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_VerBlankSize)); - write_log (_T(" VerSyncStart = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncStart)); - write_log (_T(" VerSyncSize = %d\n"), get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncSize)); - write_log (_T(" Clock = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_first_union)); - write_log (_T(" ClockDivide = %d\n"), get_byte (amigamodeinfoptr + PSSO_ModeInfo_second_union)); - write_log (_T(" PixelClock = %d\n"), get_long (amigamodeinfoptr + PSSO_ModeInfo_PixelClock)); + write_log (_T(" Node.ln_Succ = 0x%x\n"), trap_get_long(ctx, amigamodeinfoptr)); + write_log (_T(" Node.ln_Pred = 0x%x\n"), trap_get_long(ctx, amigamodeinfoptr + 4)); + write_log (_T(" Node.ln_Type = 0x%x\n"), trap_get_byte(ctx, amigamodeinfoptr + 8)); + write_log (_T(" Node.ln_Pri = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + 9)); + /*write_log (_T(" Node.ln_Name = %s\n"), uaememptr->Node.ln_Name); */ + write_log (_T(" OpenCount = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_OpenCount)); + write_log (_T(" Active = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_Active)); + write_log (_T(" Width = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_Width)); + write_log (_T(" Height = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_Height)); + write_log (_T(" Depth = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_Depth)); + write_log (_T(" Flags = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_Flags)); + write_log (_T(" HorTotal = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_HorTotal)); + write_log (_T(" HorBlankSize = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_HorBlankSize)); + write_log (_T(" HorSyncStart = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_HorSyncStart)); + write_log (_T(" HorSyncSize = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_HorSyncSize)); + write_log (_T(" HorSyncSkew = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_HorSyncSkew)); + write_log (_T(" HorEnableSkew = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_HorEnableSkew)); + write_log (_T(" VerTotal = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_VerTotal)); + write_log (_T(" VerBlankSize = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_VerBlankSize)); + write_log (_T(" VerSyncStart = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_VerSyncStart)); + write_log (_T(" VerSyncSize = %d\n"), trap_get_word(ctx, amigamodeinfoptr + PSSO_ModeInfo_VerSyncSize)); + write_log (_T(" Clock = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_first_union)); + write_log (_T(" ClockDivide = %d\n"), trap_get_byte(ctx, amigamodeinfoptr + PSSO_ModeInfo_second_union)); + write_log (_T(" PixelClock = %d\n"), trap_get_long(ctx, amigamodeinfoptr + PSSO_ModeInfo_PixelClock)); } -static void DumpLibResolutionStructure(uaecptr amigalibresptr) +static void DumpLibResolutionStructure(TrapContext *ctx, uaecptr amigalibresptr) { - int i; - uaecptr amigamodeinfoptr; - struct LibResolution* uaememptr = (struct LibResolution *)get_mem_bank(amigalibresptr).xlateaddr(amigalibresptr); + int i; + uaecptr amigamodeinfoptr; + struct LibResolution *uaememptr = (struct LibResolution *)get_mem_bank(amigalibresptr).xlateaddr(amigalibresptr); write_log (_T("LibResolution Structure Dump:\n")); - if (get_long(amigalibresptr + PSSO_LibResolution_DisplayID) == 0xFFFFFFFF) - { + if (trap_get_long(ctx, amigalibresptr + PSSO_LibResolution_DisplayID) == 0xFFFFFFFF) { write_log (_T(" Finished With LibResolutions...\n")); - } - else - { + } else { write_log (_T(" Name = %s\n"), uaememptr->P96ID); - write_log (_T(" DisplayID = 0x%x\n"), get_long (amigalibresptr + PSSO_LibResolution_DisplayID)); - write_log (_T(" Width = %d\n"), get_word (amigalibresptr + PSSO_LibResolution_Width)); - write_log (_T(" Height = %d\n"), get_word (amigalibresptr + PSSO_LibResolution_Height)); - write_log (_T(" Flags = %d\n"), get_word (amigalibresptr + PSSO_LibResolution_Flags)); - for (i = 0; i < MAXMODES; i++) - { - amigamodeinfoptr = get_long(amigalibresptr + PSSO_LibResolution_Modes + i * 4); + write_log (_T(" DisplayID = 0x%x\n"), trap_get_long(ctx, amigalibresptr + PSSO_LibResolution_DisplayID)); + write_log (_T(" Width = %d\n"), trap_get_word(ctx, amigalibresptr + PSSO_LibResolution_Width)); + write_log (_T(" Height = %d\n"), trap_get_word(ctx, amigalibresptr + PSSO_LibResolution_Height)); + write_log (_T(" Flags = %d\n"), trap_get_word(ctx, amigalibresptr + PSSO_LibResolution_Flags)); + for (i = 0; i < MAXMODES; i++) { + amigamodeinfoptr = trap_get_long(ctx, amigalibresptr + PSSO_LibResolution_Modes + i*4); write_log (_T(" ModeInfo[%d] = 0x%x\n"), i, amigamodeinfoptr); - if (amigamodeinfoptr) - DumpModeInfoStructure(amigamodeinfoptr); - } - write_log (_T(" BoardInfo = 0x%x\n"), get_long (amigalibresptr + PSSO_LibResolution_BoardInfo)); - } + if (amigamodeinfoptr) + DumpModeInfoStructure(ctx, amigamodeinfoptr); + } + write_log (_T(" BoardInfo = 0x%x\n"), trap_get_long(ctx, amigalibresptr + PSSO_LibResolution_BoardInfo)); + } } -static TCHAR binary_byte[9] = {0,0,0,0,0,0,0,0,0}; +static TCHAR binary_byte[9] = { 0,0,0,0,0,0,0,0,0 }; -static TCHAR* BuildBinaryString(uae_u8 value) +static TCHAR *BuildBinaryString (uae_u8 value) { - int i; - for (i = 0; i < 8; i++) - { - binary_byte[i] = (value & (1 << (7 - i))) ? '#' : '.'; - } - return binary_byte; + int i; + for (i = 0; i < 8; i++) { + binary_byte[i] = (value & (1 << (7 - i))) ? '#' : '.'; + } + return binary_byte; } -static void DumpPattern(struct Pattern* patt) +static void DumpPattern (struct Pattern *patt) { - uae_u8* mem; - int row, col; - for (row = 0; row < (1 << patt->Size); row++) - { - mem = patt->Memory + row * 2; - for (col = 0; col < 2; col++) - { + uae_u8 *mem; + int row, col; + + if (!patt->Memory) + return; + + for (row = 0; row < (1 << patt->Size); row++) { + mem = patt->Memory + row * 2; + for (col = 0; col < 2; col++) { write_log (_T("%s "), BuildBinaryString (*mem++)); - } + } write_log (_T("\n")); - } + } } -static void DumpTemplate(struct Template* tmp, unsigned long w, unsigned long h) +static void DumpTemplate (struct Template *tmp, unsigned long w, unsigned long h) { - uae_u8* mem = tmp->Memory; - unsigned int row, col, width; - width = (w + 7) >> 3; + uae_u8 *mem = tmp->Memory; + unsigned int row, col, width; + + if (!mem) + return; + width = (w + 7) >> 3; write_log (_T("xoffset = %d, bpr = %d\n"), tmp->XOffset, tmp->BytesPerRow); - for (row = 0; row < h; row++) - { + for (row = 0; row < h; row++) { mem = tmp->Memory + row * tmp->BytesPerRow; - for (col = 0; col < width; col++) - { + for (col = 0; col < width; col++) { write_log (_T("%s "), BuildBinaryString (*mem++)); - } + } write_log (_T("\n")); - } + } } -static void DumpLine(struct Line* line) +static void DumpLine(struct Line *line) { - if (line) - { + if (line) { write_log (_T("Line->X = %d\n"), line->X); write_log (_T("Line->Y = %d\n"), line->Y); write_log (_T("Line->Length = %d\n"), line->Length); @@ -301,51 +304,50 @@ static void DumpLine(struct Line* line) write_log (_T("Line->DrawMode = %d\n"), line->DrawMode); write_log (_T("Line->Xorigin = %d\n"), line->Xorigin); write_log (_T("Line->Yorigin = %d\n"), line->Yorigin); - } + } } -static void ShowSupportedResolutions(void) +static void ShowSupportedResolutions (void) { - int i = 0; + int i = 0; write_log (_T("-----------------\n")); - while (newmodes[i].depth >= 0) - { + while (newmodes[i].depth >= 0) { write_log (_T("%s\n"), newmodes[i].name); - i++; - } + i++; + } write_log (_T("-----------------\n")); } #endif -extern uae_u8* natmem_offset; +extern uae_u8 *natmem_offset; -static uae_u8 GetBytesPerPixel(uae_u32 RGBfmt) +static uae_u8 GetBytesPerPixel (uae_u32 RGBfmt) { - switch (RGBfmt) - { - case RGBFB_CLUT: - return 1; + switch (RGBfmt) + { + case RGBFB_CLUT: + return 1; - case RGBFB_A8R8G8B8: - case RGBFB_A8B8G8R8: - case RGBFB_R8G8B8A8: - case RGBFB_B8G8R8A8: - return 4; + case RGBFB_A8R8G8B8: + case RGBFB_A8B8G8R8: + case RGBFB_R8G8B8A8: + case RGBFB_B8G8R8A8: + return 4; - case RGBFB_B8G8R8: - case RGBFB_R8G8B8: - return 3; + case RGBFB_B8G8R8: + case RGBFB_R8G8B8: + return 3; - case RGBFB_R5G5B5: - case RGBFB_R5G6B5: - case RGBFB_R5G6B5PC: - case RGBFB_R5G5B5PC: - case RGBFB_B5G6R5PC: - case RGBFB_B5G5R5PC: - return 2; - } + case RGBFB_R5G5B5: + case RGBFB_R5G6B5: + case RGBFB_R5G6B5PC: + case RGBFB_R5G5B5PC: + case RGBFB_B5G6R5PC: + case RGBFB_B5G5R5PC: + return 2; + } return 0; } @@ -358,7 +360,7 @@ STATIC_INLINE bool validatecoords2(TrapContext *ctx, struct RenderInfo *ri, uae_ if (!Width || !Height) return true; if (ri) { - int bpp = GetBytesPerPixel(ri->RGBFormat); + int bpp = GetBytesPerPixel (ri->RGBFormat); if (X * bpp >= ri->BytesPerRow) return false; uae_u32 X2 = X + Width; @@ -376,7 +378,7 @@ static bool validatecoords(TrapContext *ctx, struct RenderInfo *ri, uae_u32 *X, { if (validatecoords2(ctx, ri, X, Y, Width, Height)) return true; - write_log(_T("RTG invalid region: %08X:%d:%d (%dx%d)-(%dx%d)\n"), ri->AMemory, ri->BytesPerRow, ri->RGBFormat, *X, *Y, *Width, *Height); + write_log (_T("RTG invalid region: %08X:%d:%d (%dx%d)-(%dx%d)\n"), ri->AMemory, ri->BytesPerRow, ri->RGBFormat, *X, *Y, *Width, *Height); return false; } @@ -389,22 +391,22 @@ static int CopyRenderInfoStructureA2U(TrapContext *ctx, uaecptr amigamemptr, str if (trap_valid_address(ctx, amigamemptr, PSSO_RenderInfo_sizeof)) { struct trapmd md[] = { - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_RenderInfo_Memory } }, - { TRAPCMD_GET_WORD,{ amigamemptr + PSSO_RenderInfo_BytesPerRow } }, - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_RenderInfo_RGBFormat } } + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_RenderInfo_Memory } }, + { TRAPCMD_GET_WORD, { amigamemptr + PSSO_RenderInfo_BytesPerRow } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_RenderInfo_RGBFormat } } }; trap_multi(ctx, md, sizeof md / sizeof(struct trapmd)); uaecptr memp = md[0].params[0]; ri->AMemory = memp; - ri->Memory = get_real_address(memp); + ri->Memory = get_real_address (memp); ri->BytesPerRow = md[1].params[0]; ri->RGBFormat = (RGBFTYPE)md[2].params[0]; // Can't really validate this better at this point, no height. if (trap_valid_address(ctx, memp, ri->BytesPerRow)) - return 1; - } - write_log(_T("ERROR - Invalid RenderInfo memory area...\n")); - return 0; + return 1; + } + write_log (_T("ERROR - Invalid RenderInfo memory area...\n")); + return 0; } static int CopyPatternStructureA2U(TrapContext *ctx, uaecptr amigamemptr, struct Pattern *pattern) @@ -412,17 +414,17 @@ static int CopyPatternStructureA2U(TrapContext *ctx, uaecptr amigamemptr, struct if (trap_valid_address(ctx, amigamemptr, PSSO_Pattern_sizeof)) { struct trapmd md[] = { - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_Pattern_Memory } }, - { TRAPCMD_GET_WORD,{ amigamemptr + PSSO_Pattern_XOffset } }, - { TRAPCMD_GET_WORD,{ amigamemptr + PSSO_Pattern_YOffset } }, - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_Pattern_FgPen } }, - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_Pattern_BgPen } }, - { TRAPCMD_GET_BYTE,{ amigamemptr + PSSO_Pattern_Size } }, - { TRAPCMD_GET_BYTE,{ amigamemptr + PSSO_Pattern_DrawMode } } + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_Pattern_Memory } }, + { TRAPCMD_GET_WORD, { amigamemptr + PSSO_Pattern_XOffset } }, + { TRAPCMD_GET_WORD, { amigamemptr + PSSO_Pattern_YOffset } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_Pattern_FgPen } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_Pattern_BgPen } }, + { TRAPCMD_GET_BYTE, { amigamemptr + PSSO_Pattern_Size } }, + { TRAPCMD_GET_BYTE, { amigamemptr + PSSO_Pattern_DrawMode } } }; trap_multi(ctx, md, sizeof md / sizeof(struct trapmd)); uaecptr memp = md[0].params[0]; - pattern->Memory = get_real_address(memp); + pattern->Memory = get_real_address (memp); pattern->AMemory = memp; pattern->XOffset = md[1].params[0]; pattern->YOffset = md[2].params[0]; @@ -431,59 +433,59 @@ static int CopyPatternStructureA2U(TrapContext *ctx, uaecptr amigamemptr, struct pattern->Size = md[5].params[0]; pattern->DrawMode = md[6].params[0]; if (trap_valid_address(ctx, memp, 2)) - return 1; - } - write_log(_T("ERROR - Invalid Pattern memory area...\n")); - return 0; + return 1; + } + write_log (_T("ERROR - Invalid Pattern memory area...\n")); + return 0; } static int CopyBitMapStructureA2U(TrapContext *ctx, uaecptr amigamemptr, struct BitMap *bm) { - int i; + int i; struct trapmd md[] = { - { TRAPCMD_GET_WORD,{ amigamemptr + PSSO_BitMap_BytesPerRow } }, - { TRAPCMD_GET_WORD,{ amigamemptr + PSSO_BitMap_Rows } }, - { TRAPCMD_GET_BYTE,{ amigamemptr + PSSO_BitMap_Flags } }, - { TRAPCMD_GET_BYTE,{ amigamemptr + PSSO_BitMap_Depth } }, - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_BitMap_Planes + 0 } }, - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_BitMap_Planes + 4 } }, - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_BitMap_Planes + 8 } }, - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_BitMap_Planes + 12 } }, - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_BitMap_Planes + 16 } }, - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_BitMap_Planes + 20 } }, - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_BitMap_Planes + 24 } }, - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_BitMap_Planes + 28 } } + { TRAPCMD_GET_WORD, { amigamemptr + PSSO_BitMap_BytesPerRow } }, + { TRAPCMD_GET_WORD, { amigamemptr + PSSO_BitMap_Rows } }, + { TRAPCMD_GET_BYTE, { amigamemptr + PSSO_BitMap_Flags } }, + { TRAPCMD_GET_BYTE, { amigamemptr + PSSO_BitMap_Depth } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 0 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 4 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 8 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 12 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 16 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 20 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 24 } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_BitMap_Planes + 28} } }; trap_multi(ctx, md, sizeof md / sizeof(struct trapmd)); bm->BytesPerRow = md[0].params[0]; bm->Rows = md[1].params[0]; bm->Flags = md[2].params[0]; bm->Depth = md[3].params[0]; + + /* ARGH - why is THIS happening? */ + if( bm->Depth > 8 ) + bm->Depth = 8; - /* ARGH - why is THIS happening? */ - if (bm->Depth > 8) - bm->Depth = 8; - - for (i = 0; i < bm->Depth; i++) { + for (i = 0; i < bm->Depth; i++) { uaecptr plane = md[4 + i].params[0]; - switch (plane) { - case 0: - bm->Planes[i] = &all_zeros_bitmap; - break; - case 0xFFFFFFFF: - bm->Planes[i] = &all_ones_bitmap; - break; - default: - if (trap_valid_address(ctx, plane, bm->BytesPerRow * bm->Rows)) - bm->Planes[i] = get_real_address(plane); - else + switch (plane) { + case 0: + bm->Planes[i] = &all_zeros_bitmap; + break; + case 0xFFFFFFFF: + bm->Planes[i] = &all_ones_bitmap; + break; + default: + if (trap_valid_address(ctx, plane, bm->BytesPerRow * bm->Rows)) + bm->Planes[i] = get_real_address (plane); + else bm->Planes[i] = &all_zeros_bitmap; - break; - } - } - return 1; + break; + } + } + return 1; } static int CopyTemplateStructureA2U(TrapContext *ctx, uaecptr amigamemptr, struct Template *tmpl) @@ -491,27 +493,27 @@ static int CopyTemplateStructureA2U(TrapContext *ctx, uaecptr amigamemptr, struc if (trap_valid_address(ctx, amigamemptr, PSSO_Template_sizeof)) { struct trapmd md[] = { - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_Template_Memory } }, - { TRAPCMD_GET_WORD,{ amigamemptr + PSSO_Template_BytesPerRow } }, - { TRAPCMD_GET_BYTE,{ amigamemptr + PSSO_Template_XOffset } }, - { TRAPCMD_GET_BYTE,{ amigamemptr + PSSO_Template_DrawMode } }, - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_Template_FgPen } }, - { TRAPCMD_GET_LONG,{ amigamemptr + PSSO_Template_BgPen } } + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_Template_Memory } }, + { TRAPCMD_GET_WORD, { amigamemptr + PSSO_Template_BytesPerRow } }, + { TRAPCMD_GET_BYTE, { amigamemptr + PSSO_Template_XOffset } }, + { TRAPCMD_GET_BYTE, { amigamemptr + PSSO_Template_DrawMode } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_Template_FgPen } }, + { TRAPCMD_GET_LONG, { amigamemptr + PSSO_Template_BgPen } } }; trap_multi(ctx, md, sizeof md / sizeof(struct trapmd)); uaecptr memp = md[0].params[0]; - tmpl->Memory = get_real_address(memp); + tmpl->Memory = get_real_address (memp); tmpl->AMemory = memp; tmpl->BytesPerRow = md[1].params[0]; tmpl->XOffset = md[2].params[0]; tmpl->DrawMode = md[3].params[0]; tmpl->FgPen = md[4].params[0]; tmpl->BgPen = md[5].params[0]; - return 1; - } - write_log(_T("ERROR - Invalid Template memory area...\n")); - return 0; + return 1; + } + write_log (_T("ERROR - Invalid Template memory area...\n")); + return 0; } /* list is Amiga address of list, in correct endian format for UAE @@ -527,85 +529,85 @@ static void AmigaListAddTail(TrapContext *ctx, uaecptr l, uaecptr n) /* * Fill a rectangle in the screen. */ -static void do_fillrect_frame_buffer(struct RenderInfo *ri, int X, int Y, int Width, int Height, uae_u32 Pen, int Bpp) +static void do_fillrect_frame_buffer (struct RenderInfo *ri, int X, int Y, int Width, int Height, uae_u32 Pen, int Bpp) { - int cols; - uae_u8 *dst; - int lines; - int bpr = ri->BytesPerRow; + int cols; + uae_u8 *dst; + int lines; + int bpr = ri->BytesPerRow; - dst = ri->Memory + X * Bpp + Y * ri->BytesPerRow; - endianswap(&Pen, Bpp); - switch (Bpp) - { + dst = ri->Memory + X * Bpp + Y * ri->BytesPerRow; + endianswap (&Pen, Bpp); + switch (Bpp) + { case 1: - for (lines = 0; lines < Height; lines++, dst += bpr) { - memset(dst, Pen, Width); - } - break; + for (lines = 0; lines < Height; lines++, dst += bpr) { + memset (dst, Pen, Width); + } + break; case 2: - Pen |= Pen << 16; - for (lines = 0; lines < Height; lines++, dst += bpr) { - uae_u16 *dst16 = (uae_u16 *)dst; - int tmpwidth = Width; - if ((uintptr_t)dst16 & 3) { - *dst16++ = (uae_u16)Pen; - tmpwidth--; - } - uae_u32 *p = (uae_u32*)dst16; - for (cols = 0; cols < tmpwidth >> 1; cols++) - *p++ = Pen; - if (tmpwidth & 1) - ((uae_u16*)p)[0] = (uae_u16)Pen; - } - break; + Pen |= Pen << 16; + for (lines = 0; lines < Height; lines++, dst += bpr) { + uae_u16 *dst16 = (uae_u16 *)dst; + int tmpwidth = Width; + if((uintptr_t)dst16 & 3) { + *dst16++ = (uae_u16)Pen; + tmpwidth--; + } + uae_u32 *p = (uae_u32*)dst16; + for (cols = 0; cols < tmpwidth >> 1; cols++) + *p++ = Pen; + if (tmpwidth & 1) + ((uae_u16*)p)[0] = (uae_u16)Pen; + } + break; case 3: - for (lines = 0; lines < Height; lines++, dst += bpr) { - uae_u8 *p = (uae_u8*)dst; - for (cols = 0; cols < Width; cols++) { - *p++ = Pen >> 0; - *p++ = Pen >> 8; - *p++ = Pen >> 16; - } - } - break; + for (lines = 0; lines < Height; lines++, dst += bpr) { + uae_u8 *p = (uae_u8*)dst; + for (cols = 0; cols < Width; cols++) { + *p++ = Pen >> 0; + *p++ = Pen >> 8; + *p++ = Pen >> 16; + } + } + break; case 4: - for (lines = 0; lines < Height; lines++, dst += bpr) { - uae_u32 *p = (uae_u32*)dst; - for (cols = 0; cols < Width; cols++) - *p++ = Pen; - } - break; - } + for (lines = 0; lines < Height; lines++, dst += bpr) { + uae_u32 *p = (uae_u32*)dst; + for (cols = 0; cols < Width; cols++) + *p++ = Pen; + } + break; + } } static int p96_framecnt; -static int doskip(void) +static int doskip (void) { - if (p96_framecnt > currprefs.gfx_framerate) - p96_framecnt = 0; - return p96_framecnt > 0; + if (p96_framecnt > currprefs.gfx_framerate) + p96_framecnt = 0; + return p96_framecnt > 0; } -void picasso_trigger_vblank(void) +void picasso_trigger_vblank (void) { TrapContext *ctx = NULL; - if (!ABI_interrupt || !uaegfx_base || !interrupt_enabled) - return; + if (!ABI_interrupt || !uaegfx_base || !interrupt_enabled) + return; trap_put_long(ctx, uaegfx_base + CARD_IRQPTR, ABI_interrupt + PSSO_BoardInfo_SoftInterrupt); trap_put_byte(ctx, uaegfx_base + CARD_IRQFLAG, 1); } -static bool rtg_render(void) +static bool rtg_render (void) { bool flushed = false; - if (!doskip()) - flushed = picasso_flushpixels(gfxmem_banks[0]->start + natmem_offset, picasso96_state.XYOffset - gfxmem_banks[0]->start); + if (!doskip ()) + flushed = picasso_flushpixels (gfxmem_banks[0]->start + natmem_offset, picasso96_state.XYOffset - gfxmem_banks[0]->start); return flushed; } -static void rtg_clear(void) +static void rtg_clear (void) { } @@ -614,181 +616,180 @@ static int set_panning_called = 0; enum { - /* DEST = RGBFB_B8G8R8A8,32 */ - RGBFB_A8R8G8B8_32 = 1, - RGBFB_A8B8G8R8_32, - RGBFB_R8G8B8A8_32, - RGBFB_B8G8R8A8_32, - RGBFB_R8G8B8_32, - RGBFB_B8G8R8_32, - RGBFB_R5G6B5PC_32, - RGBFB_R5G5B5PC_32, - RGBFB_R5G6B5_32, - RGBFB_R5G5B5_32, - RGBFB_B5G6R5PC_32, - RGBFB_B5G5R5PC_32, - RGBFB_CLUT_RGBFB_32, + /* DEST = RGBFB_B8G8R8A8,32 */ + RGBFB_A8R8G8B8_32 = 1, + RGBFB_A8B8G8R8_32, + RGBFB_R8G8B8A8_32, + RGBFB_B8G8R8A8_32, + RGBFB_R8G8B8_32, + RGBFB_B8G8R8_32, + RGBFB_R5G6B5PC_32, + RGBFB_R5G5B5PC_32, + RGBFB_R5G6B5_32, + RGBFB_R5G5B5_32, + RGBFB_B5G6R5PC_32, + RGBFB_B5G5R5PC_32, + RGBFB_CLUT_RGBFB_32, - /* DEST = RGBFB_R5G6B5PC,16 */ - RGBFB_A8R8G8B8_16, - RGBFB_A8B8G8R8_16, - RGBFB_R8G8B8A8_16, - RGBFB_B8G8R8A8_16, - RGBFB_R8G8B8_16, - RGBFB_B8G8R8_16, - RGBFB_R5G6B5PC_16, - RGBFB_R5G5B5PC_16, - RGBFB_R5G6B5_16, - RGBFB_R5G5B5_16, - RGBFB_B5G6R5PC_16, - RGBFB_B5G5R5PC_16, - RGBFB_CLUT_RGBFB_16, + /* DEST = RGBFB_R5G6B5PC,16 */ + RGBFB_A8R8G8B8_16, + RGBFB_A8B8G8R8_16, + RGBFB_R8G8B8A8_16, + RGBFB_B8G8R8A8_16, + RGBFB_R8G8B8_16, + RGBFB_B8G8R8_16, + RGBFB_R5G6B5PC_16, + RGBFB_R5G5B5PC_16, + RGBFB_R5G6B5_16, + RGBFB_R5G5B5_16, + RGBFB_B5G6R5PC_16, + RGBFB_B5G5R5PC_16, + RGBFB_CLUT_RGBFB_16, - /* DEST = RGBFB_CLUT,8 */ - RGBFB_CLUT_8 + /* DEST = RGBFB_CLUT,8 */ + RGBFB_CLUT_8 }; -static int getconvert(int rgbformat, int pixbytes) +static int getconvert (int rgbformat, int pixbytes) { int v = 0; int d = pixbytes; switch (rgbformat) - { + { case RGBFB_CLUT: - if (d == 1) - v = RGBFB_CLUT_8; - else if (d == 2) - v = RGBFB_CLUT_RGBFB_16; - else if (d == 4) - v = RGBFB_CLUT_RGBFB_32; - break; + if (d == 1) + v = RGBFB_CLUT_8; + else if (d == 2) + v = RGBFB_CLUT_RGBFB_16; + else if (d == 4) + v = RGBFB_CLUT_RGBFB_32; + break; case RGBFB_B5G6R5PC: - if (d == 2) - v = RGBFB_B5G6R5PC_16; - else if (d == 4) - v = RGBFB_B5G6R5PC_32; - break; + if (d == 2) + v = RGBFB_B5G6R5PC_16; + else if (d == 4) + v = RGBFB_B5G6R5PC_32; + break; case RGBFB_R5G6B5PC: - if (d == 2) - v = RGBFB_R5G6B5PC_16; - else if (d == 4) - v = RGBFB_R5G6B5PC_32; - break; + if (d == 2) + v = RGBFB_R5G6B5PC_16; + else if (d == 4) + v = RGBFB_R5G6B5PC_32; + break; case RGBFB_R5G5B5PC: - if (d == 4) - v = RGBFB_R5G5B5PC_32; - else if (d == 2) - v = RGBFB_R5G5B5PC_16; - break; + if (d == 4) + v = RGBFB_R5G5B5PC_32; + else if (d == 2) + v = RGBFB_R5G5B5PC_16; + break; case RGBFB_R5G6B5: - if (d == 4) - v = RGBFB_R5G6B5_32; - else - v = RGBFB_R5G6B5_16; - break; + if (d == 4) + v = RGBFB_R5G6B5_32; + else + v = RGBFB_R5G6B5_16; + break; case RGBFB_R5G5B5: - if (d == 4) - v = RGBFB_R5G5B5_32; - else - v = RGBFB_R5G5B5_16; - break; + if (d == 4) + v = RGBFB_R5G5B5_32; + else + v = RGBFB_R5G5B5_16; + break; case RGBFB_B5G5R5PC: - if (d == 4) - v = RGBFB_B5G5R5PC_32; - else - v = RGBFB_B5G5R5PC_16; - break; + if (d == 4) + v = RGBFB_B5G5R5PC_32; + else + v = RGBFB_B5G5R5PC_16; + break; case RGBFB_A8R8G8B8: - if (d == 2) - v = RGBFB_A8R8G8B8_16; - else if (d == 4) - v = RGBFB_A8R8G8B8_32; - break; + if (d == 2) + v = RGBFB_A8R8G8B8_16; + else if (d == 4) + v = RGBFB_A8R8G8B8_32; + break; case RGBFB_R8G8B8: - if (d == 2) - v = RGBFB_R8G8B8_16; - else if (d == 4) - v = RGBFB_R8G8B8_32; - break; + if (d == 2) + v = RGBFB_R8G8B8_16; + else if (d == 4) + v = RGBFB_R8G8B8_32; + break; case RGBFB_B8G8R8: - if (d == 2) - v = RGBFB_B8G8R8_16; - else if (d == 4) - v = RGBFB_B8G8R8_32; - break; + if (d == 2) + v = RGBFB_B8G8R8_16; + else if (d == 4) + v = RGBFB_B8G8R8_32; + break; case RGBFB_A8B8G8R8: - if (d == 2) - v = RGBFB_A8B8G8R8_16; - else if (d == 4) - v = RGBFB_A8B8G8R8_32; - break; + if (d == 2) + v = RGBFB_A8B8G8R8_16; + else if (d == 4) + v = RGBFB_A8B8G8R8_32; + break; case RGBFB_B8G8R8A8: - if (d == 2) - v = RGBFB_B8G8R8A8_16; - else if (d == 4) - v = RGBFB_B8G8R8A8_32; - break; + if (d == 2) + v = RGBFB_B8G8R8A8_16; + else if (d == 4) + v = RGBFB_B8G8R8A8_32; + break; case RGBFB_R8G8B8A8: - if (d == 2) - v = RGBFB_R8G8B8A8_16; - else if (d == 4) - v = RGBFB_R8G8B8A8_32; - break; - } - return v; + if (d == 2) + v = RGBFB_R8G8B8A8_16; + else if (d == 4) + v = RGBFB_R8G8B8A8_32; + break; + } + return v; } static void setconvert(void) { static int ohost_mode, orgbformat; - picasso_convert = getconvert(picasso96_state.RGBFormat, picasso_vidinfo.pixbytes); - host_mode = GetSurfacePixelFormat(); - picasso_palette(picasso96_state.CLUT); + picasso_convert = getconvert (picasso96_state.RGBFormat, picasso_vidinfo.pixbytes); + host_mode = GetSurfacePixelFormat(); + picasso_palette (picasso96_state.CLUT); if (host_mode != ohost_mode || picasso96_state.RGBFormat != orgbformat) { - write_log(_T("RTG conversion: Depth=%d HostRGBF=%d P96RGBF=%d Mode=%d\n"), - picasso_vidinfo.pixbytes, host_mode, picasso96_state.RGBFormat, picasso_convert); + write_log (_T("RTG conversion: Depth=%d HostRGBF=%d P96RGBF=%d Mode=%d\n"), + picasso_vidinfo.pixbytes, host_mode, picasso96_state.RGBFormat, picasso_convert); ohost_mode = host_mode; orgbformat = picasso96_state.RGBFormat; } } -bool picasso_is_active(void) +bool picasso_is_active (void) { return picasso_active; } /* Clear our screen, since we've got a new Picasso screen-mode, and refresh with the proper contents -* This is called on several occasions: -* 1. Amiga-->Picasso transition, via SetSwitch() -* 2. Picasso-->Picasso transition, via SetPanning(). -* 3. whenever the graphics code notifies us that the screen contents have been lost. -*/ -void picasso_refresh(void) + * This is called on several occasions: + * 1. Amiga-->Picasso transition, via SetSwitch() + * 2. Picasso-->Picasso transition, via SetPanning(). + * 3. whenever the graphics code notifies us that the screen contents have been lost. + */ +void picasso_refresh (void) { - struct RenderInfo ri; + struct RenderInfo ri; - if (!picasso_on) - return; - setconvert(); + if (!picasso_on) + return; + setconvert (); rtg_clear(); - /* Make sure that the first time we show a Picasso video mode, we don't blit any crap. - * We can do this by checking if we have an Address yet. - */ - if (picasso96_state.Address) { - /* blit the stuff from our static frame-buffer to the gfx-card */ - ri.Memory = gfxmem_bank.baseaddr + (picasso96_state.Address - gfxmem_bank.start); - ri.BytesPerRow = picasso96_state.BytesPerRow; - ri.RGBFormat = (RGBFTYPE)picasso96_state.RGBFormat; - } - else { - write_log(_T("ERROR - picasso_refresh() can't refresh!\n")); - } + /* Make sure that the first time we show a Picasso video mode, we don't blit any crap. + * We can do this by checking if we have an Address yet. + */ + if (picasso96_state.Address) { + /* blit the stuff from our static frame-buffer to the gfx-card */ + ri.Memory = gfxmem_bank.baseaddr + (picasso96_state.Address - gfxmem_bank.start); + ri.BytesPerRow = picasso96_state.BytesPerRow; + ri.RGBFormat = (RGBFTYPE)picasso96_state.RGBFormat; + } else { + write_log (_T("ERROR - picasso_refresh() can't refresh!\n")); + } } bool picasso_rendered = false; @@ -800,7 +801,7 @@ void picasso_handle_vsync(void) return; if (!picasso_on) { - picasso_trigger_vblank(); + picasso_trigger_vblank (); return; } @@ -857,7 +858,7 @@ void picasso_handle_vsync(void) #include "p96_blit.cpp" #define BLT_NAME BLIT_NOTSRC_32 #define BLT_FUNC(s,d) *d = ~(*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp" #define BLT_NAME BLIT_ONLYSRC_32 #define BLT_FUNC(s,d) *d = (*s) & ~(*d) #include "p96_blit.cpp" @@ -912,7 +913,7 @@ void picasso_handle_vsync(void) #include "p96_blit.cpp" #define BLT_NAME BLIT_NOTSRC_24 #define BLT_FUNC(s,d) *d = ~(*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp" #define BLT_NAME BLIT_ONLYSRC_24 #define BLT_FUNC(s,d) *d = (*s) & ~(*d) #include "p96_blit.cpp" @@ -967,7 +968,7 @@ void picasso_handle_vsync(void) #include "p96_blit.cpp" #define BLT_NAME BLIT_NOTSRC_16 #define BLT_FUNC(s,d) *d = ~(*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp" #define BLT_NAME BLIT_ONLYSRC_16 #define BLT_FUNC(s,d) *d = (*s) & ~(*d) #include "p96_blit.cpp" @@ -1022,7 +1023,7 @@ void picasso_handle_vsync(void) #include "p96_blit.cpp" #define BLT_NAME BLIT_NOTSRC_8 #define BLT_FUNC(s,d) *d = ~(*s) -#include "p96_blit.cpp" +#include "p96_blit.cpp" #define BLT_NAME BLIT_ONLYSRC_8 #define BLT_FUNC(s,d) *d = (*s) & ~(*d) #include "p96_blit.cpp" @@ -1069,143 +1070,137 @@ void picasso_handle_vsync(void) /* * Functions to perform an action on the frame-buffer */ -static int do_blitrect_frame_buffer(struct RenderInfo *ri, struct - RenderInfo *dstri, unsigned long srcx, unsigned long srcy, - unsigned long dstx, unsigned long dsty, unsigned long width, unsigned - long height, uae_u8 mask, BLIT_OPCODE opcode) +static int do_blitrect_frame_buffer (struct RenderInfo *ri, struct + RenderInfo *dstri, unsigned long srcx, unsigned long srcy, + unsigned long dstx, unsigned long dsty, unsigned long width, unsigned + long height, uae_u8 mask, BLIT_OPCODE opcode) { - uae_u8 *src, *dst; - uae_u8 Bpp = GetBytesPerPixel(ri->RGBFormat); - unsigned long total_width = width * Bpp; + uae_u8 *src, *dst; + uae_u8 Bpp = GetBytesPerPixel (ri->RGBFormat); + unsigned long total_width = width * Bpp; - src = ri->Memory + srcx*Bpp + srcy*ri->BytesPerRow; - dst = dstri->Memory + dstx*Bpp + dsty*dstri->BytesPerRow; + src = ri->Memory + srcx*Bpp + srcy*ri->BytesPerRow; + dst = dstri->Memory + dstx*Bpp + dsty*dstri->BytesPerRow; - if (mask != 0xFF && Bpp > 1) { - write_log(_T("WARNING - BlitRect() has mask 0x%x with Bpp %d.\n"), mask, Bpp); - } + if (mask != 0xFF && Bpp > 1) { + write_log (_T("WARNING - BlitRect() has mask 0x%x with Bpp %d.\n"), mask, Bpp); + } - P96TRACE((_T("(%dx%d)=(%dx%d)=(%dx%d)=%d\n"), srcx, srcy, dstx, dsty, width, height, opcode)); - if (mask == 0xFF || Bpp > 1) { + P96TRACE ((_T("(%dx%d)=(%dx%d)=(%dx%d)=%d\n"), srcx, srcy, dstx, dsty, width, height, opcode)); + if (mask == 0xFF || Bpp > 1) { - if (opcode == BLIT_SRC) { - /* handle normal case efficiently */ - if (ri->Memory == dstri->Memory && dsty == srcy) { - unsigned long i; - for (i = 0; i < height; i++, src += ri->BytesPerRow, dst += dstri->BytesPerRow) - memmove(dst, src, total_width); - } - else if (dsty < srcy) { - unsigned long i; - for (i = 0; i < height; i++, src += ri->BytesPerRow, dst += dstri->BytesPerRow) - memcpy(dst, src, total_width); - } - else { - unsigned long i; - src += (height - 1) * ri->BytesPerRow; - dst += (height - 1) * dstri->BytesPerRow; - for (i = 0; i < height; i++, src -= ri->BytesPerRow, dst -= dstri->BytesPerRow) - memcpy(dst, src, total_width); - } - return 1; + if(opcode == BLIT_SRC) { + /* handle normal case efficiently */ + if (ri->Memory == dstri->Memory && dsty == srcy) { + unsigned long i; + for (i = 0; i < height; i++, src += ri->BytesPerRow, dst += dstri->BytesPerRow) + memmove (dst, src, total_width); + } else if (dsty < srcy) { + unsigned long i; + for (i = 0; i < height; i++, src += ri->BytesPerRow, dst += dstri->BytesPerRow) + memcpy (dst, src, total_width); + } else { + unsigned long i; + src += (height-1) * ri->BytesPerRow; + dst += (height-1) * dstri->BytesPerRow; + for (i = 0; i < height; i++, src -= ri->BytesPerRow, dst -= dstri->BytesPerRow) + memcpy (dst, src, total_width); + } + return 1; - } - else { + } else { if (Bpp == 4) { - /* 32-bit optimized */ - switch (opcode) - { - case BLIT_FALSE: BLIT_FALSE_32(PARMS); break; - case BLIT_NOR: BLIT_NOR_32(PARMS); break; - case BLIT_ONLYDST: BLIT_ONLYDST_32(PARMS); break; - case BLIT_NOTSRC: BLIT_NOTSRC_32(PARMS); break; - case BLIT_ONLYSRC: BLIT_ONLYSRC_32(PARMS); break; - case BLIT_NOTDST: BLIT_NOTDST_32(PARMS); break; - case BLIT_EOR: BLIT_EOR_32(PARMS); break; - case BLIT_NAND: BLIT_NAND_32(PARMS); break; - case BLIT_AND: BLIT_AND_32(PARMS); break; - case BLIT_NEOR: BLIT_NEOR_32(PARMS); break; - case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_32(PARMS); break; - case BLIT_NOTONLYDST: BLIT_NOTONLYDST_32(PARMS); break; - case BLIT_OR: BLIT_OR_32(PARMS); break; - case BLIT_TRUE: BLIT_TRUE_32(PARMS); break; - case BLIT_SWAP: BLIT_SWAP_32(PARMS); break; - } + /* 32-bit optimized */ + switch (opcode) + { + case BLIT_FALSE: BLIT_FALSE_32 (PARMS); break; + case BLIT_NOR: BLIT_NOR_32 (PARMS); break; + case BLIT_ONLYDST: BLIT_ONLYDST_32 (PARMS); break; + case BLIT_NOTSRC: BLIT_NOTSRC_32 (PARMS); break; + case BLIT_ONLYSRC: BLIT_ONLYSRC_32 (PARMS); break; + case BLIT_NOTDST: BLIT_NOTDST_32 (PARMS); break; + case BLIT_EOR: BLIT_EOR_32 (PARMS); break; + case BLIT_NAND: BLIT_NAND_32 (PARMS); break; + case BLIT_AND: BLIT_AND_32 (PARMS); break; + case BLIT_NEOR: BLIT_NEOR_32 (PARMS); break; + case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_32 (PARMS); break; + case BLIT_NOTONLYDST: BLIT_NOTONLYDST_32 (PARMS); break; + case BLIT_OR: BLIT_OR_32 (PARMS); break; + case BLIT_TRUE: BLIT_TRUE_32 (PARMS); break; + case BLIT_SWAP: BLIT_SWAP_32 (PARMS); break; + } + } else if (Bpp == 3) { + + /* 24-bit (not very) optimized */ + switch (opcode) + { + case BLIT_FALSE: BLIT_FALSE_24 (PARMS); break; + case BLIT_NOR: BLIT_NOR_24 (PARMS); break; + case BLIT_ONLYDST: BLIT_ONLYDST_24 (PARMS); break; + case BLIT_NOTSRC: BLIT_NOTSRC_24 (PARMS); break; + case BLIT_ONLYSRC: BLIT_ONLYSRC_24 (PARMS); break; + case BLIT_NOTDST: BLIT_NOTDST_24 (PARMS); break; + case BLIT_EOR: BLIT_EOR_24 (PARMS); break; + case BLIT_NAND: BLIT_NAND_24 (PARMS); break; + case BLIT_AND: BLIT_AND_24 (PARMS); break; + case BLIT_NEOR: BLIT_NEOR_24 (PARMS); break; + case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_24 (PARMS); break; + case BLIT_NOTONLYDST: BLIT_NOTONLYDST_24 (PARMS); break; + case BLIT_OR: BLIT_OR_24 (PARMS); break; + case BLIT_TRUE: BLIT_TRUE_24 (PARMS); break; + case BLIT_SWAP: BLIT_SWAP_24 (PARMS); break; + } + + } else if (Bpp == 2) { + + /* 16-bit optimized */ + switch (opcode) + { + case BLIT_FALSE: BLIT_FALSE_16 (PARMS); break; + case BLIT_NOR: BLIT_NOR_16 (PARMS); break; + case BLIT_ONLYDST: BLIT_ONLYDST_16 (PARMS); break; + case BLIT_NOTSRC: BLIT_NOTSRC_16 (PARMS); break; + case BLIT_ONLYSRC: BLIT_ONLYSRC_16 (PARMS); break; + case BLIT_NOTDST: BLIT_NOTDST_16 (PARMS); break; + case BLIT_EOR: BLIT_EOR_16 (PARMS); break; + case BLIT_NAND: BLIT_NAND_16 (PARMS); break; + case BLIT_AND: BLIT_AND_16 (PARMS); break; + case BLIT_NEOR: BLIT_NEOR_16 (PARMS); break; + case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_16 (PARMS); break; + case BLIT_NOTONLYDST: BLIT_NOTONLYDST_16 (PARMS); break; + case BLIT_OR: BLIT_OR_16 (PARMS); break; + case BLIT_TRUE: BLIT_TRUE_16 (PARMS); break; + case BLIT_SWAP: BLIT_SWAP_16 (PARMS); break; + } + + } else if (Bpp == 1) { + + /* 8-bit optimized */ + switch (opcode) + { + case BLIT_FALSE: BLIT_FALSE_8 (PARMS); break; + case BLIT_NOR: BLIT_NOR_8 (PARMS); break; + case BLIT_ONLYDST: BLIT_ONLYDST_8 (PARMS); break; + case BLIT_NOTSRC: BLIT_NOTSRC_8 (PARMS); break; + case BLIT_ONLYSRC: BLIT_ONLYSRC_8 (PARMS); break; + case BLIT_NOTDST: BLIT_NOTDST_8 (PARMS); break; + case BLIT_EOR: BLIT_EOR_8 (PARMS); break; + case BLIT_NAND: BLIT_NAND_8 (PARMS); break; + case BLIT_AND: BLIT_AND_8 (PARMS); break; + case BLIT_NEOR: BLIT_NEOR_8 (PARMS); break; + case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_8 (PARMS); break; + case BLIT_NOTONLYDST: BLIT_NOTONLYDST_8 (PARMS); break; + case BLIT_OR: BLIT_OR_8 (PARMS); break; + case BLIT_TRUE: BLIT_TRUE_8 (PARMS); break; + case BLIT_SWAP: BLIT_SWAP_8 (PARMS); break; + } } - else if (Bpp == 3) { - - /* 24-bit (not very) optimized */ - switch (opcode) - { - case BLIT_FALSE: BLIT_FALSE_24(PARMS); break; - case BLIT_NOR: BLIT_NOR_24(PARMS); break; - case BLIT_ONLYDST: BLIT_ONLYDST_24(PARMS); break; - case BLIT_NOTSRC: BLIT_NOTSRC_24(PARMS); break; - case BLIT_ONLYSRC: BLIT_ONLYSRC_24(PARMS); break; - case BLIT_NOTDST: BLIT_NOTDST_24(PARMS); break; - case BLIT_EOR: BLIT_EOR_24(PARMS); break; - case BLIT_NAND: BLIT_NAND_24(PARMS); break; - case BLIT_AND: BLIT_AND_24(PARMS); break; - case BLIT_NEOR: BLIT_NEOR_24(PARMS); break; - case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_24(PARMS); break; - case BLIT_NOTONLYDST: BLIT_NOTONLYDST_24(PARMS); break; - case BLIT_OR: BLIT_OR_24(PARMS); break; - case BLIT_TRUE: BLIT_TRUE_24(PARMS); break; - case BLIT_SWAP: BLIT_SWAP_24(PARMS); break; - } - - } - else if (Bpp == 2) { - - /* 16-bit optimized */ - switch (opcode) - { - case BLIT_FALSE: BLIT_FALSE_16(PARMS); break; - case BLIT_NOR: BLIT_NOR_16(PARMS); break; - case BLIT_ONLYDST: BLIT_ONLYDST_16(PARMS); break; - case BLIT_NOTSRC: BLIT_NOTSRC_16(PARMS); break; - case BLIT_ONLYSRC: BLIT_ONLYSRC_16(PARMS); break; - case BLIT_NOTDST: BLIT_NOTDST_16(PARMS); break; - case BLIT_EOR: BLIT_EOR_16(PARMS); break; - case BLIT_NAND: BLIT_NAND_16(PARMS); break; - case BLIT_AND: BLIT_AND_16(PARMS); break; - case BLIT_NEOR: BLIT_NEOR_16(PARMS); break; - case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_16(PARMS); break; - case BLIT_NOTONLYDST: BLIT_NOTONLYDST_16(PARMS); break; - case BLIT_OR: BLIT_OR_16(PARMS); break; - case BLIT_TRUE: BLIT_TRUE_16(PARMS); break; - case BLIT_SWAP: BLIT_SWAP_16(PARMS); break; - } - - } - else if (Bpp == 1) { - - /* 8-bit optimized */ - switch (opcode) - { - case BLIT_FALSE: BLIT_FALSE_8(PARMS); break; - case BLIT_NOR: BLIT_NOR_8(PARMS); break; - case BLIT_ONLYDST: BLIT_ONLYDST_8(PARMS); break; - case BLIT_NOTSRC: BLIT_NOTSRC_8(PARMS); break; - case BLIT_ONLYSRC: BLIT_ONLYSRC_8(PARMS); break; - case BLIT_NOTDST: BLIT_NOTDST_8(PARMS); break; - case BLIT_EOR: BLIT_EOR_8(PARMS); break; - case BLIT_NAND: BLIT_NAND_8(PARMS); break; - case BLIT_AND: BLIT_AND_8(PARMS); break; - case BLIT_NEOR: BLIT_NEOR_8(PARMS); break; - case BLIT_NOTONLYSRC: BLIT_NOTONLYSRC_8(PARMS); break; - case BLIT_NOTONLYDST: BLIT_NOTONLYDST_8(PARMS); break; - case BLIT_OR: BLIT_OR_8(PARMS); break; - case BLIT_TRUE: BLIT_TRUE_8(PARMS); break; - case BLIT_SWAP: BLIT_SWAP_8(PARMS); break; - } - } - } - return 1; - } - return 0; + } + return 1; + } + return 0; } /* @@ -1215,7 +1210,7 @@ Inputs: a0: struct BoardInfo *bi d7: RGBFTYPE RGBFormat */ -static uae_u32 REGPARAM2 picasso_SetSpritePosition(TrapContext *ctx) +static uae_u32 REGPARAM2 picasso_SetSpritePosition (TrapContext *ctx) { uaecptr bi = trap_get_areg(ctx, 0); boardinfo = bi; @@ -1235,7 +1230,7 @@ d7: RGBFTYPE RGBFormat This function changes one of the possible three colors of the hardware sprite. */ -static uae_u32 REGPARAM2 picasso_SetSpriteColor(TrapContext *ctx) +static uae_u32 REGPARAM2 picasso_SetSpriteColor (TrapContext *ctx) { uaecptr bi = trap_get_areg(ctx, 0); boardinfo = bi; @@ -1268,11 +1263,11 @@ planes for one image line respectively. You have to double each pixel horizontal used in this case already assume a zoomed sprite, only the sprite data is not zoomed yet. You will have to compensate for this when accounting for hotspot offsets and sprite dimensions. */ -static uae_u32 REGPARAM2 picasso_SetSpriteImage(TrapContext *ctx) +static uae_u32 REGPARAM2 picasso_SetSpriteImage (TrapContext *ctx) { uaecptr bi = trap_get_areg(ctx, 0); boardinfo = bi; - return 0; + return 0; } /* @@ -1284,7 +1279,7 @@ d7: RGBFTYPE RGBFormat This function activates or deactivates the hardware sprite. */ -static uae_u32 REGPARAM2 picasso_SetSprite(TrapContext *ctx) +static uae_u32 REGPARAM2 picasso_SetSprite (TrapContext *ctx) { return 0; } @@ -1304,50 +1299,48 @@ static uae_u32 REGPARAM2 picasso_SetSprite(TrapContext *ctx) * BoardInfo struct supplied by the caller, the rtg.library, for example * the MemoryBase, MemorySize and RegisterBase fields. */ -static void picasso96_alloc2(TrapContext *ctx); -static uae_u32 REGPARAM2 picasso_FindCard(TrapContext *ctx) +static void picasso96_alloc2 (TrapContext *ctx); +static uae_u32 REGPARAM2 picasso_FindCard (TrapContext *ctx) { uaecptr AmigaBoardInfo = trap_get_areg(ctx, 0); - /* NOTES: See BoardInfo struct definition in Picasso96 dev info */ + /* NOTES: See BoardInfo struct definition in Picasso96 dev info */ if (!uaegfx_active || !gfxmem_bank.start) - return 0; + return 0; if (uaegfx_base) { trap_put_long(ctx, uaegfx_base + CARD_BOARDINFO, AmigaBoardInfo); + } else if (uaegfx_old) { + picasso96_alloc2 (ctx); } - else if (uaegfx_old) { - picasso96_alloc2(ctx); - } - boardinfo = AmigaBoardInfo; + boardinfo = AmigaBoardInfo; - if (gfxmem_bank.allocated_size && !picasso96_state_uaegfx.CardFound) { - /* Fill in MemoryBase, MemorySize */ + if (gfxmem_bank.allocated_size && !picasso96_state_uaegfx.CardFound) { + /* Fill in MemoryBase, MemorySize */ trap_put_long(ctx, AmigaBoardInfo + PSSO_BoardInfo_MemoryBase, gfxmem_bank.start); trap_put_long(ctx, AmigaBoardInfo + PSSO_BoardInfo_MemorySize, gfxmem_bank.allocated_size - reserved_gfxmem); - picasso96_state_uaegfx.CardFound = 1; /* mark our "card" as being found */ - return -1; - } - else - return 0; + picasso96_state_uaegfx.CardFound = 1; /* mark our "card" as being found */ + return -1; + } else + return 0; } static void FillBoardInfo(TrapContext *ctx, uaecptr amigamemptr, struct LibResolution *res, int width, int height, int depth) { - switch (depth) - { - case 8: - res->Modes[CHUNKY] = amigamemptr; - break; + switch (depth) + { + case 8: + res->Modes[CHUNKY] = amigamemptr; + break; case 15: case 16: - res->Modes[HICOLOR] = amigamemptr; - break; + res->Modes[HICOLOR] = amigamemptr; + break; case 24: - res->Modes[TRUECOLOR] = amigamemptr; - break; - default: - res->Modes[TRUEALPHA] = amigamemptr; - break; - } + res->Modes[TRUECOLOR] = amigamemptr; + break; + default: + res->Modes[TRUEALPHA] = amigamemptr; + break; + } trap_set_bytes(ctx, amigamemptr, 0, PSSO_ModeInfo_sizeof); trap_put_word(ctx, amigamemptr + PSSO_ModeInfo_Width, width); @@ -1370,32 +1363,30 @@ static void FillBoardInfo(TrapContext *ctx, uaecptr amigamemptr, struct LibResol trap_put_byte(ctx, amigamemptr + PSSO_ModeInfo_second_union, 14); trap_put_long(ctx, amigamemptr + PSSO_ModeInfo_PixelClock, - width * height * 60); + width * height * defaultHz); } -struct modeids -{ - int width, height; - int id; +struct modeids { + int width, height; + int id; }; - static struct modeids mi[] = { - /* "original" modes */ + /* "original" modes */ - 320, 200, 0, - 320, 240, 1, - 640, 400, 2, - 640, 480, 3, - 800, 600, 4, - 1024, 768, 5, - 1152, 864, 6, - 1280,1024, 7, - 1600,1280, 8, - 320, 256, 9, - 640, 512,10, + 320, 200, 0, + 320, 240, 1, + 640, 400, 2, + 640, 480, 3, + 800, 600, 4, + 1024, 768, 5, + 1152, 864, 6, + 1280,1024, 7, + 1600,1280, 8, + 320, 256, 9, + 640, 512,10, - /* new modes */ + /* new modes */ 704, 480, 129, 704, 576, 130, @@ -2154,7 +2145,6 @@ FillRect: * d5: UBYTE Mask * d7: uae_u32 RGBFormat ***********************************************************/ -//__attribute__((optimize("O2"))) is needed otherwise this crashes with O3! static uae_u32 REGPARAM2 picasso_FillRect(TrapContext *ctx) { uaecptr renderinfo = trap_get_areg(ctx, 1); @@ -3740,4 +3730,4 @@ uae_u8 *save_p96(int *len, uae_u8 *dstptr) return dstbak; } -#endif \ No newline at end of file +#endif diff --git a/src/include/picasso96.h b/src/osdep/picasso96.h similarity index 99% rename from src/include/picasso96.h rename to src/osdep/picasso96.h index e3e5361c..758c3577 100644 --- a/src/include/picasso96.h +++ b/src/osdep/picasso96.h @@ -647,9 +647,7 @@ extern int p96hsync_counter; #endif void copy_screen_8bit(uae_u8 *dst, uae_u8 *src, int bytes, uae_u32 *clut); void copy_screen_16bit_swap(uae_u8 *dst, uae_u8 *src, int bytes); - void copy_screen_16bit_swap_arm(uae_u8 *dst, uae_u8 *src, int bytes); - void copy_screen_32bit_to_16bit_neon(uae_u8 *dst, uae_u8 *src, int bytes); - void copy_screen_32bit_to_16bit_arm(uae_u8 *dst, uae_u8 *src, int bytes); + void copy_screen_32bit_to_16bit(uae_u8 *dst, uae_u8 *src, int bytes); #ifdef __cplusplus } #endif diff --git a/src/osdep/sigsegv_handler.cpp b/src/osdep/sigsegv_handler.cpp index 9d7960ee..f7459ed4 100644 --- a/src/osdep/sigsegv_handler.cpp +++ b/src/osdep/sigsegv_handler.cpp @@ -50,7 +50,7 @@ extern void invalidate_block(blockinfo* bi); extern void raise_in_cl_list(blockinfo* bi); -#define SHOW_DETAILS 0 +#define SHOW_DETAILS 2 #ifdef WITH_LOGGING #define output_log write_log diff --git a/src/osdep/sysconfig.h b/src/osdep/sysconfig.h index 36c59b96..08f9e2cb 100644 --- a/src/osdep/sysconfig.h +++ b/src/osdep/sysconfig.h @@ -30,7 +30,9 @@ #define CD32 /* CD32 emulation */ /* #define CDTV */ /* CDTV emulation */ /* #define PARALLEL_PORT */ /* parallel port emulation */ +/* #define PARALLEL_DIRECT */ /* direct parallel port emulation */ /* #define SERIAL_PORT */ /* serial port emulation */ +/* #define SERIAL_ENET */ /* serial port UDP transport */ /* #define SCSIEMU */ /* uaescsi.device emulation */ /* #define UAESERIAL */ /* uaeserial.device emulation */ #define FPUEMU /* FPU emulation */ @@ -66,11 +68,26 @@ /* #define LOGITECHLCD */ /* Logitech G15 LCD */ #define SAVESTATE /* State file support */ /* #define A2091 */ /* A590/A2091 SCSI */ -/* #define NCR */ /* A4000T/A4091 SCSI */ +/* #define A2065 */ /* A2065 Ethernet card */ +/* #define GFXBOARD */ /* Hardware graphics board */ +/* #define NCR */ /* A4000T/A4091, 53C710/53C770 SCSI */ +/* #define NCR9X */ /* 53C9X SCSI */ /* #define SANA2 */ /* SANA2 network driver */ /* #define AMAX */ /* A-Max ROM adapater emulation */ /* #define RETROPLATFORM */ /* Cloanto RetroPlayer support */ -/* #define INPUT_RECORDER */ /* Use input recoder */ +/* #define WITH_CHD */ +/* #define WITH_LUA */ /* lua scripting */ +/* #define WITH_UAENATIVE */ +/* #define WITH_SLIRP */ +/* #define WITH_BUILTIN_SLIRP */ +/* #define WITH_TABLETLIBRARY */ +/* #define WITH_UAENET_PCAP */ +/* #define WITH_PPC */ +/* #define WITH_QEMU_CPU */ +/* #define WITH_TOCCATA */ +/* #define WITH_PCI */ +/* #define WITH_X86 */ + /* #define CUSTOM_SIMPLE */ /* simplified custom chipset emulation */ /* #define CPUEMU_68000_ONLY */ /* drop 68010+ commands from CPUEMU_0 */ /* #define ADDRESS_SPACE_24BIT */ @@ -94,6 +111,8 @@ #undef D3D #endif +#include + #define SIZEOF_VOID_P 4 #if !defined(AHI) @@ -205,7 +224,7 @@ typedef long uae_atomic; /* Define if statfs takes 2 args and struct statfs has a field named f_bsize. [4.3BSD, SunOS 4, HP-UX, AIX PS/2] */ -//#define STAT_STATFS2_BSIZE 1 +/* #define STAT_STATFS2_BSIZE 1 */ /* Define if statfs takes 2 args and struct statfs has a field named f_fsize. [4.4BSD, NetBSD] */ @@ -219,7 +238,7 @@ typedef long uae_atomic; /* #undef STAT_STATFS4 */ /* Define if there is a function named statvfs. [SVR4] */ - #define STAT_STATVFS +#define STAT_STATVFS /* Define if the block counts reported by statfs may be truncated to 2GB and the correct values may be stored in the f_spare array. @@ -311,9 +330,6 @@ typedef long uae_atomic; /* Define if you have the select function. */ #define HAVE_SELECT 1 -/* Define if you have the setitimer function. */ -#define HAVE_SETITIMER 1 - /* Define if you have the sigaction function. */ #define HAVE_SIGACTION 1 @@ -482,6 +498,9 @@ typedef long uae_atomic; #define FSDB_DIR_SEPARATOR '/' #define FSDB_DIR_SEPARATOR_S "/" +/* Define to 1 if `S_un' is a member of `struct in_addr'. */ +/* #un#def HAVE_STRUCT_IN_ADDR_S_UN */ + #ifdef _GCCRES_ #undef _GCCRES_ #endif @@ -528,4 +547,4 @@ typedef char TCHAR; #define _ftelli64(x) ftello64(x) #define _fseeki64(x,y,z) fseeko64(x,y,z) #define _wunlink(x) unlink(x) -#define _istalnum(x) isalnum(x) \ No newline at end of file +#define _istalnum(x) isalnum(x) diff --git a/src/osdep/target.h b/src/osdep/target.h index ccd3247d..abb77416 100644 --- a/src/osdep/target.h +++ b/src/osdep/target.h @@ -2,8 +2,6 @@ * UAE - The Un*x Amiga Emulator * * Target specific stuff, Amiberry version - * - * Copyright 1997 Bernd Schmidt */ #pragma once @@ -36,14 +34,22 @@ unsigned long target_lastsynctime(void); extern int screen_is_picasso; void saveAdfDir(void); +bool SetVSyncRate(int hz); +void setCpuSpeed(void); +void resetCpuSpeed(void); void update_display(struct uae_prefs *); void black_screen_now(void); -void graphics_subshutdown(void); +void graphics_subshutdown (void); +void moveVertical(int value); void amiberry_stop_sound(); void keyboard_settrans(); void translate_amiberry_keys(int symbol, int newstate); +#ifdef PANDORA +int translate_pandora_keys(int symbol, int *modifier); +#endif + void SimulateMouseOrJoy(int code, int keypressed); #define REMAP_MOUSEBUTTON_LEFT -1 @@ -62,6 +68,9 @@ void SimulateMouseOrJoy(int code, int keypressed); extern void free_AmigaMem(); extern void alloc_AmigaMem(); +#ifdef WITH_LOGGING +extern void ShowLiveInfo(char *msg); +#endif extern void fetch_configurationpath(char *out, int size); extern void set_configurationpath(char *newpath); @@ -104,6 +113,8 @@ extern void gui_force_rtarea_hdchange(void); extern void gui_restart(void); extern bool hardfile_testrdb(const char *filename); +extern bool host_poweroff; + #ifdef __cplusplus extern "C" { #endif diff --git a/src/rommgr.cpp b/src/rommgr.cpp index e45276bb..d54199ff 100644 --- a/src/rommgr.cpp +++ b/src/rommgr.cpp @@ -124,736 +124,584 @@ static struct romdata roms[] = { ALTROMPN(125, 1, 3, 32768, ROMTYPE_QUAD | ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x715988a9, 0x08c36600, 0x3948c4c5, 0x4216ef8c, 0x17ebe16c, 0xc91d3b7a) ALTROMPN(125, 1, 4, 32768, ROMTYPE_QUAD | ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xc4dc7e6a, 0x66b231d0, 0x8425c858, 0xdfcd36d2, 0xd38a0df8, 0x518e06a4) -{ - _T("KS ROM v1.0 (A1000)(NTSC)"), 1, 0, 1, 0, _T("A1000\0"), 262144, 1, 0, 0, ROMTYPE_KICK, 0, 0, NULL, - 0x299790ff, 0x00C15406,0xBEB4B8AB,0x1A16AA66,0xC05860E1,0xA7C1AD79 -}, -{ _T("KS ROM v1.1 (A1000)(NTSC)"), 1, 1, 31, 34, _T("A1000\0"), 262144, 2, 0, 0, ROMTYPE_KICK, 0, 0, NULL, -0xd060572a, 0x4192C505,0xD130F446,0xB2ADA6BD,0xC91DAE73,0x0ACAFB4C }, -{ _T("KS ROM v1.1 (A1000)(PAL)"), 1, 1, 31, 34, _T("A1000\0"), 262144, 3, 0, 0, ROMTYPE_KICK, 0, 0, NULL, -0xec86dae2, 0x16DF8B5F,0xD524C5A1,0xC7584B24,0x57AC15AF,0xF9E3AD6D }, -{ _T("KS ROM v1.2 (A1000)"), 1, 2, 33, 166, _T("A1000\0"), 262144, 4, 0, 0, ROMTYPE_KICK, 0, 0, NULL, -0x9ed783d0, 0x6A7BFB5D,0xBD6B8F17,0x9F03DA84,0xD8D95282,0x67B6273B }, -{ _T("KS ROM v1.2 (A500,A1000,A2000)"), 1, 2, 33, 180, _T("A500\0A1000\0A2000\0"), 262144, 5, 0, 0, ROMTYPE_KICK, 0, 0, _T("315093-01"), -0xa6ce1636, 0x11F9E62C,0xF299F721,0x84835B7B,0x2A70A163,0x33FC0D88 }, -{ _T("KS ROM v1.3 (A500,A1000,A2000)"), 1, 3, 34, 5, _T("A500\0A1000\0A2000\0"), 262144, 6, 0, 0, ROMTYPE_KICK, 0, 0, _T("315093-02"), -0xc4f0f55f, 0x891E9A54,0x7772FE0C,0x6C19B610,0xBAF8BC4E,0xA7FCB785 }, -{ _T("KS ROM v1.3 (A3000)(SK)"), 1, 3, 34, 5, _T("A3000\0"), 262144, 32, 0, 0, ROMTYPE_KICK, 0, 0, NULL, -0xe0f37258, 0xC39BD909,0x4D4E5F4E,0x28C1411F,0x30869504,0x06062E87 }, -{ _T("KS ROM v1.4 (A3000)"), 1, 4, 36, 16, _T("A3000\0"), 524288, 59, 3, 0, ROMTYPE_KICK, 0, 0, NULL, -0xbc0ec13f, 0xF76316BF,0x36DFF14B,0x20FA349E,0xD02E4B11,0xDD932B07 }, -ALTROMPN(59, 1, 1, 262144, ROMTYPE_EVEN, _T("390629-02"), 0x58327536,0xd1713d7f,0x31474a59,0x48e6d488,0xe3368606,0x1cf3d1e2) -ALTROMPN(59, 1, 2, 262144, ROMTYPE_ODD , _T("390630-02"), 0xfe2f7fb9,0xc05c9c52,0xd014c66f,0x9019152b,0x3f2a2adc,0x2c678794) - { - _T("KS ROM v2.04 (A500+)"), 2, 4, 37, 175, _T("A500+\0"), 524288, 7, 0, 0, ROMTYPE_KICK, 0, 0, _T("390979-01"), - 0xc3bdb240, 0xC5839F5C,0xB98A7A89,0x47065C3E,0xD2F14F5F,0x42E334A1 - }, + { _T("KS ROM v1.0 (A1000)(NTSC)"), 1, 0, 1, 0, _T("A1000\0"), 262144, 1, 0, 0, ROMTYPE_KICK, 0, 0, NULL, + 0x299790ff, 0x00C15406,0xBEB4B8AB,0x1A16AA66,0xC05860E1,0xA7C1AD79 }, + { _T("KS ROM v1.1 (A1000)(NTSC)"), 1, 1, 31, 34, _T("A1000\0"), 262144, 2, 0, 0, ROMTYPE_KICK, 0, 0, NULL, + 0xd060572a, 0x4192C505,0xD130F446,0xB2ADA6BD,0xC91DAE73,0x0ACAFB4C}, + { _T("KS ROM v1.1 (A1000)(PAL)"), 1, 1, 31, 34, _T("A1000\0"), 262144, 3, 0, 0, ROMTYPE_KICK, 0, 0, NULL, + 0xec86dae2, 0x16DF8B5F,0xD524C5A1,0xC7584B24,0x57AC15AF,0xF9E3AD6D }, + { _T("KS ROM v1.2 (A1000)"), 1, 2, 33, 166, _T("A1000\0"), 262144, 4, 0, 0, ROMTYPE_KICK, 0, 0, NULL, + 0x9ed783d0, 0x6A7BFB5D,0xBD6B8F17,0x9F03DA84,0xD8D95282,0x67B6273B }, + { _T("KS ROM v1.2 (A500,A1000,A2000)"), 1, 2, 33, 180, _T("A500\0A1000\0A2000\0"), 262144, 5, 0, 0, ROMTYPE_KICK, 0, 0, _T("315093-01"), + 0xa6ce1636, 0x11F9E62C,0xF299F721,0x84835B7B,0x2A70A163,0x33FC0D88 }, + { _T("KS ROM v1.3 (A500,A1000,A2000)"), 1, 3, 34, 5, _T("A500\0A1000\0A2000\0"), 262144, 6, 0, 0, ROMTYPE_KICK, 0, 0, _T("315093-02"), + 0xc4f0f55f, 0x891E9A54,0x7772FE0C,0x6C19B610,0xBAF8BC4E,0xA7FCB785 }, + { _T("KS ROM v1.3 (A3000)(SK)"), 1, 3, 34, 5, _T("A3000\0"), 262144, 32, 0, 0, ROMTYPE_KICK, 0, 0, NULL, + 0xe0f37258, 0xC39BD909,0x4D4E5F4E,0x28C1411F,0x30869504,0x06062E87 }, + { _T("KS ROM v1.4 (A3000)"), 1, 4, 36, 16, _T("A3000\0"), 524288, 59, 3, 0, ROMTYPE_KICK, 0, 0, NULL, + 0xbc0ec13f, 0xF76316BF,0x36DFF14B,0x20FA349E,0xD02E4B11,0xDD932B07 }, + ALTROMPN(59, 1, 1, 262144, ROMTYPE_EVEN, _T("390629-02"), 0x58327536,0xd1713d7f,0x31474a59,0x48e6d488,0xe3368606,0x1cf3d1e2) + ALTROMPN(59, 1, 2, 262144, ROMTYPE_ODD , _T("390630-02"), 0xfe2f7fb9,0xc05c9c52,0xd014c66f,0x9019152b,0x3f2a2adc,0x2c678794) + { _T("KS ROM v2.04 (A500+)"), 2, 4, 37, 175, _T("A500+\0"), 524288, 7, 0, 0, ROMTYPE_KICK, 0, 0, _T("390979-01"), + 0xc3bdb240, 0xC5839F5C,0xB98A7A89,0x47065C3E,0xD2F14F5F,0x42E334A1 }, { _T("KS ROM v2.05 (A600)"), 2, 5, 37, 299, _T("A600\0"), 524288, 8, 0, 0, ROMTYPE_KICK, 0, 0, _T("391388-01"), - 0x83028fb5, 0x87508DE8,0x34DC7EB4,0x7359CEDE,0x72D2E3C8,0xA2E5D8DB }, - { _T("KS ROM v2.05 (A600HD)"), 2, 5, 37, 300, _T("A600HD\0A600\0"), 524288, 9, 0, 0, ROMTYPE_KICK, 0, 0, _T("391304-01"), - 0x64466c2a, 0xF72D8914,0x8DAC39C6,0x96E30B10,0x859EBC85,0x9226637B }, - { _T("KS ROM v2.05 (A600HD)"), 2, 5, 37, 350, _T("A600HD\0A600\0"), 524288, 10, 0, 0, ROMTYPE_KICK, 0, 0, _T("391304-02"), - 0x43b0df7b, 0x02843C42,0x53BBD29A,0xBA535B0A,0xA3BD9A85,0x034ECDE4 }, - { _T("KS ROM v2.04 (A3000)"), 2, 4, 37, 175, _T("A3000\0"), 524288, 71, 8, 0, ROMTYPE_KICK, 0, 0, NULL, - 0x234a7233, 0xd82ebb59,0xafc53540,0xddf2d718,0x7ecf239b,0x7ea91590 }, - ALTROMPN(71, 1, 1, 262144, ROMTYPE_EVEN, _T("390629-03"), 0xa245dbdf,0x83bab8e9,0x5d378b55,0xb0c6ae65,0x61385a96,0xf638598f) - ALTROMPN(71, 1, 2, 262144, ROMTYPE_ODD , _T("390630-03"), 0x7db1332b,0x48f14b31,0x279da675,0x7848df6f,0xeb531881,0x8f8f576c) + 0x83028fb5, 0x87508DE8,0x34DC7EB4,0x7359CEDE,0x72D2E3C8,0xA2E5D8DB }, + { _T("KS ROM v2.05 (A600HD)"), 2, 5, 37, 300, _T("A600HD\0A600\0"), 524288, 9, 0, 0, ROMTYPE_KICK, 0, 0, _T("391304-01"), + 0x64466c2a, 0xF72D8914,0x8DAC39C6,0x96E30B10,0x859EBC85,0x9226637B }, + { _T("KS ROM v2.05 (A600HD)"), 2, 5, 37, 350, _T("A600HD\0A600\0"), 524288, 10, 0, 0, ROMTYPE_KICK, 0, 0, _T("391304-02"), + 0x43b0df7b, 0x02843C42,0x53BBD29A,0xBA535B0A,0xA3BD9A85,0x034ECDE4 }, + { _T("KS ROM v2.04 (A3000)"), 2, 4, 37, 175, _T("A3000\0"), 524288, 71, 8, 0, ROMTYPE_KICK, 0, 0, NULL, + 0x234a7233, 0xd82ebb59,0xafc53540,0xddf2d718,0x7ecf239b,0x7ea91590 }, + ALTROMPN(71, 1, 1, 262144, ROMTYPE_EVEN, _T("390629-03"), 0xa245dbdf,0x83bab8e9,0x5d378b55,0xb0c6ae65,0x61385a96,0xf638598f) + ALTROMPN(71, 1, 2, 262144, ROMTYPE_ODD , _T("390630-03"), 0x7db1332b,0x48f14b31,0x279da675,0x7848df6f,0xeb531881,0x8f8f576c) - { - _T("KS ROM v3.0 (A1200)"), 3, 0, 39, 106, _T("A1200\0"), 524288, 11, 0, 0, ROMTYPE_KICK, 0, 0, NULL, - 0x6c9b07d2, 0x70033828,0x182FFFC7,0xED106E53,0x73A8B89D,0xDA76FAA5 - }, - ALTROMPN(11, 1, 1, 262144, ROMTYPE_EVEN, _T("391523-01"), 0xc742a412,0x999eb81c,0x65dfd07a,0x71ee1931,0x5d99c7eb,0x858ab186) - ALTROMPN(11, 1, 2, 262144, ROMTYPE_ODD , _T("391524-01"), 0xd55c6ec6,0x3341108d,0x3a402882,0xb5ef9d3b,0x242cbf3c,0x8ab1a3e9) - { - _T("KS ROM v3.0 (A4000)"), 3, 0, 39, 106, _T("A4000\0"), 524288, 12, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL, - 0x9e6ac152, 0xF0B4E9E2,0x9E12218C,0x2D5BD702,0x0E4E7852,0x97D91FD7 - }, - ALTROMPN(12, 1, 1, 262144, ROMTYPE_EVEN, _T("391513-02"), 0x36f64dd0,0x196e9f3f,0x9cad934e,0x181c07da,0x33083b1f,0x0a3c702f) - ALTROMPN(12, 1, 2, 262144, ROMTYPE_ODD , _T("391514-02"), 0x17266a55,0x42fbed34,0x53d1f11c,0xcbde89a9,0x826f2d11,0x75cca5cc) - { - _T("KS ROM v3.1 (A4000)"), 3, 1, 40, 70, _T("A4000\0"), 524288, 13, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL, - 0x2b4566f1, 0x81c631dd,0x096bbb31,0xd2af9029,0x9c76b774,0xdb74076c - }, - ALTROM(13, 1, 1, 262144, ROMTYPE_EVEN, 0xf9cbecc9,0x138d8cb4,0x3b8312fe,0x16d69070,0xde607469,0xb3d4078e) - ALTROM(13, 1, 2, 262144, ROMTYPE_ODD , 0xf8248355,0xc2379547,0x9fae3910,0xc185512c,0xa268b82f,0x1ae4fe05) - { - _T("KS ROM v3.1 (A500,A600,A2000)"), 3, 1, 40, 63, _T("A500\0A600\0A2000\0"), 524288, 14, 0, 0, ROMTYPE_KICK, 0, 0, NULL, - 0xfc24ae0d, 0x3B7F1493,0xB27E2128,0x30F989F2,0x6CA76C02,0x049F09CA - }, - { _T("KS ROM v3.1 (A1200)"), 3, 1, 40, 68, _T("A1200\0"), 524288, 15, 1, 0, ROMTYPE_KICK, 0, 0, NULL, - 0x1483a091, 0xE2154572,0x3FE8374E,0x91342617,0x604F1B3D,0x703094F1 }, - ALTROMPN(15, 1, 1, 262144, ROMTYPE_EVEN, _T("391773-01"), 0x08dbf275,0xb8800f5f,0x90929810,0x9ea69690,0xb1b8523f,0xa22ddb37) - ALTROMPN(15, 1, 2, 262144, ROMTYPE_ODD , _T("391774-01"), 0x16c07bf8,0x90e331be,0x1970b0e5,0x3f53a9b0,0x390b51b5,0x9b3869c2) - { - _T("KS ROM v3.1 (A3000)"), 3, 1, 40, 68, _T("A3000\0"), 524288, 61, 2, 0, ROMTYPE_KICK, 0, 0, NULL, - 0xefb239cc, 0xF8E210D7,0x2B4C4853,0xE0C9B85D,0x223BA20E,0x3D1B36EE - }, - ALTROM(61, 1, 1, 262144, ROMTYPE_EVEN, 0x286b9a0d,0x6763a225,0x8ec493f7,0x408cf663,0x110dae9a,0x17803ad1) - ALTROM(61, 1, 2, 262144, ROMTYPE_ODD , 0x0b8cde6a,0x5f02e97b,0x48ebbba8,0x7d516a56,0xb0400c6f,0xc3434d8d) - { - _T("KS ROM v3.1 (A4000)(Cloanto)"), 3, 1, 40, 68, _T("A4000\0"), 524288, 31, 2 | 4, 1, ROMTYPE_KICK, 0, 0, NULL, - 0x43b6dd22, 0xC3C48116,0x0866E60D,0x085E436A,0x24DB3617,0xFF60B5F9 - }, - { _T("KS ROM v3.1 (A4000)"), 3, 1, 40, 68, _T("A4000\0"), 524288, 16, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL, - 0xd6bae334, 0x5FE04842,0xD04A4897,0x20F0F4BB,0x0E469481,0x99406F49 }, - ALTROM(16, 1, 1, 262144, ROMTYPE_EVEN, 0xb2af34f8,0x24e52b5e,0xfc020495,0x17387ab7,0xb1a1475f,0xc540350e) - ALTROM(16, 1, 2, 262144, ROMTYPE_ODD , 0xe65636a3,0x313c7cbd,0xa5779e56,0xf19a41d3,0x4e760f51,0x7626d882) - { - _T("KS ROM v3.1 (A4000T)"), 3, 1, 40, 70, _T("A4000T\0"), 524288, 17, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL, - 0x75932c3a, 0xB0EC8B84,0xD6768321,0xE01209F1,0x1E6248F2,0xF5281A21 - }, - ALTROMPN(17, 1, 1, 262144, ROMTYPE_EVEN, _T("391657-01"), 0x0ca94f70,0xb3806eda,0xcb3362fc,0x16a154ce,0x1eeec5bf,0x5bc24789) - ALTROMPN(17, 1, 2, 262144, ROMTYPE_ODD , _T("391658-01"), 0xdfe03120,0xcd7a706c,0x431b04d8,0x7814d3a2,0xd8b39710,0x0cf44c0c) - { - _T("KS ROM v3.X (A4000)(Cloanto)"), 3, 10, 45, 57, _T("A4000\0"), 524288, 46, 2 | 4, 1, ROMTYPE_KICK, 0, 0, NULL, - 0x3ac99edc, 0x3cbfc9e1,0xfe396360,0x157bd161,0xde74fc90,0x1abee7ec - }, + { _T("KS ROM v3.0 (A1200)"), 3, 0, 39, 106, _T("A1200\0"), 524288, 11, 0, 0, ROMTYPE_KICK, 0, 0, NULL, + 0x6c9b07d2, 0x70033828,0x182FFFC7,0xED106E53,0x73A8B89D,0xDA76FAA5 }, + ALTROMPN(11, 1, 1, 262144, ROMTYPE_EVEN, _T("391523-01"), 0xc742a412,0x999eb81c,0x65dfd07a,0x71ee1931,0x5d99c7eb,0x858ab186) + ALTROMPN(11, 1, 2, 262144, ROMTYPE_ODD , _T("391524-01"), 0xd55c6ec6,0x3341108d,0x3a402882,0xb5ef9d3b,0x242cbf3c,0x8ab1a3e9) + { _T("KS ROM v3.0 (A4000)"), 3, 0, 39, 106, _T("A4000\0"), 524288, 12, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL, + 0x9e6ac152, 0xF0B4E9E2,0x9E12218C,0x2D5BD702,0x0E4E7852,0x97D91FD7 }, + ALTROMPN(12, 1, 1, 262144, ROMTYPE_EVEN, _T("391513-02"), 0x36f64dd0,0x196e9f3f,0x9cad934e,0x181c07da,0x33083b1f,0x0a3c702f) + ALTROMPN(12, 1, 2, 262144, ROMTYPE_ODD , _T("391514-02"), 0x17266a55,0x42fbed34,0x53d1f11c,0xcbde89a9,0x826f2d11,0x75cca5cc) + { _T("KS ROM v3.1 (A4000)"), 3, 1, 40, 70, _T("A4000\0"), 524288, 13, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL, + 0x2b4566f1, 0x81c631dd,0x096bbb31,0xd2af9029,0x9c76b774,0xdb74076c }, + ALTROM(13, 1, 1, 262144, ROMTYPE_EVEN, 0xf9cbecc9,0x138d8cb4,0x3b8312fe,0x16d69070,0xde607469,0xb3d4078e) + ALTROM(13, 1, 2, 262144, ROMTYPE_ODD , 0xf8248355,0xc2379547,0x9fae3910,0xc185512c,0xa268b82f,0x1ae4fe05) + { _T("KS ROM v3.1 (A500,A600,A2000)"), 3, 1, 40, 63, _T("A500\0A600\0A2000\0"), 524288, 14, 0, 0, ROMTYPE_KICK, 0, 0, NULL, + 0xfc24ae0d, 0x3B7F1493,0xB27E2128,0x30F989F2,0x6CA76C02,0x049F09CA }, + { _T("KS ROM v3.1 (A1200)"), 3, 1, 40, 68, _T("A1200\0"), 524288, 15, 1, 0, ROMTYPE_KICK, 0, 0, NULL, + 0x1483a091, 0xE2154572,0x3FE8374E,0x91342617,0x604F1B3D,0x703094F1 }, + ALTROMPN(15, 1, 1, 262144, ROMTYPE_EVEN, _T("391773-01"), 0x08dbf275,0xb8800f5f,0x90929810,0x9ea69690,0xb1b8523f,0xa22ddb37) + ALTROMPN(15, 1, 2, 262144, ROMTYPE_ODD , _T("391774-01"), 0x16c07bf8,0x90e331be,0x1970b0e5,0x3f53a9b0,0x390b51b5,0x9b3869c2) + { _T("KS ROM v3.1 (A3000)"), 3, 1, 40, 68, _T("A3000\0"), 524288, 61, 2, 0, ROMTYPE_KICK, 0, 0, NULL, + 0xefb239cc, 0xF8E210D7,0x2B4C4853,0xE0C9B85D,0x223BA20E,0x3D1B36EE }, + ALTROM(61, 1, 1, 262144, ROMTYPE_EVEN, 0x286b9a0d,0x6763a225,0x8ec493f7,0x408cf663,0x110dae9a,0x17803ad1) + ALTROM(61, 1, 2, 262144, ROMTYPE_ODD , 0x0b8cde6a,0x5f02e97b,0x48ebbba8,0x7d516a56,0xb0400c6f,0xc3434d8d) + { _T("KS ROM v3.1 (A4000)(Cloanto)"), 3, 1, 40, 68, _T("A4000\0"), 524288, 31, 2 | 4, 1, ROMTYPE_KICK, 0, 0, NULL, + 0x43b6dd22, 0xC3C48116,0x0866E60D,0x085E436A,0x24DB3617,0xFF60B5F9 }, + { _T("KS ROM v3.1 (A4000)"), 3, 1, 40, 68, _T("A4000\0"), 524288, 16, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL, + 0xd6bae334, 0x5FE04842,0xD04A4897,0x20F0F4BB,0x0E469481,0x99406F49 }, + ALTROM(16, 1, 1, 262144, ROMTYPE_EVEN, 0xb2af34f8,0x24e52b5e,0xfc020495,0x17387ab7,0xb1a1475f,0xc540350e) + ALTROM(16, 1, 2, 262144, ROMTYPE_ODD , 0xe65636a3,0x313c7cbd,0xa5779e56,0xf19a41d3,0x4e760f51,0x7626d882) + { _T("KS ROM v3.1 (A4000T)"), 3, 1, 40, 70, _T("A4000T\0"), 524288, 17, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL, + 0x75932c3a, 0xB0EC8B84,0xD6768321,0xE01209F1,0x1E6248F2,0xF5281A21 }, + ALTROMPN(17, 1, 1, 262144, ROMTYPE_EVEN, _T("391657-01"), 0x0ca94f70,0xb3806eda,0xcb3362fc,0x16a154ce,0x1eeec5bf,0x5bc24789) + ALTROMPN(17, 1, 2, 262144, ROMTYPE_ODD , _T("391658-01"), 0xdfe03120,0xcd7a706c,0x431b04d8,0x7814d3a2,0xd8b39710,0x0cf44c0c) + { _T("KS ROM v3.X (A4000)(Cloanto)"), 3, 10, 45, 57, _T("A4000\0"), 524288, 46, 2 | 4, 1, ROMTYPE_KICK, 0, 0, NULL, + 0x3ac99edc, 0x3cbfc9e1,0xfe396360,0x157bd161,0xde74fc90,0x1abee7ec }, - { _T("CD32 KS ROM v3.1"), 3, 1, 40, 60, _T("CD32\0"), 524288, 18, 1, 0, ROMTYPE_KICKCD32, 0, 0, NULL, - 0x1e62d4a5, 0x3525BE88,0x87F79B59,0x29E017B4,0x2380A79E,0xDFEE542D }, - { _T("CD32 extended ROM"), 3, 1, 40, 60, _T("CD32\0"), 524288, 19, 1, 0, ROMTYPE_EXTCD32, 0, 0, NULL, - 0x87746be2, 0x5BEF3D62,0x8CE59CC0,0x2A66E6E4,0xAE0DA48F,0x60E78F7F }, + { _T("CD32 KS ROM v3.1"), 3, 1, 40, 60, _T("CD32\0"), 524288, 18, 1, 0, ROMTYPE_KICKCD32, 0, 0, NULL, + 0x1e62d4a5, 0x3525BE88,0x87F79B59,0x29E017B4,0x2380A79E,0xDFEE542D }, + { _T("CD32 extended ROM"), 3, 1, 40, 60, _T("CD32\0"), 524288, 19, 1, 0, ROMTYPE_EXTCD32, 0, 0, NULL, + 0x87746be2, 0x5BEF3D62,0x8CE59CC0,0x2A66E6E4,0xAE0DA48F,0x60E78F7F }, - /* plain CD32 rom */ - { _T("CD32 ROM (KS + extended)"), 3, 1, 40, 60, _T("CD32\0"), 2 * 524288, 64, 1, 0, ROMTYPE_KICKCD32 | ROMTYPE_EXTCD32 | ROMTYPE_CD32, 0, 0, NULL, - 0xf5d4f3c8, 0x9fa14825,0xc40a2475,0xa2eba5cf,0x325bd483,0xc447e7c1 }, - /* real CD32 rom dump 391640-03 */ - ALTROMPN(64, 1, 1, 2 * 524288, ROMTYPE_CD32, _T("391640-03"), 0xa4fbc94a, 0x816ce6c5,0x07787585,0x0c7d4345,0x2230a9ba,0x3a2902db) + /* plain CD32 rom */ + { _T("CD32 ROM (KS + extended)"), 3, 1, 40, 60, _T("CD32\0"), 2 * 524288, 64, 1, 0, ROMTYPE_KICKCD32 | ROMTYPE_EXTCD32 | ROMTYPE_CD32, 0, 0, NULL, + 0xf5d4f3c8, 0x9fa14825,0xc40a2475,0xa2eba5cf,0x325bd483,0xc447e7c1 }, + /* real CD32 rom dump 391640-03 */ + ALTROMPN(64, 1, 1, 2 * 524288, ROMTYPE_CD32, _T("391640-03"), 0xa4fbc94a, 0x816ce6c5,0x07787585,0x0c7d4345,0x2230a9ba,0x3a2902db ) + + { _T("CD32 Full Motion Video Cartridge ROM"), 3, 1, 40, 30, _T("CD32FMV\0"), 262144, 23, 1, 0, ROMTYPE_CD32CART, 0, 0, NULL, + 0xc35c37bf, 0x03ca81c7,0xa7b259cf,0x64bc9582,0x863eca0f,0x6529f435 }, + { _T("CD32 Full Motion Video Cartridge ROM"), 3, 1, 40, 22, _T("CD32FMV\0"), 262144, 74, 1, 0, ROMTYPE_CD32CART, 0, 0, _T("391777-01"), + 0xf11158eb, 0x94e469a7,0x6030dcb2,0x99ebc752,0x0aaeef9d,0xb54284cf }, - { _T("CD32 Full Motion Video Cartridge ROM"), 3, 1, 40, 30, _T("CD32FMV\0"), 262144, 23, 1, 0, ROMTYPE_CD32CART, 0, 0, NULL, - 0xc35c37bf, 0x03ca81c7,0xa7b259cf,0x64bc9582,0x863eca0f,0x6529f435 }, - { _T("CD32 Full Motion Video Cartridge ROM"), 3, 1, 40, 22, _T("CD32FMV\0"), 262144, 74, 1, 0, ROMTYPE_CD32CART, 0, 0, _T("391777-01"), - 0xf11158eb, 0x94e469a7,0x6030dcb2,0x99ebc752,0x0aaeef9d,0xb54284cf }, + { _T("CDTV extended ROM v1.00"), 1, 0, 1, 0, _T("CDTV\0"), 262144, 20, 0, 0, ROMTYPE_EXTCDTV, 0, 0, NULL, + 0x42baa124, 0x7BA40FFA,0x17E500ED,0x9FED041F,0x3424BD81,0xD9C907BE }, + ALTROMPN(20, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("252606-01"), 0x791cb14b,0x277a1778,0x92449635,0x3ffe56be,0x68063d2a,0x334360e4) + ALTROMPN(20, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, _T("252607-01"), 0xaccbbc2e,0x41b06d16,0x79c6e693,0x3c3378b7,0x626025f7,0x641ebc5c) + { _T("CDTV extended ROM v2.07"), 2, 7, 2, 7, _T("CDTV\0"), 262144, 22, 0, 0, ROMTYPE_EXTCDTV, 0, 0, NULL, + 0xceae68d2, 0x5BC114BB,0xA29F60A6,0x14A31174,0x5B3E2464,0xBFA06846 }, + ALTROM(22, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x36d73cb8,0x9574e546,0x4b390697,0xf28f9a43,0x4e604e5e,0xf5e5490a) + ALTROM(22, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, 0x6e84dce7,0x01a0679e,0x895a1a0f,0x559c7253,0xf539606b,0xd447b54f) + { _T("CDTV/A570 extended ROM v2.30"), 2, 30, 2, 30, _T("CDTV\0"), 262144, 21, 0, 0, ROMTYPE_EXTCDTV, 0, 0, _T("391298-01"), + 0x30b54232, 0xED7E461D,0x1FFF3CDA,0x321631AE,0x42B80E3C,0xD4FA5EBB }, + ALTROM(21, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x48e4d74f,0x54946054,0x2269e410,0x36018402,0xe1f6b855,0xfd89092b) + ALTROM(21, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, 0x8a54f362,0x03df800f,0x032046fd,0x892f6e7e,0xec08b76d,0x33981e8c) + { _T("CDTV-CR extended ROM v3.32"), 3, 32, 3, 32, _T("CDTVCR\0"), 262144, 107, 0, 0, ROMTYPE_EXTCDTV, 0, 0, NULL, + 0x581a85cf, 0xd6b8d3f2,0x854eba9b,0x2d514579,0x9529e8b3,0x3b85e0b4 }, + { _T("CDTV-CR extended ROM v3.44"), 3, 44, 3, 44, _T("CDTVCR\0"), 262144, 108, 0, 0, ROMTYPE_EXTCDTV, 0, 0, NULL, + 0x0b7bd64f, 0x3b160c5a,0xbe79f10a,0xe6924332,0x8004bb9e,0x3162b648 }, - { _T("CDTV extended ROM v1.00"), 1, 0, 1, 0, _T("CDTV\0"), 262144, 20, 0, 0, ROMTYPE_EXTCDTV, 0, 0, NULL, - 0x42baa124, 0x7BA40FFA,0x17E500ED,0x9FED041F,0x3424BD81,0xD9C907BE }, - ALTROMPN(20, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("252606-01"), 0x791cb14b,0x277a1778,0x92449635,0x3ffe56be,0x68063d2a,0x334360e4) - ALTROMPN(20, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, _T("252607-01"), 0xaccbbc2e,0x41b06d16,0x79c6e693,0x3c3378b7,0x626025f7,0x641ebc5c) - { - _T("CDTV extended ROM v2.07"), 2, 7, 2, 7, _T("CDTV\0"), 262144, 22, 0, 0, ROMTYPE_EXTCDTV, 0, 0, NULL, - 0xceae68d2, 0x5BC114BB,0xA29F60A6,0x14A31174,0x5B3E2464,0xBFA06846 - }, - ALTROM(22, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x36d73cb8,0x9574e546,0x4b390697,0xf28f9a43,0x4e604e5e,0xf5e5490a) - ALTROM(22, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, 0x6e84dce7,0x01a0679e,0x895a1a0f,0x559c7253,0xf539606b,0xd447b54f) - { - _T("CDTV/A570 extended ROM v2.30"), 2, 30, 2, 30, _T("CDTV\0"), 262144, 21, 0, 0, ROMTYPE_EXTCDTV, 0, 0, _T("391298-01"), - 0x30b54232, 0xED7E461D,0x1FFF3CDA,0x321631AE,0x42B80E3C,0xD4FA5EBB - }, - ALTROM(21, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x48e4d74f,0x54946054,0x2269e410,0x36018402,0xe1f6b855,0xfd89092b) - ALTROM(21, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, 0x8a54f362,0x03df800f,0x032046fd,0x892f6e7e,0xec08b76d,0x33981e8c) - { - _T("CDTV-CR extended ROM v3.32"), 3, 32, 3, 32, _T("CDTVCR\0"), 262144, 107, 0, 0, ROMTYPE_EXTCDTV, 0, 0, NULL, - 0x581a85cf, 0xd6b8d3f2,0x854eba9b,0x2d514579,0x9529e8b3,0x3b85e0b4 - }, - { _T("CDTV-CR extended ROM v3.44"), 3, 44, 3, 44, _T("CDTVCR\0"), 262144, 108, 0, 0, ROMTYPE_EXTCDTV, 0, 0, NULL, - 0x0b7bd64f, 0x3b160c5a,0xbe79f10a,0xe6924332,0x8004bb9e,0x3162b648 }, + { _T("A1000 bootstrap ROM"), 0, 0, 0, 0, _T("A1000\0"), 65536, 24, 0, 0, ROMTYPE_KICK, 0, 0, NULL, + 0x0b1ad2d0, 0xBA93B8B8,0x5CA0D83A,0x68225CC3,0x3B95050D,0x72D2FDD7 }, + ALTROM(24, 1, 1, 8192, 0, 0x62f11c04, 0xC87F9FAD,0xA4EE4E69,0xF3CCA0C3,0x6193BE82,0x2B9F5FE6) + ALTROMPN(24, 2, 1, 4096, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("252179-01"), 0x42553bc4,0x8855a97f,0x7a44e3f6,0x2d1c88d9,0x38fee1f4,0xc606af5b) + ALTROMPN(24, 2, 2, 4096, ROMTYPE_ODD | ROMTYPE_8BIT, _T("252180-01"), 0x8e5b9a37,0xd10f1564,0xb99f5ffe,0x108fa042,0x362e877f,0x569de2c3) - { _T("A1000 bootstrap ROM"), 0, 0, 0, 0, _T("A1000\0"), 65536, 24, 0, 0, ROMTYPE_KICK, 0, 0, NULL, - 0x0b1ad2d0, 0xBA93B8B8,0x5CA0D83A,0x68225CC3,0x3B95050D,0x72D2FDD7 }, - ALTROM(24, 1, 1, 8192, 0, 0x62f11c04, 0xC87F9FAD,0xA4EE4E69,0xF3CCA0C3,0x6193BE82,0x2B9F5FE6) - ALTROMPN(24, 2, 1, 4096, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("252179-01"), 0x42553bc4,0x8855a97f,0x7a44e3f6,0x2d1c88d9,0x38fee1f4,0xc606af5b) - ALTROMPN(24, 2, 2, 4096, ROMTYPE_ODD | ROMTYPE_8BIT, _T("252180-01"), 0x8e5b9a37,0xd10f1564,0xb99f5ffe,0x108fa042,0x362e877f,0x569de2c3) + { _T("The Diagnostic 2.0 (Logica)"), 2, 0, 2, 0, _T("LOGICA\0"), 524288, 72, 0, 0, ROMTYPE_KICK | ROMTYPE_SPECIALKICK, 0, 0, NULL, + 0x8484f426, 0xba10d161,0x66b2e2d6,0x177c979c,0x99edf846,0x2b21651e }, - { - _T("The Diagnostic 2.0 (Logica)"), 2, 0, 2, 0, _T("LOGICA\0"), 524288, 72, 0, 0, ROMTYPE_KICK | ROMTYPE_SPECIALKICK, 0, 0, NULL, - 0x8484f426, 0xba10d161,0x66b2e2d6,0x177c979c,0x99edf846,0x2b21651e - }, + { _T("Freezer: Action Replay Mk I v1.00"), 1, 0, 1, 0, _T("AR\0"), 65536, 52, 0, 0, ROMTYPE_AR, 0, 1, NULL, + 0x2d921771, 0x1EAD9DDA,0x2DAD2914,0x6441F5EF,0x72183750,0x22E01248 }, + ALTROM(52, 1, 1, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x82d6eb87, 0x7c9bac11,0x28666017,0xeee6f019,0x63fb3890,0x7fbea355) + ALTROM(52, 1, 2, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, 0x40ae490c, 0x81d8e432,0x01b73fd9,0x2e204ebd,0x68af8602,0xb62ce397) + { _T("Freezer: Action Replay Mk I v1.50"), 1, 50, 1, 50, _T("AR\0"), 65536, 25, 0, 0, ROMTYPE_AR, 0, 1, NULL, + 0xf82c4258, 0x843B433B,0x2C56640E,0x045D5FDC,0x854DC6B1,0xA4964E7C }, + ALTROM(25, 1, 1, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x7fbd6de2, 0xb5f71a5c,0x09d65ecc,0xa8a3bc93,0x93558461,0xca190228) + ALTROM(25, 1, 2, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, 0x43018069, 0xad8ff242,0xb2cbf125,0x1fc53a73,0x581cf57a,0xb69cee00) + { _T("Freezer: Action Replay Mk II v2.05"), 2, 5, 2, 5, _T("AR\0"), 131072, 26, 0, 0, ROMTYPE_AR2, 0, 1, NULL, + 0x1287301f, 0xF6601DE8,0x888F0050,0x72BF562B,0x9F533BBC,0xAF1B0074 }, + { _T("Freezer: Action Replay Mk II v2.12"), 2, 12, 2, 12, _T("AR\0"), 131072, 27, 0, 0, ROMTYPE_AR2, 0, 1, NULL, + 0x804d0361, 0x3194A07A,0x0A82D8B5,0xF2B6AEFA,0x3CA581D6,0x8BA8762B }, + { _T("Freezer: Action Replay Mk II v2.14"), 2, 14, 2, 14, _T("AR\0"), 131072, 28, 0, 0, ROMTYPE_AR2, 0, 1, NULL, + 0x49650e4f, 0x255D6DF6,0x3A4EAB0A,0x838EB1A1,0x6A267B09,0x59DFF634 }, + { _T("Freezer: Action Replay Mk III v3.09"), 3, 9, 3, 9, _T("AR\0"), 262144, 29, 0, 0, ROMTYPE_AR2, 0, 1, NULL, + 0x0ed9b5aa, 0x0FF3170A,0xBBF0CA64,0xC9DD93D6,0xEC0C7A01,0xB5436824 }, + ALTROM(29, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x2b84519f, 0x7841873b,0xf009d834,0x1dfa2794,0xb3751bac,0xf86adcc8) + ALTROM(29, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, 0x1d35bd56, 0x6464be16,0x26b51949,0x9e76e4e3,0x409e8016,0x515d48b6) + { _T("Freezer: Action Replay Mk III v3.17"), 3, 17, 3, 17, _T("AR\0"), 262144, 30, 0, 0, ROMTYPE_AR2, 0, 1, NULL, + 0xc8a16406, 0x5D4987C2,0xE3FFEA8B,0x1B02E314,0x30EF190F,0x2DB76542 }, + { _T("Freezer: Action Replay 1200"), 0, 0, 0, 0, _T("AR\0"), 262144, 47, 0, 0, ROMTYPE_AR, 0, 1, NULL, + 0x8d760101, 0x0F6AB834,0x2810094A,0xC0642F62,0xBA42F78B,0xC0B07E6A }, - { _T("Freezer: Action Replay Mk I v1.00"), 1, 0, 1, 0, _T("AR\0"), 65536, 52, 0, 0, ROMTYPE_AR, 0, 1, NULL, - 0x2d921771, 0x1EAD9DDA,0x2DAD2914,0x6441F5EF,0x72183750,0x22E01248 }, - ALTROM(52, 1, 1, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x82d6eb87, 0x7c9bac11,0x28666017,0xeee6f019,0x63fb3890,0x7fbea355) - ALTROM(52, 1, 2, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, 0x40ae490c, 0x81d8e432,0x01b73fd9,0x2e204ebd,0x68af8602,0xb62ce397) - { - _T("Freezer: Action Replay Mk I v1.50"), 1, 50, 1, 50, _T("AR\0"), 65536, 25, 0, 0, ROMTYPE_AR, 0, 1, NULL, - 0xf82c4258, 0x843B433B,0x2C56640E,0x045D5FDC,0x854DC6B1,0xA4964E7C - }, - ALTROM(25, 1, 1, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x7fbd6de2, 0xb5f71a5c,0x09d65ecc,0xa8a3bc93,0x93558461,0xca190228) - ALTROM(25, 1, 2, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, 0x43018069, 0xad8ff242,0xb2cbf125,0x1fc53a73,0x581cf57a,0xb69cee00) - { - _T("Freezer: Action Replay Mk II v2.05"), 2, 5, 2, 5, _T("AR\0"), 131072, 26, 0, 0, ROMTYPE_AR2, 0, 1, NULL, - 0x1287301f, 0xF6601DE8,0x888F0050,0x72BF562B,0x9F533BBC,0xAF1B0074 - }, - { _T("Freezer: Action Replay Mk II v2.12"), 2, 12, 2, 12, _T("AR\0"), 131072, 27, 0, 0, ROMTYPE_AR2, 0, 1, NULL, - 0x804d0361, 0x3194A07A,0x0A82D8B5,0xF2B6AEFA,0x3CA581D6,0x8BA8762B }, - { _T("Freezer: Action Replay Mk II v2.14"), 2, 14, 2, 14, _T("AR\0"), 131072, 28, 0, 0, ROMTYPE_AR2, 0, 1, NULL, - 0x49650e4f, 0x255D6DF6,0x3A4EAB0A,0x838EB1A1,0x6A267B09,0x59DFF634 }, - { _T("Freezer: Action Replay Mk III v3.09"), 3, 9, 3, 9, _T("AR\0"), 262144, 29, 0, 0, ROMTYPE_AR2, 0, 1, NULL, - 0x0ed9b5aa, 0x0FF3170A,0xBBF0CA64,0xC9DD93D6,0xEC0C7A01,0xB5436824 }, - ALTROM(29, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x2b84519f, 0x7841873b,0xf009d834,0x1dfa2794,0xb3751bac,0xf86adcc8) - ALTROM(29, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, 0x1d35bd56, 0x6464be16,0x26b51949,0x9e76e4e3,0x409e8016,0x515d48b6) - { - _T("Freezer: Action Replay Mk III v3.17"), 3, 17, 3, 17, _T("AR\0"), 262144, 30, 0, 0, ROMTYPE_AR2, 0, 1, NULL, - 0xc8a16406, 0x5D4987C2,0xE3FFEA8B,0x1B02E314,0x30EF190F,0x2DB76542 - }, - { _T("Freezer: Action Replay 1200"), 0, 0, 0, 0, _T("AR\0"), 262144, 47, 0, 0, ROMTYPE_AR, 0, 1, NULL, - 0x8d760101, 0x0F6AB834,0x2810094A,0xC0642F62,0xBA42F78B,0xC0B07E6A }, + { _T("Freezer: Action Cartridge Super IV Professional"), 0, 0, 0, 0, _T("SUPERIV\0"), 0, 62, 0, 0, ROMTYPE_SUPERIV, 0, 1, NULL, + 0xffffffff, 0, 0, 0, 0, 0, _T("SuperIV") }, + { _T("Freezer: Action Cart. Super IV Pro (+ROM v4.3)"), 4, 3, 4, 3, _T("SUPERIV\0"), 170368, 60, 0, 0, ROMTYPE_SUPERIV, 0, 1, NULL, + 0xe668a0be, 0x633A6E65,0xA93580B8,0xDDB0BE9C,0x9A64D4A1,0x7D4B4801 }, + { _T("Freezer: X-Power Professional 500 v1.2"), 1, 2, 1, 2, _T("XPOWER\0"), 131072, 65, 0, 0, ROMTYPE_XPOWER, 0, 1, NULL, + 0x9e70c231, 0xa2977a1c,0x41a8ca7d,0x4af4a168,0x726da542,0x179d5963 }, + ALTROM(65, 1, 1, 65536, ROMTYPE_EVEN|ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0xf98742e4,0xe8e683ba,0xd8b38d1f,0x79f3ad83,0xa9e67c6f,0xa91dc96c) + ALTROM(65, 1, 2, 65536, ROMTYPE_ODD |ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0xdfb9984b,0x8d6bdd49,0x469ec8e2,0x0143fbb3,0x72e92500,0x99f07910) + { _T("Freezer: X-Power Professional 500 v1.3"), 1, 3, 1, 3, _T("XPOWER\0"), 131072, 68, 0, 0, ROMTYPE_XPOWER, 0, 1, NULL, + 0x31e057f0, 0x84650266,0x465d1859,0x7fd71dee,0x00775930,0xb7e450ee }, + ALTROM(68, 1, 1, 65536, ROMTYPE_EVEN|ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0x0b2ce0c7,0x45ad5456,0x89192404,0x956f47ce,0xf66a5274,0x57ace33b) + ALTROM(68, 1, 2, 65536, ROMTYPE_ODD |ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0x34580c35,0x8ad42566,0x7364f238,0x978f4381,0x08f8d5ec,0x470e72ea) + { _T("Freezer: Nordic Power v1.5"), 1, 5, 1, 5, _T("NPOWER\0"), 65536, 69, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL, + 0x83b4b21c, 0xc56ced25,0x506a5aab,0x3fa13813,0x4fc9e5ae,0x0f9d3709 }, + ALTROM(69, 1, 1, 32768, ROMTYPE_EVEN|ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0xdd207174,0xae67652d,0x64f5db20,0x0f4b2110,0xee59567f,0xfbd90a1b) + ALTROM(69, 1, 2, 32768, ROMTYPE_ODD |ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0x8f93d85d,0x73c62d21,0x40c0c092,0x6315b702,0xdd5d0f05,0x3dad7fab) + { _T("Freezer: Nordic Power v2.0"), 2, 0, 2, 0, _T("NPOWER\0"), 65536, 67, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL, + 0xa4db2906, 0x0aec68f7,0x25470c89,0x6b699ff4,0x6623dec5,0xc777466e }, + ALTROM(67, 1, 1, 32768, ROMTYPE_EVEN|ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0xb21be46c,0x50dc607c,0xce976bbd,0x3841eaf0,0x591ddc7e,0xa1939ad2) + ALTROM(67, 1, 2, 32768, ROMTYPE_ODD |ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0x96057aed,0xdd9209e2,0x1d5edfc1,0xcdb52abe,0x93de0f35,0xc43da696) + { _T("Freezer: Nordic Power v3.0"), 3, 0, 3, 0, _T("NPOWER\0"), 65536, 70, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL, + 0x72850aef, 0x59c91d1f,0xa8f118f9,0x0bdba05a,0x9ae788d7,0x7a6cc7c9 }, + ALTROM(70, 1, 1, 32768, ROMTYPE_EVEN|ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0xf3330e1f,0x3a597db2,0xb7d11b6c,0xb8e13496,0xc215f223,0x88c4ca3c) + ALTROM(70, 1, 2, 32768, ROMTYPE_ODD |ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0xee58e0f9,0x4148f4cb,0xb42cec33,0x8ca144de,0xd4f54118,0xe0f185dd) + { _T("Freezer: Nordic Power v3.2"), 3, 2, 3, 2, _T("NPOWER\0"), 65536, 115, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL, + 0x46158b6e, 0xd8c3f5af,0x5f109c61,0x5f6acb38,0x68fe6c06,0x580041b5 }, + ALTROM(115, 1, 1, 32768, ROMTYPE_EVEN|ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0x4bfc71de,0x51914de0,0xdc0f055a,0x29ca188d,0xa7f61914,0xfdecbd07) + ALTROM(115, 1, 2, 32768, ROMTYPE_ODD |ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0x923ec443,0x9f1e5334,0xaa620745,0xf4d0c50e,0x8736543b,0x6d4366c5) + { _T("Freezer: Pro Access v2.17"), 2, 17, 2, 17, _T("PROACCESS\0"), 65536, 116, 0, 0, ROMTYPE_AR, 0, 1, NULL, + 0xc4c265cd, 0x6a5c0d99,0x69a624dc,0x1b437aec,0x5dbcd4c7,0x2ce9064a }, + ALTROM(116, 1, 1, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x1909f7e9, 0x5abe9b9d,0xaae328c8,0x134e2b62,0x7b33b698,0xe342afc2) + ALTROM(116, 1, 2, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, 0xa3927c72, 0x7adc9352,0x2d112ae9,0x23b9a70d,0x951b1e7a,0xba800ea6) - { _T("Freezer: Action Cartridge Super IV Professional"), 0, 0, 0, 0, _T("SUPERIV\0"), 0, 62, 0, 0, ROMTYPE_SUPERIV, 0, 1, NULL, - 0xffffffff, 0, 0, 0, 0, 0, _T("SuperIV") }, - { _T("Freezer: Action Cart. Super IV Pro (+ROM v4.3)"), 4, 3, 4, 3, _T("SUPERIV\0"), 170368, 60, 0, 0, ROMTYPE_SUPERIV, 0, 1, NULL, - 0xe668a0be, 0x633A6E65,0xA93580B8,0xDDB0BE9C,0x9A64D4A1,0x7D4B4801 }, - { _T("Freezer: X-Power Professional 500 v1.2"), 1, 2, 1, 2, _T("XPOWER\0"), 131072, 65, 0, 0, ROMTYPE_XPOWER, 0, 1, NULL, - 0x9e70c231, 0xa2977a1c,0x41a8ca7d,0x4af4a168,0x726da542,0x179d5963 }, - ALTROM(65, 1, 1, 65536, ROMTYPE_EVEN | ROMTYPE_SCRAMBLED | ROMTYPE_8BIT, 0xf98742e4,0xe8e683ba,0xd8b38d1f,0x79f3ad83,0xa9e67c6f,0xa91dc96c) - ALTROM(65, 1, 2, 65536, ROMTYPE_ODD | ROMTYPE_SCRAMBLED | ROMTYPE_8BIT, 0xdfb9984b,0x8d6bdd49,0x469ec8e2,0x0143fbb3,0x72e92500,0x99f07910) - { - _T("Freezer: X-Power Professional 500 v1.3"), 1, 3, 1, 3, _T("XPOWER\0"), 131072, 68, 0, 0, ROMTYPE_XPOWER, 0, 1, NULL, - 0x31e057f0, 0x84650266,0x465d1859,0x7fd71dee,0x00775930,0xb7e450ee - }, - ALTROM(68, 1, 1, 65536, ROMTYPE_EVEN | ROMTYPE_SCRAMBLED | ROMTYPE_8BIT, 0x0b2ce0c7,0x45ad5456,0x89192404,0x956f47ce,0xf66a5274,0x57ace33b) - ALTROM(68, 1, 2, 65536, ROMTYPE_ODD | ROMTYPE_SCRAMBLED | ROMTYPE_8BIT, 0x34580c35,0x8ad42566,0x7364f238,0x978f4381,0x08f8d5ec,0x470e72ea) - { - _T("Freezer: Nordic Power v1.5"), 1, 5, 1, 5, _T("NPOWER\0"), 65536, 69, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL, - 0x83b4b21c, 0xc56ced25,0x506a5aab,0x3fa13813,0x4fc9e5ae,0x0f9d3709 - }, - ALTROM(69, 1, 1, 32768, ROMTYPE_EVEN | ROMTYPE_SCRAMBLED | ROMTYPE_8BIT, 0xdd207174,0xae67652d,0x64f5db20,0x0f4b2110,0xee59567f,0xfbd90a1b) - ALTROM(69, 1, 2, 32768, ROMTYPE_ODD | ROMTYPE_SCRAMBLED | ROMTYPE_8BIT, 0x8f93d85d,0x73c62d21,0x40c0c092,0x6315b702,0xdd5d0f05,0x3dad7fab) - { - _T("Freezer: Nordic Power v2.0"), 2, 0, 2, 0, _T("NPOWER\0"), 65536, 67, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL, - 0xa4db2906, 0x0aec68f7,0x25470c89,0x6b699ff4,0x6623dec5,0xc777466e - }, - ALTROM(67, 1, 1, 32768, ROMTYPE_EVEN | ROMTYPE_SCRAMBLED | ROMTYPE_8BIT, 0xb21be46c,0x50dc607c,0xce976bbd,0x3841eaf0,0x591ddc7e,0xa1939ad2) - ALTROM(67, 1, 2, 32768, ROMTYPE_ODD | ROMTYPE_SCRAMBLED | ROMTYPE_8BIT, 0x96057aed,0xdd9209e2,0x1d5edfc1,0xcdb52abe,0x93de0f35,0xc43da696) - { - _T("Freezer: Nordic Power v3.0"), 3, 0, 3, 0, _T("NPOWER\0"), 65536, 70, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL, - 0x72850aef, 0x59c91d1f,0xa8f118f9,0x0bdba05a,0x9ae788d7,0x7a6cc7c9 - }, - ALTROM(70, 1, 1, 32768, ROMTYPE_EVEN | ROMTYPE_SCRAMBLED | ROMTYPE_8BIT, 0xf3330e1f,0x3a597db2,0xb7d11b6c,0xb8e13496,0xc215f223,0x88c4ca3c) - ALTROM(70, 1, 2, 32768, ROMTYPE_ODD | ROMTYPE_SCRAMBLED | ROMTYPE_8BIT, 0xee58e0f9,0x4148f4cb,0xb42cec33,0x8ca144de,0xd4f54118,0xe0f185dd) - { - _T("Freezer: Nordic Power v3.2"), 3, 2, 3, 2, _T("NPOWER\0"), 65536, 115, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL, - 0x46158b6e, 0xd8c3f5af,0x5f109c61,0x5f6acb38,0x68fe6c06,0x580041b5 - }, - ALTROM(115, 1, 1, 32768, ROMTYPE_EVEN | ROMTYPE_SCRAMBLED | ROMTYPE_8BIT, 0x4bfc71de,0x51914de0,0xdc0f055a,0x29ca188d,0xa7f61914,0xfdecbd07) - ALTROM(115, 1, 2, 32768, ROMTYPE_ODD | ROMTYPE_SCRAMBLED | ROMTYPE_8BIT, 0x923ec443,0x9f1e5334,0xaa620745,0xf4d0c50e,0x8736543b,0x6d4366c5) - { - _T("Freezer: Pro Access v2.17"), 2, 17, 2, 17, _T("PROACCESS\0"), 65536, 116, 0, 0, ROMTYPE_AR, 0, 1, NULL, - 0xc4c265cd, 0x6a5c0d99,0x69a624dc,0x1b437aec,0x5dbcd4c7,0x2ce9064a - }, - ALTROM(116, 1, 1, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x1909f7e9, 0x5abe9b9d,0xaae328c8,0x134e2b62,0x7b33b698,0xe342afc2) - ALTROM(116, 1, 2, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, 0xa3927c72, 0x7adc9352,0x2d112ae9,0x23b9a70d,0x951b1e7a,0xba800ea6) + { _T("Freezer: HRTMon v2.37 (built-in)"), 0, 0, 0, 0, _T("HRTMON\0"), 0, 63, 0, 0, ROMTYPE_HRTMON, 0, 1, NULL, + 0xffffffff, 0, 0, 0, 0, 0, _T("HRTMon") }, - { - _T("Freezer: HRTMon v2.37 (built-in)"), 0, 0, 0, 0, _T("HRTMON\0"), 0, 63, 0, 0, ROMTYPE_HRTMON, 0, 1, NULL, - 0xffffffff, 0, 0, 0, 0, 0, _T("HRTMon") - }, + { _T("A2090a"), 0, 0, 0, 0, _T("A2090A\0"), 16384, 122, 0, 0, ROMTYPE_A2090, 0, 0, NULL, + 0x73fe45a7, 0x77ce9091,0x4be5a3bf,0x6f26b343,0x062b5bd8,0xc63c3754 }, + ALTROMPN(122, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, _T("315097-01"), 0x150b116c,0x8011d873,0x3be53db0,0x79dfe319,0x7ffb8634,0x1baa6dbd) + ALTROMPN(122, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("315098-01"), 0xbe422e3b,0x64ad1646,0x030db10f,0x54f13f64,0x7d449e4d,0x17f9ab5c) + { _T("A590/A2091 v4.6"), 4, 6, 4, 6, _T("A590\0A2091\0"), 16384, 202, 0, 0, ROMTYPE_A2091, 0, 0, NULL, + 0x00a38212, 0xa029a4de,0x56e5539d,0x0ee00588,0xc2634f13,0x29f06269 }, + ALTROMPN(202, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390389-02"), 0x26013266,0x60dedda8,0xd406b276,0x2ad1504a,0x88a4d6e2,0x9c0fb10d) + ALTROMPN(202, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390388-02"), 0x6c9cb089,0xbd8c6bb7,0x9ae91a4d,0x1b9ee76f,0xdd11aaf9,0x7ca4358b) + { _T("A590/A2091 v6.0"), 6, 0, 6, 0, _T("A590\0A2091\0"), 16384, 53, 0, 0, ROMTYPE_A2091, 0, 0, NULL, + 0x8396cf4e, 0x5E03BC61,0x8C862ABE,0x7BF79723,0xB4EEF4D2,0x1859A0F2 }, + ALTROMPN(53, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390389-03"), 0xb0b8cf24,0xfcf40175,0x05f4d441,0x814b45d5,0x59c19eab,0x43816b30) + ALTROMPN(53, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390388-03"), 0x2e77bbff,0x8a098845,0x068f32cf,0xa4d34a27,0x8cd290f6,0x1d35a52c) + { _T("A590/A2091 v6.1"), 6, 1, 6, 1, _T("A590\0A2091\0"), 16384, 206, 0, 0, ROMTYPE_A2091, 0, 0, NULL, + 0xaccf6452, 0xf56061ab,0x37768281,0x94d89729,0x802ee7ae,0x1de9df90 }, + ALTROMPN(206, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390722-01"), 0xc460cfdb,0x0de457da,0xec3b84f7,0x5e8fb344,0xdefe24ce,0x56cda3e0) + ALTROMPN(206, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390721-01"), 0x00dbf615,0x503940d0,0x4fb3b49e,0xaa61100f,0xd3a48701,0x8b35e25a) + { _T("A590/A2091 v6.6"), 6, 6, 6, 6, _T("A590\0A2091\0"), 16384, 54, 0, 0, ROMTYPE_A2091, 0, 0, NULL, + 0x33e00a7a, 0x739BB828,0xE874F064,0x9360F59D,0x26B5ED3F,0xBC99BB66 }, + ALTROMPN(54, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390722-02"), 0xe536bbb2,0xfd7f8a6d,0xa18c1b02,0xd07eb990,0xc2467a24,0x183ede12) + ALTROMPN(54, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390721-02"), 0xc0871d25,0xe155f18a,0xbb90cf82,0x0589c15e,0x70559d3b,0x6b391af8) + { _T("A590/A2091 v7.0"), 7, 0, 7, 0, _T("A590\0A2091\0"), 16384, 55, 0, 0, ROMTYPE_A2091, 0, 0, NULL, + 0x714a97a2, 0xE50F01BA,0xF2899892,0x85547863,0x72A82C33,0x3C91276E }, + ALTROMPN(55, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390722-03"), 0xa9ccffed,0x149f5bd5,0x2e2d2990,0x4e3de483,0xb9ad7724,0x48e9278e) + ALTROMPN(55, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390721-03"), 0x2942747a,0xdbd7648e,0x79c75333,0x7ff3e4f4,0x91de224b,0xf05e6bb6) + { _T("A590/A2091 Guru ROM v6.14"), 6, 14, 6, 14, _T("A590\0A2091\0"), 32768, 56, 0, 0, ROMTYPE_A2091, 0, 0, NULL, + 0x04e52f93, 0x6DA21B6F,0x5E8F8837,0xD64507CD,0x8A4D5CDC,0xAC4F426B }, + { _T("A4091 v40.9"), 40, 9, 40, 9, _T("A4091\0"), 32768, 57, 0, 0, ROMTYPE_A4091, 0, 0, NULL, + 0x00000000, 0, 0, 0, 0, 0 }, + { _T("A4091 v40.13"), 40, 13, 40, 13, _T("A4091\0"), 32768, 58, 0, 0, ROMTYPE_A4091, 0, 0, _T("391592-02"), + 0x54cb9e85, 0x3CE66919,0xF6FD6797,0x4923A12D,0x91B730F1,0xFFB4A7BA }, + { _T("SupraDrive AMAB6"), 3, 8, 3, 8, _T("SUPRA\0"), 16384, 121, 0, 0, ROMTYPE_SUPRA, 0, 0, _T("AMAB6"), + 0xf40bd349, 0x82168556,0x07525067,0xe9263431,0x1fb9c347,0xe737f247 }, + { _T("SupraDrive AMAB5"), 3, 0, 3, 0, _T("SUPRA\0"), 16384, 134, 0, 0, ROMTYPE_SUPRA, 0, 0, _T("AMAB5"), + 0x75e1b343, 0xf15de74b,0x4e2a9c99,0xa6dc4f6c,0x33f64c76,0x8c043d1c }, + { _T("SupraDrive AMAB4"), 0, 0, 0, 0, _T("SUPRA\0"), 8192, 135, 0, 0, ROMTYPE_SUPRA, 0, 0, _T("AMAB4"), + 0xde7f3f1c, 0xc0acbfc8,0x6641a6c1,0x024870cc,0x519f8c4c,0xbdfe8c64 }, + { _T("SupraDrive AMAB3"), 0, 0, 0, 0, _T("SUPRA\0"), 8192, 136, 0, 0, ROMTYPE_SUPRA, 0, 0, _T("AMAB3"), + 0x3ead39aa, 0x02fe79ee,0xef423098,0xec6add8c,0xb92f849f,0xc64bcd41 }, - { _T("A2090a"), 0, 0, 0, 0, _T("A2090A\0"), 16384, 122, 0, 0, ROMTYPE_A2090, 0, 0, NULL, - 0x73fe45a7, 0x77ce9091,0x4be5a3bf,0x6f26b343,0x062b5bd8,0xc63c3754 }, - ALTROMPN(122, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, _T("315097-01"), 0x150b116c,0x8011d873,0x3be53db0,0x79dfe319,0x7ffb8634,0x1baa6dbd) - ALTROMPN(122, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("315098-01"), 0xbe422e3b,0x64ad1646,0x030db10f,0x54f13f64,0x7d449e4d,0x17f9ab5c) - { - _T("A590/A2091 v4.6"), 4, 6, 4, 6, _T("A590\0A2091\0"), 16384, 202, 0, 0, ROMTYPE_A2091, 0, 0, NULL, - 0x00a38212, 0xa029a4de,0x56e5539d,0x0ee00588,0xc2634f13,0x29f06269 - }, - ALTROMPN(202, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390389-02"), 0x26013266,0x60dedda8,0xd406b276,0x2ad1504a,0x88a4d6e2,0x9c0fb10d) - ALTROMPN(202, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390388-02"), 0x6c9cb089,0xbd8c6bb7,0x9ae91a4d,0x1b9ee76f,0xdd11aaf9,0x7ca4358b) - { - _T("A590/A2091 v6.0"), 6, 0, 6, 0, _T("A590\0A2091\0"), 16384, 53, 0, 0, ROMTYPE_A2091, 0, 0, NULL, - 0x8396cf4e, 0x5E03BC61,0x8C862ABE,0x7BF79723,0xB4EEF4D2,0x1859A0F2 - }, - ALTROMPN(53, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390389-03"), 0xb0b8cf24,0xfcf40175,0x05f4d441,0x814b45d5,0x59c19eab,0x43816b30) - ALTROMPN(53, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390388-03"), 0x2e77bbff,0x8a098845,0x068f32cf,0xa4d34a27,0x8cd290f6,0x1d35a52c) - { - _T("A590/A2091 v6.1"), 6, 1, 6, 1, _T("A590\0A2091\0"), 16384, 206, 0, 0, ROMTYPE_A2091, 0, 0, NULL, - 0xaccf6452, 0xf56061ab,0x37768281,0x94d89729,0x802ee7ae,0x1de9df90 - }, - ALTROMPN(206, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390722-01"), 0xc460cfdb,0x0de457da,0xec3b84f7,0x5e8fb344,0xdefe24ce,0x56cda3e0) - ALTROMPN(206, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390721-01"), 0x00dbf615,0x503940d0,0x4fb3b49e,0xaa61100f,0xd3a48701,0x8b35e25a) - { - _T("A590/A2091 v6.6"), 6, 6, 6, 6, _T("A590\0A2091\0"), 16384, 54, 0, 0, ROMTYPE_A2091, 0, 0, NULL, - 0x33e00a7a, 0x739BB828,0xE874F064,0x9360F59D,0x26B5ED3F,0xBC99BB66 - }, - ALTROMPN(54, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390722-02"), 0xe536bbb2,0xfd7f8a6d,0xa18c1b02,0xd07eb990,0xc2467a24,0x183ede12) - ALTROMPN(54, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390721-02"), 0xc0871d25,0xe155f18a,0xbb90cf82,0x0589c15e,0x70559d3b,0x6b391af8) - { - _T("A590/A2091 v7.0"), 7, 0, 7, 0, _T("A590\0A2091\0"), 16384, 55, 0, 0, ROMTYPE_A2091, 0, 0, NULL, - 0x714a97a2, 0xE50F01BA,0xF2899892,0x85547863,0x72A82C33,0x3C91276E - }, - ALTROMPN(55, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390722-03"), 0xa9ccffed,0x149f5bd5,0x2e2d2990,0x4e3de483,0xb9ad7724,0x48e9278e) - ALTROMPN(55, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390721-03"), 0x2942747a,0xdbd7648e,0x79c75333,0x7ff3e4f4,0x91de224b,0xf05e6bb6) - { - _T("A590/A2091 Guru ROM v6.14"), 6, 14, 6, 14, _T("A590\0A2091\0"), 32768, 56, 0, 0, ROMTYPE_A2091, 0, 0, NULL, - 0x04e52f93, 0x6DA21B6F,0x5E8F8837,0xD64507CD,0x8A4D5CDC,0xAC4F426B - }, - { _T("A4091 v40.9"), 40, 9, 40, 9, _T("A4091\0"), 32768, 57, 0, 0, ROMTYPE_A4091, 0, 0, NULL, - 0x00000000, 0, 0, 0, 0, 0 }, - { _T("A4091 v40.13"), 40, 13, 40, 13, _T("A4091\0"), 32768, 58, 0, 0, ROMTYPE_A4091, 0, 0, _T("391592-02"), - 0x54cb9e85, 0x3CE66919,0xF6FD6797,0x4923A12D,0x91B730F1,0xFFB4A7BA }, - { _T("SupraDrive AMAB6"), 3, 8, 3, 8, _T("SUPRA\0"), 16384, 121, 0, 0, ROMTYPE_SUPRA, 0, 0, _T("AMAB6"), - 0xf40bd349, 0x82168556,0x07525067,0xe9263431,0x1fb9c347,0xe737f247 }, - { _T("SupraDrive AMAB5"), 3, 0, 3, 0, _T("SUPRA\0"), 16384, 134, 0, 0, ROMTYPE_SUPRA, 0, 0, _T("AMAB5"), - 0x75e1b343, 0xf15de74b,0x4e2a9c99,0xa6dc4f6c,0x33f64c76,0x8c043d1c }, - { _T("SupraDrive AMAB4"), 0, 0, 0, 0, _T("SUPRA\0"), 8192, 135, 0, 0, ROMTYPE_SUPRA, 0, 0, _T("AMAB4"), - 0xde7f3f1c, 0xc0acbfc8,0x6641a6c1,0x024870cc,0x519f8c4c,0xbdfe8c64 }, - { _T("SupraDrive AMAB3"), 0, 0, 0, 0, _T("SUPRA\0"), 8192, 136, 0, 0, ROMTYPE_SUPRA, 0, 0, _T("AMAB3"), - 0x3ead39aa, 0x02fe79ee,0xef423098,0xec6add8c,0xb92f849f,0xc64bcd41 }, + { _T("Blizzard 1230-II"), 0, 0, 0, 0, _T("B1230MKII\0"), 32768, 163, 0, 0, ROMTYPE_CB_B1230MK2, 0, 0, NULL, + 0xf307cd34, 0xd2f0bfe5, 0x6e84e9f2, 0x2dc11583, 0x30702fd7, 0xd59584ee }, + { _T("Blizzard 1230-III"), 0, 0, 0, 0, _T("B1230MKIII\0"), 32768, 162, 0, 0, ROMTYPE_CB_B1230MK3, 0, 0, NULL, + 0x8412a22c, 0x3a4c55f3, 0xdaf62084, 0xd947e418, 0x137db019, 0xf13efc7d }, + { _T("Blizzard 1230-IV"), 0, 0, 0, 0, _T("B1230MKIV\0"), 32768, 89, 0, 0, ROMTYPE_CB_BLIZ1230, 0, 0, NULL, + 0x3078dbdc, 0x4d3e7fd0,0xa1a4c3ae,0xe17c5de3,0xcbe1af03,0x447aff92 }, + { _T("Blizzard 1240/1260"), 0, 0, 0, 0, _T("B1240\0B1260\0"), 32768, 90, 0, 0, ROMTYPE_CB_BLIZ1260, 0, 0, NULL, + 0xf88ae0f1, 0xf69aca4b,0xb13e3389,0x04676f0c,0x8616f8db,0x074c313d }, - { _T("Blizzard 1230-II"), 0, 0, 0, 0, _T("B1230MKII\0"), 32768, 163, 0, 0, ROMTYPE_CB_B1230MK2, 0, 0, NULL, - 0xf307cd34, 0xd2f0bfe5, 0x6e84e9f2, 0x2dc11583, 0x30702fd7, 0xd59584ee }, - { _T("Blizzard 1230-III"), 0, 0, 0, 0, _T("B1230MKIII\0"), 32768, 162, 0, 0, ROMTYPE_CB_B1230MK3, 0, 0, NULL, - 0x8412a22c, 0x3a4c55f3, 0xdaf62084, 0xd947e418, 0x137db019, 0xf13efc7d }, - { _T("Blizzard 1230-IV"), 0, 0, 0, 0, _T("B1230MKIV\0"), 32768, 89, 0, 0, ROMTYPE_CB_BLIZ1230, 0, 0, NULL, - 0x3078dbdc, 0x4d3e7fd0,0xa1a4c3ae,0xe17c5de3,0xcbe1af03,0x447aff92 }, - { _T("Blizzard 1240/1260"), 0, 0, 0, 0, _T("B1240\0B1260\0"), 32768, 90, 0, 0, ROMTYPE_CB_BLIZ1260, 0, 0, NULL, - 0xf88ae0f1, 0xf69aca4b,0xb13e3389,0x04676f0c,0x8616f8db,0x074c313d }, + { _T("Blizzard 2060 v8.2"), 8, 2, 8, 2, _T("B2060\0"), 65536, 168, 0, 0, ROMTYPE_CB_BLIZ2060, 0, 0, NULL, + 0x2f42af81, 0x003577b8, 0x4e1f2e59, 0x3add6c9f, 0xfd65a7b4, 0x2abaa933 }, + ALTROMPN(168, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xb5892212, 0x7282a8ca, 0xf7ab194d, 0x16e1d05a, 0x582f0ebf, 0x1046b3d0) + ALTROMPN(168, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x821a01c0, 0x6fd29f69, 0x28c5980e, 0x313b3b15, 0xb5d683ac, 0x209dd1bf) + { _T("Blizzard 2060 v8.5"), 8, 5, 8, 5, _T("B2060\0"), 65536, 92, 0, 0, ROMTYPE_CB_BLIZ2060, 0, 0, NULL, + 0xce270bc0, 0xe043c1aa,0x3bb06e06,0xd4dabff3,0x0a8c6317,0xabfef2bb }, + ALTROMPN(92, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xa6023f20, 0xdfb048d6, 0xbdc03587, 0x241e8121, 0x26aba603, 0xd69b0238) + ALTROMPN(92, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x9635a9cd, 0x47578b27, 0xc4ba6e54, 0x891930dd, 0xcb4b6a45, 0x5d6b31b2) + + { _T("Blizzard SCSI Kit III"), 1, 139, 1, 139, _T("BSCSIIII\0"), 65536, 167, 0, 0, ROMTYPE_BLIZKIT3, 0, 0, NULL, + 0xfd2c772f, 0x1411c248, 0x72f7cb8d, 0xecbe4744, 0xf0b8d12a, 0x1aaaad44, NULL, _T("blizzard_scsi_kit_iv.rom") }, +{ _T("Blizzard SCSI Kit IV"), 8, 5, 8, 5, _T("BSCSIIV\0"), 32768, 94, 0, 0, ROMTYPE_BLIZKIT4, 0, 0, NULL, + 0xf53a0fca, 0xefe17ca5,0x88c44a7f,0x0f8c62be,0x20f23278,0xcfe06727, NULL, _T("blizzard_scsi_kit_iv.rom") }, + { _T("Fastlane"), 8, 5, 8, 5, _T("FASTLANE\0"), 20788, 102, 0, 0, ROMTYPE_FASTLANE, 0, 0, NULL, + 0xe4f485a5, 0x20bf7de5,0x05e45d0a,0xc411cfd2,0x806d0fd8,0xe46276de, NULL, _T("fastlanez3.rom") }, + { _T("Oktagon 2008"), 6, 12, 6, 12, _T("OKTAGON\0"), 32768, 103, 0, 0, ROMTYPE_OKTAGON, 0, 0, NULL, + 0xbb0d2f6a, 0x56c441fa,0x37d19339,0x3081b2e8,0xceae823b,0xc7e97e49, NULL, _T("oktagon2008.rom") }, + { _T("Warp Engine A4000"), 0, 0, 0, 0, _T("WARPENGINE\0WARPENGINEA4000\0"), 32768, 93, 0, 0, ROMTYPE_CB_WENGINE, 0, 0, NULL, + 0x4deb574a, 0x6e6c95ff,0xe8448391,0xd36c5b68,0xc9065cb0,0x702a7d27 }, + { _T("TekMagic 2040/2060"), 1, 0, 1, 0, _T("TEKMAGIC\0TEKMAGIC2040\0TEKMAGIC2060\0"), 65536, 104, 0, 0, ROMTYPE_CB_TEKMAGIC, 0, 0, NULL, + 0x9e9781d5, 0xf65b60d1,0x4300c50f,0x2ed17cf4,0x4dcfdef9,0x16697bc9, NULL, _T("tekmagic2060.rom") }, + ALTROMPN(104, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x888da4cf, 0x6ae85f3a, 0x65331ba4, 0xaaba67ae, 0x34763d70, 0x2bde0495) + ALTROMPN(104, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xaf1f47db, 0x28d5bed0, 0xbc517d46, 0x500e8159, 0x723e0b64, 0x4733c26a) - { _T("Blizzard 2060 v8.2"), 8, 2, 8, 2, _T("B2060\0"), 65536, 168, 0, 0, ROMTYPE_CB_BLIZ2060, 0, 0, NULL, - 0x2f42af81, 0x003577b8, 0x4e1f2e59, 0x3add6c9f, 0xfd65a7b4, 0x2abaa933 }, - ALTROMPN(168, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xb5892212, 0x7282a8ca, 0xf7ab194d, 0x16e1d05a, 0x582f0ebf, 0x1046b3d0) - ALTROMPN(168, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x821a01c0, 0x6fd29f69, 0x28c5980e, 0x313b3b15, 0xb5d683ac, 0x209dd1bf) - { - _T("Blizzard 2060 v8.5"), 8, 5, 8, 5, _T("B2060\0"), 65536, 92, 0, 0, ROMTYPE_CB_BLIZ2060, 0, 0, NULL, - 0xce270bc0, 0xe043c1aa,0x3bb06e06,0xd4dabff3,0x0a8c6317,0xabfef2bb - }, - ALTROMPN(92, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xa6023f20, 0xdfb048d6, 0xbdc03587, 0x241e8121, 0x26aba603, 0xd69b0238) - ALTROMPN(92, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x9635a9cd, 0x47578b27, 0xc4ba6e54, 0x891930dd, 0xcb4b6a45, 0x5d6b31b2) + { _T("A2620/A2630 -07"), 0, 0, 0, 0, _T("A2620\0A2630\0"), 65536, 105, 0, 0, ROMTYPE_CB_A26x0, 0, 0, _T("390282-07/390283-07"), + 0x169d80e9, 0x41f518cb,0x41c1dc1f,0xcc636383,0x20676af5,0x4969010c, NULL, NULL }, + ALTROMPN(105, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390282-07"), 0xf2904058, 0x33695119, 0x5fdf5d56, 0x095a696b, 0x0ba2641d, 0x334845df) + ALTROMPN(105, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390283-07"), 0xf697d458, 0x09fe260b, 0x03784e87, 0x3351dbec, 0x5146a455, 0x814383d1) + { _T("A2620/A2630 -06"), 0, 0, 0, 0, _T("A2620\0A2630\0"), 65536, 106, 0, 0, ROMTYPE_CB_A26x0, 0, 0, _T("390282-06/390283-06"), + 0xeb31fd9e, 0x2d6a5c68,0x1040f98d,0x7e63ad08,0x90da9e83,0x2b5c704d, NULL, NULL }, + ALTROMPN(106, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390282-06"), 0xd6ae582c, 0x47b3dea3, 0x31db76e6, 0x1380a3d6, 0x9f191657, 0xdd1cd4b3) + ALTROMPN(106, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390283-06"), 0xcd379634, 0x65e251e2, 0xf6961c8e, 0x33a86c3d, 0x01248f70, 0xa159823b) + { _T("A2620/A2630 -04"), 0, 0, 0, 0, _T("A2620\0A2630\0"), 65536, 165, 0, 0, ROMTYPE_CB_A26x0, 0, 0, _T("390282-04/390283-04"), + 0xd4666ae9, 0x93cbd775, 0x42843f6d, 0x8234c271, 0xab860304, 0x06a1ae0a, NULL, NULL }, + ALTROMPN(165, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390282-04"), 0x28d5af1e, 0xc6a51a63, 0xca2a0833, 0xf32c4a59, 0x7d9d5b95, 0xcfa79a9e) + ALTROMPN(165, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390283-04"), 0x325aaf5f, 0xe76b384b, 0x5740cc0e, 0x782ae887, 0xe921352b, 0x115b2489) + { _T("A2620/A2630 -01"), 0, 0, 0, 0, _T("A2620\0A2630\0"), 65536, 164, 0, 0, ROMTYPE_CB_A26x0, 0, 0, _T("390282-01/390283-01"), + 0x6ee2ecdd, 0x4c82e3ba, 0x2d2dd1d3, 0x82f01098, 0xc26681b8, 0xff62f36d, NULL, NULL }, + ALTROMPN(164, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390282-01"), 0xdf76493b, 0x331ede0a, 0x8ca995cc, 0x1917f592, 0x18718e5b, 0x3c7fac39) + ALTROMPN(164, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390283-01"), 0xd74187de, 0x681e4985, 0x4da64bf1, 0x6f2f99f7, 0x4b195f54, 0x0b8bd614) + + { _T("DKB 12x0"), 1, 23, 1, 23, _T("DKB\0"), 32768, 112, 0, 0, ROMTYPE_CB_DKB12x0, 0, 0, NULL, + 0xf3b2b0b3, 0x1d539593,0xb1d7514e,0xeb214ab3,0x433a97fc,0x8a010366, NULL, NULL }, + { _T("DKB Rapidfire v1.31"), 1, 31, 1, 31, _T("RAPIDFIRE\0"), 11284, 207, 0, 0, ROMTYPE_RAPIDFIRE, 0, 0, NULL, + 0x68725e50, 0xa66f8ef6,0x901e0e41,0xf8b72bba,0x12165788,0xa452cf01, NULL, NULL }, + { _T("Fusion Forty"), 0, 0, 0, 0, _T("FUSIONFORTY\0"), 131072, 113, 0, 0, ROMTYPE_CB_FUSION, 0, 0, NULL, + 0x48fcb5fd, 0x15674dac,0x90b6d8db,0xdda3a175,0x997184c2,0xa423d733, NULL, NULL }, + ALTROMPN(113, 1, 1, 32768, ROMTYPE_QUAD | ROMTYPE_EVEN | ROMTYPE_8BIT, _T("U28"), 0x434a21a8, 0x472c1623, 0x02babd00, 0x7c1a77ff, 0x40dd12ab, 0x39c97f82) + ALTROMPN(113, 1, 2, 32768, ROMTYPE_QUAD | ROMTYPE_ODD | ROMTYPE_8BIT, _T("U27"), 0x38373cf6, 0xfe8aa931, 0xada6b6f3, 0x6b48ca3c, 0x9b86677d, 0xbee4da59) + ALTROMPN(113, 1, 3, 32768, ROMTYPE_QUAD | ROMTYPE_EVEN | ROMTYPE_8BIT, _T("U25"), 0xc9e990d3, 0xb251ef73, 0x1374e796, 0xa87cbc7e, 0x9263320a, 0x28a71d2b) + ALTROMPN(113, 1, 4, 32768, ROMTYPE_QUAD | ROMTYPE_ODD | ROMTYPE_8BIT, _T("U26"), 0x2e117fe0, 0xbb2de2da, 0x6db4e92c, 0x636fefe6, 0x13a32699, 0xcea31011) + { _T("Apollo 1240/1260"), 5, 60, 5, 60, _T("APOLLO12XX\0"), 131072, 119, 0, 0, ROMTYPE_CB_APOLLO, 0, 0, NULL, + 0xcd009ad9, 0x1c3b4851,0xc5a221e3,0xa7ca24fc,0xc1df4a5b,0x9f2343ad }, + { _T("GVP A3001 Series I"), 3, 3, 3, 3, _T("A3001SI\0"), 8192, 114, 0, 0, ROMTYPE_CB_A3001S1, 0, 0, NULL, + 0xaaff7c65, 0x424cf3da,0xcc9da794,0x0ba74446,0x69dd1691,0x44ae87ee, NULL, NULL }, + { _T("Kupke Golem 030"), 0, 0, 0, 0, _T("GOLEM030\0"), 8192, 126, 0, 0, ROMTYPE_CB_GOLEM030, 0, 0, NULL, + 0x05d473f4, 0x574ec567,0xcc67e06f,0x91dcecb9,0x8c204399,0x5fe2a09f, NULL, NULL }, + { _T("DKB WildFire"), 1, 1, 1, 1, _T("WILDFIRE\0"), 18352, 143, 0, 0, ROMTYPE_CB_DBK_WF, 0, 0, NULL, + 0xb2dae8c4, 0xcdfe2d96, 0xe44d4f8d, 0x3833a5e8, 0xb6c832fd, 0xc7b341a9, NULL, NULL }, + { _T("M-Tec E-Matrix 530"), 0, 0, 0, 0, _T("EMATRIX530\0"), 65536, 144, 0, 0, ROMTYPE_CB_EMATRIX, 0, 0, NULL, + 0x3942d827, 0x5aaf118f, 0x61fc3083, 0x1435b87c, 0x8bdab6a4, 0x59b4ee22, NULL, NULL }, + { _T("SX32 Pro"), 0, 0, 0, 0, _T("SX32PRO\0"), 65536, 160, 0, 0, ROMTYPE_CB_SX32PRO, 0, 0, NULL, + 0xbfd68a88, 0x84a50880, 0x76917549, 0xadf33b16, 0x8a869adb, 0x9e5a6fac, NULL, NULL }, + { _T("IVS Vector 4.14"), 4, 14, 4, 14, _T("VECTOR030\0"), 65536, 166, 0, 0, ROMTYPE_CB_VECTOR, 0, 0, NULL, + 0x3befa0c0, 0x4414673c, 0xa52f78a0, 0xae656824, 0xfd08b54f, 0xa1de237c, NULL, NULL }, + ALTROMPN(166, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xb64e3bbf, 0xd6f4fc81, 0x38325a78, 0x74ff1c15, 0x7c93f1a2, 0x444904ae) + ALTROMPN(166, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x541b5988, 0x3546517b, 0x57cecd2f, 0x9fbfcd0c, 0xf26fdbbf, 0xfb009e3e) - { - _T("Blizzard SCSI Kit III"), 1, 139, 1, 139, _T("BSCSIIII\0"), 65536, 167, 0, 0, ROMTYPE_BLIZKIT3, 0, 0, NULL, - 0xfd2c772f, 0x1411c248, 0x72f7cb8d, 0xecbe4744, 0xf0b8d12a, 0x1aaaad44, NULL, _T("blizzard_scsi_kit_iv.rom") - }, - { _T("Blizzard SCSI Kit IV"), 8, 5, 8, 5, _T("BSCSIIV\0"), 32768, 94, 0, 0, ROMTYPE_BLIZKIT4, 0, 0, NULL, - 0xf53a0fca, 0xefe17ca5,0x88c44a7f,0x0f8c62be,0x20f23278,0xcfe06727, NULL, _T("blizzard_scsi_kit_iv.rom") }, - { _T("Fastlane"), 8, 5, 8, 5, _T("FASTLANE\0"), 20788, 102, 0, 0, ROMTYPE_FASTLANE, 0, 0, NULL, - 0xe4f485a5, 0x20bf7de5,0x05e45d0a,0xc411cfd2,0x806d0fd8,0xe46276de, NULL, _T("fastlanez3.rom") }, - { _T("Oktagon 2008"), 6, 12, 6, 12, _T("OKTAGON\0"), 32768, 103, 0, 0, ROMTYPE_OKTAGON, 0, 0, NULL, - 0xbb0d2f6a, 0x56c441fa,0x37d19339,0x3081b2e8,0xceae823b,0xc7e97e49, NULL, _T("oktagon2008.rom") }, - { _T("Warp Engine A4000"), 0, 0, 0, 0, _T("WARPENGINE\0WARPENGINEA4000\0"), 32768, 93, 0, 0, ROMTYPE_CB_WENGINE, 0, 0, NULL, - 0x4deb574a, 0x6e6c95ff,0xe8448391,0xd36c5b68,0xc9065cb0,0x702a7d27 }, - { _T("TekMagic 2040/2060"), 1, 0, 1, 0, _T("TEKMAGIC\0TEKMAGIC2040\0TEKMAGIC2060\0"), 65536, 104, 0, 0, ROMTYPE_CB_TEKMAGIC, 0, 0, NULL, - 0x9e9781d5, 0xf65b60d1,0x4300c50f,0x2ed17cf4,0x4dcfdef9,0x16697bc9, NULL, _T("tekmagic2060.rom") }, - ALTROMPN(104, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x888da4cf, 0x6ae85f3a, 0x65331ba4, 0xaaba67ae, 0x34763d70, 0x2bde0495) - ALTROMPN(104, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xaf1f47db, 0x28d5bed0, 0xbc517d46, 0x500e8159, 0x723e0b64, 0x4733c26a) + { _T("Preferred Technologies Nexus"), 1, 0, 1, 0, _T("PTNEXUS\0"), 8192, 139, 0, 0, ROMTYPE_PTNEXUS, 0, 0, NULL, + 0xf495879a, 0xa3bd0202, 0xe14aa5b6, 0x49d3ce88, 0x22975950, 0x6500dbc2, NULL, NULL }, + { _T("ICD AdSCSI 2000"), 1, 6, 1, 6, _T("ADSCSI\0"), 32768, 133, 0, 0, ROMTYPE_ADSCSI, 0, 0, NULL, + 0x7dba3e1f, 0x1e05f284, 0xd59a1e5d, 0x4e4de44e, 0x6f075175, 0x625cd6c0, NULL, NULL }, + { _T("Archos ADD-500"), 1, 21, 1, 21, _T("ADD\0"), 16384, 132, 0, 0, ROMTYPE_ADD500, 0, 0, NULL, + 0x3f4e4a74, 0x9ed96fc0,0xd6381dc3,0x3192b0af,0xdfae4b74,0x576c3a69, NULL, NULL }, + { _T("Protar A500HD"), 1, 193, 1, 193, _T("PROTAR\0"), 32768, 131, 0, 0, ROMTYPE_PROTAR, 0, 0, NULL, + 0x10c1b22c, 0x2b800cde,0x79fd559e,0xebd5e432,0xd711af3d,0x0b8ea7e9, NULL, NULL }, + { _T("M-Tec AT500 v1.33w"), 1, 33, 1, 33, _T("MTECAT\0"), 32768, 130, 0, 0, ROMTYPE_MTEC, 0, 0, NULL, + 0x38b6b6b0, 0x8bb1093a,0xd592e7df,0x99c48f83,0xb9f842b2,0xb1a6e618, NULL, NULL }, + { _T("AdIDE 40/44 v33"), 33, 0, 33, 0, _T("ADIDE\0"), 16384, 141, 0, 0, ROMTYPE_ADIDE, 0, 0, NULL, + 0x330254ce, 0xc91dd3b5,0x3f1986bd,0x94fba150,0xe753c2da,0x4dee78e7, NULL, NULL }, + { _T("AdIDE 40/44 v34"), 34, 0, 34, 0, _T("ADIDE\0"), 16384, 129, 0, 0, ROMTYPE_ADIDE, 0, 0, NULL, + 0xedf84cbe, 0xabdbc01d,0xaa0b3aae,0xe4401ad7,0xe65525a9,0x6bfa2b27, NULL, NULL }, + { _T("Vector Falcon 8000 v7.1"), 7, 1, 7, 1, _T("VECTOR\0"), 32768, 128, 0, 0, ROMTYPE_VECTOR, 0, 0, NULL, + 0xa8120c55, 0x248935ab,0xf4d74036,0xefdafdbb,0x7817e232,0xfc13e0fa, NULL, NULL }, + ALTROMPN(128, 1, 1, 16384, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x798b1152, 0x603ba087,0xecee69ac,0x7ccf6e88,0x3e374fc8,0x808bcbb4) + ALTROMPN(128, 1, 2, 16384, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xd8b2f469, 0xbc600f99,0xa0ff7384,0xdabc7a04,0xb7bb0e71,0xad615db5) + { _T("Vector Falcon 8000 v7.6"), 7, 6, 7, 6, _T("VECTOR\0"), 32768, 172, 0, 0, ROMTYPE_VECTOR, 0, 0, NULL, + 0x2177a145, 0x8a7e617f,0xed566bb8,0xb33f6409, 0x05d9b946, 0xcee6d4bf, NULL, NULL }, + ALTROMPN(172, 1, 1, 16384, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x6228a3e4,0x72fa4175,0x21731e91,0x6c6c8519,0x91110287,0x9f4c0cb9) + ALTROMPN(172, 1, 2, 16384, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xf0a0ab0d,0xd239405a,0x5c4983ce,0xeaff0fd2,0x36d42d82,0x5a0cafd1) + { _T("Kommos A500/A2000 v1.8"), 1, 8, 1, 8, _T("KOMMOS\0"), 32768, 127, 0, 0, ROMTYPE_KOMMOS, 0, 0, NULL, + 0xc1a5c848, 0x291310f1, 0x25455f2d, 0x8e114bcd, 0xe104ca4c, 0x9db51747, NULL, NULL }, + ALTROMPN(127, 1, 1, 16384, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x1b86d2ed, 0x969995a1, 0x2ebf8c15, 0xab87e8d0, 0xddc837a1, 0xb90fbfa8) + ALTROMPN(127, 1, 2, 16384, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x65b4c3a0, 0x60e904d4, 0xe45bb6ba, 0x3e253ffa, 0xda4ee2e5, 0xc8548da1) + { _T("Kommos A500/A2000 v1.7"), 1, 7, 1, 7, _T("KOMMOS\0"), 32768, 140, 0, 0, ROMTYPE_KOMMOS, 0, 0, NULL, + 0x025d7835, 0x8205ad6e, 0x08dbf5a6, 0x9ba17956, 0xb5237ffe, 0x768de5a4, NULL, NULL }, + ALTROMPN(140, 1, 1, 16384, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x3d982391, 0xbe26e141, 0x1e16cab4, 0xeab8af33, 0x1476ef8e, 0x21fcb2af) + ALTROMPN(140, 1, 2, 16384, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x68adc0ad, 0xb5eef088, 0xed8a9439, 0xb0302907, 0xcb3cb207, 0x62f28da7) + { _T("Kupke Golem v3.9"), 3, 9, 3, 9, _T("GOLEM\0"), 16384, 124, 0, 0, ROMTYPE_GOLEM, 0, 0, NULL, + 0x49157dd0, 0x03b615c9,0x2befa474,0xa37303ca,0xdc3e830d,0x3c0d9a9f, NULL, NULL }, + ALTROMPN(124, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x88cf2ec5, 0x59680f8d, 0xae520893, 0xff9ada35, 0xac9a1146, 0x4f87453c) + ALTROMPN(124, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x713298ad, 0x2ad7d6f3, 0xd696fd2c, 0x51a256ee, 0xea185c47, 0x52906e04) + { _T("GVP Series I v1.0"), 1, 0, 1, 16, _T("GVPI\0"), 16384, 123, 0, 0, ROMTYPE_GVPS1, 0, 0, NULL, + 0x1a4c20aa, 0xb9a3377e,0x2d9b5163,0x28693c63,0x19ffb65b,0x40ae3618, NULL, NULL }, + ALTROMPN(123, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x27f15785, 0x1a71a78d, 0xdd4e9559, 0x0f133bba, 0x4a71122f, 0x44caef78) + ALTROMPN(123, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xa723193e, 0x05b4a072, 0x785c7824, 0x54e003c3, 0x6d88bd9b, 0xf5f561b9) + { _T("GVP Series I/II v3.15"), 3, 15, 3, 15, _T("GVPII\0GVPI\0"), 16384, 111, 0, 0, ROMTYPE_GVPS12, 0, 0, NULL, + 0xf99c6f11, 0x77098a9e,0x35acaef2,0x11a546f0,0xc564cdac,0xf52836c4, NULL, NULL }, + { _T("GVP Series II v4.15"), 4, 15, 4, 15, _T("GVPII\0"), 16384, 109, 0, 0, ROMTYPE_GVPS2, 0, 0, NULL, + 0xf89f44d6, 0xbf10c12c,0xc72dd040,0x549ea17c,0x24947633,0xe3773297, NULL, NULL }, + { _T("GVP Series II Guru ROM"), 6, 14, 6, 14, _T("GVPII\0"), 32768, 110, 0, 0, ROMTYPE_GVPS2, 0, 0, NULL, + 0x756103b1, 0x7f1335ea,0xf5b7ce73,0xc5231173,0x261da5aa,0xe7249645, NULL, NULL }, + { _T("AlfaPower v6.10"), 6, 10, 6, 10, _T("ALFAPOWER\0"), 32768, 117, 0, 0, ROMTYPE_ALFA, 0, 0, NULL, + 0x1cfb0a0b, 0xc7275eda,0x547d6664,0x5c4eb7a0,0x3b5cef37,0xa498365a, NULL, NULL }, + { _T("AlfaPower v8.3"), 8, 3, 8, 3, _T("ALFAPOWERPLUS\0"), 32768, 118, 0, 0, ROMTYPE_ALFAPLUS, 0, 0, NULL, + 0xe8201bad, 0xdefea015,0x596fce32,0x11e84397,0x23046a31,0x5a7726dc, NULL, NULL }, + { _T("Masoboshi MC-702 v2.201"), 2, 201, 2, 201, _T("MASOBOSHI\0"), 32768, 120, 0, 0, ROMTYPE_MASOBOSHI, 0, 0, NULL, + 0xcd99b98a, 0x3897e46a,0x66d5833f,0x849b8e81,0x30acb3cb,0x319a2fa0, NULL, NULL }, + { _T("Roctec RocHard RH800C v1"), 1, 0, 1, 0, _T("ROCHARD\0"), 16384, 138, 0, 0, ROMTYPE_ROCHARD, 0, 0, NULL, + 0x0e980aec, 0xbcafa14d,0xe80576cb,0xe3e0c638,0x1ca90379,0xe078a8bd, NULL, NULL }, + ALTROMPN(138, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xde3a855b, 0xda2fe069, 0xd78c9ccc, 0xc221711f, 0x1e598298, 0x2bdabffd) + ALTROMPN(138, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xb0ed3006, 0x0a88d84e, 0x2094f9e5, 0x18d37f90, 0x34764f22, 0x9696c3d9) + { _T("Roctec RocHard RH800C v2"), 2, 0, 2, 0, _T("ROCHARD\0"), 16384, 146, 0, 0, ROMTYPE_ROCHARD, 0, 0, NULL, + 0x5c27be3f, 0xacdb8bc7,0x64493f65,0x9da4c1e8,0x3005ceeb,0xced73dbc, NULL, NULL }, + ALTROMPN(146, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xc5b8f068, 0x6ada1205, 0x44d284d0, 0x326d68cb, 0x7a2d9fb4, 0x77f35852) + ALTROMPN(146, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xc88843cb, 0x3d7eb1b6, 0x8139b81b, 0x0665684c, 0x536ab3d0, 0x52a5dd9d) + { _T("Apollo 500/2000"), 0, 0, 0, 0, _T("APOLLOHD\0"), 16384, 145, 0, 0, ROMTYPE_APOLLOHD, 0, 0, NULL, + 0x931bad25, 0x24b4ee4c,0x129c7a93,0xf83ad570,0x66afd80c,0x4179f39c, NULL, NULL }, + { _T("Multi Evolution 500/2000 v3.0"), 3, 0, 3, 0, _T("MULTIEVOLUTION\0"), 65536, 156, 0, 0, ROMTYPE_MEVOLUTION, 0, 0, NULL, + 0xd13a2c89, 0xf9e38c4b,0xf5c6499d,0x486946ba,0x7b7636b8,0x0845265b, NULL, NULL }, + ALTROMPN(156, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x339b3549, 0x74de857b, 0x42f9a8e0, 0xc1f3c29e, 0x06982622, 0x853d08fe) + ALTROMPN(156, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x3aca5d1f, 0x786f2197, 0xc614be91, 0xae7e87da, 0xb42c3290, 0xd7997763) + { _T("Kupke Golem v4.2"), 4, 2, 4, 2, _T("GOLEMFAST\0"), 16384, 157, 0, 0, ROMTYPE_GOLEMFAST, 0, 0, NULL, + 0x5e94ee56, 0xf83dae55, 0x49f9b735, 0x52d5c6e0, 0x41da4c6c, 0x995a7f47, NULL, NULL }, + ALTROMPN(157, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xec13fda0, 0x6af1447c, 0x4363c46d, 0x05697458, 0x01daa30c, 0x03c01c9f) + ALTROMPN(157, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x39b0075e, 0xf6644ea0, 0x6c3ed349, 0xfb0fb6b4, 0xa9f07655, 0x0b104179) + { _T("Phoenix Board SCSI v.J"), 3, 1, 3, 1, _T("PBSCSI\0"), 32768, 159, 0, 0, ROMTYPE_PHOENIXB, 0, 0, NULL, + 0x1f672e4b, 0xb20d50b8, 0x31ec9823, 0xfa732fc6, 0x522ecc6a, 0xae36ec33, NULL, NULL }, + { _T("IVS GramdSlam/Trumpcard Pro v4.9"), 4, 9, 4, 9, _T("IVSPRO\0"), 16384, 161, 0, 0, ROMTYPE_IVSTPRO, 0, 0, NULL, + 0x4a15f224, 0x29500b47, 0x289e84ac, 0x575e3c7d, 0x82199b45, 0x605d8fc9, NULL, NULL }, + { _T("Expansion Systems Dataflyer+ v1.5"), 1, 5, 1, 5, _T("DATAFLYERPLUS\0"), 32768, 170, 0, 0, ROMTYPE_DATAFLYER, 0, 0, NULL, + 0x00888f19, 0x54b73354, 0xb3592691, 0x59a80909, 0x0bdb67df, 0x8ac22aa9, NULL, NULL }, + { _T("Expansion Systems Dataflyer+ v1.7"), 1, 7, 1, 7, _T("DATAFLYERPLUS\0"), 32768, 171, 0, 0, ROMTYPE_DATAFLYER, 0, 0, NULL, + 0xb0814aca, 0xb817672c, 0x1beb86c6, 0x840aa4bd, 0xf4640835, 0x1ed103f4, NULL, NULL }, + { _T("Expansion Systems Dataflyer+ v2.1"), 2, 1, 2, 1, _T("DATAFLYERPLUS\0"), 32768, 169, 0, 0, ROMTYPE_DATAFLYER, 0, 0, NULL, + 0xc49daa65, 0x20275716, 0xdc7eb00e, 0x5dc53680, 0xb5c8a90a, 0x7c00e390, NULL, NULL }, + { _T("Microbotics HardFrame v1.5"), 1, 5, 1, 5, _T("HARDFRAME\0"), 32768, 173, 0, 0, ROMTYPE_HARDFRAME, 0, 0, NULL, + 0x8d144212, 0xc5a4f497, 0x5216c1b1, 0xe08760d0, 0x0bd579ef, 0xea226354, NULL, NULL }, + { _T("Mainhattan Data A-Team v1.8"), 1, 8, 1, 8, _T("ATEAM\0"), 65536, 174, 0, 0, ROMTYPE_ATEAM, 0, 0, NULL, + 0x4fe08a5d, 0x007e5c61, 0x4048f598, 0x6d14011d, 0x23a41435, 0x5e0a2259, NULL, NULL }, + { _T("M-Tec AT500 Megabody v1.33"), 1, 33, 1, 33, _T("MTECAT\0"), 32768, 199, 0, 0, ROMTYPE_MTEC, 0, 0, NULL, + 0x19715a2f, 0x124f9d10, 0x19f1b285, 0x16f33f4e, 0x2bf03ca0, 0x2f9ad772, NULL, NULL }, + { _T("Comspec SA-1000 v34.805"), 34, 805, 34, 805, _T("COMSPEC\0"), 16384, 200, 0, 0, ROMTYPE_COMSPEC, 0, 0, NULL, + 0x44458e28, 0x048b8232, 0xfe54252b, 0xb81e0d06, 0x83c9e92d, 0x880f3cbf, NULL, NULL }, + ALTROMPN(200, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xd5838a35, 0xb3d83657, 0x661a9fe1, 0xd54e6e69, 0xc8b13878, 0x0960a107) + ALTROMPN(200, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x098c5529, 0x6f51827d, 0x40a79438, 0x69e2d0fb, 0x6e2e46e9, 0xb65c1244) + { _T("California Access Malibu v1.0"), 1, 0, 1, 0, _T("MALIBU\0"), 8192, 201, 0, 0, ROMTYPE_MALIBU, 0, 0, NULL, + 0xe60b1ce6, 0xa7c4b709, 0x494f4034, 0x42b8ec11, 0x090dc1d0, 0x18098ebc, NULL, NULL }, - { - _T("A2620/A2630 -07"), 0, 0, 0, 0, _T("A2620\0A2630\0"), 65536, 105, 0, 0, ROMTYPE_CB_A26x0, 0, 0, _T("390282-07/390283-07"), - 0x169d80e9, 0x41f518cb,0x41c1dc1f,0xcc636383,0x20676af5,0x4969010c, NULL, NULL - }, - ALTROMPN(105, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390282-07"), 0xf2904058, 0x33695119, 0x5fdf5d56, 0x095a696b, 0x0ba2641d, 0x334845df) - ALTROMPN(105, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390283-07"), 0xf697d458, 0x09fe260b, 0x03784e87, 0x3351dbec, 0x5146a455, 0x814383d1) - { - _T("A2620/A2630 -06"), 0, 0, 0, 0, _T("A2620\0A2630\0"), 65536, 106, 0, 0, ROMTYPE_CB_A26x0, 0, 0, _T("390282-06/390283-06"), - 0xeb31fd9e, 0x2d6a5c68,0x1040f98d,0x7e63ad08,0x90da9e83,0x2b5c704d, NULL, NULL - }, - ALTROMPN(106, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390282-06"), 0xd6ae582c, 0x47b3dea3, 0x31db76e6, 0x1380a3d6, 0x9f191657, 0xdd1cd4b3) - ALTROMPN(106, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390283-06"), 0xcd379634, 0x65e251e2, 0xf6961c8e, 0x33a86c3d, 0x01248f70, 0xa159823b) - { - _T("A2620/A2630 -04"), 0, 0, 0, 0, _T("A2620\0A2630\0"), 65536, 165, 0, 0, ROMTYPE_CB_A26x0, 0, 0, _T("390282-04/390283-04"), - 0xd4666ae9, 0x93cbd775, 0x42843f6d, 0x8234c271, 0xab860304, 0x06a1ae0a, NULL, NULL - }, - ALTROMPN(165, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390282-04"), 0x28d5af1e, 0xc6a51a63, 0xca2a0833, 0xf32c4a59, 0x7d9d5b95, 0xcfa79a9e) - ALTROMPN(165, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390283-04"), 0x325aaf5f, 0xe76b384b, 0x5740cc0e, 0x782ae887, 0xe921352b, 0x115b2489) - { - _T("A2620/A2630 -01"), 0, 0, 0, 0, _T("A2620\0A2630\0"), 65536, 164, 0, 0, ROMTYPE_CB_A26x0, 0, 0, _T("390282-01/390283-01"), - 0x6ee2ecdd, 0x4c82e3ba, 0x2d2dd1d3, 0x82f01098, 0xc26681b8, 0xff62f36d, NULL, NULL - }, - ALTROMPN(164, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, _T("390282-01"), 0xdf76493b, 0x331ede0a, 0x8ca995cc, 0x1917f592, 0x18718e5b, 0x3c7fac39) - ALTROMPN(164, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("390283-01"), 0xd74187de, 0x681e4985, 0x4da64bf1, 0x6f2f99f7, 0x4b195f54, 0x0b8bd614) + { _T("CyberStorm MK I 68040"), 0, 0, 0, 0, _T("CSMKI\0"), 32768, 95, 0, 0, ROMTYPE_CB_CSMK1, 0, 0, NULL, + 0, 0, 0, 0, 0, 0, NULL, _T("cyberstormmk1_040.rom") }, + { _T("CyberStorm MK I 68060"), 0, 0, 0, 0, _T("CSMKI\0"), 65536, 101, 0, 0, ROMTYPE_CB_CSMK1, 0, 0, NULL, + 0, 0, 0, 0, 0, 0, NULL, _T("cyberstormmk1_060.rom") }, + { _T("CyberStorm MK II"), 0, 0, 0, 0, _T("CSMKII\0"), 131072, 96, 0, 0, ROMTYPE_CB_CSMK2, 0, 0, NULL, + 0, 0, 0, 0, 0, 0, NULL, _T("cyberstormmk2.rom") }, + { _T("CyberStorm MK III"), 0, 0, 0, 0, _T("CSMKIII\0"), 131072, 97, 0, 0, ROMTYPE_CB_CSMK3, 0, 0, NULL, + 0, 0, 0, 0, 0, 0, NULL, _T("cyberstormmk3.rom") }, + { _T("CyberStorm PPC"), 0, 0, 0, 0, _T("CSPPC\0"), 131072, 98, 0, 0, ROMTYPE_CB_CSPPC, 0, 0, NULL, + 0, 0, 0, 0, 0, 0, NULL, _T("cyberstormppc.rom") }, + { _T("Blizzard PPC 68040"), 0, 0, 0, 0, _T("BPPC\0"), 524288, 99, 0, 0, ROMTYPE_CB_BLIZPPC, 0, 0, NULL, + 0, 0, 0, 0, 0, 0, NULL, _T("blizzardppc_040.rom") }, + { _T("Blizzard PPC 68060"), 0, 0, 0, 0, _T("BPPC\0"), 524288, 100, 0, 0, ROMTYPE_CB_BLIZPPC, 0, 0, NULL, + 0, 0, 0, 0, 0, 0, NULL, _T("blizzardppc_060.rom") }, + { _T("ACA 500"), 0, 0, 0, 0, _T("ACA500\0"), 524288, 137, 0, 0, ROMTYPE_CB_ACA500, 0, 0, NULL, + 0, 0, 0, 0, 0, 0, NULL, _T("menu500.aca") }, - { - _T("DKB 12x0"), 1, 23, 1, 23, _T("DKB\0"), 32768, 112, 0, 0, ROMTYPE_CB_DKB12x0, 0, 0, NULL, - 0xf3b2b0b3, 0x1d539593,0xb1d7514e,0xeb214ab3,0x433a97fc,0x8a010366, NULL, NULL - }, - { _T("DKB Rapidfire v1.31"), 1, 31, 1, 31, _T("RAPIDFIRE\0"), 11284, 207, 0, 0, ROMTYPE_RAPIDFIRE, 0, 0, NULL, - 0x68725e50, 0xa66f8ef6,0x901e0e41,0xf8b72bba,0x12165788,0xa452cf01, NULL, NULL }, - { _T("Fusion Forty"), 0, 0, 0, 0, _T("FUSIONFORTY\0"), 131072, 113, 0, 0, ROMTYPE_CB_FUSION, 0, 0, NULL, - 0x48fcb5fd, 0x15674dac,0x90b6d8db,0xdda3a175,0x997184c2,0xa423d733, NULL, NULL }, - ALTROMPN(113, 1, 1, 32768, ROMTYPE_QUAD | ROMTYPE_EVEN | ROMTYPE_8BIT, _T("U28"), 0x434a21a8, 0x472c1623, 0x02babd00, 0x7c1a77ff, 0x40dd12ab, 0x39c97f82) - ALTROMPN(113, 1, 2, 32768, ROMTYPE_QUAD | ROMTYPE_ODD | ROMTYPE_8BIT, _T("U27"), 0x38373cf6, 0xfe8aa931, 0xada6b6f3, 0x6b48ca3c, 0x9b86677d, 0xbee4da59) - ALTROMPN(113, 1, 3, 32768, ROMTYPE_QUAD | ROMTYPE_EVEN | ROMTYPE_8BIT, _T("U25"), 0xc9e990d3, 0xb251ef73, 0x1374e796, 0xa87cbc7e, 0x9263320a, 0x28a71d2b) - ALTROMPN(113, 1, 4, 32768, ROMTYPE_QUAD | ROMTYPE_ODD | ROMTYPE_8BIT, _T("U26"), 0x2e117fe0, 0xbb2de2da, 0x6db4e92c, 0x636fefe6, 0x13a32699, 0xcea31011) - { - _T("Apollo 1240/1260"), 5, 60, 5, 60, _T("APOLLO12XX\0"), 131072, 119, 0, 0, ROMTYPE_CB_APOLLO, 0, 0, NULL, - 0xcd009ad9, 0x1c3b4851,0xc5a221e3,0xa7ca24fc,0xc1df4a5b,0x9f2343ad - }, - { _T("GVP A3001 Series I"), 3, 3, 3, 3, _T("A3001SI\0"), 8192, 114, 0, 0, ROMTYPE_CB_A3001S1, 0, 0, NULL, - 0xaaff7c65, 0x424cf3da,0xcc9da794,0x0ba74446,0x69dd1691,0x44ae87ee, NULL, NULL }, - { _T("Kupke Golem 030"), 0, 0, 0, 0, _T("GOLEM030\0"), 8192, 126, 0, 0, ROMTYPE_CB_GOLEM030, 0, 0, NULL, - 0x05d473f4, 0x574ec567,0xcc67e06f,0x91dcecb9,0x8c204399,0x5fe2a09f, NULL, NULL }, - { _T("DKB WildFire"), 1, 1, 1, 1, _T("WILDFIRE\0"), 18352, 143, 0, 0, ROMTYPE_CB_DBK_WF, 0, 0, NULL, - 0xb2dae8c4, 0xcdfe2d96, 0xe44d4f8d, 0x3833a5e8, 0xb6c832fd, 0xc7b341a9, NULL, NULL }, - { _T("M-Tec E-Matrix 530"), 0, 0, 0, 0, _T("EMATRIX530\0"), 65536, 144, 0, 0, ROMTYPE_CB_EMATRIX, 0, 0, NULL, - 0x3942d827, 0x5aaf118f, 0x61fc3083, 0x1435b87c, 0x8bdab6a4, 0x59b4ee22, NULL, NULL }, - { _T("SX32 Pro"), 0, 0, 0, 0, _T("SX32PRO\0"), 65536, 160, 0, 0, ROMTYPE_CB_SX32PRO, 0, 0, NULL, - 0xbfd68a88, 0x84a50880, 0x76917549, 0xadf33b16, 0x8a869adb, 0x9e5a6fac, NULL, NULL }, - { _T("IVS Vector 4.14"), 4, 14, 4, 14, _T("VECTOR030\0"), 65536, 166, 0, 0, ROMTYPE_CB_VECTOR, 0, 0, NULL, - 0x3befa0c0, 0x4414673c, 0xa52f78a0, 0xae656824, 0xfd08b54f, 0xa1de237c, NULL, NULL }, - ALTROMPN(166, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xb64e3bbf, 0xd6f4fc81, 0x38325a78, 0x74ff1c15, 0x7c93f1a2, 0x444904ae) - ALTROMPN(166, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x541b5988, 0x3546517b, 0x57cecd2f, 0x9fbfcd0c, 0xf26fdbbf, 0xfb009e3e) + { _T("Picasso IV"), 7, 4, 7, 4, _T("PIV\0"), 131072, 91, 0, 0, ROMTYPE_PICASSOIV, 0, 0, NULL, + 0xa8133e7e, 0xcafafb91,0x6f16b9f3,0xec9b49aa,0x4b40eb4e,0xeceb5b5b }, - { - _T("Preferred Technologies Nexus"), 1, 0, 1, 0, _T("PTNEXUS\0"), 8192, 139, 0, 0, ROMTYPE_PTNEXUS, 0, 0, NULL, - 0xf495879a, 0xa3bd0202, 0xe14aa5b6, 0x49d3ce88, 0x22975950, 0x6500dbc2, NULL, NULL - }, - { _T("ICD AdSCSI 2000"), 1, 6, 1, 6, _T("ADSCSI\0"), 32768, 133, 0, 0, ROMTYPE_ADSCSI, 0, 0, NULL, - 0x7dba3e1f, 0x1e05f284, 0xd59a1e5d, 0x4e4de44e, 0x6f075175, 0x625cd6c0, NULL, NULL }, - { _T("Archos ADD-500"), 1, 21, 1, 21, _T("ADD\0"), 16384, 132, 0, 0, ROMTYPE_ADD500, 0, 0, NULL, - 0x3f4e4a74, 0x9ed96fc0,0xd6381dc3,0x3192b0af,0xdfae4b74,0x576c3a69, NULL, NULL }, - { _T("Protar A500HD"), 1, 193, 1, 193, _T("PROTAR\0"), 32768, 131, 0, 0, ROMTYPE_PROTAR, 0, 0, NULL, - 0x10c1b22c, 0x2b800cde,0x79fd559e,0xebd5e432,0xd711af3d,0x0b8ea7e9, NULL, NULL }, - { _T("M-Tec AT500 v1.33w"), 1, 33, 1, 33, _T("MTECAT\0"), 32768, 130, 0, 0, ROMTYPE_MTEC, 0, 0, NULL, - 0x38b6b6b0, 0x8bb1093a,0xd592e7df,0x99c48f83,0xb9f842b2,0xb1a6e618, NULL, NULL }, - { _T("AdIDE 40/44 v33"), 33, 0, 33, 0, _T("ADIDE\0"), 16384, 141, 0, 0, ROMTYPE_ADIDE, 0, 0, NULL, - 0x330254ce, 0xc91dd3b5,0x3f1986bd,0x94fba150,0xe753c2da,0x4dee78e7, NULL, NULL }, - { _T("AdIDE 40/44 v34"), 34, 0, 34, 0, _T("ADIDE\0"), 16384, 129, 0, 0, ROMTYPE_ADIDE, 0, 0, NULL, - 0xedf84cbe, 0xabdbc01d,0xaa0b3aae,0xe4401ad7,0xe65525a9,0x6bfa2b27, NULL, NULL }, - { _T("Vector Falcon 8000 v7.1"), 7, 1, 7, 1, _T("VECTOR\0"), 32768, 128, 0, 0, ROMTYPE_VECTOR, 0, 0, NULL, - 0xa8120c55, 0x248935ab,0xf4d74036,0xefdafdbb,0x7817e232,0xfc13e0fa, NULL, NULL }, - ALTROMPN(128, 1, 1, 16384, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x798b1152, 0x603ba087,0xecee69ac,0x7ccf6e88,0x3e374fc8,0x808bcbb4) - ALTROMPN(128, 1, 2, 16384, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xd8b2f469, 0xbc600f99,0xa0ff7384,0xdabc7a04,0xb7bb0e71,0xad615db5) - { - _T("Vector Falcon 8000 v7.6"), 7, 6, 7, 6, _T("VECTOR\0"), 32768, 172, 0, 0, ROMTYPE_VECTOR, 0, 0, NULL, - 0x2177a145, 0x8a7e617f,0xed566bb8,0xb33f6409, 0x05d9b946, 0xcee6d4bf, NULL, NULL - }, - ALTROMPN(172, 1, 1, 16384, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x6228a3e4,0x72fa4175,0x21731e91,0x6c6c8519,0x91110287,0x9f4c0cb9) - ALTROMPN(172, 1, 2, 16384, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xf0a0ab0d,0xd239405a,0x5c4983ce,0xeaff0fd2,0x36d42d82,0x5a0cafd1) - { - _T("Kommos A500/A2000 v1.8"), 1, 8, 1, 8, _T("KOMMOS\0"), 32768, 127, 0, 0, ROMTYPE_KOMMOS, 0, 0, NULL, - 0xc1a5c848, 0x291310f1, 0x25455f2d, 0x8e114bcd, 0xe104ca4c, 0x9db51747, NULL, NULL - }, - ALTROMPN(127, 1, 1, 16384, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x1b86d2ed, 0x969995a1, 0x2ebf8c15, 0xab87e8d0, 0xddc837a1, 0xb90fbfa8) - ALTROMPN(127, 1, 2, 16384, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x65b4c3a0, 0x60e904d4, 0xe45bb6ba, 0x3e253ffa, 0xda4ee2e5, 0xc8548da1) - { - _T("Kommos A500/A2000 v1.7"), 1, 7, 1, 7, _T("KOMMOS\0"), 32768, 140, 0, 0, ROMTYPE_KOMMOS, 0, 0, NULL, - 0x025d7835, 0x8205ad6e, 0x08dbf5a6, 0x9ba17956, 0xb5237ffe, 0x768de5a4, NULL, NULL - }, - ALTROMPN(140, 1, 1, 16384, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x3d982391, 0xbe26e141, 0x1e16cab4, 0xeab8af33, 0x1476ef8e, 0x21fcb2af) - ALTROMPN(140, 1, 2, 16384, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x68adc0ad, 0xb5eef088, 0xed8a9439, 0xb0302907, 0xcb3cb207, 0x62f28da7) - { - _T("Kupke Golem v3.9"), 3, 9, 3, 9, _T("GOLEM\0"), 16384, 124, 0, 0, ROMTYPE_GOLEM, 0, 0, NULL, - 0x49157dd0, 0x03b615c9,0x2befa474,0xa37303ca,0xdc3e830d,0x3c0d9a9f, NULL, NULL - }, - ALTROMPN(124, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x88cf2ec5, 0x59680f8d, 0xae520893, 0xff9ada35, 0xac9a1146, 0x4f87453c) - ALTROMPN(124, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x713298ad, 0x2ad7d6f3, 0xd696fd2c, 0x51a256ee, 0xea185c47, 0x52906e04) - { - _T("GVP Series I v1.0"), 1, 0, 1, 16, _T("GVPI\0"), 16384, 123, 0, 0, ROMTYPE_GVPS1, 0, 0, NULL, - 0x1a4c20aa, 0xb9a3377e,0x2d9b5163,0x28693c63,0x19ffb65b,0x40ae3618, NULL, NULL - }, - ALTROMPN(123, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x27f15785, 0x1a71a78d, 0xdd4e9559, 0x0f133bba, 0x4a71122f, 0x44caef78) - ALTROMPN(123, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xa723193e, 0x05b4a072, 0x785c7824, 0x54e003c3, 0x6d88bd9b, 0xf5f561b9) - { - _T("GVP Series I/II v3.15"), 3, 15, 3, 15, _T("GVPII\0GVPI\0"), 16384, 111, 0, 0, ROMTYPE_GVPS12, 0, 0, NULL, - 0xf99c6f11, 0x77098a9e,0x35acaef2,0x11a546f0,0xc564cdac,0xf52836c4, NULL, NULL - }, - { _T("GVP Series II v4.15"), 4, 15, 4, 15, _T("GVPII\0"), 16384, 109, 0, 0, ROMTYPE_GVPS2, 0, 0, NULL, - 0xf89f44d6, 0xbf10c12c,0xc72dd040,0x549ea17c,0x24947633,0xe3773297, NULL, NULL }, - { _T("GVP Series II Guru ROM"), 6, 14, 6, 14, _T("GVPII\0"), 32768, 110, 0, 0, ROMTYPE_GVPS2, 0, 0, NULL, - 0x756103b1, 0x7f1335ea,0xf5b7ce73,0xc5231173,0x261da5aa,0xe7249645, NULL, NULL }, - { _T("AlfaPower v6.10"), 6, 10, 6, 10, _T("ALFAPOWER\0"), 32768, 117, 0, 0, ROMTYPE_ALFA, 0, 0, NULL, - 0x1cfb0a0b, 0xc7275eda,0x547d6664,0x5c4eb7a0,0x3b5cef37,0xa498365a, NULL, NULL }, - { _T("AlfaPower v8.3"), 8, 3, 8, 3, _T("ALFAPOWERPLUS\0"), 32768, 118, 0, 0, ROMTYPE_ALFAPLUS, 0, 0, NULL, - 0xe8201bad, 0xdefea015,0x596fce32,0x11e84397,0x23046a31,0x5a7726dc, NULL, NULL }, - { _T("Masoboshi MC-702 v2.201"), 2, 201, 2, 201, _T("MASOBOSHI\0"), 32768, 120, 0, 0, ROMTYPE_MASOBOSHI, 0, 0, NULL, - 0xcd99b98a, 0x3897e46a,0x66d5833f,0x849b8e81,0x30acb3cb,0x319a2fa0, NULL, NULL }, - { _T("Roctec RocHard RH800C v1"), 1, 0, 1, 0, _T("ROCHARD\0"), 16384, 138, 0, 0, ROMTYPE_ROCHARD, 0, 0, NULL, - 0x0e980aec, 0xbcafa14d,0xe80576cb,0xe3e0c638,0x1ca90379,0xe078a8bd, NULL, NULL }, - ALTROMPN(138, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xde3a855b, 0xda2fe069, 0xd78c9ccc, 0xc221711f, 0x1e598298, 0x2bdabffd) - ALTROMPN(138, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xb0ed3006, 0x0a88d84e, 0x2094f9e5, 0x18d37f90, 0x34764f22, 0x9696c3d9) - { - _T("Roctec RocHard RH800C v2"), 2, 0, 2, 0, _T("ROCHARD\0"), 16384, 146, 0, 0, ROMTYPE_ROCHARD, 0, 0, NULL, - 0x5c27be3f, 0xacdb8bc7,0x64493f65,0x9da4c1e8,0x3005ceeb,0xced73dbc, NULL, NULL - }, - ALTROMPN(146, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xc5b8f068, 0x6ada1205, 0x44d284d0, 0x326d68cb, 0x7a2d9fb4, 0x77f35852) - ALTROMPN(146, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xc88843cb, 0x3d7eb1b6, 0x8139b81b, 0x0665684c, 0x536ab3d0, 0x52a5dd9d) - { - _T("Apollo 500/2000"), 0, 0, 0, 0, _T("APOLLOHD\0"), 16384, 145, 0, 0, ROMTYPE_APOLLOHD, 0, 0, NULL, - 0x931bad25, 0x24b4ee4c,0x129c7a93,0xf83ad570,0x66afd80c,0x4179f39c, NULL, NULL - }, - { _T("Multi Evolution 500/2000 v3.0"), 3, 0, 3, 0, _T("MULTIEVOLUTION\0"), 65536, 156, 0, 0, ROMTYPE_MEVOLUTION, 0, 0, NULL, - 0xd13a2c89, 0xf9e38c4b,0xf5c6499d,0x486946ba,0x7b7636b8,0x0845265b, NULL, NULL }, - ALTROMPN(156, 1, 1, 32768, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x339b3549, 0x74de857b, 0x42f9a8e0, 0xc1f3c29e, 0x06982622, 0x853d08fe) - ALTROMPN(156, 1, 2, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x3aca5d1f, 0x786f2197, 0xc614be91, 0xae7e87da, 0xb42c3290, 0xd7997763) - { - _T("Kupke Golem v4.2"), 4, 2, 4, 2, _T("GOLEMFAST\0"), 16384, 157, 0, 0, ROMTYPE_GOLEMFAST, 0, 0, NULL, - 0x5e94ee56, 0xf83dae55, 0x49f9b735, 0x52d5c6e0, 0x41da4c6c, 0x995a7f47, NULL, NULL - }, - ALTROMPN(157, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xec13fda0, 0x6af1447c, 0x4363c46d, 0x05697458, 0x01daa30c, 0x03c01c9f) - ALTROMPN(157, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x39b0075e, 0xf6644ea0, 0x6c3ed349, 0xfb0fb6b4, 0xa9f07655, 0x0b104179) - { - _T("Phoenix Board SCSI v.J"), 3, 1, 3, 1, _T("PBSCSI\0"), 32768, 159, 0, 0, ROMTYPE_PHOENIXB, 0, 0, NULL, - 0x1f672e4b, 0xb20d50b8, 0x31ec9823, 0xfa732fc6, 0x522ecc6a, 0xae36ec33, NULL, NULL - }, - { _T("IVS GramdSlam/Trumpcard Pro v4.9"), 4, 9, 4, 9, _T("IVSPRO\0"), 16384, 161, 0, 0, ROMTYPE_IVSTPRO, 0, 0, NULL, - 0x4a15f224, 0x29500b47, 0x289e84ac, 0x575e3c7d, 0x82199b45, 0x605d8fc9, NULL, NULL }, - { _T("Expansion Systems Dataflyer+ v1.5"), 1, 5, 1, 5, _T("DATAFLYERPLUS\0"), 32768, 170, 0, 0, ROMTYPE_DATAFLYER, 0, 0, NULL, - 0x00888f19, 0x54b73354, 0xb3592691, 0x59a80909, 0x0bdb67df, 0x8ac22aa9, NULL, NULL }, - { _T("Expansion Systems Dataflyer+ v1.7"), 1, 7, 1, 7, _T("DATAFLYERPLUS\0"), 32768, 171, 0, 0, ROMTYPE_DATAFLYER, 0, 0, NULL, - 0xb0814aca, 0xb817672c, 0x1beb86c6, 0x840aa4bd, 0xf4640835, 0x1ed103f4, NULL, NULL }, - { _T("Expansion Systems Dataflyer+ v2.1"), 2, 1, 2, 1, _T("DATAFLYERPLUS\0"), 32768, 169, 0, 0, ROMTYPE_DATAFLYER, 0, 0, NULL, - 0xc49daa65, 0x20275716, 0xdc7eb00e, 0x5dc53680, 0xb5c8a90a, 0x7c00e390, NULL, NULL }, - { _T("Microbotics HardFrame v1.5"), 1, 5, 1, 5, _T("HARDFRAME\0"), 32768, 173, 0, 0, ROMTYPE_HARDFRAME, 0, 0, NULL, - 0x8d144212, 0xc5a4f497, 0x5216c1b1, 0xe08760d0, 0x0bd579ef, 0xea226354, NULL, NULL }, - { _T("Mainhattan Data A-Team v1.8"), 1, 8, 1, 8, _T("ATEAM\0"), 65536, 174, 0, 0, ROMTYPE_ATEAM, 0, 0, NULL, - 0x4fe08a5d, 0x007e5c61, 0x4048f598, 0x6d14011d, 0x23a41435, 0x5e0a2259, NULL, NULL }, - { _T("M-Tec AT500 Megabody v1.33"), 1, 33, 1, 33, _T("MTECAT\0"), 32768, 199, 0, 0, ROMTYPE_MTEC, 0, 0, NULL, - 0x19715a2f, 0x124f9d10, 0x19f1b285, 0x16f33f4e, 0x2bf03ca0, 0x2f9ad772, NULL, NULL }, - { _T("Comspec SA-1000 v34.805"), 34, 805, 34, 805, _T("COMSPEC\0"), 16384, 200, 0, 0, ROMTYPE_COMSPEC, 0, 0, NULL, - 0x44458e28, 0x048b8232, 0xfe54252b, 0xb81e0d06, 0x83c9e92d, 0x880f3cbf, NULL, NULL }, - ALTROMPN(200, 1, 1, 8192, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xd5838a35, 0xb3d83657, 0x661a9fe1, 0xd54e6e69, 0xc8b13878, 0x0960a107) - ALTROMPN(200, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x098c5529, 0x6f51827d, 0x40a79438, 0x69e2d0fb, 0x6e2e46e9, 0xb65c1244) - { - _T("California Access Malibu v1.0"), 1, 0, 1, 0, _T("MALIBU\0"), 8192, 201, 0, 0, ROMTYPE_MALIBU, 0, 0, NULL, - 0xe60b1ce6, 0xa7c4b709, 0x494f4034, 0x42b8ec11, 0x090dc1d0, 0x18098ebc, NULL, NULL - }, + { _T("A1060 BIOS 2.06"), 2, 6, 2, 6, _T("A1060\0"), 16384, 147, 0, 0, ROMTYPE_A1060, 0, 0, _T("380619-03"), + 0x185f2bbd, 0xeba74ad1,0x000a5351,0xa5d99179,0xbf75f831,0xac2d2402, NULL, NULL }, + { _T("A2088 BIOS 3.4"), 3, 4, 3, 4, _T("A2088\0"), 16384, 148, 0, 0, ROMTYPE_A2088, 0, 0, _T("380788-04"), + 0x05552160, 0xd1defdee, 0x1c0eae41, 0x07d81e26, 0x74915cd2, 0x9d352f2e, NULL, NULL }, + { _T("A2088 BIOS 3.5"), 3, 5, 3, 5, _T("A2088\0"), 16384, 158, 0, 0, ROMTYPE_A2088, 0, 0, _T("380788-04"), + 0xf8e1ad83, 0x45a2b7db,0x6e86fe80,0x5cfef63c,0x65c331a7,0x16a6e9e8, NULL, NULL }, + { _T("A2088 BIOS 3.6.1"), 3, 61, 3, 61, _T("A2088\0"), 16384, 149, 0, 0, ROMTYPE_A2088, 0, 0, _T("380788-06"), + 0x5fd93e56, 0xc1b707a8,0xa62907d7,0x5299f10a,0xa60efd1f,0x44514b26, NULL, NULL }, + { _T("A2088T BIOS 4.0 (09/11/89)"), 4, 10, 4, 10, _T("A2088T\0"), 32768, 203, 0, 0, ROMTYPE_A2088T, 0, 0, _T("390657-01"), + 0x12545545, 0x54f7a99e,0x2e5dbc30,0x43f52001,0xa4abb3b6,0x8e4832fd, NULL, NULL }, + { _T("A2088T BIOS 4.0 (14/11/89)"), 4, 10, 4, 10, _T("A2088T\0"), 32768, 204, 0, 0, ROMTYPE_A2088T, 0, 0, _T("390657-01"), + 0xb6b3b6f7, 0x7929a92f,0x25203cea,0xad302ddd,0x31db55cd,0x49b3020a, NULL, NULL }, + { _T("A2088T BIOS 4.10"), 4, 10, 4, 11, _T("A2088T\0"), 32768, 150, 0, 0, ROMTYPE_A2088T, 0, 0, _T("390657-02"), + 0x20c5d1a9, 0x08e3fbb7,0x28dfc514,0x24083313,0x373ea7a5,0xa2c3e965, NULL, NULL }, + { _T("A2088T BIOS 4.11"), 4, 11, 4, 11, _T("A2088T\0"), 32768, 151, 0, 0, ROMTYPE_A2088T, 0, 0, _T("390547-02"), + 0x074bc9b0, 0x2a3f56bc,0xe395f203,0x46eb68c4,0xade7153e,0x3e69f892, NULL, NULL }, + { _T("A2088T BIOS 4.12"), 4, 12, 4, 12, _T("A2088T\0"), 32768, 152, 0, 0, ROMTYPE_A2088T, 0, 0, _T("390547-03"), + 0x92447176, 0x582fa254,0x73aa2679,0xefcd41a5,0xbdadf1a2,0x6a87a75f, NULL, NULL }, + { _T("A2286 BIOS 3.6"), 3, 6, 3, 6, _T("A2286\0"), 32768, 153, 0, 0, ROMTYPE_A2286, 0, 0, NULL, + 0x63d75f70, 0x9f5d6c78,0x656d2fe7,0x36608644,0x771b6d30,0x31083264, NULL, NULL }, + ALTROMPN(153, 1, 1, 16384, ROMTYPE_ODD | ROMTYPE_8BIT, _T("380682-03"), 0xb3f76402, 0xef9ba5f2, 0x2714ad6d, 0xfa5e0aef, 0x2d09ce83, 0x578ee26d) + ALTROMPN(153, 1, 2, 16384, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("380683-03"), 0xab053693, 0x75229d80, 0x443fad78, 0xa298d04b, 0x37c8e6c3, 0x2c1b6df0) + { _T("A2286 BIOS 4.2"), 4, 2, 4, 2, _T("A2286\0"), 32768, 154, 0, 0, ROMTYPE_A2286, 0, 0, NULL, + 0xd572e205, 0x74fdf0f8,0x325fbc41,0x2b98c72d,0xf5095804,0x831c46b5, NULL, NULL }, + ALTROMPN(154, 1, 1, 16384, ROMTYPE_ODD | ROMTYPE_8BIT, _T("380682-04"), 0xc23dcd55, 0x38dc24b7, 0x14427b15, 0xd5214cc9, 0xb9be0de7, 0x20bd6a34) + ALTROMPN(154, 1, 2, 16384, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("380683-04"), 0xdad80c0b, 0x12fe2916, 0x64f8c412, 0x3877a24e, 0x05837091, 0x44d8acd0) + { _T("A2386SX BIOS 1.00"), 1, 0, 1, 0, _T("A2386SX\0"), 65536, 155, 0, 0, ROMTYPE_A2386, 0, 0, _T("391168-01"), + 0x37003e0c, 0x2e127e9c,0x8581d30c,0x2e46404b,0x21608e3c,0xe935fa27, NULL, NULL }, + { _T("A2386SX BIOS 1.00.03"), 1, 0, 1, 0, _T("A2386SX\0"), 65536, 205, 0, 0, ROMTYPE_A2386, 0, 0, _T("391168-01"), + 0x41041761, 0x78659be4,0x5755f8bd,0x004a101b,0x658ae75d,0xf142ddc9, NULL, NULL }, - { _T("CyberStorm MK I 68040"), 0, 0, 0, 0, _T("CSMKI\0"), 32768, 95, 0, 0, ROMTYPE_CB_CSMK1, 0, 0, NULL, - 0, 0, 0, 0, 0, 0, NULL, _T("cyberstormmk1_040.rom") }, - { _T("CyberStorm MK I 68060"), 0, 0, 0, 0, _T("CSMKI\0"), 65536, 101, 0, 0, ROMTYPE_CB_CSMK1, 0, 0, NULL, - 0, 0, 0, 0, 0, 0, NULL, _T("cyberstormmk1_060.rom") }, - { _T("CyberStorm MK II"), 0, 0, 0, 0, _T("CSMKII\0"), 131072, 96, 0, 0, ROMTYPE_CB_CSMK2, 0, 0, NULL, - 0, 0, 0, 0, 0, 0, NULL, _T("cyberstormmk2.rom") }, - { _T("CyberStorm MK III"), 0, 0, 0, 0, _T("CSMKIII\0"), 131072, 97, 0, 0, ROMTYPE_CB_CSMK3, 0, 0, NULL, - 0, 0, 0, 0, 0, 0, NULL, _T("cyberstormmk3.rom") }, - { _T("CyberStorm PPC"), 0, 0, 0, 0, _T("CSPPC\0"), 131072, 98, 0, 0, ROMTYPE_CB_CSPPC, 0, 0, NULL, - 0, 0, 0, 0, 0, 0, NULL, _T("cyberstormppc.rom") }, - { _T("Blizzard PPC 68040"), 0, 0, 0, 0, _T("BPPC\0"), 524288, 99, 0, 0, ROMTYPE_CB_BLIZPPC, 0, 0, NULL, - 0, 0, 0, 0, 0, 0, NULL, _T("blizzardppc_040.rom") }, - { _T("Blizzard PPC 68060"), 0, 0, 0, 0, _T("BPPC\0"), 524288, 100, 0, 0, ROMTYPE_CB_BLIZPPC, 0, 0, NULL, - 0, 0, 0, 0, 0, 0, NULL, _T("blizzardppc_060.rom") }, - { _T("ACA 500"), 0, 0, 0, 0, _T("ACA500\0"), 524288, 137, 0, 0, ROMTYPE_CB_ACA500, 0, 0, NULL, - 0, 0, 0, 0, 0, 0, NULL, _T("menu500.aca") }, + { _T("Arcadia OnePlay 2.11"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 49, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 }, + { _T("Arcadia TenPlay 2.11"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 50, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 }, + { _T("Arcadia TenPlay 2.20"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 75, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 }, + { _T("Arcadia OnePlay 3.00"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 51, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 }, + { _T("Arcadia TenPlay 3.11"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 76, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 }, + { _T("Arcadia TenPlay 4.00"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 77, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 }, - { _T("Picasso IV"), 7, 4, 7, 4, _T("PIV\0"), 131072, 91, 0, 0, ROMTYPE_PICASSOIV, 0, 0, NULL, - 0xa8133e7e, 0xcafafb91,0x6f16b9f3,0xec9b49aa,0x4b40eb4e,0xeceb5b5b }, + { _T("Arcadia SportTime Table Hockey v2.1"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 33, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia SportTime Bowling v2.1"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 34, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia World Darts v2.1"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 35, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Magic Johnson's Fast Break v2.8"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 36, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Leader Board Golf v2.4"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 37, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Leader Board Golf"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 38, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Ninja Mission v2.5"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 39, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Road Wars v2.3"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 40, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Sidewinder v2.1"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 41, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Spot v2.0"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 42, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Space Ranger v2.0"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 43, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Xenon v2.3"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 44, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia World Trophy Soccer v3.0"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 45, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Blastaball v2.1"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 78, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Delta Command"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 79, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Pharaohs Match"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 80, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia SportTime Table Hockey"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 81, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia World Darts (bad)"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 82, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Magic Johnson's Fast Break v2.7"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 83, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Ninja Mission"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 84, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Sidewinder"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 85, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Leader Board Golf v2.5"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 86, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, + { _T("Arcadia Aaargh"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 88, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("A1060 BIOS 2.06"), 2, 6, 2, 6, _T("A1060\0"), 16384, 147, 0, 0, ROMTYPE_A1060, 0, 0, _T("380619-03"), - 0x185f2bbd, 0xeba74ad1,0x000a5351,0xa5d99179,0xbf75f831,0xac2d2402, NULL, NULL }, - { _T("A2088 BIOS 3.4"), 3, 4, 3, 4, _T("A2088\0"), 16384, 148, 0, 0, ROMTYPE_A2088, 0, 0, _T("380788-04"), - 0x05552160, 0xd1defdee, 0x1c0eae41, 0x07d81e26, 0x74915cd2, 0x9d352f2e, NULL, NULL }, - { _T("A2088 BIOS 3.5"), 3, 5, 3, 5, _T("A2088\0"), 16384, 158, 0, 0, ROMTYPE_A2088, 0, 0, _T("380788-04"), - 0xf8e1ad83, 0x45a2b7db,0x6e86fe80,0x5cfef63c,0x65c331a7,0x16a6e9e8, NULL, NULL }, - { _T("A2088 BIOS 3.6.1"), 3, 61, 3, 61, _T("A2088\0"), 16384, 149, 0, 0, ROMTYPE_A2088, 0, 0, _T("380788-06"), - 0x5fd93e56, 0xc1b707a8,0xa62907d7,0x5299f10a,0xa60efd1f,0x44514b26, NULL, NULL }, - { _T("A2088T BIOS 4.0 (09/11/89)"), 4, 10, 4, 10, _T("A2088T\0"), 32768, 203, 0, 0, ROMTYPE_A2088T, 0, 0, _T("390657-01"), - 0x12545545, 0x54f7a99e,0x2e5dbc30,0x43f52001,0xa4abb3b6,0x8e4832fd, NULL, NULL }, - { _T("A2088T BIOS 4.0 (14/11/89)"), 4, 10, 4, 10, _T("A2088T\0"), 32768, 204, 0, 0, ROMTYPE_A2088T, 0, 0, _T("390657-01"), - 0xb6b3b6f7, 0x7929a92f,0x25203cea,0xad302ddd,0x31db55cd,0x49b3020a, NULL, NULL }, - { _T("A2088T BIOS 4.10"), 4, 10, 4, 11, _T("A2088T\0"), 32768, 150, 0, 0, ROMTYPE_A2088T, 0, 0, _T("390657-02"), - 0x20c5d1a9, 0x08e3fbb7,0x28dfc514,0x24083313,0x373ea7a5,0xa2c3e965, NULL, NULL }, - { _T("A2088T BIOS 4.11"), 4, 11, 4, 11, _T("A2088T\0"), 32768, 151, 0, 0, ROMTYPE_A2088T, 0, 0, _T("390547-02"), - 0x074bc9b0, 0x2a3f56bc,0xe395f203,0x46eb68c4,0xade7153e,0x3e69f892, NULL, NULL }, - { _T("A2088T BIOS 4.12"), 4, 12, 4, 12, _T("A2088T\0"), 32768, 152, 0, 0, ROMTYPE_A2088T, 0, 0, _T("390547-03"), - 0x92447176, 0x582fa254,0x73aa2679,0xefcd41a5,0xbdadf1a2,0x6a87a75f, NULL, NULL }, - { _T("A2286 BIOS 3.6"), 3, 6, 3, 6, _T("A2286\0"), 32768, 153, 0, 0, ROMTYPE_A2286, 0, 0, NULL, - 0x63d75f70, 0x9f5d6c78,0x656d2fe7,0x36608644,0x771b6d30,0x31083264, NULL, NULL }, - ALTROMPN(153, 1, 1, 16384, ROMTYPE_ODD | ROMTYPE_8BIT, _T("380682-03"), 0xb3f76402, 0xef9ba5f2, 0x2714ad6d, 0xfa5e0aef, 0x2d09ce83, 0x578ee26d) - ALTROMPN(153, 1, 2, 16384, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("380683-03"), 0xab053693, 0x75229d80, 0x443fad78, 0xa298d04b, 0x37c8e6c3, 0x2c1b6df0) - { - _T("A2286 BIOS 4.2"), 4, 2, 4, 2, _T("A2286\0"), 32768, 154, 0, 0, ROMTYPE_A2286, 0, 0, NULL, - 0xd572e205, 0x74fdf0f8,0x325fbc41,0x2b98c72d,0xf5095804,0x831c46b5, NULL, NULL - }, - ALTROMPN(154, 1, 1, 16384, ROMTYPE_ODD | ROMTYPE_8BIT, _T("380682-04"), 0xc23dcd55, 0x38dc24b7, 0x14427b15, 0xd5214cc9, 0xb9be0de7, 0x20bd6a34) - ALTROMPN(154, 1, 2, 16384, ROMTYPE_EVEN | ROMTYPE_8BIT, _T("380683-04"), 0xdad80c0b, 0x12fe2916, 0x64f8c412, 0x3877a24e, 0x05837091, 0x44d8acd0) - { - _T("A2386SX BIOS 1.00"), 1, 0, 1, 0, _T("A2386SX\0"), 65536, 155, 0, 0, ROMTYPE_A2386, 0, 0, _T("391168-01"), - 0x37003e0c, 0x2e127e9c,0x8581d30c,0x2e46404b,0x21608e3c,0xe935fa27, NULL, NULL - }, - { _T("A2386SX BIOS 1.00.03"), 1, 0, 1, 0, _T("A2386SX\0"), 65536, 205, 0, 0, ROMTYPE_A2386, 0, 0, _T("391168-01"), - 0x41041761, 0x78659be4,0x5755f8bd,0x004a101b,0x658ae75d,0xf142ddc9, NULL, NULL }, + // maddog_01.dat, maddog_02.dat + { _T("American Laser Games Mad Dog McCree v1C"), 0, 0, 0, 0, _T("ALG\0"), 131072, 175, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x48fd863c, 0x9bf6f337,0x585122a5,0x97c19d71,0x224e3b68,0x347a98de }, + ALTROMPN(175, 1, 1, 65536, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xf64014ec, 0xd343a2cb, 0x5d899215, 0x3b8c916f, 0x39b11d3d, 0xb736543d) + ALTROMPN(175, 1, 2, 65536, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x04572557, 0x3dfe2ce9, 0x4ced8701, 0xa3e73ed5, 0x869b6fbe, 0x1c8b3286) + // md_2.02_u1.bin, md_2.02_u2.bin + { _T("American Laser Games Mad Dog McCree v2.02"), 0, 0, 0, 0, _T("ALG\0"), 262144, 176, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x65181234, 0x321fe70a,0xb0986712,0xe4c6cc17,0x0fe48f1d,0x491ba069 }, + ALTROMPN(176, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xf46e1242, 0x2960bc18,0x00b22eea,0x50036ae4,0x3fd3cb2a,0xb7dcf8a4) + ALTROMPN(176, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xa49890d1, 0x148f78fb,0x426f5b91,0x2e8c3836,0xa149bfcb,0x966da477) + // md_2.03_1.bin, md_2.03_2.bin + { _T("American Laser Games Mad Dog McCree v2.03"), 0, 0, 0, 0, _T("ALG\0"), 262144, 177, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0xbf0878ad, 0x7ff88de7,0x3fd5245e,0x346cca21,0xd0765de1,0x8ba28877 }, + ALTROMPN(177, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xa50d3c04, 0x4cf100fd,0xb5b2f223,0x6539fd0e,0xc33b3db1,0x9c64a6b8) + ALTROMPN(177, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x6f5b8f2d, 0xbbf32bb2,0x7a998d53,0x744411d7,0x5efdbdb7,0x30855809) + // md2_01.bin, md2_02.bin + { _T("American Laser Games Mad Dog II: The Lost Gold v2.02"), 0, 0, 0, 0, _T("ALG\0"), 262144, 178, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x992f9a53, 0xf039a74c,0xc63e1465,0xb3036d4c,0x030df1ef,0x5ba03ff4 }, + ALTROMPN(178, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xaddffa51, 0x665e9d93,0xddfa6b2e,0xa5d006b4,0x1bf7eac3,0x294244cc) + ALTROMPN(178, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x4092227f, 0x6e5393aa,0x5e64b598,0x87260f48,0x3c509600,0x84de7bd1) + // md2_1.10_u1.bin, md2_1.10_u2.bin + { _T("American Laser Games Mad Dog II: The Lost Gold v1.10"), 0, 0, 0, 0, _T("ALG\0"), 262144, 179, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0xc3230ece, 0x4dd60b21,0xf7ab65cd,0x77304753,0x6a4ff2eb,0x75b0778c }, + ALTROMPN(179, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x0e113b2c, 0x739d777f,0x3cb92fbc,0x730c6c1b,0x664d8741,0x21d191b1) + ALTROMPN(179, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x61808612, 0x1a0a301e,0x79585a81,0xe6cf4673,0x7068970f,0xb8a205fa) + // md2_01_v.2.04.bin, md2_02_v.2.04.bin + { _T("American Laser Games Mad Dog II: The Lost Gold v2.04"), 0, 0, 0, 0, _T("ALG\0"), 262144, 180, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x1b9ddae6, 0xd52cc668,0xe4876294,0x5c4d9033,0x71d8a0b1,0x323b4464 }, + ALTROMPN(180, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x361bd99c, 0x5de6ef38,0xe334e19f,0x509227de,0x7880306a,0xc984ec23) + ALTROMPN(180, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x0e1227f4, 0xbfd9081b,0xb7d2bcbb,0x77357839,0xf292ce61,0x36e9b228) + // md2_1.0_1.bin, md2_1.0_2.bin + { _T("American Laser Games Mad Dog II: The Lost Gold v1.00"), 0, 0, 0, 0, _T("ALG\0"), 262144, 181, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x348b1a05, 0xece8f1ec,0x4d97f98d,0xb1279ed5,0x28cb0fca,0x51c167bb }, + ALTROMPN(181, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x0ce8db97, 0xdd4c09db,0x59bb8c6c,0xaba935b1, 0xb28babe2, 0x8ba8516b) + ALTROMPN(181, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x97272a1d, 0x10901464,0x7c491f01,0x9ffb2109, 0x1c7d0b89, 0xe1755b75) + // sp_14_u1.bin, sp_14_u2.bin + { _T("American Laser Games Space Pirates v1.4"), 0, 0, 0, 0, _T("ALG\0"), 262144, 182, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x69e09b90, 0xda3cba84,0x1c37222f,0xc45b4704,0x997072ad,0x1e9a1f8e }, + ALTROMPN(182, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x4102988c, 0x969d4668,0xbe50990c,0x7debf9ed,0x4e8b8c6e,0x422acdf5) + ALTROMPN(182, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x30390ab0, 0x80fa14d8,0x81902258,0x398225bd,0xfd71ed5e,0x9e2d6c91) + // sp_01.dat, sp_02.dat + { _T("American Laser Games Space Pirates v2.2"), 0, 0, 0, 0, _T("ALG\0"), 262144, 183, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x09c2cfcb, 0x93ad6a25,0x77fa7870,0x971890f2,0x6af11382, 0xa433f80b }, + ALTROMPN(183, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x10d162a2, 0x26833d5b,0xe1057be8,0x639c00a7,0xbe18be33,0x404ea751) + ALTROMPN(183, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xc0975188, 0xfd7643dc,0x972e7861,0x249ab7e7,0x61999759,0x84888ae4) + // johnny_01.bin, johnny_02.bin + { _T("American Laser Games Who Shot Johnny Rock? v1.6"), 0, 0, 0, 0, _T("ALG\0"), 131072, 184, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0xaeda7df4, 0xa612c4b9,0x2bd81ab9,0x564e58da,0x9a6a4d81,0x93c59acf }, + ALTROMPN(184, 1, 1, 65536, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x046569b3, 0xefe5a8b2,0xbe1c5556,0x95f2a91c,0x88951d35,0x45f1b915) + ALTROMPN(184, 1, 2, 65536, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xedde1745, 0x573b79f8,0x808fedaa,0xbf3b7623,0x50a91579,0x2d26c1bc) + // wsjr151.bin,wsjr152.bin + { _T("American Laser Games Who Shot Johnny Rock? v1.5"), 0, 0, 0, 0, _T("ALG\0"), 131072, 185, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x50eb4827, 0x72568673,0x4163aa16,0xd0ad3177,0xbd720187,0x125a63ec }, + ALTROMPN(185, 1, 1, 65536, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x8ab626dd, 0xe45561f7,0x7fc279b7,0x1dc1dd2e,0x15a0870c,0xb5c1cd89) + ALTROMPN(185, 1, 2, 65536, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x9beeb1d7, 0x3fe0265e,0x5d36103d,0x3d9557d7,0x5e5e3728,0xe0b30da7) + // gg_1.dat,gg_2.dat + { _T("American Laser Games Gallagher's Gallery v2.2"), 0, 0, 0, 0, _T("ALG\0"), 262144, 186, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0xcbe791de, 0x17aa6f16,0x7e138409,0xe1ef039e,0x928fee5a,0xf43e91cb }, + ALTROMPN(186, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x855c9d82, 0x96711aaa,0x02f309ca,0xcd3e8d8e,0xfbe95cfc,0x811aba96) + ALTROMPN(186, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x3793b211, 0xdccb1d9c,0x5e2d6a4d,0x249426ae,0x6348e9fc,0x9b72e665) + // gg_21_rom1.bin,gg_21_rom2.bin + { _T("American Laser Games Gallagher's Gallery v2.1"), 0, 0, 0, 0, _T("ALG\0"), 262144, 187, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x9bfe35bb, 0x76c8cad8,0xd0f4758f,0x1adc0fc9,0x7cb6ad30,0x44b54d47 }, + ALTROMPN(187, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x70f887e5, 0xcd6cedc8,0x5bbe6767,0x4dfd140f,0xed901877,0x8f8cd8db) + ALTROMPN(187, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x4109f39e, 0x42d06de4,0x2c56f21e,0x4899b4c4,0x252baabb,0x51f24fda) + // fd_131_u1.bin,fd_131_u2.bin + { _T("American Laser Games Fast Draw Showdown v1.31"), 0, 0, 0, 0, _T("ALG\0"), 262144, 188, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x6977addf, 0xdc845431,0xbb1a39bd,0x615afe5f,0x7cb7c8d0,0x3433ef8c }, + ALTROMPN(188, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xe1ed7982, 0xf7562c6e,0x0ce6bf1a,0x9885cc59,0x3e08c250,0x9f82bbe1) + ALTROMPN(188, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xb7c79ab3, 0x6eca1bc9,0x590c22a0,0x04fb8590,0x1e5c7d41,0xf5b14ee2) + // fast_01.bin,fast_02.bin + { _T("American Laser Games Fast Draw Showdown v1.30"), 0, 0, 0, 0, _T("ALG\0"), 262144, 189, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x47772e36, 0x5af67b5e,0xa56b2337,0xfdd427fb,0xd82d478f,0xb1994dbc }, + ALTROMPN(189, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x0d76a2da, 0xd396371a,0xe1b9b0b6,0xe6bc6f1f,0x85c4b97b,0xfc5dc34d) + ALTROMPN(189, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x4c4eb71e, 0x3bd487c5,0x46b6c807,0x70a5fc88,0x0dcb1039,0x5ca431a2) + // lbh_101_u1.bin,lbh_101_u2.bin + { _T("American Laser Games The Last Bounty Hunter v1.01"), 0, 0, 0, 0, _T("ALG\0"), 262144, 190, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0xd2a5a539, 0xb97c799b,0x53355b55,0x4dfbf335,0x6f20fd2b,0xa5998806 }, + ALTROMPN(190, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xb21c5c42, 0x9ac856cd,0xf2c9538c,0xc4ae55f0,0x79f33737,0x6d3361c0) + ALTROMPN(190, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xf13b25d2, 0xe2f663c2,0x3b03592f,0x482ef5e1,0xdf87b651,0x937a500d) + // bounty_01.bin,bounty_02.bin + { _T("American Laser Games The Last Bounty Hunter v0.06"), 0, 0, 0, 0, _T("ALG\0"), 262144, 191, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0xce600734, 0xe52aea03,0x080dcd08,0x8d4b61ed,0xe46de9c7,0xfc4dd74e }, + ALTROMPN(191, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x2727ef1d, 0xf5342139,0x0b65c21a,0x7666ff9d,0x0f53ebf2,0xa463d836) + ALTROMPN(191, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x977566b2, 0x937e079e,0x992ecb59,0x30b17c10,0x24c326e1,0x0962642b) + // cp_151_u1.bin,cp_151_u2.bin + { _T("American Laser Games Crime Patrol v1.51"), 0, 0, 0, 0, _T("ALG\0"), 262144, 192, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0xcada2bed, 0xc5da9d82,0x7864feff,0x75d87dd1,0x9ec06529,0x7d2b318b }, + ALTROMPN(192, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xaefd6e09, 0x351e665e,0x2e636804,0x7a5cc80d,0x0f9d876b,0xca068b6a) + ALTROMPN(192, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xf2270cee, 0x1e735373,0x723c3cff,0xb6dd04d5,0xc30c08e7,0x57deae61) + // cp01.dat,cp02.dat + { _T("American Laser Games Crime Patrol v1.4"), 0, 0, 0, 0, _T("ALG\0"), 262144, 193, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x51ba3153, 0x55086ba0,0xef41c6d6,0x41041b73,0x047cad38,0xaf2a21f3 }, + ALTROMPN(193, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xa39a8b50, 0x55ca317e,0xf13c3a42,0xf12d68c4,0x80e6cc2d,0x4459f6a4) + ALTROMPN(193, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xe41fd2e8, 0x1cd9875f,0xb4133ba4,0xe3616271,0x975dc736,0xb343f156) + // cp_1.20_u1.bin,cp_1.20_u2.bin + { _T("American Laser Games Crime Patrol v1.2"), 0, 0, 0, 0, _T("ALG\0"), 262144, 194, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x63e9f444, 0x6f2624a5,0x6a672f97,0xc751ae51,0xb4b834a5,0x097a855a }, + ALTROMPN(194, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x475e847a, 0x82fd1608,0x35758cd5,0x1ea22f90,0xb08921a4,0x0409f94d) + ALTROMPN(194, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x814f5777, 0x341a1d7b,0x64112af3,0xe8243bdb,0xfec72e7f,0xa85aa903) + // cp2_1.3_1.bin, cp2_1.3_2.bin + { _T("American Laser Games Crime Patrol 2: Drug Wars v1.3"), 0, 0, 0, 0, _T("ALG\0"), 262144, 195, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x57d1f606, 0xffbee51c,0x9c52a9c6,0x6440cbf8,0x34144321,0x75036282 }, + ALTROMPN(195, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xdbdaa79a, 0x99804490,0x9d5c93e3,0xbd1baafe,0xfab818fd,0xb7b3f55e) + ALTROMPN(195, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xe653395d, 0x8f6c86d9,0x8a52b7d8,0x5ae285fd,0x841167cd,0x07979318) + // cp2_1.dat, cp2_2.dat + { _T("American Laser Games Crime Patrol 2: Drug Wars v1.1"), 0, 0, 0, 0, _T("ALG\0"), 262144, 196, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x49c751db, 0x789679f9,0xa3fe3aa0,0xf9b8bb35,0x1f3ea632,0xe429408d }, + ALTROMPN(196, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xf4e5251e, 0xe0c91343,0xa98193d4,0x87c40e7a,0x85f542b2,0xa7a88f03) + ALTROMPN(196, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x47879042, 0x8bb6c541,0xe4e8e450,0x8da8d4b9,0x3600176a,0x2e7a1f41) + // platoonv4u1.bin,platoonv4u2.bin + { _T("Nova Platoon V.3.1 US"), 0, 0, 0, 0, _T("ALG\0"), 262144, 197, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0xad975c96, 0x9565207f,0x6684baa8,0xe5c85c34,0x740a3f60,0x75d3a7b5 }, + ALTROMPN(197, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x09a133cf, 0x9b3ff630,0x35be8576,0xc88fb284,0xa25c2da5,0xdb0d5160) + ALTROMPN(197, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x8b33263e, 0xa1df3823,0x6321af90,0xb522e2a7,0x83984fdf,0x02e4c597) + // zb_u2.bin,zb_u3.bin + { _T("Web Picmatic Zorton Brothers (Los Justicieros)"), 0, 0, 0, 0, _T("ALG\0"), 131072, 198, 0, 0, ROMTYPE_ALG, 0, 0, NULL, + 0x9cda09ae, 0x3353ae63,0x64b3d0b1,0x006db48e,0xa2bdc7b5,0x4946bbb9 }, + ALTROMPN(198, 1, 1, 65536, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xf59cfc4a, 0x9fadf7f1,0xe23d6b4e,0x828bf2b3,0xde919d08,0x7c690a3f) + ALTROMPN(198, 1, 2, 65536, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x938b25cb, 0xd0114bbc,0x588dcfce,0x6a469013,0xd0e35afb,0x93e38af5) - { _T("Arcadia OnePlay 2.11"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 49, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 }, - { _T("Arcadia TenPlay 2.11"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 50, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 }, - { _T("Arcadia TenPlay 2.20"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 75, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 }, - { _T("Arcadia OnePlay 3.00"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 51, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 }, - { _T("Arcadia TenPlay 3.11"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 76, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 }, - { _T("Arcadia TenPlay 4.00"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 77, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 }, - - { _T("Arcadia SportTime Table Hockey v2.1"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 33, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia SportTime Bowling v2.1"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 34, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia World Darts v2.1"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 35, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Magic Johnson's Fast Break v2.8"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 36, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Leader Board Golf v2.4"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 37, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Leader Board Golf"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 38, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Ninja Mission v2.5"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 39, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Road Wars v2.3"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 40, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Sidewinder v2.1"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 41, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Spot v2.0"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 42, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Space Ranger v2.0"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 43, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Xenon v2.3"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 44, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia World Trophy Soccer v3.0"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 45, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Blastaball v2.1"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 78, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Delta Command"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 79, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Pharaohs Match"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 80, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia SportTime Table Hockey"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 81, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia World Darts (bad)"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 82, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Magic Johnson's Fast Break v2.7"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 83, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Ninja Mission"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 84, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Sidewinder"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 85, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Leader Board Golf v2.5"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 86, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - { _T("Arcadia Aaargh"), 0, 0, 0, 0, _T("ARCADIA\0"), 0, 88, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 }, - - // maddog_01.dat, maddog_02.dat - { _T("American Laser Games Mad Dog McCree v1C"), 0, 0, 0, 0, _T("ALG\0"), 131072, 175, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x48fd863c, 0x9bf6f337,0x585122a5,0x97c19d71,0x224e3b68,0x347a98de }, - ALTROMPN(175, 1, 1, 65536, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xf64014ec, 0xd343a2cb, 0x5d899215, 0x3b8c916f, 0x39b11d3d, 0xb736543d) - ALTROMPN(175, 1, 2, 65536, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x04572557, 0x3dfe2ce9, 0x4ced8701, 0xa3e73ed5, 0x869b6fbe, 0x1c8b3286) - // md_2.02_u1.bin, md_2.02_u2.bin - { - _T("American Laser Games Mad Dog McCree v2.02"), 0, 0, 0, 0, _T("ALG\0"), 262144, 176, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x65181234, 0x321fe70a,0xb0986712,0xe4c6cc17,0x0fe48f1d,0x491ba069 - }, - ALTROMPN(176, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xf46e1242, 0x2960bc18,0x00b22eea,0x50036ae4,0x3fd3cb2a,0xb7dcf8a4) - ALTROMPN(176, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xa49890d1, 0x148f78fb,0x426f5b91,0x2e8c3836,0xa149bfcb,0x966da477) - // md_2.03_1.bin, md_2.03_2.bin - { - _T("American Laser Games Mad Dog McCree v2.03"), 0, 0, 0, 0, _T("ALG\0"), 262144, 177, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0xbf0878ad, 0x7ff88de7,0x3fd5245e,0x346cca21,0xd0765de1,0x8ba28877 - }, - ALTROMPN(177, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xa50d3c04, 0x4cf100fd,0xb5b2f223,0x6539fd0e,0xc33b3db1,0x9c64a6b8) - ALTROMPN(177, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x6f5b8f2d, 0xbbf32bb2,0x7a998d53,0x744411d7,0x5efdbdb7,0x30855809) - // md2_01.bin, md2_02.bin - { - _T("American Laser Games Mad Dog II: The Lost Gold v2.02"), 0, 0, 0, 0, _T("ALG\0"), 262144, 178, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x992f9a53, 0xf039a74c,0xc63e1465,0xb3036d4c,0x030df1ef,0x5ba03ff4 - }, - ALTROMPN(178, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xaddffa51, 0x665e9d93,0xddfa6b2e,0xa5d006b4,0x1bf7eac3,0x294244cc) - ALTROMPN(178, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x4092227f, 0x6e5393aa,0x5e64b598,0x87260f48,0x3c509600,0x84de7bd1) - // md2_1.10_u1.bin, md2_1.10_u2.bin - { - _T("American Laser Games Mad Dog II: The Lost Gold v1.10"), 0, 0, 0, 0, _T("ALG\0"), 262144, 179, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0xc3230ece, 0x4dd60b21,0xf7ab65cd,0x77304753,0x6a4ff2eb,0x75b0778c - }, - ALTROMPN(179, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x0e113b2c, 0x739d777f,0x3cb92fbc,0x730c6c1b,0x664d8741,0x21d191b1) - ALTROMPN(179, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x61808612, 0x1a0a301e,0x79585a81,0xe6cf4673,0x7068970f,0xb8a205fa) - // md2_01_v.2.04.bin, md2_02_v.2.04.bin - { - _T("American Laser Games Mad Dog II: The Lost Gold v2.04"), 0, 0, 0, 0, _T("ALG\0"), 262144, 180, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x1b9ddae6, 0xd52cc668,0xe4876294,0x5c4d9033,0x71d8a0b1,0x323b4464 - }, - ALTROMPN(180, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x361bd99c, 0x5de6ef38,0xe334e19f,0x509227de,0x7880306a,0xc984ec23) - ALTROMPN(180, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x0e1227f4, 0xbfd9081b,0xb7d2bcbb,0x77357839,0xf292ce61,0x36e9b228) - // md2_1.0_1.bin, md2_1.0_2.bin - { - _T("American Laser Games Mad Dog II: The Lost Gold v1.00"), 0, 0, 0, 0, _T("ALG\0"), 262144, 181, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x348b1a05, 0xece8f1ec,0x4d97f98d,0xb1279ed5,0x28cb0fca,0x51c167bb - }, - ALTROMPN(181, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x0ce8db97, 0xdd4c09db,0x59bb8c6c,0xaba935b1, 0xb28babe2, 0x8ba8516b) - ALTROMPN(181, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x97272a1d, 0x10901464,0x7c491f01,0x9ffb2109, 0x1c7d0b89, 0xe1755b75) - // sp_14_u1.bin, sp_14_u2.bin - { - _T("American Laser Games Space Pirates v1.4"), 0, 0, 0, 0, _T("ALG\0"), 262144, 182, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x69e09b90, 0xda3cba84,0x1c37222f,0xc45b4704,0x997072ad,0x1e9a1f8e - }, - ALTROMPN(182, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x4102988c, 0x969d4668,0xbe50990c,0x7debf9ed,0x4e8b8c6e,0x422acdf5) - ALTROMPN(182, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x30390ab0, 0x80fa14d8,0x81902258,0x398225bd,0xfd71ed5e,0x9e2d6c91) - // sp_01.dat, sp_02.dat - { - _T("American Laser Games Space Pirates v2.2"), 0, 0, 0, 0, _T("ALG\0"), 262144, 183, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x09c2cfcb, 0x93ad6a25,0x77fa7870,0x971890f2,0x6af11382, 0xa433f80b - }, - ALTROMPN(183, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x10d162a2, 0x26833d5b,0xe1057be8,0x639c00a7,0xbe18be33,0x404ea751) - ALTROMPN(183, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xc0975188, 0xfd7643dc,0x972e7861,0x249ab7e7,0x61999759,0x84888ae4) - // johnny_01.bin, johnny_02.bin - { - _T("American Laser Games Who Shot Johnny Rock? v1.6"), 0, 0, 0, 0, _T("ALG\0"), 131072, 184, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0xaeda7df4, 0xa612c4b9,0x2bd81ab9,0x564e58da,0x9a6a4d81,0x93c59acf - }, - ALTROMPN(184, 1, 1, 65536, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x046569b3, 0xefe5a8b2,0xbe1c5556,0x95f2a91c,0x88951d35,0x45f1b915) - ALTROMPN(184, 1, 2, 65536, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xedde1745, 0x573b79f8,0x808fedaa,0xbf3b7623,0x50a91579,0x2d26c1bc) - // wsjr151.bin,wsjr152.bin - { - _T("American Laser Games Who Shot Johnny Rock? v1.5"), 0, 0, 0, 0, _T("ALG\0"), 131072, 185, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x50eb4827, 0x72568673,0x4163aa16,0xd0ad3177,0xbd720187,0x125a63ec - }, - ALTROMPN(185, 1, 1, 65536, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x8ab626dd, 0xe45561f7,0x7fc279b7,0x1dc1dd2e,0x15a0870c,0xb5c1cd89) - ALTROMPN(185, 1, 2, 65536, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x9beeb1d7, 0x3fe0265e,0x5d36103d,0x3d9557d7,0x5e5e3728,0xe0b30da7) - // gg_1.dat,gg_2.dat - { - _T("American Laser Games Gallagher's Gallery v2.2"), 0, 0, 0, 0, _T("ALG\0"), 262144, 186, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0xcbe791de, 0x17aa6f16,0x7e138409,0xe1ef039e,0x928fee5a,0xf43e91cb - }, - ALTROMPN(186, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x855c9d82, 0x96711aaa,0x02f309ca,0xcd3e8d8e,0xfbe95cfc,0x811aba96) - ALTROMPN(186, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x3793b211, 0xdccb1d9c,0x5e2d6a4d,0x249426ae,0x6348e9fc,0x9b72e665) - // gg_21_rom1.bin,gg_21_rom2.bin - { - _T("American Laser Games Gallagher's Gallery v2.1"), 0, 0, 0, 0, _T("ALG\0"), 262144, 187, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x9bfe35bb, 0x76c8cad8,0xd0f4758f,0x1adc0fc9,0x7cb6ad30,0x44b54d47 - }, - ALTROMPN(187, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x70f887e5, 0xcd6cedc8,0x5bbe6767,0x4dfd140f,0xed901877,0x8f8cd8db) - ALTROMPN(187, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x4109f39e, 0x42d06de4,0x2c56f21e,0x4899b4c4,0x252baabb,0x51f24fda) - // fd_131_u1.bin,fd_131_u2.bin - { - _T("American Laser Games Fast Draw Showdown v1.31"), 0, 0, 0, 0, _T("ALG\0"), 262144, 188, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x6977addf, 0xdc845431,0xbb1a39bd,0x615afe5f,0x7cb7c8d0,0x3433ef8c - }, - ALTROMPN(188, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xe1ed7982, 0xf7562c6e,0x0ce6bf1a,0x9885cc59,0x3e08c250,0x9f82bbe1) - ALTROMPN(188, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xb7c79ab3, 0x6eca1bc9,0x590c22a0,0x04fb8590,0x1e5c7d41,0xf5b14ee2) - // fast_01.bin,fast_02.bin - { - _T("American Laser Games Fast Draw Showdown v1.30"), 0, 0, 0, 0, _T("ALG\0"), 262144, 189, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x47772e36, 0x5af67b5e,0xa56b2337,0xfdd427fb,0xd82d478f,0xb1994dbc - }, - ALTROMPN(189, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x0d76a2da, 0xd396371a,0xe1b9b0b6,0xe6bc6f1f,0x85c4b97b,0xfc5dc34d) - ALTROMPN(189, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x4c4eb71e, 0x3bd487c5,0x46b6c807,0x70a5fc88,0x0dcb1039,0x5ca431a2) - // lbh_101_u1.bin,lbh_101_u2.bin - { - _T("American Laser Games The Last Bounty Hunter v1.01"), 0, 0, 0, 0, _T("ALG\0"), 262144, 190, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0xd2a5a539, 0xb97c799b,0x53355b55,0x4dfbf335,0x6f20fd2b,0xa5998806 - }, - ALTROMPN(190, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xb21c5c42, 0x9ac856cd,0xf2c9538c,0xc4ae55f0,0x79f33737,0x6d3361c0) - ALTROMPN(190, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xf13b25d2, 0xe2f663c2,0x3b03592f,0x482ef5e1,0xdf87b651,0x937a500d) - // bounty_01.bin,bounty_02.bin - { - _T("American Laser Games The Last Bounty Hunter v0.06"), 0, 0, 0, 0, _T("ALG\0"), 262144, 191, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0xce600734, 0xe52aea03,0x080dcd08,0x8d4b61ed,0xe46de9c7,0xfc4dd74e - }, - ALTROMPN(191, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x2727ef1d, 0xf5342139,0x0b65c21a,0x7666ff9d,0x0f53ebf2,0xa463d836) - ALTROMPN(191, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x977566b2, 0x937e079e,0x992ecb59,0x30b17c10,0x24c326e1,0x0962642b) - // cp_151_u1.bin,cp_151_u2.bin - { - _T("American Laser Games Crime Patrol v1.51"), 0, 0, 0, 0, _T("ALG\0"), 262144, 192, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0xcada2bed, 0xc5da9d82,0x7864feff,0x75d87dd1,0x9ec06529,0x7d2b318b - }, - ALTROMPN(192, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xaefd6e09, 0x351e665e,0x2e636804,0x7a5cc80d,0x0f9d876b,0xca068b6a) - ALTROMPN(192, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xf2270cee, 0x1e735373,0x723c3cff,0xb6dd04d5,0xc30c08e7,0x57deae61) - // cp01.dat,cp02.dat - { - _T("American Laser Games Crime Patrol v1.4"), 0, 0, 0, 0, _T("ALG\0"), 262144, 193, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x51ba3153, 0x55086ba0,0xef41c6d6,0x41041b73,0x047cad38,0xaf2a21f3 - }, - ALTROMPN(193, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xa39a8b50, 0x55ca317e,0xf13c3a42,0xf12d68c4,0x80e6cc2d,0x4459f6a4) - ALTROMPN(193, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xe41fd2e8, 0x1cd9875f,0xb4133ba4,0xe3616271,0x975dc736,0xb343f156) - // cp_1.20_u1.bin,cp_1.20_u2.bin - { - _T("American Laser Games Crime Patrol v1.2"), 0, 0, 0, 0, _T("ALG\0"), 262144, 194, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x63e9f444, 0x6f2624a5,0x6a672f97,0xc751ae51,0xb4b834a5,0x097a855a - }, - ALTROMPN(194, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x475e847a, 0x82fd1608,0x35758cd5,0x1ea22f90,0xb08921a4,0x0409f94d) - ALTROMPN(194, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x814f5777, 0x341a1d7b,0x64112af3,0xe8243bdb,0xfec72e7f,0xa85aa903) - // cp2_1.3_1.bin, cp2_1.3_2.bin - { - _T("American Laser Games Crime Patrol 2: Drug Wars v1.3"), 0, 0, 0, 0, _T("ALG\0"), 262144, 195, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x57d1f606, 0xffbee51c,0x9c52a9c6,0x6440cbf8,0x34144321,0x75036282 - }, - ALTROMPN(195, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xdbdaa79a, 0x99804490,0x9d5c93e3,0xbd1baafe,0xfab818fd,0xb7b3f55e) - ALTROMPN(195, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0xe653395d, 0x8f6c86d9,0x8a52b7d8,0x5ae285fd,0x841167cd,0x07979318) - // cp2_1.dat, cp2_2.dat - { - _T("American Laser Games Crime Patrol 2: Drug Wars v1.1"), 0, 0, 0, 0, _T("ALG\0"), 262144, 196, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x49c751db, 0x789679f9,0xa3fe3aa0,0xf9b8bb35,0x1f3ea632,0xe429408d - }, - ALTROMPN(196, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xf4e5251e, 0xe0c91343,0xa98193d4,0x87c40e7a,0x85f542b2,0xa7a88f03) - ALTROMPN(196, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x47879042, 0x8bb6c541,0xe4e8e450,0x8da8d4b9,0x3600176a,0x2e7a1f41) - // platoonv4u1.bin,platoonv4u2.bin - { - _T("Nova Platoon V.3.1 US"), 0, 0, 0, 0, _T("ALG\0"), 262144, 197, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0xad975c96, 0x9565207f,0x6684baa8,0xe5c85c34,0x740a3f60,0x75d3a7b5 - }, - ALTROMPN(197, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0x09a133cf, 0x9b3ff630,0x35be8576,0xc88fb284,0xa25c2da5,0xdb0d5160) - ALTROMPN(197, 1, 2, 131072, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x8b33263e, 0xa1df3823,0x6321af90,0xb522e2a7,0x83984fdf,0x02e4c597) - // zb_u2.bin,zb_u3.bin - { - _T("Web Picmatic Zorton Brothers (Los Justicieros)"), 0, 0, 0, 0, _T("ALG\0"), 131072, 198, 0, 0, ROMTYPE_ALG, 0, 0, NULL, - 0x9cda09ae, 0x3353ae63,0x64b3d0b1,0x006db48e,0xa2bdc7b5,0x4946bbb9 - }, - ALTROMPN(198, 1, 1, 65536, ROMTYPE_EVEN | ROMTYPE_8BIT, NULL, 0xf59cfc4a, 0x9fadf7f1,0xe23d6b4e,0x828bf2b3,0xde919d08,0x7c690a3f) - ALTROMPN(198, 1, 2, 65536, ROMTYPE_ODD | ROMTYPE_8BIT, NULL, 0x938b25cb, 0xd0114bbc,0x588dcfce,0x6a469013,0xd0e35afb,0x93e38af5) - - { - NULL - } + { NULL } }; diff --git a/src/sounddep/pandora_sound.cpp b/src/sounddep/pandora_sound.cpp new file mode 100644 index 00000000..df2c05e7 --- /dev/null +++ b/src/sounddep/pandora_sound.cpp @@ -0,0 +1,322 @@ + /* + * Minimalistic sound.c implementation for gp2x + * (c) notaz, 2007 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "sysconfig.h" +#include "sysdeps.h" +#include "uae.h" +#include "options.h" +#include "memory.h" +#include "newcpu.h" +#include "custom.h" +#include "audio.h" +#include "gensound.h" +#include "sounddep/sound.h" +#include "savestate.h" + + +uae_u16 sndbuffer[4][(SNDBUFFER_LEN+32)*DEFAULT_SOUND_CHANNELS]; +uae_u16 *sndbufpt = sndbuffer[0]; +uae_u16 *render_sndbuff = sndbuffer[0]; +uae_u16 *finish_sndbuff = sndbuffer[0] + SNDBUFFER_LEN*2; + +uae_u16 cdaudio_buffer[CDAUDIO_BUFFERS][(CDAUDIO_BUFFER_LEN + 32) * 2]; +uae_u16 *cdbufpt = cdaudio_buffer[0]; +uae_u16 *render_cdbuff = cdaudio_buffer[0]; +uae_u16 *finish_cdbuff = cdaudio_buffer[0] + CDAUDIO_BUFFER_LEN * 2; +bool cdaudio_active = false; +static int cdwrcnt = 0; +static int cdrdcnt = 0; + +static int have_sound = 0; +static int lastfreq; + +void update_sound (float clk) +{ + float evtime; + + evtime = clk * CYCLE_UNIT / (float)currprefs.sound_freq; + scaled_sample_evtime = (int)evtime; +} + + +static int sounddev = -1, s_oldrate = 0, s_oldbits = 0, s_oldstereo = 0; +static int sound_thread_active = 0, sound_thread_exit = 0; +static sem_t sound_sem; +static sem_t sound_out_sem; +static int output_cnt = 0; +static int wrcnt = 0; + +static void *sound_thread(void *unused) +{ + int cnt = 0, sem_val = 0; + sound_thread_active = 1; + + for (;;) + { + sem_getvalue(&sound_sem, &sem_val); + while (sem_val > 1) + { + sem_wait(&sound_sem); + sem_getvalue(&sound_sem, &sem_val); + } + + sem_wait(&sound_sem); + if (sound_thread_exit) + break; + + cnt = output_cnt; + sem_post(&sound_out_sem); + + if(currprefs.sound_stereo) { + if(cdaudio_active && currprefs.sound_freq == 44100 && cdrdcnt < cdwrcnt) { + for(int i=0; i 22050) { bsize*=4; buffers*=2; } // 44k mode seems to be very demanding + while ((bsize>>=1)) frag++; + frag |= buffers<<16; // 16 buffers + ioctl(sounddev, SNDCTL_DSP_SETFRAGMENT, &frag); + + s_oldrate = rate; + s_oldbits = bits; + s_oldstereo = stereo; + usleep(100000); + return 0; +} + + +// this is meant to be called only once on exit +void pandora_stop_sound(void) +{ + if (sound_thread_exit) + printf("don't call pandora_stop_sound more than once!\n"); + if (sound_thread_active) + { + sound_thread_exit = 1; + sem_post(&sound_sem); + sem_wait(&sound_out_sem); + sem_destroy(&sound_sem); + sem_destroy(&sound_out_sem); + } + + if (sounddev > 0) + close(sounddev); + sounddev = -1; +} + + +void finish_sound_buffer (void) +{ + output_cnt = wrcnt; + + sem_post(&sound_sem); + sem_wait(&sound_out_sem); + + wrcnt++; + sndbufpt = render_sndbuff = sndbuffer[wrcnt&3]; + if(currprefs.sound_stereo) + finish_sndbuff = sndbufpt + SNDBUFFER_LEN; + else + finish_sndbuff = sndbufpt + SNDBUFFER_LEN/2; +} + + +void pause_sound_buffer (void) +{ + reset_sound (); +} + + +void restart_sound_buffer(void) +{ + sndbufpt = render_sndbuff = sndbuffer[wrcnt&3]; + if(currprefs.sound_stereo) + finish_sndbuff = sndbufpt + SNDBUFFER_LEN; + else + finish_sndbuff = sndbufpt + SNDBUFFER_LEN/2; + + cdbufpt = render_cdbuff = cdaudio_buffer[cdwrcnt & (CDAUDIO_BUFFERS - 1)]; + finish_cdbuff = cdbufpt + CDAUDIO_BUFFER_LEN * 2; +} + + +void finish_cdaudio_buffer (void) +{ + cdwrcnt++; + cdbufpt = render_cdbuff = cdaudio_buffer[cdwrcnt & (CDAUDIO_BUFFERS - 1)]; + finish_cdbuff = cdbufpt + CDAUDIO_BUFFER_LEN; + audio_activate(); +} + + +bool cdaudio_catchup(void) +{ + while((cdwrcnt > cdrdcnt + CDAUDIO_BUFFERS - 10) && (sound_thread_active != 0) && (quit_program == 0)) { + sleep_millis(10); + } + return (sound_thread_active != 0); +} + + +/* Try to determine whether sound is available. This is only for GUI purposes. */ +int setup_sound (void) +{ + if (pandora_start_sound(currprefs.sound_freq, 16, currprefs.sound_stereo) != 0) + return 0; + + sound_available = 1; + return 1; +} + +static int open_sound (void) +{ + config_changed = 1; + + if (pandora_start_sound(currprefs.sound_freq, 16, currprefs.sound_stereo) != 0) + return 0; + + have_sound = 1; + sound_available = 1; + + if(currprefs.sound_stereo) + sample_handler = sample16s_handler; + else + sample_handler = sample16_handler; + + return 1; +} + +void close_sound (void) +{ + config_changed = 1; + + if (!have_sound) + return; + + // testing shows that reopenning sound device is not a good idea on pandora (causes random sound driver crashes) + // we will close it on real exit instead + //pandora_stop_sound(); + have_sound = 0; +} + +int init_sound (void) +{ + have_sound=open_sound(); + return have_sound; +} + +void pause_sound (void) +{ + /* nothing to do */ +} + +void resume_sound (void) +{ + /* nothing to do */ +} + +void reset_sound (void) +{ + if (!have_sound) + return; + + init_soundbuffer_usage(); + + clear_sound_buffers(); + clear_cdaudio_buffers(); +} + +void sound_volume (int dir) +{ + config_changed = 1; +} diff --git a/src/sounddep/sound.cpp b/src/sounddep/sound.cpp index 71bf20b1..d14fc000 100644 --- a/src/sounddep/sound.cpp +++ b/src/sounddep/sound.cpp @@ -7,15 +7,13 @@ #include #include #include -#include -#include #include #include #include -#include #include "sysconfig.h" #include "sysdeps.h" +#include "config.h" #include "uae.h" #include "options.h" #include "memory.h" @@ -24,10 +22,16 @@ #include "audio.h" #include "gensound.h" #include "sounddep/sound.h" -#include "savestate.h" -#include "SDL.h" +#include -uae_u16 sndbuffer[4][(SNDBUFFER_LEN + 32)*DEFAULT_SOUND_CHANNELS]; +#ifdef ANDROIDSDL +#include +#endif + +// "consumer" means the actual SDL sound output, as opposed to +#define SOUND_CONSUMER_BUFFER_LENGTH (SNDBUFFER_LEN * SOUND_BUFFERS_COUNT / 4) + +uae_u16 sndbuffer[SOUND_BUFFERS_COUNT][(SNDBUFFER_LEN + 32) * DEFAULT_SOUND_CHANNELS]; uae_u16 *sndbufpt = sndbuffer[0]; uae_u16 *render_sndbuff = sndbuffer[0]; uae_u16 *finish_sndbuff = sndbuffer[0] + SNDBUFFER_LEN * 2; @@ -41,7 +45,6 @@ static int cdwrcnt = 0; static int cdrdcnt = 0; static int have_sound = 0; -static int lastfreq; void update_sound(float clk) { @@ -49,60 +52,59 @@ void update_sound(float clk) scaled_sample_evtime = int(evtime); } -static int sounddev = -1, s_oldrate = 0, s_oldbits = 0, s_oldstereo = 0; +static int s_oldrate = 0, s_oldbits = 0, s_oldstereo = 0; static int sound_thread_active = 0, sound_thread_exit = 0; -static sem_t sound_sem; -static sem_t sound_out_sem; -static int output_cnt = 0; +static int rdcnt = 0; static int wrcnt = 0; -static void *sound_thread(void *unused) +static void sound_copy_produced_block(void *ud, Uint8 *stream, int len) { - int cnt = 0, sem_val = 0; + if (currprefs.sound_stereo) + { + if (cdaudio_active && currprefs.sound_freq == 44100 && cdrdcnt < cdwrcnt) + { + for (int i = 0; i < SNDBUFFER_LEN * 2; ++i) + sndbuffer[rdcnt & (SOUND_BUFFERS_COUNT - 1)][i] += cdaudio_buffer[cdrdcnt & (CDAUDIO_BUFFERS - 1)][i]; + cdrdcnt++; + } + + memcpy(stream, sndbuffer[rdcnt & (SOUND_BUFFERS_COUNT - 1)], len); + } + else + memcpy(stream, sndbuffer[rdcnt & (SOUND_BUFFERS_COUNT - 1)], len); + + if (wrcnt - rdcnt >= (SOUND_BUFFERS_COUNT / 2)) + { + rdcnt++; + } +} + + +static void sound_thread_mixer(void *ud, Uint8 *stream, int len) +{ + if (sound_thread_exit) + return; sound_thread_active = 1; - for (;;) - { - sem_getvalue(&sound_sem, &sem_val); - while (sem_val > 1) - { - sem_wait(&sound_sem); - sem_getvalue(&sound_sem, &sem_val); - } + int sample_size = currprefs.sound_stereo ? 4 : 2; - sem_wait(&sound_sem); - if (sound_thread_exit) - break; - - cnt = output_cnt; - sem_post(&sound_out_sem); - - if (currprefs.sound_stereo) { - if (cdaudio_active && currprefs.sound_freq == 44100 && cdrdcnt < cdwrcnt) { - for (int i = 0; i 0) { + int l = len < SNDBUFFER_LEN * sample_size ? len : SNDBUFFER_LEN * sample_size; + sound_copy_produced_block(ud, stream, l); + stream += l; + len -= l; } - - cdrdcnt = cdwrcnt; - sound_thread_active = 0; - sem_post(&sound_out_sem); - return NULL; } + static void init_soundbuffer_usage(void) { sndbufpt = sndbuffer[0]; render_sndbuff = sndbuffer[0]; finish_sndbuff = sndbuffer[0] + SNDBUFFER_LEN * 2; - output_cnt = 0; + rdcnt = 0; wrcnt = 0; - + cdbufpt = cdaudio_buffer[0]; render_cdbuff = cdaudio_buffer[0]; finish_cdbuff = cdaudio_buffer[0] + CDAUDIO_BUFFER_LEN * 2; @@ -115,57 +117,41 @@ static int amiberry_start_sound(int rate, int bits, int stereo) int frag = 0, buffers, ret; unsigned int bsize; - if (!sound_thread_active) - { - // init sem, start sound thread - pthread_t thr; + if(SDL_GetAudioStatus() == SDL_AUDIO_STOPPED) { + init_soundbuffer_usage(); - init_soundbuffer_usage(); - - s_oldrate = 0; - s_oldbits = 0; - s_oldstereo = 0; + s_oldrate = 0; + s_oldbits = 0; + s_oldstereo = 0; sound_thread_exit = 0; - ret = sem_init(&sound_sem, 0, 0); - if (ret != 0) - write_log("sem_init() failed: %i, errno=%i\n", ret, errno); - sem_init(&sound_out_sem, 0, 0); - ret = pthread_create(&thr, NULL, sound_thread, NULL); - if (ret != 0) - write_log("pthread_create() failed: %i\n", ret); - pthread_detach(thr); - } - - if (sounddev <= 0) - { - sounddev = open("/dev/dsp", O_WRONLY); - if (sounddev == -1) - { - write_log("open(\"/dev/dsp\") failed with %i\n", errno); - return -1; - } - } + } // if no settings change, we don't need to do anything - if (rate == s_oldrate && s_oldbits == bits && s_oldstereo == stereo) + if (rate == s_oldrate && s_oldbits == bits && s_oldstereo == stereo) return 0; - ioctl(sounddev, SNDCTL_DSP_SPEED, &rate); - ioctl(sounddev, SNDCTL_DSP_SETFMT, &bits); - ioctl(sounddev, SNDCTL_DSP_STEREO, &stereo); - // calculate buffer size - buffers = 16; - bsize = rate / 32; - if (rate > 22050) { bsize *= 4; buffers *= 2; } // 44k mode seems to be very demanding - while ((bsize >>= 1)) frag++; - frag |= buffers << 16; // 16 buffers - ioctl(sounddev, SNDCTL_DSP_SETFRAGMENT, &frag); + SDL_AudioSpec as; + memset(&as, 0, sizeof(as)); + + as.freq = rate; + as.format = (bits == 8 ? AUDIO_S8 : AUDIO_S16); + as.channels = (stereo ? 2 : 1); + as.samples = SOUND_CONSUMER_BUFFER_LENGTH; + as.callback = sound_thread_mixer; - s_oldrate = rate; - s_oldbits = bits; + if (SDL_OpenAudio(&as, NULL)) + printf("Error when opening SDL audio !\n"); + + s_oldrate = rate; + s_oldbits = bits; s_oldstereo = stereo; - usleep(100000); + + clear_sound_buffers(); + clear_cdaudio_buffers(); + + SDL_PauseAudio(0); + return 0; } @@ -173,37 +159,27 @@ static int amiberry_start_sound(int rate, int bits, int stereo) // this is meant to be called only once on exit void amiberry_stop_sound(void) { - int valuesem; - if (sound_thread_exit) - printf("don't call amiberry_stop_sound more than once!\n"); - SDL_PauseAudio(1); - if (sound_thread_active) - { - sound_thread_exit = 1; - sem_post(&sound_sem); - sem_wait(&sound_out_sem); - sem_destroy(&sound_sem); - sem_destroy(&sound_out_sem); - } - - if (sounddev > 0) - close(sounddev); - sounddev = -1; + if(sound_thread_exit == 0) { + SDL_PauseAudio(1); + sound_thread_exit = 1; + SDL_CloseAudio(); + } } void finish_sound_buffer(void) { - output_cnt = wrcnt; - - sem_post(&sound_sem); - sem_wait(&sound_out_sem); - wrcnt++; - sndbufpt = render_sndbuff = sndbuffer[wrcnt & 3]; + sndbufpt = render_sndbuff = sndbuffer[wrcnt & (SOUND_BUFFERS_COUNT - 1)]; + if (currprefs.sound_stereo) - finish_sndbuff = sndbufpt + SNDBUFFER_LEN; + finish_sndbuff = sndbufpt + SNDBUFFER_LEN * 2; else - finish_sndbuff = sndbufpt + SNDBUFFER_LEN / 2; + finish_sndbuff = sndbufpt + SNDBUFFER_LEN; + + while ((wrcnt & (SOUND_BUFFERS_COUNT - 1)) == (rdcnt & (SOUND_BUFFERS_COUNT - 1))) + { + usleep(500); + } } void pause_sound_buffer(void) @@ -213,11 +189,11 @@ void pause_sound_buffer(void) void restart_sound_buffer(void) { - sndbufpt = render_sndbuff = sndbuffer[wrcnt & 3]; + sndbufpt = render_sndbuff = sndbuffer[wrcnt & (SOUND_BUFFERS_COUNT - 1)]; if (currprefs.sound_stereo) - finish_sndbuff = sndbufpt + SNDBUFFER_LEN; + finish_sndbuff = sndbufpt + SNDBUFFER_LEN * 2; else - finish_sndbuff = sndbufpt + SNDBUFFER_LEN / 2; + finish_sndbuff = sndbufpt + SNDBUFFER_LEN; cdbufpt = render_cdbuff = cdaudio_buffer[cdwrcnt & (CDAUDIO_BUFFERS - 1)]; finish_cdbuff = cdbufpt + CDAUDIO_BUFFER_LEN * 2; @@ -227,7 +203,7 @@ void finish_cdaudio_buffer(void) { cdwrcnt++; cdbufpt = render_cdbuff = cdaudio_buffer[cdwrcnt & (CDAUDIO_BUFFERS - 1)]; - finish_cdbuff = cdbufpt + CDAUDIO_BUFFER_LEN; + finish_cdbuff = cdbufpt + CDAUDIO_BUFFER_LEN * 2; audio_activate(); } @@ -243,7 +219,7 @@ bool cdaudio_catchup(void) /* Try to determine whether sound is available. This is only for GUI purposes. */ int setup_sound(void) { - if (amiberry_start_sound(currprefs.sound_freq, 16, currprefs.sound_stereo) != 0) + if (pandora_start_sound(currprefs.sound_freq, 16, currprefs.sound_stereo) != 0) return 0; sound_available = 1; @@ -252,6 +228,7 @@ int setup_sound(void) static int open_sound(void) { + config_changed = 1; if (amiberry_start_sound(currprefs.sound_freq, 16, currprefs.sound_stereo) != 0) return 0; @@ -268,14 +245,11 @@ static int open_sound(void) void close_sound(void) { + config_changed = 1; if (!have_sound) return; - // testing shows that reopenning sound device is not a good idea (causes random sound driver crashes) - // we will close it on real exit instead -#ifdef AMIBERRY - //amiberry_stop_sound(); -#endif + amiberry_stop_sound(); have_sound = 0; } @@ -287,12 +261,12 @@ int init_sound(void) void pause_sound(void) { - //SDL_PauseAudio(1); + SDL_PauseAudio(1); } void resume_sound(void) { - //SDL_PauseAudio(0); + SDL_PauseAudio(0); } void reset_sound(void) @@ -310,4 +284,4 @@ void reset_sound(void) void sound_volume(int dir) { config_changed = 1; -} \ No newline at end of file +} diff --git a/src/sounddep/sound.h b/src/sounddep/sound.h index 79ec030e..90da1ea2 100644 --- a/src/sounddep/sound.h +++ b/src/sounddep/sound.h @@ -6,15 +6,12 @@ * Copyright 1997 Bernd Schmidt */ -#if defined(AMIBERRY) || defined(ANDROIDSDL) #define DEFAULT_SOUND_CHANNELS 2 -#else -#define DEFAULT_SOUND_CHANNELS 1 -#endif +#define SOUND_BUFFERS_COUNT 4 #define SNDBUFFER_LEN 2048 -extern uae_u16 sndbuffer[4][(SNDBUFFER_LEN+32)*DEFAULT_SOUND_CHANNELS]; +extern uae_u16 sndbuffer[SOUND_BUFFERS_COUNT][(SNDBUFFER_LEN+32)*DEFAULT_SOUND_CHANNELS]; extern uae_u16 *sndbufpt; extern uae_u16 *render_sndbuff; extern uae_u16 *finish_sndbuff; @@ -40,7 +37,7 @@ STATIC_INLINE void set_sound_buffers (void) STATIC_INLINE void clear_sound_buffers (void) { - memset (sndbuffer, 0, 4 * (SNDBUFFER_LEN + 32) * DEFAULT_SOUND_CHANNELS); + memset(sndbuffer, 0, sizeof(sndbuffer)); } #define PUT_SOUND_WORD(b) do { *sndbufpt = b; sndbufpt = sndbufpt + 1; } while (0) @@ -70,7 +67,7 @@ extern bool cdaudio_active; STATIC_INLINE void clear_cdaudio_buffers (void) { - memset (cdaudio_buffer, 0, CDAUDIO_BUFFERS * (CDAUDIO_BUFFER_LEN + 32) * 2); + memset (cdaudio_buffer, 0, sizeof(cdaudio_buffer)); } #define PUT_CDAUDIO_WORD_STEREO(l,r) do { *((uae_u32 *)cdbufpt) = (r << 16) | (l & 0xffff); cdbufpt = cdbufpt + 2; } while (0) diff --git a/src/statusline.cpp b/src/statusline.cpp index d7943cba..ef97bf56 100644 --- a/src/statusline.cpp +++ b/src/statusline.cpp @@ -64,15 +64,17 @@ void draw_status_line_single(uae_u8 *buf, int y, int totalwidth) x = totalwidth - TD_PADX - VISIBLE_LEDS * TD_WIDTH; x += 100 - (TD_WIDTH * (currprefs.nr_floppies - 1)) - TD_WIDTH; - if (nr_units() < 1) - x += TD_WIDTH; + if(nr_units() < 1) + x += TD_WIDTH; + if(currprefs.pandora_hide_idle_led) + x += TD_WIDTH; + + if(picasso_on) + memset (buf + (x - 4) * 2, 0, (prSDLScreen->w - x + 4) * 2); + else + memset (buf + (x - 4) * gfxvidinfo.drawbuffer.pixbytes, 0, (gfxvidinfo.drawbuffer.outwidth - x + 4) * gfxvidinfo.drawbuffer.pixbytes); - if (picasso_on) - memset(buf + (x - 4) * 2, 0, (screen->w - x + 4) * 2); - else - memset(buf + (x - 4) * gfxvidinfo.drawbuffer.pixbytes, 0, (gfxvidinfo.drawbuffer.outwidth - x + 4) * gfxvidinfo.drawbuffer.pixbytes); - - for (led = -1; led < (currprefs.nr_floppies + 1); led++) { + for (led = (currprefs.pandora_hide_idle_led == 0) ? -2 : -1; led < (currprefs.nr_floppies+1); led++) { int num1 = -1, num2 = -1, num3 = -1; if (led == 0 && nr_units() < 1) diff --git a/src/traps.cpp b/src/traps.cpp index 4153c8cb..92d586c4 100644 --- a/src/traps.cpp +++ b/src/traps.cpp @@ -107,7 +107,10 @@ unsigned int define_trap(TrapHandler handler_func, int flags, const TCHAR *name) target_startup_msg(_T("Internal error"), _T("Ran out of emulator traps.")); uae_restart(1, nullptr); return -1; - } + } else { + int i; + unsigned int trap_num; + struct Trap *trap; uaecptr addr = here(); for (int i = 0; i < trap_count; i++) { diff --git a/src/zfile.cpp b/src/zfile.cpp index 52490dd1..1a70b4ef 100644 --- a/src/zfile.cpp +++ b/src/zfile.cpp @@ -789,9 +789,9 @@ static struct zfile *wrp(struct zfile *z, int *retcode) #endif #ifdef A_7Z -#include "archivers/7z/Xz.h" -#include "archivers/7z/LzmaDec.h" -#include "archivers/7z/7zCrc.h" +#include "7z/Xz.h" +#include "7z/LzmaDec.h" +#include "7z/7zCrc.h" static void *SzAlloc(void *p, size_t size) { diff --git a/src/zfile_archive.cpp b/src/zfile_archive.cpp index f9b3f3e1..b76c2dfe 100644 --- a/src/zfile_archive.cpp +++ b/src/zfile_archive.cpp @@ -486,11 +486,11 @@ static struct zfile *archive_unpack_zip(struct zfile *zf) #ifdef A_7Z /* 7Z */ -#include "archivers/7z/7z.h" -#include "archivers/7z/Alloc.h" -#include "archivers/7z/7zFile.h" -#include "archivers/7z/7zVersion.h" -#include "archivers/7z/7zCrc.h" +#include "7z/7z.h" +#include "7z/Alloc.h" +#include "7z/7zFile.h" +#include "7z/7zVersion.h" +#include "7z/7zCrc.h" static void *SzAlloc(void *p, size_t size) {