-
Notifications
You must be signed in to change notification settings - Fork 7
/
tape.h
86 lines (77 loc) · 2.1 KB
/
tape.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
YAPE - Yet Another Plus/4 Emulator
The program emulates the Commodore 264 family of 8 bit microcomputers
This program is free software, you are welcome to distribute it,
and/or modify it under certain conditions. For more information,
read 'Copying'.
(c) 2000, 2001, 2007, 2016 Attila Grósz
*/
#ifndef _TAPE_H
#define _TAPE_H
#include "types.h"
#define C64PALFREQ 123156 /* 985248 / 8 */
#define C64NTSCFREQ 127841 /* 1022727 / 8 */
#define VICPALFREQ 138551 /* 1108405 / 8 */
#define VICNTSCFREQ 127841 /* 1022727 / 8 */
#define C16PALFREQ 110840 /* 886724 / 8 */
#define C16NTSCFREQ 111860 /* 894886 / 8 */
enum TapeFormat {
TAPE_FORMAT_MTAP1 = 0,
TAPE_FORMAT_MTAP2,
TAPE_FORMAT_PCM8,
TAPE_FORMAT_PCM16,
TAPE_FORMAT_PCM1,
TAPE_FORMAT_NONE
};
class TAP {
private:
char tapefilename[260];
unsigned int tapeFileSize;
unsigned char *tapeBuffer;
unsigned int tapeDelay, origTapeDelay;
//
ClockCycle lastCycle;
unsigned char edge;
bool motorOn;
unsigned int buttonPressed;
void convTAPUnitsToCycles();
void readMtapData(unsigned int);
void readWavData(unsigned int elapsed);
unsigned int readNextTapDelay();
TapeFormat tapeFormat;
bool fallingEdge;
unsigned int bitcount;
unsigned char *tapeHeaderRead;
unsigned int tapeImageHeaderSize;
unsigned int tapeImageSampleRate;
public:
TAP();
class TED *mem;
bool attachTape(const char *fname);
bool createTape(const char *fname);
bool detachTape();
void rewind();
void changewave(bool wholewave);
unsigned int tapeSoFar;
//
unsigned char readCSTIn(ClockCycle cycle);
void writeCSTOut(ClockCycle cycle, unsigned char value);
void pressTapeButton(ClockCycle cycle, unsigned int);
unsigned int IsButtonPressed() {
//fprintf(stderr,"Button state checked: %i\n", buttonPressed);
return buttonPressed;
}
void setTapeMotor(ClockCycle cycle, unsigned int on);
inline bool isMotorOn() {
return motorOn;
}
bool getFallingEdgeState(ClockCycle clk) {
readCSTIn(clk);
return fallingEdge;
}
void resetFallingEdge(ClockCycle clk) {
readCSTIn(clk);
fallingEdge = false;
}
};
#endif // _TAPE_H