Rumble mode selection
This commit is contained in:
parent
4c443d51ce
commit
4b24178553
@ -43,6 +43,7 @@
|
|||||||
@"GBDMGModel": @(GB_MODEL_DMG_B),
|
@"GBDMGModel": @(GB_MODEL_DMG_B),
|
||||||
@"GBCGBModel": @(GB_MODEL_CGB_E),
|
@"GBCGBModel": @(GB_MODEL_CGB_E),
|
||||||
@"GBSGBModel": @(GB_MODEL_SGB2),
|
@"GBSGBModel": @(GB_MODEL_SGB2),
|
||||||
|
@"GBRumbleMode": @(GB_RUMBLE_CARTRIDGE_ONLY),
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[JOYController startOnRunLoop:[NSRunLoop currentRunLoop] withOptions:@{
|
[JOYController startOnRunLoop:[NSRunLoop currentRunLoop] withOptions:@{
|
||||||
|
@ -228,6 +228,11 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
|
|||||||
borderModeChanged = true;
|
borderModeChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) updateRumbleMode
|
||||||
|
{
|
||||||
|
GB_set_rumble_mode(&gb, [[NSUserDefaults standardUserDefaults] integerForKey:@"GBRumbleMode"]);
|
||||||
|
}
|
||||||
|
|
||||||
- (void) initCommon
|
- (void) initCommon
|
||||||
{
|
{
|
||||||
GB_init(&gb, [self internalModel]);
|
GB_init(&gb, [self internalModel]);
|
||||||
@ -247,6 +252,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
|
|||||||
GB_set_rewind_length(&gb, [[NSUserDefaults standardUserDefaults] integerForKey:@"GBRewindLength"]);
|
GB_set_rewind_length(&gb, [[NSUserDefaults standardUserDefaults] integerForKey:@"GBRewindLength"]);
|
||||||
GB_apu_set_sample_callback(&gb, audioCallback);
|
GB_apu_set_sample_callback(&gb, audioCallback);
|
||||||
GB_set_rumble_callback(&gb, rumbleCallback);
|
GB_set_rumble_callback(&gb, rumbleCallback);
|
||||||
|
[self updateRumbleMode];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) updateMinSize
|
- (void) updateMinSize
|
||||||
@ -556,6 +562,11 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
|
|||||||
name:@"GBBorderModeChanged"
|
name:@"GBBorderModeChanged"
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(updateRumbleMode)
|
||||||
|
name:@"GBRumbleModeChanged"
|
||||||
|
object:nil];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(updateRewindLength)
|
selector:@selector(updateRewindLength)
|
||||||
name:@"GBRewindLengthChanged"
|
name:@"GBRewindLengthChanged"
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
@property (strong) IBOutlet NSButton *skipButton;
|
@property (strong) IBOutlet NSButton *skipButton;
|
||||||
@property (strong) IBOutlet NSMenuItem *bootROMsFolderItem;
|
@property (strong) IBOutlet NSMenuItem *bootROMsFolderItem;
|
||||||
@property (strong) IBOutlet NSPopUpButtonCell *bootROMsButton;
|
@property (strong) IBOutlet NSPopUpButtonCell *bootROMsButton;
|
||||||
|
@property (strong) IBOutlet NSPopUpButton *rumbleModePopupButton;
|
||||||
|
|
||||||
@property (weak) IBOutlet NSPopUpButton *dmgPopupButton;
|
@property (weak) IBOutlet NSPopUpButton *dmgPopupButton;
|
||||||
@property (weak) IBOutlet NSPopUpButton *sgbPopupButton;
|
@property (weak) IBOutlet NSPopUpButton *sgbPopupButton;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
NSPopUpButton *_dmgPopupButton, *_sgbPopupButton, *_cgbPopupButton;
|
NSPopUpButton *_dmgPopupButton, *_sgbPopupButton, *_cgbPopupButton;
|
||||||
NSPopUpButton *_preferredJoypadButton;
|
NSPopUpButton *_preferredJoypadButton;
|
||||||
|
NSPopUpButton *_rumbleModePopupButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray *)filterList
|
+ (NSArray *)filterList
|
||||||
@ -125,6 +126,18 @@
|
|||||||
return _displayBorderPopupButton;
|
return _displayBorderPopupButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setRumbleModePopupButton:(NSPopUpButton *)rumbleModePopupButton
|
||||||
|
{
|
||||||
|
_rumbleModePopupButton = rumbleModePopupButton;
|
||||||
|
NSInteger mode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBRumbleMode"];
|
||||||
|
[_rumbleModePopupButton selectItemWithTag:mode];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSPopUpButton *)rumbleModePopupButton
|
||||||
|
{
|
||||||
|
return _rumbleModePopupButton;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setRewindPopupButton:(NSPopUpButton *)rewindPopupButton
|
- (void)setRewindPopupButton:(NSPopUpButton *)rewindPopupButton
|
||||||
{
|
{
|
||||||
_rewindPopupButton = rewindPopupButton;
|
_rewindPopupButton = rewindPopupButton;
|
||||||
@ -267,6 +280,13 @@
|
|||||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBBorderModeChanged" object:nil];
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBBorderModeChanged" object:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (IBAction)rumbleModeChanged:(id)sender
|
||||||
|
{
|
||||||
|
[[NSUserDefaults standardUserDefaults] setObject:@([sender selectedItem].tag)
|
||||||
|
forKey:@"GBRumbleMode"];
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"GBRumbleModeChanged" object:nil];
|
||||||
|
}
|
||||||
|
|
||||||
- (IBAction)rewindLengthChanged:(id)sender
|
- (IBAction)rewindLengthChanged:(id)sender
|
||||||
{
|
{
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:@([sender selectedTag])
|
[[NSUserDefaults standardUserDefaults] setObject:@([sender selectedTag])
|
||||||
|
@ -76,6 +76,7 @@
|
|||||||
<outlet property="playerListButton" destination="gWx-7h-0xq" id="zo6-82-JId"/>
|
<outlet property="playerListButton" destination="gWx-7h-0xq" id="zo6-82-JId"/>
|
||||||
<outlet property="preferredJoypadButton" destination="0Az-0R-oNw" id="7JM-tw-BhK"/>
|
<outlet property="preferredJoypadButton" destination="0Az-0R-oNw" id="7JM-tw-BhK"/>
|
||||||
<outlet property="rewindPopupButton" destination="7fg-Ww-JjR" id="Ka2-TP-B1x"/>
|
<outlet property="rewindPopupButton" destination="7fg-Ww-JjR" id="Ka2-TP-B1x"/>
|
||||||
|
<outlet property="rumbleModePopupButton" destination="Ogs-xG-b4b" id="vuw-VN-MTp"/>
|
||||||
<outlet property="sgbPopupButton" destination="dza-T7-RkX" id="B0o-Nb-pIH"/>
|
<outlet property="sgbPopupButton" destination="dza-T7-RkX" id="B0o-Nb-pIH"/>
|
||||||
<outlet property="skipButton" destination="d2I-jU-sLb" id="udX-8K-0sK"/>
|
<outlet property="skipButton" destination="d2I-jU-sLb" id="udX-8K-0sK"/>
|
||||||
</connections>
|
</connections>
|
||||||
@ -463,11 +464,11 @@
|
|||||||
<point key="canvasLocation" x="-176" y="890"/>
|
<point key="canvasLocation" x="-176" y="890"/>
|
||||||
</customView>
|
</customView>
|
||||||
<customView id="8TU-6J-NCg">
|
<customView id="8TU-6J-NCg">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="292" height="401"/>
|
<rect key="frame" x="0.0" y="0.0" width="292" height="467"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Utu-t4-cLx">
|
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Utu-t4-cLx">
|
||||||
<rect key="frame" x="10" y="364" width="122" height="17"/>
|
<rect key="frame" x="10" y="430" width="122" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Control settings for" id="YqW-Ds-VIC">
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Control settings for" id="YqW-Ds-VIC">
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
@ -475,8 +476,17 @@
|
|||||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
|
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DZu-ts-deW">
|
||||||
|
<rect key="frame" x="18" y="87" width="105" height="17"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Enable rumble:" id="QMX-3p-s1Z">
|
||||||
|
<font key="font" metaFont="system"/>
|
||||||
|
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
<scrollView focusRingType="none" fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" verticalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="PBp-dj-EIa">
|
<scrollView focusRingType="none" fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" horizontalScrollElasticity="none" verticalScrollElasticity="none" translatesAutoresizingMaskIntoConstraints="NO" id="PBp-dj-EIa">
|
||||||
<rect key="frame" x="32" y="142" width="240" height="211"/>
|
<rect key="frame" x="32" y="208" width="240" height="211"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<clipView key="contentView" focusRingType="none" ambiguous="YES" drawsBackground="NO" id="AMs-PO-nid">
|
<clipView key="contentView" focusRingType="none" ambiguous="YES" drawsBackground="NO" id="AMs-PO-nid">
|
||||||
<rect key="frame" x="1" y="1" width="238" height="209"/>
|
<rect key="frame" x="1" y="1" width="238" height="209"/>
|
||||||
@ -534,7 +544,7 @@
|
|||||||
</scroller>
|
</scroller>
|
||||||
</scrollView>
|
</scrollView>
|
||||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fcF-wc-KwM">
|
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fcF-wc-KwM">
|
||||||
<rect key="frame" x="30" y="117" width="203" height="17"/>
|
<rect key="frame" x="30" y="183" width="203" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Controller for multiplayer games:" id="AJA-9b-VKI">
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Controller for multiplayer games:" id="AJA-9b-VKI">
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
@ -543,7 +553,7 @@
|
|||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="0Az-0R-oNw">
|
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="0Az-0R-oNw">
|
||||||
<rect key="frame" x="42" y="86" width="208" height="26"/>
|
<rect key="frame" x="42" y="152" width="208" height="26"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<popUpButtonCell key="cell" type="push" title="None" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingMiddle" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="hy8-cr-RrE" id="uEC-vN-8Jq">
|
<popUpButtonCell key="cell" type="push" title="None" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingMiddle" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="hy8-cr-RrE" id="uEC-vN-8Jq">
|
||||||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||||
@ -559,11 +569,11 @@
|
|||||||
</connections>
|
</connections>
|
||||||
</popUpButton>
|
</popUpButton>
|
||||||
<box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="VEc-Ed-Z6f">
|
<box verticalHuggingPriority="750" fixedFrame="YES" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="VEc-Ed-Z6f">
|
||||||
<rect key="frame" x="12" y="73" width="268" height="5"/>
|
<rect key="frame" x="12" y="139" width="268" height="5"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
</box>
|
</box>
|
||||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ReM-uo-H0r">
|
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ReM-uo-H0r">
|
||||||
<rect key="frame" x="215" y="364" width="8" height="17"/>
|
<rect key="frame" x="215" y="430" width="8" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title=":" id="VhO-3T-glt">
|
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title=":" id="VhO-3T-glt">
|
||||||
<font key="font" metaFont="system"/>
|
<font key="font" metaFont="system"/>
|
||||||
@ -572,7 +582,7 @@
|
|||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
</textField>
|
</textField>
|
||||||
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gWx-7h-0xq">
|
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gWx-7h-0xq">
|
||||||
<rect key="frame" x="131" y="357" width="87" height="26"/>
|
<rect key="frame" x="131" y="423" width="87" height="26"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<popUpButtonCell key="cell" type="push" title="Player 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="TO3-R7-9HN" id="pbt-Lr-bU1">
|
<popUpButtonCell key="cell" type="push" title="Player 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="TO3-R7-9HN" id="pbt-Lr-bU1">
|
||||||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||||
@ -590,8 +600,26 @@
|
|||||||
<action selector="refreshJoypadMenu:" target="QvC-M9-y7g" id="5hY-tg-9VE"/>
|
<action selector="refreshJoypadMenu:" target="QvC-M9-y7g" id="5hY-tg-9VE"/>
|
||||||
</connections>
|
</connections>
|
||||||
</popUpButton>
|
</popUpButton>
|
||||||
|
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ogs-xG-b4b">
|
||||||
|
<rect key="frame" x="30" y="58" width="245" height="22"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<popUpButtonCell key="cell" type="push" title="Never" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="jki-7x-bnM" id="o9b-MH-8kd">
|
||||||
|
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||||
|
<font key="font" metaFont="menu"/>
|
||||||
|
<menu key="menu" id="8p7-je-0Fh">
|
||||||
|
<items>
|
||||||
|
<menuItem title="Never" id="jki-7x-bnM"/>
|
||||||
|
<menuItem title="For rumble-enabled cartridges" state="on" tag="1" id="58e-Tp-TWd"/>
|
||||||
|
<menuItem title="Always" tag="2" id="qVe-2b-W1P"/>
|
||||||
|
</items>
|
||||||
|
</menu>
|
||||||
|
</popUpButtonCell>
|
||||||
|
<connections>
|
||||||
|
<action selector="rumbleModeChanged:" target="QvC-M9-y7g" id="AQe-vQ-mSl"/>
|
||||||
|
</connections>
|
||||||
|
</popUpButton>
|
||||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RuW-Db-dzW">
|
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="RuW-Db-dzW">
|
||||||
<rect key="frame" x="18" y="44" width="264" height="25"/>
|
<rect key="frame" x="18" y="110" width="264" height="25"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<buttonCell key="cell" type="check" title="Analog turbo and slow-motion controls" bezelStyle="regularSquare" imagePosition="left" lineBreakMode="charWrapping" inset="2" id="Mvp-oc-N3t">
|
<buttonCell key="cell" type="check" title="Analog turbo and slow-motion controls" bezelStyle="regularSquare" imagePosition="left" lineBreakMode="charWrapping" inset="2" id="Mvp-oc-N3t">
|
||||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||||
@ -624,7 +652,7 @@
|
|||||||
</connections>
|
</connections>
|
||||||
</button>
|
</button>
|
||||||
</subviews>
|
</subviews>
|
||||||
<point key="canvasLocation" x="-159" y="1128.5"/>
|
<point key="canvasLocation" x="-159" y="1161.5"/>
|
||||||
</customView>
|
</customView>
|
||||||
</objects>
|
</objects>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -661,6 +661,7 @@ struct GB_gameboy_internal_s {
|
|||||||
bool vblank_just_occured; // For slow operations involving syscalls; these should only run once per vblank
|
bool vblank_just_occured; // For slow operations involving syscalls; these should only run once per vblank
|
||||||
uint8_t cycles_since_run; // How many cycles have passed since the last call to GB_run(), in 8MHz units
|
uint8_t cycles_since_run; // How many cycles have passed since the last call to GB_run(), in 8MHz units
|
||||||
double clock_multiplier;
|
double clock_multiplier;
|
||||||
|
GB_rumble_mode_t rumble_mode;
|
||||||
uint32_t rumble_on_cycles;
|
uint32_t rumble_on_cycles;
|
||||||
uint32_t rumble_off_cycles;
|
uint32_t rumble_off_cycles;
|
||||||
|
|
||||||
|
@ -1,16 +1,27 @@
|
|||||||
#include "rumble.h"
|
#include "rumble.h"
|
||||||
#include "gb.h"
|
#include "gb.h"
|
||||||
|
|
||||||
|
void GB_set_rumble_mode(GB_gameboy_t *gb, GB_rumble_mode_t mode)
|
||||||
|
{
|
||||||
|
gb->rumble_mode = mode;
|
||||||
|
if (gb->rumble_callback) {
|
||||||
|
gb->rumble_callback(gb, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GB_handle_rumble(GB_gameboy_t *gb)
|
void GB_handle_rumble(GB_gameboy_t *gb)
|
||||||
{
|
{
|
||||||
if (gb->rumble_callback) {
|
if (gb->rumble_callback) {
|
||||||
|
if (gb->rumble_mode == GB_RUMBLE_DISABLED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (gb->cartridge_type->has_rumble) {
|
if (gb->cartridge_type->has_rumble) {
|
||||||
if (gb->rumble_on_cycles + gb->rumble_off_cycles) {
|
if (gb->rumble_on_cycles + gb->rumble_off_cycles) {
|
||||||
gb->rumble_callback(gb, gb->rumble_on_cycles / (double)(gb->rumble_on_cycles + gb->rumble_off_cycles));
|
gb->rumble_callback(gb, gb->rumble_on_cycles / (double)(gb->rumble_on_cycles + gb->rumble_off_cycles));
|
||||||
gb->rumble_on_cycles = gb->rumble_off_cycles = 0;
|
gb->rumble_on_cycles = gb->rumble_off_cycles = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (gb->rumble_mode == GB_RUMBLE_ALL_GAMES) {
|
||||||
unsigned volume = (gb->io_registers[GB_IO_NR50] & 7) + 1 + ((gb->io_registers[GB_IO_NR50] >> 4) & 7) + 1;
|
unsigned volume = (gb->io_registers[GB_IO_NR50] & 7) + 1 + ((gb->io_registers[GB_IO_NR50] >> 4) & 7) + 1;
|
||||||
unsigned ch4_volume = volume * (!!(gb->io_registers[GB_IO_NR51] & 8) + !!(gb->io_registers[GB_IO_NR51] & 0x80));
|
unsigned ch4_volume = volume * (!!(gb->io_registers[GB_IO_NR51] & 8) + !!(gb->io_registers[GB_IO_NR51] & 0x80));
|
||||||
unsigned ch1_volume = volume * (!!(gb->io_registers[GB_IO_NR51] & 1) + !!(gb->io_registers[GB_IO_NR51] & 0x10));
|
unsigned ch1_volume = volume * (!!(gb->io_registers[GB_IO_NR51] & 1) + !!(gb->io_registers[GB_IO_NR51] & 0x10));
|
||||||
|
@ -3,6 +3,15 @@
|
|||||||
|
|
||||||
#include "gb_struct_def.h"
|
#include "gb_struct_def.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GB_RUMBLE_DISABLED,
|
||||||
|
GB_RUMBLE_CARTRIDGE_ONLY,
|
||||||
|
GB_RUMBLE_ALL_GAMES
|
||||||
|
} GB_rumble_mode_t;
|
||||||
|
|
||||||
|
#ifdef GB_INTERNAL
|
||||||
void GB_handle_rumble(GB_gameboy_t *gb);
|
void GB_handle_rumble(GB_gameboy_t *gb);
|
||||||
|
#endif
|
||||||
|
void GB_set_rumble_mode(GB_gameboy_t *gb, GB_rumble_mode_t mode);
|
||||||
|
|
||||||
#endif /* rumble_h */
|
#endif /* rumble_h */
|
||||||
|
Loading…
Reference in New Issue
Block a user