Skip to content

Commit

Permalink
Pokes and refinement.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddTheSane committed Jan 11, 2025
1 parent a170365 commit f6aef51
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 58 deletions.
12 changes: 6 additions & 6 deletions Boxer/BXEmulatedMT32.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN

@class BXEmulatedMT32;
/// 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.
/// We implement a thin C++ wrapper that sends messages back to `BXEmulatedMT32` for handling.
class BXEmulatedMT32ReportHandler : public MT32Emu::ReportHandler
{
public:
Expand All @@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark Constants

extern NSErrorDomain const BXEmulatedMT32ErrorDomain;
/// Keys included in the error dictionary for \c BXEmulatedMT32MismatchedROMs errors.
/// Keys included in the error dictionary for `BXEmulatedMT32MismatchedROMs` errors.
/// These point to NSNumbers whose integer values represent the types of the respective ROMs.
extern NSErrorUserInfoKey const BXMT32ControlROMTypeKey;
extern NSErrorUserInfoKey const BXMT32PCMROMTypeKey;
Expand Down Expand Up @@ -89,9 +89,9 @@ typedef NS_OPTIONS(NSUInteger, BXMT32ROMType) {

@protocol BXEmulatedMT32Delegate;

/// \c BXEmulatedMT32 provides a \c BXMIDIDevice wrapper for the MUNT MT-32 emulator.
/// `BXEmulatedMT32` provides a `BXMIDIDevice` wrapper for the MUNT MT-32 emulator.
/// It takes an optional delegate to which it sends notifications of LCD display messages.
/// Unlike the other \c BXMIDIDevice classes, this currently feeds audio output back into
/// Unlike the other `BXMIDIDevice` classes, this currently feeds audio output back into
/// DOSBox's own mixer.
@interface BXEmulatedMT32 : NSObject <BXMIDIDevice, BXAudioSource>

Expand All @@ -110,12 +110,12 @@ typedef NS_OPTIONS(NSUInteger, BXMT32ROMType) {
#pragma mark Helper class methods

/// Returns the exact type of ROM at the specified URL: PCM/Control, MT32/CM32L.
/// Returns \c BXMT32ROMTypeUnknown and populates \c outError if the type of ROM could
/// Returns `BXMT32ROMTypeUnknown` and populates `outError` if the type of ROM could
/// not be determined.
+ (BXMT32ROMType) typeOfROMAtURL: (NSURL *)URL error: (out NSError **)outError NS_REFINED_FOR_SWIFT;

/// Returns whether the specified pair of ROMs is MT32 or CM32L.
/// Returns \c BXMT32ROMTypeUnknown and populates \c outError if there was an error
/// Returns `BXMT32ROMTypeUnknown` and populates `outError` if there was an error
/// determining the types of the ROMs or if they are mismatched.
+ (BXMT32ROMType) typeOfROMPairWithControlROMURL: (NSURL *)controlROMURL
PCMROMURL: (NSURL *)PCMROMURL
Expand Down
2 changes: 1 addition & 1 deletion Boxer/BXEmulatedMT32Delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN

@class BXEmulatedMT32;

/// \c BXEmulatedMT32Delegate defines delegate notification callbacks
/// `BXEmulatedMT32Delegate` defines delegate notification callbacks
/// to handle information coming from the MT-32.
@protocol BXEmulatedMT32Delegate <NSObject>

Expand Down
25 changes: 13 additions & 12 deletions Boxer/BXEmulator+BXAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,25 @@ typedef NS_ENUM(NSInteger, BXMIDIMusicType) {
BXMIDIMusicMT32 = 2
};

/// An NSNumber corresponding to one of the BXMIDIMusicType constants.
/// If BXMIDIMusicDisabled, Boxer will disable MIDI playback.
/// An `NSNumber` corresponding to one of the `BXMIDIMusicType` constants.
/// If `BXMIDIMusicDisabled`, Boxer will disable MIDI playback.
extern NSString * const BXMIDIMusicTypeKey;

/// An NSNumber boolean indicating whether an external General MIDI playback device
/// An `NSNumber` boolean indicating whether an external General MIDI playback device
/// should be chosen if any are available.
extern NSString * const BXMIDIPreferExternalKey;

/// An NSNumber indicating the unique ID of the external device to use for MIDI playback.
/// Only applicable if @c BXMIDIPreferExternal is YES.
/// An `NSNumber` indicating the unique ID of the external device to use for MIDI playback.
/// Only applicable if `BXMIDIPreferExternal` is `YES`.
extern NSString * const BXMIDIExternalDeviceUniqueIDKey;

/// An NSNumber indicating the numeric enumeration order of the external device to use for MIDI playback.
/// Only applicable if @c BXMIDIPreferExternalKey is @c YES.
/// @note If both this and @c BXMIDIExternalDeviceUniqueIDKey are omitted, delegates should return the
/// An `NSNumber` indicating the numeric enumeration order of the external device to use for MIDI playback.
/// Only applicable if `BXMIDIPreferExternalKey` is `YES`.
/// - note: If both this and `BXMIDIExternalDeviceUniqueIDKey` are omitted, delegates should return the
/// first appropriate MIDI device that is found.
extern NSString * const BXMIDIExternalDeviceIndexKey;

/// An NSNumber boolean indicating whether the requested external MIDI device requires additional sysex
/// An `NSNumber` boolean indicating whether the requested external MIDI device requires additional sysex
/// delays when sending MIDI signals. Necessary for older-generation MT-32 devices.
extern NSString * const BXMIDIExternalDeviceNeedsMT32SysexDelaysKey;

Expand All @@ -62,7 +62,7 @@ extern NSString * const BXMIDIExternalDeviceNeedsMT32SysexDelaysKey;

@protocol BXMIDIDevice;

/// The \c BXAudio category extends \c BXEmulator with functionality
/// The `BXAudio` category extends `BXEmulator` with functionality
/// for controlling DOSBox's audio emulation and output.
@interface BXEmulator (BXAudio) <BXEmulatedMT32Delegate>

Expand All @@ -75,11 +75,12 @@ extern NSString * const BXMIDIExternalDeviceNeedsMT32SysexDelaysKey;

/// Attach a new active MIDI device suitable for the specified description.
/// Returns the newly-attached device if it was initialized and attached successfully,
/// or \c nil if the device could not be created.
/// or `nil` if the device could not be created.
- (id <BXMIDIDevice>) attachMIDIDeviceForDescription: (NSDictionary *)description;

/// Dispatch the specified MIDI message/sysex onward to the active MIDI device.
/// Dispatch the specified MIDI message onward to the active MIDI device.
- (void) sendMIDIMessage: (NSData *)message;
/// Dispatch the specified MIDI sysex onward to the active MIDI device.
- (void) sendMIDISysex: (NSData *)message;

@end
6 changes: 3 additions & 3 deletions Boxer/BXMIDIDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark -
#pragma mark Protocol declaration

/// The \c BXMIDIDevice protocol defines an interface for emulated (and not-so-emulated)
/// The `BXMIDIDevice` protocol defines an interface for emulated (and not-so-emulated)
/// MIDI devices, to which BXEmulator can send MIDI output.
@protocol BXMIDIDevice <NSObject>

#pragma mark -
#pragma mark Properties

/// The master volume of the MIDI device from \c 0.0 to \c 1.0, independent of the volume
/// The master volume of the MIDI device from *0.0* to *1.0*, independent of the volume
/// of individual channels. MIDI devices are not expected to support fine-grained
/// volume control, but at the very least should mute themselves when their volume
/// is set to 0.
Expand All @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly) BOOL supportsGeneralMIDIMusic;

/// Returns whether this device is still processing events.
/// If <code>YES</code>, further messages should not be sent until <code>dateWhenReady</code>.
/// If `YES`, further messages should not be sent until `dateWhenReady`.
@property (readonly, getter=isProcessing) BOOL processing;

/// The date at which this device will next be able to receive events.
Expand Down
32 changes: 8 additions & 24 deletions Boxer/MT32LCDDisplay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,28 @@ import Cocoa
/// Non-ASCII characters will be drawn as empty space.
class MT32LCDDisplay : NSTextField {
/// The image containing glyph data for the pixel font.
private var pixelFont: NSImage {
return NSImage(named: "MT32ScreenDisplay/MT32LCDFontTemplate")!
}
private let pixelFont = NSImage(named: "MT32ScreenDisplay/MT32LCDFontTemplate")!

/// The mask image to use for the LCD pixel grid.
/// This will be drawn in for 20 character places.
private var pixelGrid: NSImage {
return NSImage(named: "MT32ScreenDisplay/MT32LCDGridTemplate")!
}
private let pixelGrid = NSImage(named: "MT32ScreenDisplay/MT32LCDGridTemplate")!

/// The background color of the field.
private var screenColor: NSColor {
return NSColor(named: "MT32ScreenDisplay/screenColor")!
}
private let screenColor = NSColor(named: "MT32ScreenDisplay/screenColor")!

private var frameColor: NSColor {
return NSColor(named: "MT32ScreenDisplay/frameColor")!
}
private let frameColor = NSColor(named: "MT32ScreenDisplay/frameColor")!

/// The background color of the LCD pixel grid.
private var gridColor: NSColor {
return NSColor(named: "MT32ScreenDisplay/gridColor")!
}
private let gridColor = NSColor(named: "MT32ScreenDisplay/gridColor")!

/// The colour of lit LCD pixels upon the grid.
private var pixelColor: NSColor {
return NSColor(named: "MT32ScreenDisplay/pixelColor")!
}
private let pixelColor = NSColor(named: "MT32ScreenDisplay/pixelColor")!

/// The inner shadow of the screen.
private var innerShadow: NSShadow {
return NSShadow(blurRadius: 10, offset: NSSize(width: 0, height: -2.0), color: NSColor(named: "MT32ScreenDisplay/innerShadowColor")!)
}
private let innerShadow = NSShadow(blurRadius: 10, offset: NSSize(width: 0, height: -2.0), color: NSColor(named: "MT32ScreenDisplay/innerShadowColor")!)

/// The lighting effects applied on top of the screen.
private var screenLighting: NSGradient {
return NSGradient(colorsAndLocations: (NSColor(calibratedWhite: 1.0, alpha: 0.10), 0.0), (NSColor(calibratedWhite: 1.0, alpha: 0.07), 0.5), (NSColor.clear, 0.55))!
}
private let screenLighting = NSGradient(colorsAndLocations: (NSColor(calibratedWhite: 1.0, alpha: 0.10), 0.0), (NSColor(calibratedWhite: 1.0, alpha: 0.07), 0.5), (NSColor.clear, 0.55))!

override func draw(_ dirtyRect: NSRect) {
let charsToDisplay = stringValue.padding(toLength: 20, withPad: " ", startingAt: 0)
Expand Down
4 changes: 2 additions & 2 deletions Boxer/Printing/BXPrintSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ - (void) beginPageWithSize: (NSSize)size
NSSize canvasSize = NSMakeSize(ceil(size.width * self.previewDPI.width),
ceil(size.height * self.previewDPI.height));

self._previewCanvas = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
self._previewCanvas = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL
pixelsWide: canvasSize.width
pixelsHigh: canvasSize.height
bitsPerSample: 8
Expand All @@ -164,7 +164,7 @@ - (void) beginPageWithSize: (NSSize)size
isPlanar: NO
colorSpaceName: NSDeviceRGBColorSpace
bytesPerRow: 0
bitsPerPixel: 0];
bitsPerPixel: 0] bitmapImageRepByRetaggingWithColorSpace:NSColorSpace.sRGBColorSpace] ;

//Wrap this in an NSImage so upstream contexts can display the preview easily.
NSImage *preview = [[NSImage alloc] initWithSize: canvasSize];
Expand Down
4 changes: 2 additions & 2 deletions Other Sources/ADBToolkit/NSImage+ADBSaveImages.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL) saveToURL: (NSURL *)URL
withType: (NSBitmapImageFileType)type
properties: (NSDictionary<NSBitmapImageRepPropertyKey, id> *)properties
error: (out NSError **)outError;
error: (out NSError *__autoreleasing*)outError;

/// Creates a .ICNS-format at the specified location. Returns @c YES on success, or @c NO and populates
/// @c outError if there was an error (including that a file at the specified destination already exists.)
- (BOOL) saveAsIconToURL: (NSURL *)URL
error: (out NSError **)outError;
error: (out NSError *__autoreleasing*)outError;

@end

Expand Down
17 changes: 9 additions & 8 deletions Other Sources/ADBToolkit/URL+ADBFilesystemHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,15 @@ extension URL {
// reports `public.folder` as the UTI when the extension conforms to a more
// specific UTI.
let ext = pathExtension
if ext.count != 0 {
let utiForExt = UTType(filenameExtension: ext)
if let utiForExt,
utiForExt != reportedUTI,
utiForExt.conforms(to: comparisonUTI) {
return true
}
}
guard !ext.isEmpty else {
return false
}
let utiForExt = UTType(filenameExtension: ext)
if let utiForExt,
utiForExt != reportedUTI,
utiForExt.conforms(to: comparisonUTI) {
return true
}

return false
}
Expand Down

0 comments on commit f6aef51

Please sign in to comment.