Disk Sound Effect enable button

This commit is contained in:
tudnai 2020-06-11 23:16:26 -07:00
parent 3ef337771b
commit 6f78b92344
5 changed files with 42 additions and 17 deletions

View File

@ -1394,13 +1394,13 @@
</customSpacing>
</stackView>
<stackView distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lVP-FP-u6x" userLabel="CPU Speed Selection">
<rect key="frame" x="8" y="8" width="104" height="301"/>
<rect key="frame" x="8" y="8" width="104" height="323"/>
<subviews>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="7yw-J0-Fmj">
<rect key="frame" x="0.0" y="298" width="96" height="5"/>
<rect key="frame" x="0.0" y="320" width="96" height="5"/>
</box>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="e2E-di-h3i">
<rect key="frame" x="-2" y="276" width="83" height="18"/>
<rect key="frame" x="-2" y="298" width="83" height="18"/>
<buttonCell key="cell" type="check" title="KeybStick" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="UW9-Bt-pMv">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -1410,7 +1410,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Wa3-TC-XUI">
<rect key="frame" x="-2" y="254" width="79" height="18"/>
<rect key="frame" x="-2" y="276" width="79" height="18"/>
<buttonCell key="cell" type="check" title="MouStick" bezelStyle="regularSquare" imagePosition="left" inset="2" id="BGz-fX-MyG">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -1420,7 +1420,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xrz-jA-1Fh">
<rect key="frame" x="-2" y="232" width="63" height="18"/>
<rect key="frame" x="-2" y="254" width="63" height="18"/>
<buttonCell key="cell" type="check" title="Mouse" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="1RG-zY-mD2">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -1430,10 +1430,10 @@
</connections>
</button>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="rIK-Xk-n9g">
<rect key="frame" x="0.0" y="223" width="96" height="5"/>
<rect key="frame" x="0.0" y="245" width="96" height="5"/>
</box>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ccb-cj-gLu">
<rect key="frame" x="-2" y="201" width="87" height="18"/>
<rect key="frame" x="-2" y="223" width="87" height="18"/>
<buttonCell key="cell" type="check" title="Quick Disk" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="6QV-uF-Gh7">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -1442,11 +1442,21 @@
<action selector="QuickDisk:" target="XfG-lQ-9wD" id="tt5-2M-B2Y"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9nQ-Yf-2xf">
<rect key="frame" x="-2" y="201" width="91" height="18"/>
<buttonCell key="cell" type="check" title="Disk Sound" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="AJi-1B-qeg">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="DiskSound:" target="XfG-lQ-9wD" id="iPC-sW-ZFh"/>
</connections>
</button>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="wih-Y6-2Bz">
<rect key="frame" x="0.0" y="192" width="96" height="5"/>
</box>
<splitView hidden="YES" dividerStyle="thin" vertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ge3-qD-JO6">
<rect key="frame" x="0.0" y="278" width="104" height="23"/>
<rect key="frame" x="0.0" y="300" width="104" height="23"/>
<subviews>
<textField verticalHuggingPriority="750" fixedFrame="YES" id="SNE-lV-JXn" userLabel="SoundGap">
<rect key="frame" x="0.0" y="0.0" width="90" height="23"/>
@ -1578,6 +1588,7 @@
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
@ -1596,6 +1607,7 @@
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>

View File

@ -891,15 +891,22 @@ class ViewController: NSViewController {
@IBAction func QuickDisk(_ sender: NSButton) {
if sender.state == .on {
// diskAccelerator_speed = Int32( 25 * M / Double(fps) )
diskAccelerator_enabled = 1;
}
else {
// diskAccelerator_speed = 0
diskAccelerator_enabled = 0;
}
}
@IBAction func DiskSound(_ sender: NSButton) {
if sender.state == .on {
disk_sfx_enabled = 1;
}
else {
disk_sfx_enabled = 0;
}
}
@objc func openDiskImage() {
let openPanel = NSOpenPanel()

View File

@ -225,6 +225,8 @@ void spkr_init() {
// Dealloc OpenAL
void spkr_exit() {
if ( spkr_src[0] ) {
alSourceStop( spkr_src[0] );
ALCdevice *dev = NULL;
ALCcontext *ctx = NULL;
ctx = alcGetCurrentContext();
@ -238,6 +240,8 @@ void spkr_exit() {
memset(spkr_src, 0, sizeof(spkr_src));
memset(spkr_buffers, 0, sizeof(spkr_buffers));
spkr_disk_motor_buf = 0;
spkr_disk_arm_buf = 0;
}
}
@ -486,20 +490,20 @@ void spkr_stop_sfx( ALuint src ) {
void spkr_play_disk_motor() {
if ( clk_6502_per_frm <= iicplus_MHz_6502 / fps ) {
if ( ( disk_sfx_enabled ) && ( clk_6502_per_frm <= iicplus_MHz_6502 / fps ) ) {
spkr_play_sfx( spkr_src[1], diskmotor_sfx, diskmotor_sfx_len );
}
}
void spkr_stop_disk_motor( int time ) {
if ( clk_6502_per_frm <= iicplus_MHz_6502 / fps ) {
if ( ( disk_sfx_enabled ) && ( clk_6502_per_frm <= iicplus_MHz_6502 / fps ) ) {
spkr_play_disk_motor_time = time;
}
}
void spkr_play_disk_arm() {
if ( clk_6502_per_frm <= iicplus_MHz_6502 / fps ) {
if ( ( disk_sfx_enabled ) && ( clk_6502_per_frm <= iicplus_MHz_6502 / fps ) ) {
if ( spkr_play_disk_ioerr_time == 0 ) {
spkr_play_sfx( spkr_src[2], diskarm_sfx, diskarm_sfx_len );
spkr_play_disk_arm_time = 2;
@ -509,8 +513,8 @@ void spkr_play_disk_arm() {
void spkr_play_disk_ioerr() {
if ( clk_6502_per_frm <= iicplus_MHz_6502 / fps ) {
spkr_playqueue_sfx( spkr_src[3], diskioerr_sfx, diskioerr_sfx_len - 512);
if ( ( disk_sfx_enabled ) && ( clk_6502_per_frm <= iicplus_MHz_6502 / fps ) ) {
spkr_playqueue_sfx( spkr_src[3], diskioerr_sfx, diskioerr_sfx_len);
spkr_play_disk_ioerr_time = 4;
}
}
@ -526,7 +530,7 @@ void update_disk_sfx( unsigned * time, ALuint src ) {
void spkr_update_disk_sfx() {
// is user speeds up the machine, disk sfx needs to be stopped
if ( clk_6502_per_frm > iicplus_MHz_6502 / fps ) {
if ( ( ! disk_sfx_enabled ) || ( clk_6502_per_frm > iicplus_MHz_6502 / fps ) ) {
if ( spkr_play_disk_motor_time ) {
spkr_play_disk_motor_time = 1; // rest will be taken care below
}

View File

@ -22,6 +22,7 @@ const int diskAccelerator_frames = 2;
int diskAccelerator_count = 0;
int diskAccelerator_speed = 25 * M / fps; // if less than actual CPU speed means no acceleration
int diskAccelerator_enabled = 1;
int disk_sfx_enabled = 1;
// motor position from the magnet state
// -1 means invalid, not supported

View File

@ -57,6 +57,7 @@ extern const int diskAccelerator_frames; // number of frames disk acceleratio
extern int diskAccelerator_count; // counter for the disk acceleration frames
extern int diskAccelerator_speed; // if less than the actual CPU speed, no acceleration
extern int diskAccelerator_enabled;
extern int disk_sfx_enabled;
extern void disk_phase(void);
extern void disk_phase_on( uint8_t currentMagnet );