mirror of
https://github.com/trudnai/Steve2.git
synced 2024-12-20 23:29:19 +00:00
Sound fixes
WOZ fixes Load DSK fixes
This commit is contained in:
parent
b31c138604
commit
ebdc0b045d
@ -14,10 +14,13 @@
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "specialized closure #1 in ViewController.Update():ViewController.swift">
|
||||
contextName = "BRA:6502_instr_branch.h">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "self.HiRes.frame">
|
||||
value = "">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "RAM[0x346f]">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
@ -64,7 +67,7 @@
|
||||
contextName = "closure #1 in ViewController.Update():ViewController.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "txtArr">
|
||||
value = "MEMcfg.is_80STORE">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "self.shadowTxt">
|
||||
@ -76,7 +79,7 @@
|
||||
value = "MEMcfg.txt_page_2">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "MEMcfg.is_80STORE">
|
||||
value = "txtArr">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
@ -218,13 +221,25 @@
|
||||
contextName = "spkr_update:speaker.c">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "(uint8_t)spkr_samples[455]">
|
||||
value = "(uint8_t)spkr_samples[452]">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "clk_6502_per_frm_max">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "clkfrm">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(uint8_t)spkr_samples[451]">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(uint8_t)spkr_samples[452]">
|
||||
value = "spkr_sample_idx">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(uint8_t)spkr_samples[455]">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "clk_6502_per_frm">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
@ -280,7 +295,7 @@
|
||||
value = "pdl_value[pdl]">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "normalized_time >= pdl_value[pdl] ? 255 : 0">
|
||||
value = "normalized_time">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(3300 * 255/3300)">
|
||||
@ -292,7 +307,7 @@
|
||||
value = "1 * 512 * (1 - ( 3300 / 3300.0 ))">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "normalized_time">
|
||||
value = "normalized_time >= pdl_value[pdl] ? 255 : 0">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
@ -309,13 +324,13 @@
|
||||
value = "textLines">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "hires.layer">
|
||||
value = "hires.frame">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "view">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "hires.frame">
|
||||
value = "hires.layer">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
@ -331,7 +346,7 @@
|
||||
contextName = "LoRes.Update():LoRes.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "blockChanged[ screenIdx ]">
|
||||
value = "UInt8( (block >> 4) & 0x0F )">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "UInt8(block)">
|
||||
@ -340,7 +355,7 @@
|
||||
value = "UInt8(block & 4)">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "UInt8( (block >> 4) & 0x0F )">
|
||||
value = "blockChanged[ screenIdx ]">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
@ -375,10 +390,10 @@
|
||||
contextName = "set_flags_NZC:common.h">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "(unsigned)test ">
|
||||
value = "(unsigned)0xFF">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(unsigned)0xFF">
|
||||
value = "(unsigned)test ">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
@ -504,20 +519,6 @@
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "HiRes.compute():HiRes.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "computePipelineState.maxTotalThreadsPerThreadgroup">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "result[2]">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "UnsafeRawBufferPointer(result)">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "spkr_toggle:speaker.c">
|
||||
<PersistentStrings>
|
||||
@ -538,22 +539,14 @@
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "set_flags_V:common.h">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "test">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "HiRes.draw(_:):HiRes.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "linAddr">
|
||||
value = "ctx?.bitsPerComponent">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(blockH7 | ( block & bitMask ))">
|
||||
value = "ctx?.data">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "ctx?.width">
|
||||
@ -570,20 +563,42 @@
|
||||
<PersistentString
|
||||
value = "ctx?.bitmapInfo">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(blockH7 | ( block & bitMask ))">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "HiRes.blockCols">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "shadowScreen">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "linAddr">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "ctx?.height">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "set_flags_V:common.h">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "ctx?.bitsPerComponent">
|
||||
value = "test">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "HiRes.compute():HiRes.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "UnsafeRawBufferPointer(result)">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "ctx?.data">
|
||||
value = "result[2]">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "computePipelineState.maxTotalThreadsPerThreadgroup">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
@ -626,16 +641,16 @@
|
||||
value = "m6502">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "Apple2_64K_RAM + 0x3600">
|
||||
value = "Apple2_64K_AUX + 0x3600">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "m6502.PC">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(void*)Apple2_64K_RAM">
|
||||
value = "Apple2_64K_RAM + 0x3600">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "Apple2_64K_AUX + 0x3600">
|
||||
value = "(void*)Apple2_64K_RAM">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
@ -691,7 +706,7 @@
|
||||
value = "new">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "WOZwrite.shift16">
|
||||
value = "WOZtmp.shift16">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "WOZwrite.shift">
|
||||
@ -703,7 +718,7 @@
|
||||
value = "(1 << i) - 1">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "WOZtmp.shift16">
|
||||
value = "WOZwrite.shift16">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
@ -725,10 +740,10 @@
|
||||
value = "Apple2_64K_AUX + 0xC600">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "(void*)rom">
|
||||
value = "Apple2_64K_RAM + 0xC600">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "Apple2_64K_RAM + 0xC600">
|
||||
value = "(void*)rom">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "strlen(fullPath)">
|
||||
@ -753,13 +768,10 @@
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
<ContextState
|
||||
contextName = "BRA:6502_instr_branch.h">
|
||||
contextName = "specialized closure #1 in ViewController.Update():ViewController.swift">
|
||||
<PersistentStrings>
|
||||
<PersistentString
|
||||
value = "">
|
||||
</PersistentString>
|
||||
<PersistentString
|
||||
value = "RAM[0x346f]">
|
||||
value = "self.HiRes.frame">
|
||||
</PersistentString>
|
||||
</PersistentStrings>
|
||||
</ContextState>
|
||||
|
@ -39,14 +39,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
|
||||
@IBAction func selectAnImageFromFile(sender: AnyObject) {
|
||||
ViewController.current?.openDiskImage()
|
||||
ViewController.current?.openDiskImageDialog()
|
||||
}
|
||||
|
||||
|
||||
func application(_ sender: NSApplication, openFile filename: String) -> Bool {
|
||||
let woz_err = woz_loadFile( filename )
|
||||
|
||||
return woz_err == 0;
|
||||
ViewController.current?.openDiskImage(url: URL(fileURLWithPath: filename))
|
||||
return true;
|
||||
}
|
||||
|
||||
@IBAction func saveFile(_ sender: NSMenuItem) {
|
||||
|
@ -1211,7 +1211,7 @@
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<rect key="contentRect" x="196" y="240" width="1280" height="840"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
|
||||
<toolbar key="toolbar" implicitIdentifier="D7F4F3E7-F7E8-42A7-9D76-F84781D283E0" centeredItem="djd-zw-gXS" autosavesConfiguration="NO" displayMode="iconAndLabel" sizeMode="regular" id="CJg-XD-KnO">
|
||||
<toolbar key="toolbar" implicitIdentifier="D7F4F3E7-F7E8-42A7-9D76-F84781D283E0" centeredItem="djd-zw-gXS" autosavesConfiguration="NO" allowsUserCustomization="NO" displayMode="iconAndLabel" sizeMode="regular" id="CJg-XD-KnO">
|
||||
<allowedToolbarItems>
|
||||
<toolbarItem implicitItemIdentifier="NSToolbarShowColorsItem" id="3J5-kY-CUW">
|
||||
<connections>
|
||||
@ -1710,7 +1710,7 @@
|
||||
</menu>
|
||||
</popUpButtonCell>
|
||||
<connections>
|
||||
<action selector="CPUMode:" target="B8D-0N-5wS" id="LpB-wd-ryF"/>
|
||||
<action selector="setCPUMode:" target="XfG-lQ-9wD" id="cui-we-Dj4"/>
|
||||
</connections>
|
||||
</popUpButton>
|
||||
</subviews>
|
||||
@ -1728,13 +1728,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="312"/>
|
||||
<rect key="frame" x="8" y="8" width="104" height="343"/>
|
||||
<subviews>
|
||||
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="7yw-J0-Fmj">
|
||||
<rect key="frame" x="0.0" y="309" width="96" height="5"/>
|
||||
<rect key="frame" x="0.0" y="340" width="96" height="5"/>
|
||||
</box>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="isd-yh-gCV">
|
||||
<rect key="frame" x="-2" y="287" width="98" height="18"/>
|
||||
<rect key="frame" x="-2" y="318" width="98" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="CRT Monitor" bezelStyle="regularSquare" imagePosition="left" inset="2" id="UQ8-Nn-Kt7">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -1744,7 +1744,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="kmk-ZV-ubT">
|
||||
<rect key="frame" x="-1" y="264" width="105" height="18"/>
|
||||
<rect key="frame" x="-1" y="295" width="105" height="18"/>
|
||||
<buttonCell key="cell" type="radio" title="Color Monitor" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" state="on" inset="2" id="dIU-uM-oqn">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -1754,7 +1754,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hi6-xc-XvO">
|
||||
<rect key="frame" x="-1" y="240" width="95" height="18"/>
|
||||
<rect key="frame" x="-1" y="271" width="95" height="18"/>
|
||||
<buttonCell key="cell" type="radio" title="White Mono" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="NOI-xa-uDn">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -1764,7 +1764,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0TV-RF-TRX">
|
||||
<rect key="frame" x="-1" y="216" width="97" height="18"/>
|
||||
<rect key="frame" x="-1" y="247" width="97" height="18"/>
|
||||
<buttonCell key="cell" type="radio" title="Green Mono" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="3IU-9X-jIe">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -1774,7 +1774,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="PDL-Db-4L2">
|
||||
<rect key="frame" x="-1" y="192" width="100" height="18"/>
|
||||
<rect key="frame" x="-1" y="223" width="100" height="18"/>
|
||||
<buttonCell key="cell" type="radio" title="Amber Mono" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="8c4-i2-4Tf">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -1784,10 +1784,10 @@
|
||||
</connections>
|
||||
</button>
|
||||
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="t35-xh-L18">
|
||||
<rect key="frame" x="0.0" y="182" width="96" height="5"/>
|
||||
<rect key="frame" x="0.0" y="213" width="96" height="5"/>
|
||||
</box>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="e2E-di-h3i">
|
||||
<rect key="frame" x="-2" y="160" width="83" height="18"/>
|
||||
<rect key="frame" x="-2" y="191" 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"/>
|
||||
@ -1797,7 +1797,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Wa3-TC-XUI">
|
||||
<rect key="frame" x="-2" y="138" width="79" height="18"/>
|
||||
<rect key="frame" x="-2" y="169" 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"/>
|
||||
@ -1807,7 +1807,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xrz-jA-1Fh">
|
||||
<rect key="frame" x="-2" y="116" width="63" height="18"/>
|
||||
<rect key="frame" x="-2" y="147" 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"/>
|
||||
@ -1817,10 +1817,10 @@
|
||||
</connections>
|
||||
</button>
|
||||
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="rIK-Xk-n9g">
|
||||
<rect key="frame" x="0.0" y="107" width="96" height="5"/>
|
||||
<rect key="frame" x="0.0" y="138" width="96" height="5"/>
|
||||
</box>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ccb-cj-gLu">
|
||||
<rect key="frame" x="-2" y="85" width="87" height="18"/>
|
||||
<rect key="frame" x="-2" y="116" width="87" height="18"/>
|
||||
<buttonCell key="cell" type="check" title="Quick Disk" bezelStyle="regularSquare" imagePosition="left" inset="2" id="6QV-uF-Gh7">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
@ -1830,7 +1830,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9nQ-Yf-2xf">
|
||||
<rect key="frame" x="-2" y="63" width="91" height="18"/>
|
||||
<rect key="frame" x="-2" y="94" 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"/>
|
||||
@ -1840,10 +1840,10 @@
|
||||
</connections>
|
||||
</button>
|
||||
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="wih-Y6-2Bz">
|
||||
<rect key="frame" x="0.0" y="54" width="96" height="5"/>
|
||||
<rect key="frame" x="0.0" y="85" 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="289" width="104" height="23"/>
|
||||
<splitView dividerStyle="thin" vertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ge3-qD-JO6">
|
||||
<rect key="frame" x="0.0" y="56" 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"/>
|
||||
|
@ -1088,8 +1088,8 @@ class ViewController: NSViewController {
|
||||
}
|
||||
|
||||
|
||||
@IBAction func setCPUMode(_ sender: NSButton) {
|
||||
setSimulationMode(mode: sender.title )
|
||||
@IBAction func setCPUMode(_ sender: NSPopUpButton) {
|
||||
setSimulationMode(mode: sender.selectedItem?.title ?? "Normal" )
|
||||
}
|
||||
|
||||
@IBOutlet weak var SoundGap: NSTextFieldCell!
|
||||
@ -1179,7 +1179,43 @@ class ViewController: NSViewController {
|
||||
}
|
||||
|
||||
|
||||
@objc func openDiskImage() {
|
||||
func openDiskImage( url: URL ) {
|
||||
switch url.pathExtension.uppercased() {
|
||||
|
||||
case "WOZ":
|
||||
let err = woz_loadFile( url.path )
|
||||
|
||||
if err == WOZ_ERR_OK {
|
||||
NSDocumentController.shared.noteNewRecentDocumentURL(URL(fileURLWithPath: url.path))
|
||||
}
|
||||
else {
|
||||
self.chk_woz_load(err: err)
|
||||
}
|
||||
|
||||
case "DSK", "DO", "PO" :
|
||||
woz_eject()
|
||||
|
||||
let err = dsk2woz( url.path )
|
||||
|
||||
if err == WOZ_ERR_OK {
|
||||
let err = woz_parseBuffer()
|
||||
|
||||
if err == WOZ_ERR_OK {
|
||||
NSDocumentController.shared.noteNewRecentDocumentURL(URL(fileURLWithPath: url.path))
|
||||
}
|
||||
}
|
||||
else {
|
||||
self.chk_woz_load(err: err)
|
||||
}
|
||||
|
||||
default:
|
||||
break
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@objc func openDiskImageDialog() {
|
||||
let openPanel = NSOpenPanel()
|
||||
openPanel.title = "Open Disk Image"
|
||||
openPanel.allowsMultipleSelection = false
|
||||
@ -1190,46 +1226,21 @@ class ViewController: NSViewController {
|
||||
|
||||
openPanel.begin { (result) -> Void in
|
||||
if result == NSApplication.ModalResponse.OK {
|
||||
print("file:", openPanel.url!.path)
|
||||
// print("file:", openPanel.url!.path)
|
||||
//Do what you will
|
||||
//If there's only one URL, surely 'openPanel.URL'
|
||||
//but otherwise a for loop works
|
||||
|
||||
switch openPanel.url?.pathExtension.uppercased() {
|
||||
|
||||
case "WOZ":
|
||||
if let filePath = openPanel.url?.path {
|
||||
let err = woz_loadFile( filePath )
|
||||
|
||||
if err == WOZ_ERR_OK {
|
||||
NSDocumentController.shared.noteNewRecentDocumentURL(URL(fileURLWithPath: filePath))
|
||||
}
|
||||
else {
|
||||
self.chk_woz_load(err: err)
|
||||
}
|
||||
}
|
||||
if let url = openPanel.url {
|
||||
self.openDiskImage(url: url)
|
||||
}
|
||||
else {
|
||||
let a = NSAlert()
|
||||
a.messageText = "File Not Found"
|
||||
a.informativeText = "Could not locate selected file"
|
||||
a.alertStyle = .critical
|
||||
|
||||
case "DSK", "DO", "PO" :
|
||||
if let filePath = openPanel.url?.path {
|
||||
woz_eject()
|
||||
|
||||
let err = dsk2woz( filePath )
|
||||
|
||||
if err == WOZ_ERR_OK {
|
||||
let err = woz_parseBuffer()
|
||||
|
||||
if err == WOZ_ERR_OK {
|
||||
NSDocumentController.shared.noteNewRecentDocumentURL(URL(fileURLWithPath: filePath))
|
||||
}
|
||||
}
|
||||
else {
|
||||
self.chk_woz_load(err: err)
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
break
|
||||
|
||||
a.beginSheetModal( for: self.view.window! )
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1247,13 +1258,13 @@ class ViewController: NSViewController {
|
||||
|
||||
openPanel.begin { (result) -> Void in
|
||||
if result == NSApplication.ModalResponse.OK {
|
||||
print("file:", openPanel.url!.path)
|
||||
// print("file:", openPanel.url!.path)
|
||||
//Do what you will
|
||||
//If there's only one URL, surely 'openPanel.URL'
|
||||
//but otherwise a for loop works
|
||||
|
||||
if let filePath = openPanel.url?.path {
|
||||
let woz_err = woz_loadFile( filePath )
|
||||
let woz_err = woz_saveFile( filePath )
|
||||
|
||||
if woz_err == WOZ_ERR_OK {
|
||||
NSDocumentController.shared.noteNewRecentDocumentURL(URL(fileURLWithPath: filePath))
|
||||
@ -1268,7 +1279,7 @@ class ViewController: NSViewController {
|
||||
|
||||
|
||||
@IBAction func openDocument(_ sender: Any?) {
|
||||
openDiskImage()
|
||||
openDiskImageDialog()
|
||||
}
|
||||
|
||||
@IBAction func traceEnable(_ sender: NSButton) {
|
||||
|
@ -82,9 +82,10 @@ const unsigned spkr_sample_rate = 44100;
|
||||
const unsigned sfx_sample_rate = 22050; // original sample rate
|
||||
//const unsigned sfx_sample_rate = 26000; // bit higher pitch
|
||||
int spkr_extra_buf = 0; // 800 / spkr_fps;
|
||||
const unsigned spkr_buf_alloc_size = spkr_seconds * spkr_sample_rate * SPKR_CHANNELS / DEFAULT_FPS;
|
||||
unsigned spkr_buf_size = spkr_buf_alloc_size;
|
||||
int16_t spkr_samples [ spkr_buf_alloc_size * DEFAULT_FPS * BUFFER_COUNT * SPKR_CHANNELS]; // stereo
|
||||
typedef int16_t spkr_sample_t;
|
||||
const unsigned spkr_buf_alloc_size = spkr_seconds * spkr_sample_rate * SPKR_CHANNELS * sizeof(spkr_sample_t) / DEFAULT_FPS; // stereo
|
||||
unsigned spkr_buf_size = spkr_buf_alloc_size / sizeof(spkr_sample_t);
|
||||
spkr_sample_t spkr_samples [ spkr_buf_alloc_size * DEFAULT_FPS * BUFFER_COUNT]; // can store up to 1 sec of sound
|
||||
unsigned spkr_sample_idx = 0;
|
||||
|
||||
unsigned spkr_play_timeout = 8; // increase to 32 for 240 fps, normally 8 for 30 fps
|
||||
@ -166,7 +167,7 @@ void spkr_init() {
|
||||
alcMakeContextCurrent(ctx);
|
||||
|
||||
// Fill buffer with zeros
|
||||
memset( spkr_samples, spkr_level, spkr_buf_size * sizeof(spkr_samples[0]) );
|
||||
memset( spkr_samples, spkr_level, spkr_buf_alloc_size + spkr_extra_buf);
|
||||
|
||||
// Create buffer to store samples
|
||||
alGenBuffers(BUFFER_COUNT, spkr_buffers);
|
||||
@ -278,10 +279,13 @@ int spkr_unqueue( ALuint src ) {
|
||||
alGetSourcei ( src, AL_BUFFERS_PROCESSED, &processed );
|
||||
al_check_error();
|
||||
// printf("%s alGetSourcei(%d)\n", __FUNCTION__, src);
|
||||
// printf("p:%d\n", processed);
|
||||
|
||||
if ( processed ) {
|
||||
if ( processed > 0 ) {
|
||||
alSourceUnqueueBuffers( src, processed, &spkr_buffers[freeBuffers]);
|
||||
al_check_error();
|
||||
freeBuffers += processed;
|
||||
freeBuffers = clamp( 1, freeBuffers, BUFFER_COUNT );
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,16 +317,14 @@ void spkr_exit() {
|
||||
alDeleteSources(SOURCES_COUNT, spkr_src);
|
||||
al_check_error();
|
||||
|
||||
|
||||
ALCdevice *dev = NULL;
|
||||
ALCcontext *ctx = NULL;
|
||||
ctx = alcGetCurrentContext();
|
||||
dev = alcGetContextsDevice(ctx);
|
||||
ALCdevice *dev = alcGetContextsDevice(ctx);
|
||||
ALCcontext *ctx = alcGetCurrentContext();
|
||||
|
||||
alcMakeContextCurrent(NULL);
|
||||
al_check_error();
|
||||
alcDestroyContext(ctx);
|
||||
al_check_error();
|
||||
alcCloseDevice(dev);
|
||||
|
||||
al_check_error();
|
||||
|
||||
memset(spkr_src, 0, sizeof(spkr_src));
|
||||
@ -398,7 +400,7 @@ void spkr_toggle() {
|
||||
for ( int i = spkr_sample_idx; i < spkr_buf_size + spkr_extra_buf; i++ ) {
|
||||
spkr_samples[i] = spkr_level;
|
||||
}
|
||||
// memset(spkr_samples + spkr_sample_idx, spkr_level, spkr_buf_size * sizeof(spkr_samples[0]));
|
||||
// memset(spkr_samples + spkr_sample_idx, spkr_level, spkr_buf_size * sizeof(spkr_sample_t));
|
||||
|
||||
}
|
||||
}
|
||||
@ -412,7 +414,15 @@ void spkr_update() {
|
||||
if ( ++spkr_frame_cntr >= spkr_fps_divider ) {
|
||||
spkr_frame_cntr = 0;
|
||||
|
||||
if ( spkr_play_time ) {
|
||||
// Fix: Unqueue was not working properly some cases, so we need to monitor
|
||||
// queued elements and if there are too many, let's just wait
|
||||
#define SPKR_MAX_QUEUED 10
|
||||
ALint queued = 0;
|
||||
alGetSourcei ( spkr_src[SPKR_SRC_GAME_SFX], AL_BUFFERS_QUEUED, &queued );
|
||||
al_check_error();
|
||||
// printf("q:%d clkfrm:%d frm:%llu max:%llu\n", queued, clkfrm, clk_6502_per_frm, clk_6502_per_frm_max);
|
||||
|
||||
if ( ( spkr_play_time ) && ( queued < SPKR_MAX_QUEUED ) ) {
|
||||
if ( freeBuffers ) {
|
||||
// in Game Mode do not fade out and stop playing
|
||||
if ( ( cpuMode_game != cpuMode ) && ( --spkr_play_time == 0 ) ) {
|
||||
@ -431,18 +441,25 @@ void spkr_update() {
|
||||
spkr_level = SPKR_LEVEL_ZERO;
|
||||
|
||||
//spkr_samples[sample_idx] = spkr_level;
|
||||
memset(spkr_samples + spkr_sample_idx, SPKR_LEVEL_ZERO, spkr_extra_buf * sizeof(spkr_samples[0]));
|
||||
memset(spkr_samples + spkr_sample_idx, SPKR_LEVEL_ZERO, spkr_extra_buf * sizeof(spkr_sample_t));
|
||||
|
||||
freeBuffers--;
|
||||
alBufferData(spkr_buffers[freeBuffers], AL_FORMAT_STEREO16, spkr_samples, spkr_sample_idx * sizeof(spkr_samples[0]), spkr_sample_rate);
|
||||
alBufferData(spkr_buffers[freeBuffers], AL_FORMAT_STEREO16, spkr_samples, spkr_sample_idx * sizeof(spkr_sample_t), spkr_sample_rate);
|
||||
al_check_error();
|
||||
alSourceQueueBuffers(spkr_src[SPKR_SRC_GAME_SFX], 1, &spkr_buffers[freeBuffers]);
|
||||
al_check_error();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// push a click into the speaker buffer
|
||||
// (we will play the entire buffer at the end of the frame)
|
||||
spkr_sample_idx = ( (spkr_clk + clkfrm) / ( MHZ(default_MHz_6502) / spkr_sample_rate)) * SPKR_CHANNELS;
|
||||
|
||||
freeBuffers--;
|
||||
alBufferData(spkr_buffers[freeBuffers], AL_FORMAT_STEREO16, spkr_samples, (spkr_buf_size + spkr_extra_buf) * sizeof(spkr_samples[0]), spkr_sample_rate);
|
||||
// alBufferData(spkr_buffers[freeBuffers], AL_FORMAT_STEREO16, spkr_samples, (spkr_sample_idx + spkr_extra_buf) * sizeof(spkr_sample_t), spkr_sample_rate);
|
||||
// ALint bufSize = spkr_sample_idx + 20 < spkr_buf_size ? spkr_sample_idx * sizeof(spkr_sample_t) + 20 : spkr_buf_alloc_size;
|
||||
// alBufferData(spkr_buffers[freeBuffers], AL_FORMAT_STEREO16, spkr_samples, bufSize + spkr_extra_buf, spkr_sample_rate);
|
||||
al_check_error();
|
||||
alSourceQueueBuffers(spkr_src[SPKR_SRC_GAME_SFX], 1, &spkr_buffers[freeBuffers]);
|
||||
al_check_error();
|
||||
@ -466,6 +483,9 @@ void spkr_update() {
|
||||
|
||||
default:
|
||||
alSourcePlay(spkr_src[SPKR_SRC_GAME_SFX]);
|
||||
// this is so we will set state to AL_PAUSED immediately
|
||||
// As a result there will be an extra queued buffer
|
||||
// which gives us a glitch free sound
|
||||
alSourcePause(spkr_src[SPKR_SRC_GAME_SFX]);
|
||||
break;
|
||||
}
|
||||
@ -484,13 +504,13 @@ void spkr_update() {
|
||||
|
||||
spkr_clk = 0;
|
||||
|
||||
// free up unused buffers
|
||||
freeBuffers += spkr_unqueue( spkr_src[SPKR_SRC_GAME_SFX] );
|
||||
freeBuffers = clamp( 1, freeBuffers, BUFFER_COUNT );
|
||||
}
|
||||
else {
|
||||
spkr_clk += clkfrm;
|
||||
}
|
||||
|
||||
// free up unused buffers
|
||||
spkr_unqueue( spkr_src[SPKR_SRC_GAME_SFX] );
|
||||
}
|
||||
|
||||
|
||||
@ -578,9 +598,7 @@ void spkr_stop_sfx( ALuint src ) {
|
||||
}
|
||||
|
||||
// free up unused buffers
|
||||
freeBuffers += spkr_unqueue( src );
|
||||
freeBuffers = clamp( 1, freeBuffers, BUFFER_COUNT );
|
||||
|
||||
spkr_unqueue( src );
|
||||
}
|
||||
|
||||
|
||||
|
@ -219,54 +219,82 @@ void woz_loadTrack( int track ) {
|
||||
|
||||
uint8_t woz_read() {
|
||||
|
||||
int track = woz_tmap->phase[disk.phase.count];
|
||||
if (outdev) fprintf(outdev, "track: %d (%d) ", track, disk.phase.count);
|
||||
if ( track >= 40 ) {
|
||||
dbgPrintf("TRCK TOO HIGH!\n");
|
||||
return rand();
|
||||
}
|
||||
|
||||
static int clkBeforeSync = 0;
|
||||
|
||||
clkelpased = m6502.clktime + clkfrm - m6502.clklast;
|
||||
m6502.clklast = m6502.clktime + clkfrm;
|
||||
|
||||
clkBeforeSync += clkelpased;
|
||||
|
||||
const int clkBeforeAdjusting = 512;
|
||||
const int magicShiftOffset = 45;
|
||||
|
||||
uint16_t usedBytes = (*woz_trks)[track].bytes_used < WOZ1_TRACK_BYTE_COUNT ? (*woz_trks)[track].bytes_used : WOZ1_TRACK_BYTE_COUNT;
|
||||
|
||||
if ( usedBytes ) {
|
||||
int shiftOffset = magicShiftOffset;
|
||||
if ( woz_tmap && woz_trks ) {
|
||||
int track = woz_tmap->phase[disk.phase.count];
|
||||
if (outdev) fprintf(outdev, "track: %d (%d) ", track, disk.phase.count);
|
||||
if ( track >= 40 ) {
|
||||
dbgPrintf("TRCK TOO HIGH!\n");
|
||||
return rand();
|
||||
}
|
||||
|
||||
// printf("elpased : %llu (clkBefRd:%d)\n", clkelpased, clkBeforeSync);
|
||||
static int clkBeforeSync = 0;
|
||||
|
||||
if ( clkelpased > clkBeforeAdjusting ) {
|
||||
// printf("NEED SYNC : %llu (clkBefRd:%d)\n", clkelpased, clkBeforeSync);
|
||||
clkBeforeSync = 0;
|
||||
bitOffset = (clkelpased >> 2) & 7;
|
||||
trackOffset += clkelpased >> 5;
|
||||
if ( trackOffset >= usedBytes ) {
|
||||
bitOffset = 0;
|
||||
trackOffset = 0;
|
||||
clkelpased = m6502.clktime + clkfrm - m6502.clklast;
|
||||
m6502.clklast = m6502.clktime + clkfrm;
|
||||
|
||||
clkBeforeSync += clkelpased;
|
||||
|
||||
const int clkBeforeAdjusting = 512;
|
||||
const int magicShiftOffset = 45;
|
||||
|
||||
uint16_t usedBytes = (*woz_trks)[track].bytes_used < WOZ1_TRACK_BYTE_COUNT ? (*woz_trks)[track].bytes_used : WOZ1_TRACK_BYTE_COUNT;
|
||||
|
||||
if ( usedBytes ) {
|
||||
int shiftOffset = magicShiftOffset;
|
||||
|
||||
// printf("elpased : %llu (clkBefRd:%d)\n", clkelpased, clkBeforeSync);
|
||||
|
||||
if ( clkelpased > clkBeforeAdjusting ) {
|
||||
// printf("NEED SYNC : %llu (clkBefRd:%d)\n", clkelpased, clkBeforeSync);
|
||||
clkBeforeSync = 0;
|
||||
bitOffset = (clkelpased >> 2) & 7;
|
||||
trackOffset += clkelpased >> 5;
|
||||
if ( trackOffset >= usedBytes ) {
|
||||
bitOffset = 0;
|
||||
trackOffset = 0;
|
||||
WOZread.shift = 0;
|
||||
shiftOffset = 0;
|
||||
}
|
||||
// trackOffset %= usedBytes;
|
||||
|
||||
// preroll data stream
|
||||
WOZread.shift = 0;
|
||||
shiftOffset = 0;
|
||||
WOZread.data = (*woz_trks)[track].data[trackOffset++];
|
||||
trackOffset %= usedBytes;
|
||||
trackWRoffset = trackOffset;
|
||||
|
||||
WOZread.shift <<= bitOffset;
|
||||
WOZwrite = WOZread;
|
||||
|
||||
for ( int i = 0; i < shiftOffset; i++ ) {
|
||||
for ( ; bitOffset < 8; bitOffset++ ) {
|
||||
WOZread.shift <<= 1;
|
||||
WOZwrite.shift <<= 1;
|
||||
|
||||
if ( WOZread.valid ) {
|
||||
WOZread.latch = 0;
|
||||
}
|
||||
}
|
||||
trackWRoffset = trackOffset;
|
||||
WOZwrite.data = WOZread.data = (*woz_trks)[track].data[trackOffset++];
|
||||
trackOffset %= usedBytes;
|
||||
bitOffset = 0;
|
||||
}
|
||||
}
|
||||
// trackOffset %= usedBytes;
|
||||
else {
|
||||
uint64_t bitForward = (clkelpased >> 2);
|
||||
|
||||
// preroll data stream
|
||||
WOZread.shift = 0;
|
||||
WOZread.data = (*woz_trks)[track].data[trackOffset++];
|
||||
trackOffset %= usedBytes;
|
||||
trackWRoffset = trackOffset;
|
||||
// to avoid infinite loop and to search for bit 7 high
|
||||
for ( uint64_t i = 0; i < bitForward; i++ ) {
|
||||
if ( ++bitOffset >= 8 ) {
|
||||
bitOffset = 0;
|
||||
trackWRoffset = trackOffset;
|
||||
trackOffset++;
|
||||
trackOffset %= usedBytes;
|
||||
|
||||
WOZread.shift <<= bitOffset;
|
||||
WOZwrite = WOZread;
|
||||
WOZwrite.data = WOZread.data = (*woz_trks)[track].data[trackOffset];
|
||||
}
|
||||
|
||||
for ( int i = 0; i < shiftOffset; i++ ) {
|
||||
for ( ; bitOffset < 8; bitOffset++ ) {
|
||||
WOZread.shift <<= 1;
|
||||
WOZwrite.shift <<= 1;
|
||||
|
||||
@ -274,17 +302,23 @@ uint8_t woz_read() {
|
||||
WOZread.latch = 0;
|
||||
}
|
||||
}
|
||||
trackWRoffset = trackOffset;
|
||||
WOZwrite.data = WOZread.data = (*woz_trks)[track].data[trackOffset++];
|
||||
trackOffset %= usedBytes;
|
||||
bitOffset = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
uint64_t bitForward = (clkelpased >> 2);
|
||||
|
||||
// to avoid infinite loop and to search for bit 7 high
|
||||
for ( uint64_t i = 0; i < bitForward; i++ ) {
|
||||
for ( int i = 0; i < usedBytes * 8; i++ ) {
|
||||
if ( WOZread.valid ) {
|
||||
WOZread.latch = 0;
|
||||
// if (outdev) fprintf(outdev, "byte: %02X\n", byte);
|
||||
|
||||
if ( woz_decodeTrkSec(WOZwrite.latch, clkelpased, trackOffset * 8 + bitOffset) == wozTrackState_END ) {
|
||||
if (outdev) fprintf(outdev, "vol:%d trk:%d sec:%d\n", vol, trk, sec);
|
||||
}
|
||||
|
||||
if (outdev) fprintf(outdev, "elpased:%lld read: %02X\n", clkelpased, WOZwrite.latch);
|
||||
|
||||
return WOZwrite.latch;
|
||||
}
|
||||
|
||||
if ( ++bitOffset >= 8 ) {
|
||||
bitOffset = 0;
|
||||
trackWRoffset = trackOffset;
|
||||
@ -293,44 +327,12 @@ uint8_t woz_read() {
|
||||
|
||||
WOZwrite.data = WOZread.data = (*woz_trks)[track].data[trackOffset];
|
||||
}
|
||||
|
||||
|
||||
WOZread.shift <<= 1;
|
||||
WOZwrite.shift <<= 1;
|
||||
|
||||
if ( WOZread.valid ) {
|
||||
WOZread.latch = 0;
|
||||
}
|
||||
}
|
||||
// if (outdev) fprintf(outdev, "TIME OUT!\n");
|
||||
}
|
||||
|
||||
// to avoid infinite loop and to search for bit 7 high
|
||||
for ( int i = 0; i < usedBytes * 8; i++ ) {
|
||||
if ( WOZread.valid ) {
|
||||
WOZread.latch = 0;
|
||||
// if (outdev) fprintf(outdev, "byte: %02X\n", byte);
|
||||
|
||||
if ( woz_decodeTrkSec(WOZwrite.latch, clkelpased, trackOffset * 8 + bitOffset) == wozTrackState_END ) {
|
||||
if (outdev) fprintf(outdev, "vol:%d trk:%d sec:%d\n", vol, trk, sec);
|
||||
}
|
||||
|
||||
if (outdev) fprintf(outdev, "elpased:%lld read: %02X\n", clkelpased, WOZwrite.latch);
|
||||
|
||||
return WOZwrite.latch;
|
||||
}
|
||||
|
||||
if ( ++bitOffset >= 8 ) {
|
||||
bitOffset = 0;
|
||||
trackWRoffset = trackOffset;
|
||||
trackOffset++;
|
||||
trackOffset %= usedBytes;
|
||||
|
||||
WOZwrite.data = WOZread.data = (*woz_trks)[track].data[trackOffset];
|
||||
}
|
||||
|
||||
WOZread.shift <<= 1;
|
||||
WOZwrite.shift <<= 1;
|
||||
}
|
||||
// if (outdev) fprintf(outdev, "TIME OUT!\n");
|
||||
}
|
||||
|
||||
return rand();
|
||||
@ -363,108 +365,109 @@ void printWozBuffer (const char * s, int n, WOZread_t WOZbuf ) {
|
||||
|
||||
void woz_write( uint8_t data ) {
|
||||
|
||||
int track = woz_tmap->phase[disk.phase.count];
|
||||
if (outdev) fprintf(outdev, "track: %d (%d) ", track, disk.phase.count);
|
||||
if ( track >= 40 ) {
|
||||
dbgPrintf("TRACK TOO HIGH!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
woz_flags.disk_modified = 1;
|
||||
|
||||
clkelpased = m6502.clktime + clkfrm - m6502.clklast;
|
||||
m6502.clklast = m6502.clktime + clkfrm;
|
||||
|
||||
uint16_t usedBytes = (*woz_trks)[track].bytes_used < WOZ1_TRACK_BYTE_COUNT ? (*woz_trks)[track].bytes_used : WOZ1_TRACK_BYTE_COUNT;
|
||||
|
||||
if ( usedBytes ) {
|
||||
if ( woz_tmap && woz_trks ) {
|
||||
int track = woz_tmap->phase[disk.phase.count];
|
||||
if (outdev) fprintf(outdev, "track: %d (%d) ", track, disk.phase.count);
|
||||
if ( track >= 40 ) {
|
||||
dbgPrintf("TRACK TOO HIGH!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// for DEBUG ONLY!!!
|
||||
if (outdev) fprintf(outdev, "elpased:%llu data:$%02X\n", clkelpased, data);
|
||||
printWozBuffer("*start", 0, WOZwrite);
|
||||
|
||||
woz_flags.disk_modified = 1;
|
||||
|
||||
if ( clkelpased > 32 ) {
|
||||
// if (outdev) fprintf(outdev, "I/O ERROR : %llu\n", clkelpased);
|
||||
clkelpased = m6502.clktime + clkfrm - m6502.clklast;
|
||||
m6502.clklast = m6502.clktime + clkfrm;
|
||||
|
||||
uint64_t bitForward = (clkelpased - 32) >> 2;
|
||||
uint16_t usedBytes = (*woz_trks)[track].bytes_used < WOZ1_TRACK_BYTE_COUNT ? (*woz_trks)[track].bytes_used : WOZ1_TRACK_BYTE_COUNT;
|
||||
|
||||
if ( usedBytes ) {
|
||||
|
||||
// simulate disk spin over time
|
||||
while ( bitForward-- ) {
|
||||
// for DEBUG ONLY!!!
|
||||
if (outdev) fprintf(outdev, "elpased:%llu data:$%02X\n", clkelpased, data);
|
||||
printWozBuffer("*start", 0, WOZwrite);
|
||||
|
||||
|
||||
if ( clkelpased > 32 ) {
|
||||
// if (outdev) fprintf(outdev, "I/O ERROR : %llu\n", clkelpased);
|
||||
|
||||
uint64_t bitForward = (clkelpased - 32) >> 2;
|
||||
|
||||
// simulate disk spin over time
|
||||
while ( bitForward-- ) {
|
||||
if ( ++bitOffset >= 8 ) {
|
||||
bitOffset = 0;
|
||||
trackWRoffset = trackOffset;
|
||||
trackOffset++;
|
||||
trackOffset %= usedBytes;
|
||||
|
||||
// WOZwrite.data =
|
||||
WOZread.data = (*woz_trks)[track].data[trackOffset];
|
||||
}
|
||||
|
||||
WOZread.shift <<= 1;
|
||||
WOZwrite.shift <<= 1;
|
||||
|
||||
if ( WOZread.valid ) {
|
||||
WOZread.latch = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ok now we can latch data
|
||||
WOZwrite.data = WOZread.data = data;
|
||||
printWozBuffer("datain", 0, WOZwrite);
|
||||
|
||||
int i = 8; // 8 bit to shift in
|
||||
|
||||
// shift in 8 bits of data and write it out
|
||||
while ( i-- ) {
|
||||
if ( ++bitOffset >= 8 ) {
|
||||
// write out first part
|
||||
(*woz_trks)[track].data[trackWRoffset] = WOZwrite.latch;
|
||||
|
||||
bitOffset = 0;
|
||||
trackWRoffset = trackOffset;
|
||||
trackOffset++;
|
||||
trackOffset %= usedBytes;
|
||||
|
||||
// WOZwrite.data =
|
||||
WOZread.data = (*woz_trks)[track].data[trackOffset];
|
||||
// simulate shift in data (path of write latch is already loaded, we should not overwrite it!)
|
||||
uint8_t new = (*woz_trks)[track].data[trackOffset];
|
||||
new >>= i + 1;
|
||||
WOZread.data |= new;
|
||||
// WOZwrite.data |= new;
|
||||
|
||||
printWozBuffer("shl1in", i, WOZwrite);
|
||||
WOZread.shift <<= 1;
|
||||
WOZwrite.shift <<= 1;
|
||||
break;
|
||||
}
|
||||
|
||||
WOZread.shift <<= 1;
|
||||
WOZwrite.shift <<= 1;
|
||||
|
||||
if ( WOZread.valid ) {
|
||||
WOZread.latch = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ok now we can latch data
|
||||
WOZwrite.data = WOZread.data = data;
|
||||
printWozBuffer("datain", 0, WOZwrite);
|
||||
|
||||
int i = 8; // 8 bit to shift in
|
||||
|
||||
// shift in 8 bits of data and write it out
|
||||
while ( i-- ) {
|
||||
if ( ++bitOffset >= 8 ) {
|
||||
// write out first part
|
||||
(*woz_trks)[track].data[trackWRoffset] = WOZwrite.latch;
|
||||
|
||||
bitOffset = 0;
|
||||
trackWRoffset = trackOffset;
|
||||
trackOffset++;
|
||||
trackOffset %= usedBytes;
|
||||
|
||||
// simulate shift in data (path of write latch is already loaded, we should not overwrite it!)
|
||||
uint8_t new = (*woz_trks)[track].data[trackOffset];
|
||||
new >>= i + 1;
|
||||
WOZread.data |= new;
|
||||
// WOZwrite.data |= new;
|
||||
|
||||
printWozBuffer("shl1in", i, WOZwrite);
|
||||
WOZread.shift <<= 1;
|
||||
WOZwrite.shift <<= 1;
|
||||
break;
|
||||
}
|
||||
|
||||
WOZread.shift <<= 1;
|
||||
WOZwrite.shift <<= 1;
|
||||
printWozBuffer("shift1", i, WOZwrite);
|
||||
};
|
||||
printWozBuffer("shift1", 9, WOZwrite);
|
||||
printWozBuffer("shift1", i, WOZwrite);
|
||||
};
|
||||
printWozBuffer("shift1", 9, WOZwrite);
|
||||
|
||||
// write the remaining bits without altering WOZ track offsets and indexes
|
||||
// WOZread_t WOZtmp = WOZwrite;
|
||||
// int bo = bitOffset;
|
||||
|
||||
// second half
|
||||
while ( i-- ) {
|
||||
if ( ++bitOffset >= 8 ) {
|
||||
// write out first part
|
||||
(*woz_trks)[track].data[trackWRoffset] = WOZwrite.latch;
|
||||
break;
|
||||
}
|
||||
// write the remaining bits without altering WOZ track offsets and indexes
|
||||
// WOZread_t WOZtmp = WOZwrite;
|
||||
// int bo = bitOffset;
|
||||
|
||||
WOZwrite.shift <<= 1;
|
||||
printWozBuffer("shift2", i, WOZwrite);
|
||||
};
|
||||
printWozBuffer("shift2", 9, WOZwrite);
|
||||
// second half
|
||||
while ( i-- ) {
|
||||
if ( ++bitOffset >= 8 ) {
|
||||
// write out first part
|
||||
(*woz_trks)[track].data[trackWRoffset] = WOZwrite.latch;
|
||||
break;
|
||||
}
|
||||
|
||||
WOZwrite.shift <<= 1;
|
||||
printWozBuffer("shift2", i, WOZwrite);
|
||||
};
|
||||
printWozBuffer("shift2", 9, WOZwrite);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user