Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ build
*.mode2v3
xcuserdata
project.xcworkspace
# Backup directories (don't commit these)
Frameworks/*.backup/
Frameworks/*.framework.backup/
99 changes: 53 additions & 46 deletions Boxer.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Boxer/BX2ButtonJoystickLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "BX2ButtonJoystickLayout.h"
#import "BXEmulatedJoystick.h"

#if defined(__x86_64__) || defined(__i386__)
@implementation BX2ButtonJoystickLayout

+ (void) load
Expand Down Expand Up @@ -67,3 +68,9 @@ + (JoypadControllerLayout *)layout
return layout;
}
@end
#else
@implementation BX2ButtonJoystickLayout
+ (void) load { }
+ (id) layout { return nil; }
@end
#endif
8 changes: 7 additions & 1 deletion Boxer/BX2ButtonWheelLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "BX2ButtonWheelLayout.h"
#import "BXEmulatedJoystick.h"


#if defined(__x86_64__) || defined(__i386__)
@implementation BX2ButtonWheelLayout

+ (void) load
Expand Down Expand Up @@ -77,3 +77,9 @@ + (JoypadControllerLayout *)layout
return layout;
}
@end
#else
@implementation BX2ButtonWheelLayout
+ (void) load { }
+ (id) layout { return nil; }
@end
#endif
7 changes: 7 additions & 0 deletions Boxer/BX4ButtonJoystickLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "BX4ButtonJoystickLayout.h"
#import "BXEmulatedJoystick.h"

#if defined(__x86_64__) || defined(__i386__)
@implementation BX4ButtonJoystickLayout

+ (void) load
Expand Down Expand Up @@ -83,3 +84,9 @@ + (JoypadControllerLayout *)layout
return layout;
}
@end
#else
@implementation BX4ButtonJoystickLayout
+ (void) load { }
+ (id) layout { return nil; }
@end
#endif
8 changes: 7 additions & 1 deletion Boxer/BX4ButtonWheelLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "BX4ButtonWheelLayout.h"
#import "BXEmulatedJoystick.h"


#if defined(__x86_64__) || defined(__i386__)
@implementation BX4ButtonWheelLayout

+ (void) load
Expand Down Expand Up @@ -91,3 +91,9 @@ + (JoypadControllerLayout *)layout
return layout;
}
@end
#else
@implementation BX4ButtonWheelLayout
+ (void) load { }
+ (id) layout { return nil; }
@end
#endif
8 changes: 4 additions & 4 deletions Boxer/BXCHFlightstick.mm
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ - (BOOL) POV: (NSUInteger)POVNumber directionIsDown: (BXEmulatedPOVDirection)dir
}


- (float) throttleAxis { return [self positionForGameportAxis: BXCHFlightstickProThrottleAxis]; }
- (float) rudderAxis { return [self positionForGameportAxis: BXCHFlightstickProRudderAxis]; }
- (float) throttleAxis { return [self positionForGameportAxis: (BXGameportAxis)BXCHFlightstickProThrottleAxis]; }
- (float) rudderAxis { return [self positionForGameportAxis: (BXGameportAxis)BXCHFlightstickProRudderAxis]; }

- (void) setThrottleAxis: (float)position { [self setPosition: position forGameportAxis: BXCHFlightstickProThrottleAxis]; }
- (void) setRudderAxis: (float)position { [self setPosition: position forGameportAxis: BXCHFlightstickProRudderAxis]; }
- (void) setThrottleAxis: (float)position { [self setPosition: position forGameportAxis: (BXGameportAxis)BXCHFlightstickProThrottleAxis]; }
- (void) setRudderAxis: (float)position { [self setPosition: position forGameportAxis: (BXGameportAxis)BXCHFlightstickProRudderAxis]; }


- (void) setButton: (BXEmulatedJoystickButton)button toState: (BOOL)pressed
Expand Down
6 changes: 5 additions & 1 deletion Boxer/BXCoalfaceAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#import "BXCoalface.h"
#import <SDL2/SDL.h>

typedef enum {
BXLeftChannel,
Expand All @@ -25,4 +26,7 @@ void boxer_sendMIDISysex(Bit8u *msg, Bitu len);
float boxer_masterVolume(BXAudioChannel channel);

//Defined in mixer.cpp. Update the volumes of all active channels.
void boxer_updateVolumes();
void boxer_updateVolumes();

// SDL2: Get the audio device ID for pausing/resuming audio
SDL_AudioDeviceID boxer_getAudioDeviceID();
2 changes: 1 addition & 1 deletion Boxer/BXEmulatedJoystick.mm
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ - (void) setButton: (BXEmulatedJoystickButton)button toState: (BOOL)pressed

- (void) releaseButton: (NSNumber *)button
{
[self buttonUp: [button unsignedIntegerValue]];
[self buttonUp: (BXEmulatedJoystickButton)[button unsignedIntegerValue]];
}

@end
Expand Down
2 changes: 1 addition & 1 deletion Boxer/BXEmulatedMT32.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#import "BXAudioSource.h"

#ifdef __cplusplus
#import "MT32Emu/mt32emu.h"
#import <MT32Emu/mt32emu/mt32emu.h>

//MT32Emu has a C++ callback class for handling emulated synth notifications.
//We implement a thin C++ wrapper that sends messages back to BXEmulatedMT32 for handling.
Expand Down
21 changes: 11 additions & 10 deletions Boxer/BXEmulator+BXAudio.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#import "BXAudioSource.h"
#import "BXDrive.h"

#import <SDL/SDL.h>
#import <SDL2/SDL.h>
#import "mixer.h"


Expand Down Expand Up @@ -175,21 +175,22 @@ - (void) sendMIDISysex: (NSData *)message

- (void) _suspendAudio
{
SDL_PauseAudio(YES);

_cdromWasPlaying = (SDL_CDStatus(NULL) == CD_PLAYING);
if (_cdromWasPlaying)
SDL_CDPause(NULL);
// SDL2: Use SDL_PauseAudioDevice() instead of SDL_PauseAudio()
SDL_AudioDeviceID deviceID = boxer_getAudioDeviceID();
if (deviceID != 0) {
SDL_PauseAudioDevice(deviceID, 1); // 1 = pause
}

[self.activeMIDIDevice pause];
}

- (void) _resumeAudio
{
SDL_PauseAudio(NO);

if (_cdromWasPlaying)
SDL_CDResume(NULL);
// SDL2: Resume audio using device ID from DOSBox mixer
SDL_AudioDeviceID deviceID = boxer_getAudioDeviceID();
if (deviceID != 0) {
SDL_PauseAudioDevice(deviceID, 0); // 0 = unpause
}

[self.activeMIDIDevice resume];
}
Expand Down
13 changes: 7 additions & 6 deletions Boxer/BXEmulator+BXDOSFileSystem.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1130,13 +1130,14 @@ - (DOS_Drive *) _CDROMDriveFromPath: (NSString *)path

int SDLCDNum = -1;

//Check that any audio CDs are actually present before enabling CD audio:
//this fixes Warcraft II's copy protection, which will fail if audio tracks
//are reported to be present but cannot be found.
if (useCDAudio && SDL_CDNumDrives() > 0)
// SDL2: CD audio support was removed, so we can't check for CD drives via SDL
// CD audio will be handled through DOSBox's CDROM interface instead
// For now, disable SDL CD audio support
if (useCDAudio)
{
//NOTE: SDL's CD audio API for OS X only ever exposes one CD, which will be #0.
SDLCDNum = 0;
// SDL2 doesn't support CD audio, so we'll use DOSBox's CDROM interface
// Set to -1 to indicate no SDL CD support
SDLCDNum = -1;
}

//NOTE: ioctl is currently unimplemented for OS X in DOSBox 0.74, so this will always fall back to SDL.
Expand Down
5 changes: 3 additions & 2 deletions Boxer/BXEmulator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "BXEmulatorPrivate.h"
#import "NSObject+ADBPerformExtensions.h"

#import <SDL/SDL.h>
#import <SDL2/SDL.h>
#import "cpu.h"
#import "control.h"
#import "shell.h"
Expand Down Expand Up @@ -926,7 +926,8 @@ - (void) _runLoopDidFinishWithContextInfo: (void *)contextInfo
- (void) _startDOSBox
{
//Initialize the SDL modules that DOSBox will need.
NSAssert1(!SDL_Init(SDL_INIT_AUDIO|SDL_INIT_TIMER|SDL_INIT_CDROM|SDL_INIT_NOPARACHUTE),
//Note: SDL_INIT_CDROM and SDL_INIT_NOPARACHUTE were removed in SDL2
NSAssert1(!SDL_Init(SDL_INIT_AUDIO|SDL_INIT_TIMER),
@"SDL failed to initialize with the following error: %s", SDL_GetError());

try
Expand Down
8 changes: 7 additions & 1 deletion Boxer/BXFlightstickAccelerometerLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "BXFlightstickAccelerometerLayout.h"
#import "BXEmulatedJoystick.h"


#if defined(__x86_64__) || defined(__i386__)
@implementation BXFlightstickAccelerometerLayout

+ (void) load
Expand Down Expand Up @@ -81,3 +81,9 @@ + (JoypadControllerLayout *)layout
return layout;
}
@end
#else
@implementation BXFlightstickAccelerometerLayout
+ (void) load { }
+ (id) layout { return nil; }
@end
#endif
7 changes: 7 additions & 0 deletions Boxer/BXFlightstickLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "BXFlightstickLayout.h"
#import "BXEmulatedJoystick.h"

#if defined(__x86_64__) || defined(__i386__)
@implementation BXFlightstickLayout

+ (void) load
Expand Down Expand Up @@ -107,3 +108,9 @@ + (JoypadControllerLayout *)layout
return layout;
}
@end
#else
@implementation BXFlightstickLayout
+ (void) load { }
+ (id) layout { return nil; }
@end
#endif
22 changes: 22 additions & 0 deletions Boxer/BXJoypadController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,43 @@
//q.v. http://getjoypad.com/ and https://github.com/lzell/JoypadSDK#readme

#import <Foundation/Foundation.h>
#if defined(__x86_64__) || defined(__i386__)
#import "JoypadSDK.h"
#else
@class JoypadManager, JoypadControllerLayout, JoypadDevice;
@protocol JoypadManagerDelegate;
#endif

#if defined(__x86_64__) || defined(__i386__)
@interface BXJoypadController : NSObject <JoypadManagerDelegate>
#else
@interface BXJoypadController : NSObject
#endif
{
#if defined(__x86_64__) || defined(__i386__)
JoypadManager *joypadManager;
JoypadControllerLayout *currentLayout;
#else
id joypadManager;
id currentLayout;
#endif
BOOL hasJoypadDevices;
}
#if defined(__x86_64__) || defined(__i386__)
@property (readonly, nonatomic) JoypadManager *joypadManager;
#else
@property (readonly, nonatomic) id joypadManager;
#endif

//An array of all currently-connected joypad devices being used by Boxer.
@property (readonly, nonatomic) NSArray *joypadDevices;

//The current joystick controller layout in use.
#if defined(__x86_64__) || defined(__i386__)
@property (retain, nonatomic) JoypadControllerLayout *currentLayout;
#else
@property (retain, nonatomic) id currentLayout;
#endif

//Returns YES if there are any joypad devices connected or in the process
//of connecting, NO otherwise.
Expand Down
16 changes: 16 additions & 0 deletions Boxer/BXJoypadController.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
*/

#import "BXJoypadController.h"
#if defined(__x86_64__) || defined(__i386__)
#import "JoypadSDK.h"
#endif
#import "BXJoypadController.h"
#import "BXBaseAppController.h"
#import "BXSession.h"
#import "BXDOSWindowController.h"
#import "BXInputController+BXJoypadInput.h"
#if defined(__x86_64__) || defined(__i386__)
#import "BX4ButtonJoystickLayout.h"
#endif


#pragma mark -
Expand All @@ -32,6 +36,7 @@ @implementation BXJoypadController
#pragma mark -
#pragma mark Initialization and deallocation

#if defined(__x86_64__) || defined(__i386__)
- (void) setCurrentLayout: (JoypadControllerLayout *)layout
{
if (currentLayout != layout)
Expand Down Expand Up @@ -161,4 +166,15 @@ - (void) joypadManager: (JoypadManager *)manager

[device setDelegate: nil];
}
#else
- (void) setCurrentLayout: (id)layout { }
- (void) awakeFromNib { }
- (void) dealloc { [super dealloc]; }
- (NSArray *) joypadDevices { return @[]; }
- (id) activeWindowController { return nil; }
- (void) observeValueForKeyPath: (NSString *)keyPath ofObject: (id)object change: (NSDictionary *)change context: (void *)context { }
- (BOOL) joypadManager: (id)manager deviceShouldConnect: (id)device { return NO; }
- (void) joypadManager: (id)manager deviceDidConnect: (id)device player: (unsigned int)player { }
- (void) joypadManager: (id)manager deviceDidDisconnect: (id)device player: (unsigned int)player { }
#endif
@end
14 changes: 14 additions & 0 deletions Boxer/BXJoypadLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
online at [http://www.gnu.org/licenses/gpl-2.0.txt].
*/

#if defined(__x86_64__) || defined(__i386__)
#import "JoypadSDK.h"
#else
#import <Foundation/Foundation.h>
@class JoypadControllerLayout;
#endif

//BXJoypadLayot is a base class for our custom joypad controller layouts.
//It mostly provides functions to register layouts for particular joystick types.
Expand All @@ -22,7 +27,11 @@ enum {
BXJoyInputFakeDPadButtonLeft
};

#if defined(__x86_64__) || defined(__i386__)
@interface BXJoypadLayout : JoypadControllerLayout
#else
@interface BXJoypadLayout : NSObject
#endif

//Register a Joypad controller layout as matching the specified joystick type.
//Used by BXJoypadLayout subclasses to register themeselves.
Expand All @@ -34,12 +43,17 @@ enum {

//Returns a fully prepared custom joystick controller layout for the specified
//joystick type, suitable for passing to JoypadManager.
#if defined(__x86_64__) || defined(__i386__)
+ (JoypadControllerLayout *) layoutForJoystickType: (Class)joystickType;

//Returns an empty JoypadControllerLayout. Intended to be overridden by subclasses
//to provide fully-configured layouts.
//NOTE: we must provide instances of JoypadControllerLayout because the Joypad SDK
//does not support subclassing JoypadControllerLayout.
+ (JoypadControllerLayout *) layout;
#else
+ (id) layoutForJoystickType: (Class)joystickType;
+ (id) layout;
#endif

@end
Loading