- Added UI Control over Disk Acceleration

- Effort to make sound smoother on higher frequencies
This commit is contained in:
tudnai 2020-05-27 19:12:28 -07:00
parent 17927f4ab0
commit add26cffc0
6 changed files with 51 additions and 10 deletions

View File

@ -14,6 +14,7 @@
#import "6502.h"
#include "speaker.h" // So we can access to speaker stuff from Swift
#include "disk.h"
#endif /* A2Mac_Bridging_Header_h */

View File

@ -991,8 +991,18 @@
</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="217"/>
<rect key="frame" x="8" y="8" width="104" height="239"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ccb-cj-gLu">
<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"/>
</buttonCell>
<connections>
<action selector="QuickDisk:" target="XfG-lQ-9wD" id="tt5-2M-B2Y"/>
</connections>
</button>
<splitView dividerStyle="thin" vertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ge3-qD-JO6">
<rect key="frame" x="0.0" y="194" width="104" height="23"/>
<subviews>
@ -1119,6 +1129,7 @@
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
@ -1130,6 +1141,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

@ -754,7 +754,29 @@ class ViewController: NSViewController {
}
else if let freq = Double( sender.title ) {
setCPUClockSpeed(freq: freq)
// TODO: Probably this is not the best way to deal with the problem: To make sound continous independent of FPS and Freq
spkr_extra_buf = 780 / fps
switch freq {
case 2.0:
spkr_extra_buf = UInt32( Double(spkr_extra_buf) * 2.961538461538462 ) // normally it should come up as 77, but this way it is calculated with FPS
break
case 4.0:
spkr_extra_buf = UInt32( Double(spkr_extra_buf) * 1.346153846153846 ) // normally it should come up as 35, but this way it is calculated with FPS
break
default:
spkr_extra_buf = 780 / fps // normally it should come up as 26, but this way it is calculated with FPS
break
}
SoundGap.integerValue = Int(spkr_extra_buf)
}
}
@ -765,5 +787,14 @@ class ViewController: NSViewController {
spkr_extra_buf = UInt32( sender.integerValue )
}
@IBAction func QuickDisk(_ sender: NSButton) {
if sender.state == .on {
diskAccelerator_speed = Int32( 25 * M / Double(fps) )
}
else {
diskAccelerator_speed = 0
}
}
}

View File

@ -10,8 +10,7 @@
#define __6502_H__
#include <stdint.h>
#include "../../src/util/common.h"
#include "../../src/dev/audio/speaker.h" // So we can access to speaker stuff from Swift
#include "common.h"
extern const unsigned long long default_MHz_6502;

View File

@ -7,8 +7,8 @@
//
#include "disk.h"
#include "../../cpu/6502.h"
#include "../../util/common.h"
#include "6502.h"
#include "common.h"
#include "woz.h"
@ -19,9 +19,7 @@ disk_t disk = {
const int diskAccelerator_frames = 2;
int diskAccelerator_count = 0;
int diskAccelerator_speed = 25 * M / fps; // less than actual CPU speed means no acceleration
//const unsigned long long clk_6502_per_frm_diskAccelerator = 25 * M / fps; // disk acceleration bumps up CPU clock to 25 MHz
//const unsigned long long clk_diskAcceleratorTimeout = 1000ULL;
int diskAccelerator_speed = 25 * M / fps; // if less than actual CPU speed means no acceleration
// motor position from the magnet state

View File

@ -58,7 +58,7 @@ extern int diskAccelerator_count; // counter for the disk acceleration
extern int diskAccelerator_speed; // if less than the actual CPU speed, no acceleration
extern int diskAccelerator_count;
extern int diskAccelerator_speed;
//extern const unsigned long long clk_6502_per_frm_diskAccelerator;
//extern const unsigned long long clk_diskAcceleratorTimeout;