ROLAND  0.70
Amstrad Emulator based on Caprice Source rewritten in C++.
fdc.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Fred Klaus *
3  * frednet@web.de *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 #ifndef CPC_FDC_H
21 #define CPC_FDC_H
22 
23 #include "fdcconst.h"
24 #include "types.h"
25 #include "drive.h"
26 #include "cmdtable.h"
27 
28 #include <cstdio>
29 
30 
31 namespace cpcx
32 {
34  class Fdc final
35  {
36 
37  public:
38  Fdc();
40 
41  typedef void (Fdc::*CmdHandler)(void);
42 
43  void write_data(tUBYTE val);
45  tUBYTE read_data();
46  void specify();
47  void drvstat();
48  void recalib();
49  void intstat();
50  void seek();
51  void readtrk();
52  void write();
53  void read();
54  void readID();
55  void writeID();
56  void scan();
57 
58  void check_unit();
59  int init_status_regs();
60  Sector* find_sector(tUBYTE *requested_CHRN);
61  inline void cmd_write();
62  inline void cmd_read();
63  inline void cmd_readtrk();
64  inline void cmd_scan();
65 
66  int dsk_load(const char *pchFileName, int drv = 0, char chID='A');
67  void dsk_eject(int drv = 0);
68 
69  //void scanlo();
70  //void scanhi();
71 
72  int motor() {return mMotor;}
73  void setMotor(int s) {mMotor = s;}
74  int flags() {return mFlags;}
75  void addFlags(int flags) {mFlags |= flags;}
76  int phase() {return mPhase;}
77  int timeout() {return mTimeout;}
78  void setTimeout(int val) {mTimeout = val;}
79 
80  int cmdDirection() {return mCmdDirection;}
81 
82  bool led() {return mLed;}
83 
84  private:
85  int mTimeout;
86  int mMotor;
87  bool mLed;
88  int mFlags;
89  int mPhase;
95  CmdHandler mCmdHandler;
96  //void (Fdc::*mCmdHandler)(void);
97 
99 
104 
107 
108  Drive *mActiveDrive; // reference to the currently selected drive
109  Track *mActiveTrack; // reference to the currently selected track, of the active_drive
112 
114 
115  FILE *pfileObject;
116 
117  };
118 } // namespace cpcx
119 #endif
120 
121 
void setTimeout(int val)
Definition: fdc.h:78
int mResLength
Definition: fdc.h:93
tUWORD mReadStatusDelay
Definition: fdc.h:110
Drive * mActiveDrive
Definition: fdc.h:108
int mByteCount
Definition: fdc.h:90
Track * mActiveTrack
Definition: fdc.h:109
tUBYTE read_data()
Definition: fdc.cpp:384
int motor()
Definition: fdc.h:72
A floppy drive.
Definition: drive.h:29
int timeout()
Definition: fdc.h:77
int dsk_load(const char *pchFileName, int drv=0, char chID='A')
Definition: fdc.cpp:1182
void writeID()
Definition: fdc.cpp:782
Namespace for all CPC components.
Definition: colours.cpp:22
void recalib()
Definition: fdc.cpp:537
void addFlags(int flags)
Definition: fdc.h:75
void cmd_read()
Definition: fdc.cpp:1006
void seek()
Definition: fdc.cpp:597
tUWORD mBytesTransferred
Definition: fdc.h:111
Drive mDriveA
Definition: fdc.h:105
FILE * pfileObject
Definition: fdc.h:115
tUBYTE mCommand[12]
Definition: fdc.h:102
The floppy drive controller.
Definition: fdc.h:34
void read()
Definition: fdc.cpp:703
int cmdDirection()
Definition: fdc.h:80
Command table.
Definition: cmdtable.h:29
void cmd_scan()
Definition: fdc.cpp:1119
tUBYTE read_status()
Definition: fdc.cpp:349
void readtrk()
Definition: fdc.cpp:615
Fdc()
Definition: fdc.cpp:54
CmdTable mCmdTable
Definition: fdc.h:113
int mPhase
Definition: fdc.h:89
int mBufferCount
Definition: fdc.h:91
int mCmdLength
Definition: fdc.h:92
Sector * find_sector(tUBYTE *requested_CHRN)
Definition: fdc.cpp:899
A track of a disk.
Definition: track.h:32
tUBYTE * mBufferEndPtr
Definition: fdc.h:101
void drvstat()
Definition: fdc.cpp:515
A sector of a disk.
Definition: sector.h:29
tUBYTE mResult[8]
Definition: fdc.h:103
bool led()
Definition: fdc.h:82
void specify()
Definition: fdc.cpp:509
void check_unit()
Definition: fdc.cpp:870
Drive mDriveB
Definition: fdc.h:106
tUBYTE * pbGPBuffer
Definition: fdc.h:98
int mCmdDirection
Definition: fdc.h:94
void intstat()
Definition: fdc.cpp:543
#define ROLAND_DEFAULT
Definition: compspec.h:46
uint8_t tUBYTE
Definition: types.h:74
void readID()
Definition: fdc.cpp:741
void dsk_eject(int drv=0)
Definition: fdc.cpp:1405
bool mLed
Definition: fdc.h:87
void setMotor(int s)
Definition: fdc.h:73
uint16_t tUWORD
Definition: types.h:80
int mFlags
Definition: fdc.h:88
tUBYTE * mBufferPtr
Definition: fdc.h:100
int init_status_regs()
Definition: fdc.cpp:884
CmdHandler mCmdHandler
Definition: fdc.h:95
void write()
Definition: fdc.cpp:656
void cmd_readtrk()
Definition: fdc.cpp:1082
int flags()
Definition: fdc.h:74
void scan()
Definition: fdc.cpp:827
int phase()
Definition: fdc.h:76
int mMotor
Definition: fdc.h:86
int mTimeout
Definition: fdc.h:85
void cmd_write()
Definition: fdc.cpp:952