1
0
mirror of https://github.com/trudnai/Steve2.git synced 2024-12-29 22:30:06 +00:00

- Trace Enabler from UI

- Disk optimization tweaks
- Disk Drive selector
- Aux Memory handling fix
This commit is contained in:
tudnai 2020-06-19 15:16:27 -07:00
parent 7f6ade463b
commit c467b8223c
10 changed files with 168 additions and 54 deletions
A2Mac.xcodeproj
project.pbxproj
project.xcworkspace/xcuserdata/trudnai.xcuserdatad/xcdebugger
A2Mac
src

View File

@ -1410,7 +1410,7 @@
"@executable_path/../Frameworks",
);
OTHER_CFLAGS = (
"-DDISASSEMBLER",
"-D_NO_DISASSEMBLER",
"-D_NO_INTERRUPT_CHECK_PER_STEP",
"-D_NO_CLK_ABSOLUTE_PRECISE",
);
@ -1447,7 +1447,7 @@
);
LLVM_LTO = YES_THIN;
OTHER_CFLAGS = (
"-DDISASSEMBLER",
"-D_NO_DISASSEMBLER",
"-D_NO_INTERRUPT_CHECK_PER_STEP",
"-D_NO_CLK_ABSOLUTE_PRECISE",
);

View File

@ -223,6 +223,14 @@
<ContextState
contextName = "spkr_playUpd:speaker.c">
</ContextState>
<ContextState
contextName = "fetch:mmio.h">
<PersistentStrings>
<PersistentString
value = "memread8_low( m6502.PC)">
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName = "mach_msg_trap:(null)">
<PersistentStrings>
@ -339,6 +347,14 @@
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName = "addr_zp:mmio.h">
<PersistentStrings>
<PersistentString
value = "memread8(m6502.PC)">
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName = "set_flags_NZC:common.h">
<PersistentStrings>
@ -582,6 +598,9 @@
<PersistentString
value = "m6502">
</PersistentString>
<PersistentString
value = "m6502.PC">
</PersistentString>
<PersistentString
value = "Apple2_64K_AUX + 0x3600">
</PersistentString>
@ -593,6 +612,26 @@
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName = "_INC:6502_instr_inc_dec.h">
<PersistentStrings>
<PersistentString
value = "WRLOMEM[addr]">
</PersistentString>
<PersistentString
value = "Apple2_64K_MEM[1]">
</PersistentString>
<PersistentString
value = "WRHIMEM[addr]">
</PersistentString>
<PersistentString
value = "Apple2_64K_RAM[1]">
</PersistentString>
<PersistentString
value = "Apple2_64K_AUX[1]">
</PersistentString>
</PersistentStrings>
</ContextState>
<ContextState
contextName = "ioRead:mmio.h">
<PersistentStrings>

View File

@ -1388,13 +1388,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="469"/>
<rect key="frame" x="8" y="8" width="104" height="500"/>
<subviews>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="7yw-J0-Fmj">
<rect key="frame" x="0.0" y="466" width="96" height="5"/>
<rect key="frame" x="0.0" y="497" width="96" height="5"/>
</box>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="isd-yh-gCV">
<rect key="frame" x="-2" y="444" width="98" height="18"/>
<rect key="frame" x="-2" y="475" 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"/>
@ -1404,10 +1404,10 @@
</connections>
</button>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="t35-xh-L18">
<rect key="frame" x="0.0" y="435" width="96" height="5"/>
<rect key="frame" x="0.0" y="466" width="96" height="5"/>
</box>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="e2E-di-h3i">
<rect key="frame" x="-2" y="413" width="83" height="18"/>
<rect key="frame" x="-2" y="444" 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"/>
@ -1417,7 +1417,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Wa3-TC-XUI">
<rect key="frame" x="-2" y="391" width="79" height="18"/>
<rect key="frame" x="-2" y="422" 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"/>
@ -1427,7 +1427,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xrz-jA-1Fh">
<rect key="frame" x="-2" y="369" width="63" height="18"/>
<rect key="frame" x="-2" y="400" 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"/>
@ -1437,10 +1437,10 @@
</connections>
</button>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="rIK-Xk-n9g">
<rect key="frame" x="0.0" y="360" width="96" height="5"/>
<rect key="frame" x="0.0" y="391" width="96" height="5"/>
</box>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ccb-cj-gLu">
<rect key="frame" x="-2" y="338" width="87" height="18"/>
<rect key="frame" x="-2" y="369" 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"/>
@ -1450,7 +1450,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9nQ-Yf-2xf">
<rect key="frame" x="-2" y="316" width="91" height="18"/>
<rect key="frame" x="-2" y="347" 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"/>
@ -1460,10 +1460,10 @@
</connections>
</button>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="wih-Y6-2Bz">
<rect key="frame" x="0.0" y="307" width="96" height="5"/>
<rect key="frame" x="0.0" y="338" 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="446" width="104" height="23"/>
<rect key="frame" x="0.0" y="477" 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"/>
@ -1492,7 +1492,7 @@
</holdingPriorities>
</splitView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FZk-VW-alq">
<rect key="frame" x="-2" y="284" width="75" height="17"/>
<rect key="frame" x="-2" y="315" width="75" height="17"/>
<constraints>
<constraint firstAttribute="height" constant="17" id="ai1-6C-5tW"/>
</constraints>
@ -1503,10 +1503,10 @@
</textFieldCell>
</textField>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="Ml4-a9-XEQ">
<rect key="frame" x="0.0" y="273" width="96" height="5"/>
<rect key="frame" x="0.0" y="304" width="96" height="5"/>
</box>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Fb7-Jc-jmt">
<rect key="frame" x="-2" y="250" width="74" height="17"/>
<rect key="frame" x="-2" y="281" width="74" height="17"/>
<constraints>
<constraint firstAttribute="height" constant="17" id="xCE-LE-hVy"/>
</constraints>
@ -1517,7 +1517,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7Pw-e8-92m">
<rect key="frame" x="-1" y="225" width="55" height="18"/>
<rect key="frame" x="-1" y="256" width="55" height="18"/>
<buttonCell key="cell" type="radio" title="1.023" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" state="on" inset="2" id="AgQ-Np-TYQ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -1527,7 +1527,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hU1-g7-CCX">
<rect key="frame" x="-1" y="201" width="30" height="18"/>
<rect key="frame" x="-1" y="232" width="30" height="18"/>
<buttonCell key="cell" type="radio" title="2" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="nfH-ww-Ofp">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -1537,7 +1537,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Hfg-DD-meM">
<rect key="frame" x="-1" y="177" width="31" height="18"/>
<rect key="frame" x="-1" y="208" width="31" height="18"/>
<buttonCell key="cell" type="radio" title="4" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="dqL-yg-qaX">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -1547,7 +1547,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="OsQ-RW-v8K">
<rect key="frame" x="-1" y="153" width="37" height="18"/>
<rect key="frame" x="-1" y="184" width="37" height="18"/>
<buttonCell key="cell" type="radio" title="10" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="3Ve-WW-CIS">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -1557,7 +1557,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vGb-dz-KHi">
<rect key="frame" x="-1" y="129" width="45" height="18"/>
<rect key="frame" x="-1" y="160" width="45" height="18"/>
<buttonCell key="cell" type="radio" title="100" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="BUX-kX-vwG">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -1567,7 +1567,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="umb-DW-vGc">
<rect key="frame" x="-1" y="105" width="51" height="18"/>
<rect key="frame" x="-1" y="136" width="51" height="18"/>
<buttonCell key="cell" type="radio" title="MAX" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="8VU-4B-7Pe">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -1577,10 +1577,10 @@
</connections>
</button>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="1b6-qR-DoP">
<rect key="frame" x="0.0" y="95" width="96" height="5"/>
<rect key="frame" x="0.0" y="126" width="96" height="5"/>
</box>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Www-DG-lcV">
<rect key="frame" x="-2" y="72" width="69" height="17"/>
<rect key="frame" x="-2" y="103" width="69" height="17"/>
<constraints>
<constraint firstAttribute="height" constant="17" id="V60-fY-1kt"/>
</constraints>
@ -1591,7 +1591,7 @@
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="WeH-Xd-mtE">
<rect key="frame" x="-1" y="47" width="66" height="18"/>
<rect key="frame" x="-1" y="78" width="66" height="18"/>
<buttonCell key="cell" type="radio" title="Normal" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" state="on" inset="2" id="0UN-dl-3nf">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -1601,7 +1601,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="25n-Et-ouy">
<rect key="frame" x="-1" y="23" width="45" height="18"/>
<rect key="frame" x="-1" y="54" width="45" height="18"/>
<buttonCell key="cell" type="radio" title="Eco" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="t39-st-goM">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -1611,7 +1611,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="pQx-FY-gmj">
<rect key="frame" x="-1" y="-1" width="58" height="18"/>
<rect key="frame" x="-1" y="30" width="58" height="18"/>
<buttonCell key="cell" type="radio" title="Game" bezelStyle="regularSquare" imagePosition="left" alignment="left" refusesFirstResponder="YES" inset="2" id="Dgy-OG-1MD">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
@ -1620,6 +1620,19 @@
<action selector="setCPUMode:" target="XfG-lQ-9wD" id="iTd-yU-Vd4"/>
</connections>
</button>
<box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="G0a-hc-JMD">
<rect key="frame" x="0.0" y="20" width="96" height="5"/>
</box>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ht7-rA-5YN">
<rect key="frame" x="-2" y="-2" width="56" height="18"/>
<buttonCell key="cell" type="check" title="Trace" bezelStyle="regularSquare" imagePosition="left" inset="2" id="bgY-G9-iDK">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="traceEnable:" target="XfG-lQ-9wD" id="z2w-sG-5c0"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="Ge3-qD-JO6" secondAttribute="trailing" id="CjH-r2-t3y"/>
@ -1651,6 +1664,8 @@
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
@ -1678,6 +1693,8 @@
<real value="3.4028234663852886e+38"/>
<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

@ -1050,6 +1050,17 @@ class ViewController: NSViewController {
openDiskImage()
}
@IBAction func traceEnable(_ sender: NSButton) {
switch sender.state {
case .on:
m6502.dbgLevel.trace = 1
openLog()
default:
m6502.dbgLevel.trace = 0
closeLog()
}
}
}

View File

@ -254,11 +254,11 @@ INLINE int m6502_Step() {
case 0x16: ASL( addr_zp_X() ); return 6; // ASL zpg,X
case 0x17: SLO( addr_zp_X() ); return 6; // SLO* zpg,X (undocumented)
case 0x18: CLC(); return 2; // CLC
case 0x19: ORA( src_abs_Y() ); return 4; // ORA abs,Y
case 0x19: ORA( src_abs_Y() ); return 4+1; // ORA abs,Y
case 0x1A: NOP(); return 2; // NOP* (undocumented)
case 0x1B: SLO( addr_abs_Y() ); return 7; // SLO* abs,Y (undocumented)
case 0x1C: NOP(); src_abs_X(); return 4; // NOP* (undocumented)
case 0x1D: ORA( src_abs_X() ); return 4; // ORA abs,X
case 0x1D: ORA( src_abs_X() ); return 4+1; // ORA abs,X
case 0x1E: ASL( addr_abs_X() ); return 7; // ASL abs,X
case 0x1F: SLO( addr_abs_X() ); return 7; // SLO* abs,X (undocumented)
case 0x20: JSR( abs_addr() ); return 6; // JSR abs
@ -409,10 +409,10 @@ INLINE int m6502_Step() {
case 0xB1: LDA( src_ind_Y() ); return 5; // LDA ind,Y
case 0xB2: HLT(); return 0; // HLT* - Halts / Hangs / Jams / Kills the CPU (undocumented)
case 0xB3: LAX( src_ind_Y() ); return 5; // LAX* izy 5 (undocumented)
case 0xB4: LDY( src_zp_X() ); return 4; // LDY zpg,X
case 0xB5: LDA( src_zp_X() ); return 4; // LDA zpg,X
case 0xB6: LDX( src_zp_Y() ); return 4; // LDX zpg,Y
case 0xB7: LAX( src_zp_Y() ); return 4; // LAX* zpy 4 (undocumented)
case 0xB4: LDY( src_zp_X() ); return 4+1; // LDY zpg,X
case 0xB5: LDA( src_zp_X() ); return 4+1; // LDA zpg,X
case 0xB6: LDX( src_zp_Y() ); return 4+1; // LDX zpg,Y
case 0xB7: LAX( src_zp_Y() ); return 4+1; // LAX* zpy 4 (undocumented)
case 0xB8: CLV(); return 2; // CLV
case 0xB9: LDA( src_abs_Y() ); return 4; // LDA abs,Y
case 0xBA: TSX(); return 2; // TSX
@ -478,11 +478,11 @@ INLINE int m6502_Step() {
case 0xF6: INC( addr_zp_X() ); return 6; // INC zpg,X
case 0xF7: ISB( addr_zp_X() ); return 6; // ISB* zpx 6 (undocumented)
case 0xF8: SED(); return 2; // SED
case 0xF9: SBC( src_abs_Y() ); return 4; // SBC abs,Y
case 0xF9: SBC( src_abs_Y() ); return 4+1; // SBC abs,Y
case 0xFA: NOP(); return 2; // NOP
case 0xFB: ISB( addr_abs_Y() ); return 7; // ISB* aby 7 (undocumented)
case 0xFC: NOP(); src_abs_X(); return 4; // NOP* abx 4 (undocumented)
case 0xFD: SBC( src_abs_X() ); return 4; // SBC abs,X
case 0xFD: SBC( src_abs_X() ); return 4+1; // SBC abs,X
case 0xFE: INC( addr_abs_X() ); return 7; // INC abs,X
case 0xFF: ISB( addr_abs_X() ); return 7; // ISB* abx 7 (undocumented)
@ -677,6 +677,23 @@ void rom_loadFile( const char * bundlePath, const char * filename ) {
}
void openLog() {
outdev = fopen("/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/disassembly_new.log", "w+");
// for DEBUG ONLY!!! -- use stdout if could not create log file
// if (outdev == NULL) {
// outdev = stdout;
// }
}
void closeLog() {
if ( ( outdev ) && ( outdev != stdout ) && ( outdev != stderr ) ) {
fclose(outdev);
}
}
void m6502_ColdReset( const char * bundlePath, const char * romFileName ) {
inst_cnt = 0;
@ -699,13 +716,6 @@ void m6502_ColdReset( const char * bundlePath, const char * romFileName ) {
resetMemory();
// for DEBUG ONLY!!!
// outdev = fopen("/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/disassembly_new.log", "w+");
// if (outdev == NULL) {
// outdev = stdout;
// }
#ifdef FUNCTIONTEST
FILE * f = fopen("/Users/trudnai/Library/Containers/com.gamealloy.A2Mac/Data/6502_functional_test.bin", "rb");

View File

@ -134,7 +134,7 @@ typedef struct disassembly_s {
typedef struct MEMcfg_s {
unsigned RAM_16K : 1;
unsigned RAM_128K : 1;
unsigned RD_RAM : 1;
unsigned RD_INT_RAM : 1;
unsigned WR_RAM : 1;
unsigned RAM_BANK_2 : 1;
unsigned AUX_BANK : 1;
@ -193,5 +193,9 @@ extern void interrupt_NMI(void);
extern void hardReset(void);
extern void softReset(void);
extern void openLog(void);
extern void closeLog(void);
#endif /* __6502_H__ */

View File

@ -6,6 +6,9 @@
// Copyright © 2020 GameAlloy. All rights reserved.
//
#include <stdlib.h>
#include "disk.h"
#include "6502.h"
#include "common.h"
@ -15,7 +18,9 @@
disk_t disk = {
{ 0, 0, 0 }, // phase
0, // clk_last_access
0, // clk_since_last_read
0, // drive number
};
const int diskAccelerator_frames = 2;
@ -137,12 +142,17 @@ void disk_motor_off() {
uint8_t disk_read() {
dbgPrintf("io_DISK_READ (S%u)\n", 6);
disk.clk_last_access = m6502.clktime;
disk_accelerator_speedup();
// Debug disk read
// spkr_toggle();
if ( disk.drive ) {
return rand();
}
return woz_read();
}

View File

@ -30,6 +30,7 @@ typedef struct disk_s {
phase_t phase;
uint64_t clk_last_access;
uint64_t clk_last_read;
uint8_t drive;
} disk_t;

View File

@ -230,11 +230,13 @@ uint8_t woz_read() {
clkBeforeSync += clkelpased;
const int clkBeforeAdjusting = 512;
const int magicShiftOffset = 50;
const int magicShiftOffset = 45;
uint16_t usedBytes = woz_trks[track].bytes_used < WOZ_TRACK_BYTE_COUNT ? woz_trks[track].bytes_used : WOZ_TRACK_BYTE_COUNT;
if ( usedBytes ) {
int shiftOffset = magicShiftOffset;
// printf("elpased : %llu (clkBefRd:%d)\n", clkelpased, clkBeforeSync);
if ( clkelpased > clkBeforeAdjusting ) {
@ -242,7 +244,13 @@ uint8_t woz_read() {
clkBeforeSync = 0;
bitOffset = (clkelpased >> 2) & 7;
trackOffset += clkelpased >> 5;
trackOffset %= usedBytes;
if ( trackOffset >= usedBytes ) {
bitOffset = 0;
trackOffset = 0;
WOZread.shift = 0;
shiftOffset = 0;
}
// trackOffset %= usedBytes;
// preroll data stream
WOZread.shift = 0;
@ -253,7 +261,7 @@ uint8_t woz_read() {
WOZread.shift <<= bitOffset;
WOZwrite = WOZread;
for ( int i = 0; i < magicShiftOffset; i++ ) {
for ( int i = 0; i < shiftOffset; i++ ) {
for ( ; bitOffset < 8; bitOffset++ ) {
WOZread.shift <<= 1;
WOZwrite.shift <<= 1;

View File

@ -326,7 +326,7 @@ void resetMemory() {
// Reset memory configuration
MEMcfg.RAM_16K = 0;
MEMcfg.RAM_128K = 1;
MEMcfg.RD_RAM = 0;
MEMcfg.RD_INT_RAM = 0;
MEMcfg.WR_RAM = 0;
MEMcfg.RAM_BANK_2 = 0;
MEMcfg.AUX_BANK = 0;
@ -401,14 +401,24 @@ void auxMemorySelect( MEMcfg_t newMEMcfg ) {
}
if ( MEMcfg.WR_AUX_MEM ) {
WRLOMEM = Apple2_64K_AUX;
if ( MEMcfg.RD_INT_RAM ) {
WRLOMEM = Apple2_64K_AUX;
}
else {
WRLOMEM = Apple2_64K_MEM;
}
}
else {
WRLOMEM = Apple2_64K_RAM;
if ( MEMcfg.RD_INT_RAM ) {
WRLOMEM = Apple2_64K_MEM;
}
else {
WRLOMEM = Apple2_64K_RAM;
}
}
}
else {
WRLOMEM = Apple2_64K_RAM;
WRLOMEM = Apple2_64K_MEM;
}
// load new content to shadow memory
@ -473,7 +483,7 @@ INLINE void io_RAM_EXP( uint16_t addr ) {
// printf("RD_RAM\n");
MEMcfg.RD_RAM = 1;
MEMcfg.RD_INT_RAM = 1;
// load the content of Aux Memory
memcpy(Apple2_64K_MEM + 0xD000, RAM_BANK, 0x1000);
@ -485,7 +495,7 @@ INLINE void io_RAM_EXP( uint16_t addr ) {
default:
// printf("RD_ROM\n");
MEMcfg.RD_RAM = 0;
MEMcfg.RD_INT_RAM = 0;
// load the content of ROM Memory
memcpy(Apple2_64K_MEM + 0xD000, Apple2_16K_ROM + 0x1000, 0x3000);
@ -611,7 +621,7 @@ INLINE uint8_t ioRead( uint16_t addr ) {
return MEMcfg.RAM_BANK_2 << 7;
case (uint8_t)io_RDLCRAM:
return MEMcfg.RD_RAM << 7;
return MEMcfg.RD_INT_RAM << 7;
case (uint8_t)io_RDRAMRD:
return MEMcfg.RD_AUX_MEM << 7;
@ -752,10 +762,12 @@ INLINE uint8_t ioRead( uint16_t addr ) {
case (uint8_t)io_DISK_SELECT_1 + SLOT6:
dbgPrintf2("io_DISK_SELECT_1 (S%u)\n", 6);
disk.drive = 0;
return 0;
case (uint8_t)io_DISK_SELECT_2 + SLOT6:
dbgPrintf2("io_DISK_SELECT_2 (S%u)\n", 6);
disk.drive = 1;
return 0;
case (uint8_t)io_DISK_READ + SLOT6:
@ -1018,10 +1030,12 @@ INLINE void ioWrite( uint16_t addr, uint8_t val ) {
case (uint8_t)io_DISK_SELECT_1 + SLOT6:
dbgPrintf2("io_DISK_SELECT_1 (S%u)\n", 6);
disk.drive = 0;
break;
case (uint8_t)io_DISK_SELECT_2 + SLOT6:
dbgPrintf2("io_DISK_SELECT_2 (S%u)\n", 6);
disk.drive = 1;
break;
case (uint8_t)io_DISK_READ + SLOT6: