1 //////////////////////////////////////////////////
2 //                                              //
3 // Emu64                                        //
4 // von Thorsten Kattanek                        //
5 //                                              //
6 // #file: reu_class.cpp                         //
7 //                                              //
8 // Dieser Sourcecode ist Copyright geschützt!   //
9 // Geistiges Eigentum von Th.Kattanek           //
10 //                                              //
11 // Letzte Änderung am 13.09.2019                //
12 // www.emu64.de                                 //
13 //                                              //
14 //////////////////////////////////////////////////
15 
16 #ifndef REU_CLASS_H
17 #define REU_CLASS_H
18 
19 #include <fstream>
20 #include <functional>
21 
22 #include "./structs.h"
23 
24 class REUClass
25 {
26     public:
27     REUClass();
28     ~REUClass();
29 
30     // Funktionen
31     void WriteIO1(unsigned short adresse,unsigned char wert);
32     void WriteIO2(unsigned short adresse,unsigned char wert);
33     unsigned char ReadIO1(unsigned short adresse);
34     unsigned char ReadIO2(unsigned short adresse);
35 
36     void Insert(void);
37     void Remove(void);
38     int LoadRAM(const char *filename);
39     int SaveRAM(const char *filename);
40     void ClearRAM(void);
41     void Reset(void);
42     void OneZyklus(void);
43 
44     bool SaveFreez(FILE *File);
45     bool LoadFreez(FILE *File,unsigned short Version);
46 
47     std::function<unsigned char(unsigned short)> *ReadProcTbl;
48     std::function<void(unsigned short,unsigned char)> *WriteProcTbl;
49     std::function<void(int)> CpuTriggerInterrupt;
50     std::function<void(int)> CpuClearInterrupt;
51 
52     // Variablen
53     bool *BA;			// Extern
54     bool *RESET;		// Extern
55     bool *WRITE_FF00;	// Extern
56 
57     unsigned char DMAStatus;	// 0=kein Transfer / 1=Lesen / 2=Schreiben / 3=Swap / 4=Verify
58 
59     private:
60     // Funktionen
61     inline unsigned char Read(unsigned short adresse);
62     inline void Write(unsigned short adresse, unsigned char wert);
63 
64     // Variablen
65 
66     bool			BA_STATUS;
67 
68     //unsigned char	RamBaenke[32][0x10000];	// 32 x 64KB = 2MB
69     unsigned char	RamBaenke[256][0x10000]; // 256 x 64KB = 16MB
70 
71     bool			REUInsert;
72     bool			REUWait_FF00;
73 
74     // IO
75     unsigned char	IO[0x0B];
76     unsigned char	CPUWaitCounter;
77     bool			TransferStart;
78     unsigned short	AdresseC64;
79     unsigned short	AdresseREU;
80     unsigned short	Counter;
81     unsigned char	Bank;
82     unsigned char	TransferTyp;
83 };
84 
85 #endif // REU_CLASS_H
86