libfusefdc: better TR-DOS boot setting
[zymosis.git] / src / ZXEmuT / tapeaccel.c
blob067b54787090a0711ed1557c4954d9fefe08fa50
1 /***************************************************************************
3 * ZXEmuT -- ZX Spectrum Emulator with Tcl scripting
5 * Copyright (C) 2012-2020 Ketmar Dark <ketmar@ketmar.no-ip.org>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, version 3 of the License ONLY.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **************************************************************************/
20 static int tapDetectInCount = 0;
21 static int tapDetectLastInTS = -666;
22 static int tapDetectLastInB = 0x00;
25 void emuTapeAcceleratorEdgeAdvance (int flags) {}
26 void emuTapeAcceleratorStop (void) {}
27 void emuTapeAcceleratorStart (void) {}
30 void emuTapeAcceleratorAdvanceFrame (void) {
31 if (tapDetectLastInTS > -100666) tapDetectLastInTS -= machineInfo.tsperframe;
35 void emuTapeLoaderDetector (void) {
36 int tdelta = z80.tstates-tapDetectLastInTS;
37 uint8_t bdelta = ((int)z80.bc.b-tapDetectLastInB)&0xff;
39 tapDetectLastInTS = z80.tstates;
40 tapDetectLastInB = z80.bc.b;
42 if (optTapeDetector) {
43 // detector is on
44 if (optTapePlaying) {
45 // tape is playing
46 if (tdelta > 1000 || (bdelta != 1 && bdelta != 0 && bdelta != 0xff)) {
47 if (++tapDetectInCount >= 2) {
48 // seems that this is not a loader anymore
49 emuStopTape();
51 } else {
52 tapDetectInCount = 0;
54 } else {
55 // tape is not playing
56 if (tdelta <= 500 && (bdelta == 1 || bdelta == 0xff)) {
57 if (zxCurTape != NULL && !tapNeedRewind) {
58 if (++tapDetectInCount >= 10) {
59 // seems that this is LD-EDGE
60 emuStartTapeAuto();
62 } else {
63 tapDetectInCount = 0;
65 } else {
66 tapDetectInCount = 0;
69 } else {
70 // detector is off
71 tapDetectInCount = 0;