Play / Pause / Stop / Reset menus connected

This commit is contained in:
tudnai 2020-06-25 20:23:08 -07:00
parent 73078e1a9e
commit 8a94024636
7 changed files with 126 additions and 37 deletions

View File

@ -67,8 +67,29 @@ class AppDelegate: NSObject, NSApplicationDelegate {
if ( preferencesController != nil ) {
preferencesController?.showWindow(sender)
}
}
@IBAction func PowerOn(_ sender: Any) {
ViewController.current?.PowerOn(sender)
}
@IBAction func Pause(_ sender: Any) {
ViewController.current?.Pause(sender)
}
@IBAction func PowerOff(_ sender: Any) {
ViewController.current?.PowerOff(sender)
}
@IBAction func ColdReset(_ sender: Any) {
ViewController.current?.Reset(sender)
}
@IBAction func WarmReset(_ sender: Any) {
ViewController.current?.Reset(sender)
}
}

View File

@ -778,35 +778,50 @@
<items>
<menuItem title="► Power On" id="VJp-Pq-vAd">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="PowerOn:" target="Voe-Tx-rLC" id="IYU-yC-Gc6"/>
</connections>
</menuItem>
<menuItem title="❚❚ Pause" id="UvV-rl-Pa2">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="Pause:" target="Voe-Tx-rLC" id="DhQ-Sl-WbJ"/>
</connections>
</menuItem>
<menuItem title="■ Off" id="Pvr-O3-O0W">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="PowerOff:" target="Voe-Tx-rLC" id="DT5-Hh-7bR"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="EpV-Zl-RlZ"/>
<menuItem title="Cold Reset" id="nzj-IC-y8T">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="ColdReset:" target="Voe-Tx-rLC" id="sWD-Vp-yRD"/>
</connections>
</menuItem>
<menuItem title="Warm Reset" id="ivK-Gh-v9c">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="WarmReset:" target="Voe-Tx-rLC" id="rnE-hI-s4T"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="iZQ-dd-f8J"/>
<menuItem title="Snapshot" id="5oA-Fb-xBS">
<menuItem title="Snapshot" enabled="NO" id="5oA-Fb-xBS">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Machine" id="sPt-bm-xHF">
<items>
<menuItem title="Save" id="TfJ-FC-fVE">
<menuItem title="Save" enabled="NO" id="TfJ-FC-fVE">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Revert" id="BSq-Md-dlE">
<menuItem title="Revert" enabled="NO" id="BSq-Md-dlE">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Clone" id="62P-mr-JdC">
<menuItem title="Clone" enabled="NO" id="62P-mr-JdC">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Remove" id="F3V-BM-MBF">
<menuItem title="Remove" enabled="NO" id="F3V-BM-MBF">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
@ -1367,7 +1382,7 @@
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="Power:" target="XfG-lQ-9wD" id="IvK-jh-tRI"/>
<action selector="PowerOn:" target="XfG-lQ-9wD" id="IvK-jh-tRI"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rR3-9T-NFu">

View File

@ -151,10 +151,11 @@ class ViewController: NSViewController {
var workItem : DispatchWorkItem? = nil;
@IBAction func Power(_ sender: Any) {
@IBAction func PowerOn(_ sender: Any) {
upd.suspend()
cpuState = cpuState_inited;
spkr_stopAll()
//------------------------------------------------------------
// Animated Splash Screen fade out and (Text) Monitor fade in
@ -204,6 +205,48 @@ class ViewController: NSViewController {
#endif
}
@IBAction func PowerOff(_ sender: Any) {
upd.suspend()
cpuState = cpuState_inited;
spkr_stopAll()
//------------------------------------------------------------
// Animated Splash Screen fade out and (Text) Monitor fade in
hires.isHidden = true
displayField.alphaValue = 0
displayField.isHidden = false
splashScreen.alphaValue = 1
splashScreen.isHidden = false
//------------------------------------------------------------
}
@IBAction func Pause(_ sender: Any) {
switch ( cpuState ) {
case cpuState_halted:
upd.resume()
cpuState = cpuState_running
break
case cpuState_running:
upd.suspend()
cpuState = cpuState_halted
break
default:
// upd.suspend()
// cpuState = cpuState_halted
break
}
}
@IBAction func Reset(_ sender: Any) {
// m6502.interrupt = SOFTRESET;

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
@ -17,14 +16,14 @@
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="A2iOS" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UDx-40-ORS" userLabel="Background View">
<rect key="frame" x="0.0" y="44" width="414" height="294"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="426"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" adjustsFontForContentSizeCategory="YES" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nMe-JQ-ldk" userLabel="Display View">
<rect key="frame" x="8" y="8" width="398" height="278"/>
<rect key="frame" x="8" y="8" width="584" height="410"/>
<string key="text">1234567890123456789012345678901234567890
@@@@@@@@@1@@@@@@@@@2@@@@@@@@@3@@@@@@@@@4
@@@@@@@@@@@@@@@@@@@3@@@@@@@@@@@@@@@@@@@@
@ -73,7 +72,7 @@
</constraints>
</view>
<navigationBar contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NfH-Md-IFn">
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="600" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="wqp-NV-x0V"/>
</constraints>
@ -85,7 +84,7 @@
<navigationItem title="A2iOS" id="vFD-A6-f26">
<barButtonItem key="leftBarButtonItem" title="Power" id="wzl-9p-KCO">
<connections>
<action selector="Power:" destination="BYZ-38-t0r" id="9BP-2y-d77"/>
<action selector="PowerOn:" destination="BYZ-38-t0r" id="9BP-2y-d77"/>
</connections>
</barButtonItem>
<barButtonItem key="rightBarButtonItem" title="Reset" id="icP-Ci-Ygt">
@ -98,7 +97,7 @@
</items>
</navigationBar>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Q9J-69-63J">
<rect key="frame" x="274" y="346" width="120" height="26"/>
<rect key="frame" x="460" y="434" width="120" height="26"/>
<constraints>
<constraint firstAttribute="width" constant="120" id="Nub-YK-2HW"/>
<constraint firstAttribute="height" constant="26" id="f39-gy-BwM"/>
@ -108,7 +107,7 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LWV-xR-zzl">
<rect key="frame" x="327" y="380" width="67" height="30"/>
<rect key="frame" x="513" y="468" width="67" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="67" id="WHb-SE-Gkk"/>
<constraint firstAttribute="height" constant="30" id="qDC-k4-fB7"/>
@ -121,7 +120,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rYe-dy-hot">
<rect key="frame" x="327" y="418" width="67" height="30"/>
<rect key="frame" x="513" y="506" width="67" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="67" id="Mkd-qV-Kj1"/>
<constraint firstAttribute="height" constant="30" id="oKy-qh-d9O"/>
@ -134,7 +133,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="f9G-OM-FNm">
<rect key="frame" x="327" y="456" width="67" height="30"/>
<rect key="frame" x="513" y="544" width="67" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="67" id="8Y3-Vw-dfz"/>
<constraint firstAttribute="height" constant="30" id="iTY-HK-wl7"/>
@ -147,7 +146,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="TLZ-33-q0M">
<rect key="frame" x="327" y="494" width="67" height="30"/>
<rect key="frame" x="513" y="582" width="67" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="8pg-Fn-9at"/>
<constraint firstAttribute="width" constant="67" id="9SL-QA-6sZ"/>
@ -160,7 +159,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qNn-GH-aIG">
<rect key="frame" x="327" y="532" width="67" height="30"/>
<rect key="frame" x="513" y="620" width="67" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="67" id="mSD-q3-vE4"/>
<constraint firstAttribute="height" constant="30" id="rXv-K3-Vr2"/>
@ -173,7 +172,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="InU-ap-ckM">
<rect key="frame" x="8" y="346" width="67" height="30"/>
<rect key="frame" x="8" y="434" width="67" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="ATG-c1-PNL"/>
<constraint firstAttribute="width" constant="67" id="hoo-za-ij5"/>
@ -186,7 +185,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lGY-TL-dYl">
<rect key="frame" x="8" y="384" width="67" height="30"/>
<rect key="frame" x="8" y="472" width="67" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="67" id="TJ7-tO-TV6"/>
<constraint firstAttribute="height" constant="30" id="rNb-jZ-CLx"/>
@ -199,7 +198,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lBw-C9-kAw">
<rect key="frame" x="8" y="422" width="67" height="30"/>
<rect key="frame" x="8" y="510" width="67" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="67" id="C5g-6H-QPQ"/>
<constraint firstAttribute="height" constant="30" id="Xsx-5I-uow"/>
@ -212,7 +211,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xbl-kL-cRQ">
<rect key="frame" x="8" y="460" width="280" height="30"/>
<rect key="frame" x="8" y="548" width="280" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="280" id="4g2-2b-aRp"/>
<constraint firstAttribute="height" constant="30" id="gGm-Qo-Gvf"/>
@ -225,7 +224,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Wuq-OJ-QCj">
<rect key="frame" x="8" y="498" width="280" height="30"/>
<rect key="frame" x="8" y="586" width="280" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="280" id="RyG-XC-bdy"/>
<constraint firstAttribute="height" constant="30" id="yiN-OC-wrq"/>
@ -238,7 +237,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PL9-nx-yy4">
<rect key="frame" x="8" y="536" width="280" height="30"/>
<rect key="frame" x="8" y="624" width="280" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="280" id="VYA-Dc-Vyv"/>
<constraint firstAttribute="height" constant="30" id="Vc1-xv-qLq"/>
@ -251,7 +250,7 @@
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Disk Accel" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DQV-kq-kpF">
<rect key="frame" x="274" y="574" width="120" height="26"/>
<rect key="frame" x="460" y="662" width="120" height="26"/>
<constraints>
<constraint firstAttribute="height" constant="26" id="Bdd-pU-rtD"/>
<constraint firstAttribute="width" constant="120" id="CHD-6p-heI"/>
@ -261,7 +260,7 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XuV-wg-S6w">
<rect key="frame" x="327" y="608" width="67" height="30"/>
<rect key="frame" x="513" y="696" width="67" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="67" id="8rZ-oM-unL"/>
<constraint firstAttribute="height" constant="30" id="Iho-Oo-RVC"/>
@ -274,7 +273,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="nzo-cq-BqT">
<rect key="frame" x="327" y="646" width="67" height="30"/>
<rect key="frame" x="513" y="734" width="67" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="GZe-0n-i9h"/>
<constraint firstAttribute="width" constant="67" id="bfg-tJ-krJ"/>
@ -287,7 +286,7 @@
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0PZ-a6-C0R">
<rect key="frame" x="327" y="684" width="67" height="30"/>
<rect key="frame" x="513" y="772" width="67" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="Ngo-hs-Tpl"/>
<constraint firstAttribute="width" constant="67" id="RIc-Ya-YCY"/>

View File

@ -537,6 +537,8 @@ void softReset() {
// N V - B D I Z C
// 0 0 1 0 0 1 0 1
setFlags(0x25);
spkr_stopAll();
}
void m6502_Run() {

View File

@ -59,13 +59,6 @@ int spkr_level = SPKR_LEVEL_ZERO;
#define BUFFER_COUNT 256
#define SOURCES_COUNT 4
enum {
SPKR_SRC_GAME_SFX = 0,
SPKR_SRC_DISK_MOTOR_SFX,
SPKR_SRC_DISK_ARM_SFX,
SPKR_SRC_DISK_IOERR_SFX,
};
ALuint spkr_src [SOURCES_COUNT] = { 0, 0, 0, 0 };
ALuint spkr_buffers[BUFFER_COUNT];
@ -557,6 +550,12 @@ void spkr_play_disk_ioerr() {
}
void spkr_stopAll() {
for ( int i = 0; i < SOURCES_COUNT; i++ ) {
spkr_stop_sfx( spkr_src[i] );
}
}
void update_disk_sfx( unsigned * time, ALuint src ) {
if ( *time ) {
if ( --*time == 0 ) {

View File

@ -32,6 +32,14 @@
#define SPKR_LEVEL_ZERO 0 // as defined in OpenAL documentation for 8bit PCM
enum {
SPKR_SRC_GAME_SFX = 0,
SPKR_SRC_DISK_MOTOR_SFX,
SPKR_SRC_DISK_ARM_SFX,
SPKR_SRC_DISK_IOERR_SFX,
};
extern const unsigned spkr_sample_rate;
extern const unsigned spkr_buf_alloc_size;
extern unsigned spkr_buf_size;
@ -57,6 +65,8 @@ extern void spkr_load_sfx( const char * bundlePath );
extern void spkr_play_disk_motor(void);
extern void spkr_stop_disk_motor( int time );
extern void spkr_update_disk_sfx(void);
extern void spkr_stop_sfx( ALuint src );
extern void spkr_stopAll(void);
extern void spkr_play_disk_arm(void);
extern void spkr_play_disk_ioerr(void);