ROLAND  0.70
Amstrad Emulator based on Caprice Source rewritten in C++.
memman.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) by Fred Klaus *
3  * development@fkweb.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_MEMMAN_H
21 #define CPC_MEMMAN_H
22 
23 #include "def.h"
24 #include "gatearray.h"
25 #include "z80.h"
26 
27 namespace cpcx
28 {
29 
31  class MemMan final
32  {
33 
34  public:
35  MemMan(Z80* z80 = nullptr, GateArray* gatearray = nullptr,
36  const tSTRING & cpcrom = "", const tSTRING & amsdos = "");
38 
39  enum RamSize : tUWORD {ram64=64, ram128=128, ram256=256, ram512=512};
40 
42 
43  int init(tUWORD ramsize = 128, const tSTRING & cpcrom = "", const tSTRING & amsdos = "");
44  int init(Z80* z80, GateArray* gatearray);
45 
46  inline void initBanking();
47  void memoryManager();
48 
49  inline void toggleLowerRom();
50  inline void toggleUpperRom();
51 
52  tUBYTE* memBankConfig(tUBYTE bank, tUBYTE seg) {return mMemBankConfig[bank][seg];}
53  tUBYTE* rom(int bank) {return mRom[bank];}
54 
55  tUBYTE* upperRom() {return mUpperRom;}
56  tUBYTE* lowerRom() {return mLowerRom;}
57 
58  tUBYTE* base() {return mMemBankConfig[0][0];}
59 
60  bool openRom(int idx, const tSTRING & filename);
61  bool openCpcRom(const tSTRING & filename);
62 
63  private:
66 
68  tUBYTE* mRom[256];
69  tUBYTE mCpcRom[2*16384];
71 
74 
75  int mRamSize;
76 
77  };
78 
79  inline void MemMan::toggleUpperRom()
80  {
81 
82  if (!(mGateArray->romConfig() & 0x08))
83  {
84  if ((mGateArray->upperRom() == 0) || (mRom[mGateArray->upperRom()] == 0))
85  {
87  }
88  else
89  {
91  }
92  }
93  }
94 
95  inline void MemMan::toggleLowerRom()
96  {
97  if (!(mGateArray->romConfig() & 0x04))
98  {
100  }
101  }
102 
103 } // cpc
104 
105 #endif // CPC_MEMMAN_H
void initBanking()
Definition: memman.cpp:138
void memoryManager()
Definition: memman.cpp:197
bool openCpcRom(const tSTRING &filename)
tUBYTE * mLowerRom
Definition: memman.h:73
Definition: memman.h:41
Error
Definition: memman.h:41
void toggleUpperRom()
Definition: memman.h:79
std::string tSTRING
Definition: types.h:31
tUBYTE romConfig() const
Definition: gatearray.h:45
Namespace for all CPC components.
Definition: colours.cpp:22
tUBYTE * memBankConfig(tUBYTE bank, tUBYTE seg)
Definition: memman.h:52
void setMembank_read(tUBYTE bank, tUBYTE *ptr)
Definition: z80.h:211
tUBYTE * mUpperRom
Definition: memman.h:72
void toggleLowerRom()
Definition: memman.h:95
Definition: memman.h:41
tUBYTE * mRom[256]
Definition: memman.h:68
int mRamSize
Definition: memman.h:75
MemMan(Z80 *z80=nullptr, GateArray *gatearray=nullptr, const tSTRING &cpcrom="", const tSTRING &amsdos="")
Definition: memman.h:41
tUBYTE * upperRom()
Definition: memman.h:55
Definition: z80.h:44
Definition: memman.h:31
tUBYTE mCpcRom[2 *16384]
Definition: memman.h:69
tUBYTE * base()
Definition: memman.h:58
bool openRom(int idx, const tSTRING &filename)
Definition: memman.h:41
GateArray * mGateArray
Definition: memman.h:64
tUBYTE * lowerRom()
Definition: memman.h:56
Z80 * mZ80
Definition: memman.h:65
#define ROLAND_DEFAULT
Definition: compspec.h:46
uint8_t tUBYTE
Definition: types.h:74
tUBYTE * mMemBankConfig[8][4]
Definition: memman.h:70
int init(tUWORD ramsize=128, const tSTRING &cpcrom="", const tSTRING &amsdos="")
Definition: gatearray.h:31
uint16_t tUWORD
Definition: types.h:80
tUBYTE * mRam
Definition: memman.h:67
tUBYTE upperRom() const
Definition: gatearray.h:48
tUBYTE * rom(int bank)
Definition: memman.h:53