diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index 4f377c1e2..fcdba3d66 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -875,6 +875,7 @@ static FORCEINLINE void CopyLineReduce_C(void *__restrict dst, const void *__res } } +#ifdef ENABLE_SSE2 template static FORCEINLINE void CopyLineReduce_SSE2(void *__restrict dst, const void *__restrict src, size_t srcWidth) { @@ -1153,6 +1154,7 @@ static FORCEINLINE void CopyLineReduce_SSE2(void *__restrict dst, const void *__ } } } +#endif template static FORCEINLINE void CopyLineReduce(void *__restrict dst, const void *__restrict src, size_t srcWidth) @@ -8269,14 +8271,15 @@ void GPUEngineA::_HandleDisplayModeMainMemory(const size_t l) { // Displays video using color data directly read from main memory. // Doing this should always result in an output line that is at the native size (192px x 1px). + +#ifdef ENABLE_SSE2 switch (OUTPUTFORMAT) { case NDSColorFormat_BGR555_Rev: { - u32 *dst = (u32 *)((u16 *)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH)); - -#ifdef ENABLE_SSE2 + u32 *__restrict dst = (u32 *__restrict)((u16 *)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH)); const __m128i alphaBit = _mm_set1_epi16(0x8000); + for (size_t i = 0; i < GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(u16) / sizeof(__m128i); i++) { const u32 srcA = DISP_FIFOrecv(); @@ -8286,22 +8289,63 @@ void GPUEngineA::_HandleDisplayModeMainMemory(const size_t l) const __m128i fifoColor = _mm_setr_epi32(srcA, srcB, srcC, srcD); _mm_store_si128((__m128i *)dst + i, _mm_or_si128(fifoColor, alphaBit)); } + break; + } + + case NDSColorFormat_BGR666_Rev: + case NDSColorFormat_BGR888_Rev: + { + FragmentColor *__restrict dst = (FragmentColor *__restrict)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH); + __m128i dstLo; + __m128i dstHi; + + for (size_t i = 0, d = 0; i < GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(u16) / sizeof(__m128i); i++, d+=2) + { + const u32 srcA = DISP_FIFOrecv(); + const u32 srcB = DISP_FIFOrecv(); + const u32 srcC = DISP_FIFOrecv(); + const u32 srcD = DISP_FIFOrecv(); + const __m128i fifoColor = _mm_setr_epi32(srcA, srcB, srcC, srcD); + + if (OUTPUTFORMAT == NDSColorFormat_BGR666_Rev) + { + ColorspaceConvert555To6665Opaque_SSE2(fifoColor, dstLo, dstHi); + } + else if (OUTPUTFORMAT == NDSColorFormat_BGR888_Rev) + { + ColorspaceConvert555To8888Opaque_SSE2(fifoColor, dstLo, dstHi); + } + + _mm_store_si128((__m128i *)dst + d + 0, dstLo); + _mm_store_si128((__m128i *)dst + d + 1, dstHi); + } + break; + } + } #else + switch (OUTPUTFORMAT) + { + case NDSColorFormat_BGR555_Rev: + { + u32 *__restrict dst = (u32 *__restrict)((u16 *)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH)); for (size_t i = 0; i < GPU_FRAMEBUFFER_NATIVE_WIDTH * sizeof(u16) / sizeof(u32); i++) { - dst[i] = DISP_FIFOrecv() | 0x80008000; - } + const u32 src = DISP_FIFOrecv(); +#ifdef MSB_FIRST + dst[i] = (src >> 16) | (src << 16) | 0x80008000; +#else + dst[i] = src | 0x80008000; #endif + } break; } case NDSColorFormat_BGR666_Rev: { - FragmentColor *dst = (FragmentColor *)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH); - + FragmentColor *__restrict dst = (FragmentColor *__restrict)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH); for (size_t i = 0; i < GPU_FRAMEBUFFER_NATIVE_WIDTH; i+=2) { - u32 src = DISP_FIFOrecv(); + const u32 src = DISP_FIFOrecv(); dst[i+0].color = COLOR555TO6665_OPAQUE((src >> 0) & 0x7FFF); dst[i+1].color = COLOR555TO6665_OPAQUE((src >> 16) & 0x7FFF); } @@ -8310,17 +8354,17 @@ void GPUEngineA::_HandleDisplayModeMainMemory(const size_t l) case NDSColorFormat_BGR888_Rev: { - FragmentColor *dst = (FragmentColor *)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH); - + FragmentColor *__restrict dst = (FragmentColor *__restrict)this->nativeBuffer + (l * GPU_FRAMEBUFFER_NATIVE_WIDTH); for (size_t i = 0; i < GPU_FRAMEBUFFER_NATIVE_WIDTH; i+=2) { - u32 src = DISP_FIFOrecv(); + const u32 src = DISP_FIFOrecv(); dst[i+0].color = COLOR555TO8888_OPAQUE((src >> 0) & 0x7FFF); dst[i+1].color = COLOR555TO8888_OPAQUE((src >> 16) & 0x7FFF); } break; } } +#endif } template diff --git a/desmume/src/frontend/cocoa/userinterface/InputManager.mm b/desmume/src/frontend/cocoa/userinterface/InputManager.mm index 827d2ac17..88ac3364d 100644 --- a/desmume/src/frontend/cocoa/userinterface/InputManager.mm +++ b/desmume/src/frontend/cocoa/userinterface/InputManager.mm @@ -1,6 +1,6 @@ /* Copyright (C) 2011 Roger Manuel - Copyright (C) 2012-2017 DeSmuME Team + Copyright (C) 2012-2018 DeSmuME Team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -116,7 +116,7 @@ static NSDictionary *hidUsageTable = nil; CFRelease(elementArray); // Set up force feedback. -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 +#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 if (IsOSXVersionSupported(10, 6, 0)) { ioService = IOHIDDeviceGetService(hidDeviceRef); diff --git a/desmume/src/frontend/cocoa/userinterface/appDelegate.mm b/desmume/src/frontend/cocoa/userinterface/appDelegate.mm index 50bb43176..03b25059f 100644 --- a/desmume/src/frontend/cocoa/userinterface/appDelegate.mm +++ b/desmume/src/frontend/cocoa/userinterface/appDelegate.mm @@ -109,8 +109,11 @@ // simply save the passed in file name, and then automatically call this method again with our // previously saved file name the moment before [NSApplicationDelgate applicationDidFinishLaunching:] // finishes. + // + // We'll do the delayed ROM loading only for Mavericks and later, since this delayed loading code + // doesn't seem to work on older macOS versions. - if (![self didApplicationFinishLaunching]) + if (IsOSXVersionSupported(10, 9, 0) && ![self didApplicationFinishLaunching]) { [self setDelayedROMFileName:filename]; result = YES; @@ -171,10 +174,12 @@ // On macOS v10.13 and later, some unwanted menu items will show up in the View menu. // Disable automatic window tabbing for all NSWindows in order to rid ourselves of // these unwanted menu items. +#if defined(MAC_OS_X_VERSION_10_13) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13) if ([[NSWindow class] respondsToSelector:@selector(setAllowsAutomaticWindowTabbing:)]) { [NSWindow setAllowsAutomaticWindowTabbing:NO]; } +#endif // Setup the About window. NSString *descriptionStr = [[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"] stringByAppendingString:@" "] stringByAppendingString:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]]; @@ -342,7 +347,7 @@ // If the user is trying to load a ROM file while launching the app, then ensure that the // ROM file is loaded at the end of this method and never any time before that. [self setDidApplicationFinishLaunching:YES]; - if ([self delayedROMFileName] != nil) + if (IsOSXVersionSupported(10, 9, 0) && [self delayedROMFileName] != nil) { [self application:NSApp openFile:[self delayedROMFileName]]; [self setDelayedROMFileName:nil]; diff --git a/desmume/src/wifi.h b/desmume/src/wifi.h index 429554a28..901b59228 100755 --- a/desmume/src/wifi.h +++ b/desmume/src/wifi.h @@ -497,18 +497,18 @@ typedef union u8 reserved1:4; u8 DAC:4; - u8 VTC_EN1:1; - u8 LPF1:1; - u8 CPL1:1; - u8 PDP1:1; - u8 AUTOCAL_EN1:1; - u8 LD_EN1:1; - u8 P1:1; + u8 VTC_EN:1; + u8 LPF:1; + u8 CPL:1; + u8 PDP:1; + u8 AUTOCAL_EN:1; + u8 LD_EN:1; + u8 P:1; u8 reserved2:1; u8 :6; - u8 PLL_EN1:1; - u8 KV_EN1:1; + u8 PLL_EN:1; + u8 KV_EN:1; u8 :8; #endif