ROLAND  0.70
Amstrad Emulator based on Caprice Source rewritten in C++.
vdu.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2013 by Fred Klaus <development@fkweb.de> *
3  * *
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_VDU_H
21 #define CPC_VDU_H
22 
23 #include "compspec.h"
24 #include "def.h"
25 
26 #ifdef USE_MMX
27  #include "mmx_memcpy.h"
28 #else
29  #include <memory>
30 #endif
31 
32 namespace cpcx
33 {
34 
35  class GateArray;
36  class Crtc;
37  class Z80;
38 
40  class Vdu final
41  {
42 
43  public:
44  enum Bpp : unsigned char {Bpp16=0, Bpp24=1, Bpp32=2};
45 
46  Vdu(Crtc* crtc=nullptr, GateArray* gatearray=nullptr, Z80* z80=nullptr);
48 
50  typedef void (Vdu::*ModeHandler)();
52  typedef void (Vdu::*BorderHandler)();
53 
54  void init(bool full=false, Crtc* crtc=0, GateArray* gatearray=0, Z80* z80=0);
55 
56  void access_video_memory(int repeat_count);
57 
58  void draw16bpp_border();
59  void draw16bpp_nullborder();
60  void draw16bpp_mode0();
61  void draw16bpp_mode1();
62  void draw16bpp_mode2();
63 
64  void draw24bpp_border();
65  void draw24bpp_nullborder();
66  void draw24bpp_mode0();
67  void draw24bpp_mode1();
68  void draw24bpp_mode2();
69 
70  void draw32bpp_border();
71  void draw32bpp_nullborder();
72  void draw32bpp_mode0();
73  void draw32bpp_mode1();
74  void draw32bpp_mode2();
75 
76  void draw16bppx2_border();
77  void draw16bppx2_nullborder();
78  void draw16bppx2_mode0();
79  void draw16bppx2_mode1();
80  void draw16bppx2_mode2();
81 
82  void draw24bppx2_border();
83  void draw24bppx2_nullborder();
84  void draw24bppx2_mode0();
85  void draw24bppx2_mode1();
86  void draw24bppx2_mode2();
87 
88  void draw32bppx2_border();
89  void draw32bppx2_nullborder();
90  void draw32bppx2_mode0();
91  void draw32bppx2_mode1();
92  void draw32bppx2_mode2();
93 
94 
95  //uint hsw() {return mHsw;}
96  uint hswActive() const {return mHswActive;}
97  uint hswCount() const {return mHswCount;}
98  uint vswCount() const {return mVswCount;}
99  uint hDelay() const {return mHDelay;}
100  uint vDelay() const {return mVDelay;}
101  uint scanline() const {return mScanline;}
102  uint scanlineMin() const {return mScanlineMin;}
103  bool frameCompleted() const {return mFrameCompleted;}
104  uint charCount() const {return mCharCount;}
105  uint hCount() const {return mHCount;}
106  uint hStart() const {return mHStart;}
107  uint hWidth() const {return mHWidth;}
108  uint vCount() const {return mVCount;}
109  uint vStart() const {return mVStart;}
110  uint vHeight() const {return mVHeight;}
111 
112  void setBpp (Bpp bpp);
113  void setBorder (bool border = true);
114  void setLineDoubling(bool doubling = true);
115 
116  //void setHsw (uint value) {mHsw = value;}
117  void setHswActive (uint value) {mHswActive = value;}
118  void setHswCount (uint value) {mHswCount = value;}
119  void setVswCount (uint value) {mVswCount = value;}
120  void setHDelay (uint value) {mHDelay = value;}
121  void setVDelay (uint value) {mVDelay = value;}
122  void setScanline (uint value) {mScanline = value;}
123  void setScanlineMin (uint value) {mScanlineMin = value;}
124  void setFrameCompleted(bool value) {mFrameCompleted = value;}
125  void setCharCount (uint value) {mCharCount = value;}
126  void setHCount (uint value) {mHCount = value;}
127  void setHStart (uint value) {mHStart = value;}
128  void setHWidth (uint value) {mHWidth = value;}
129  void setVCount (uint value) {mVCount = value;}
130  void setVStart (uint value) {mVStart = value;}
131  void setVHeight (uint value) {mVHeight = value;}
132 
133  void setScrBase (uint* value) {mScrBase = value;}
134  void setScrEnd (uint* value) {mScrEnd = value;}
135  void setScrLineOffset(uint value) {mScrLineOffset = value;}
136  void setScrOffset (uint value) {mScrOffset = value;}
137  void setScrLine (uint value) {mScrLine = value;}
138  void setCpcRamBase (tUBYTE* value) {mCpcRamBase = value;}
139 
140  void setScale(uchar scale);
141 
142  inline void doubling();
143 
144  private:
148 
150 
151  tREGPAIR addr;
152 
154  bool mBorder;
156 
157  //uint mHsw;
172 
173  /*
174  uint mScrFsWidth;
175  uint mScrFsHeight;
176  uint mScrFs_bpp;
177  uint mScrStyle;
178  uint mScrVSync;
179  uint mScrLed;
180  uint mScrFps;
181  uint mScrTube;
182  uint mScrWindow;
183  uint mScrBps;
184  */
185 
194 
196 
198 
201 
202  ModeHandler mModeHandler[3][4]; // [bpp][mode]
205 
206  ModeHandler mCurModeHandler;
208 
209  };
210 
211 } // cpc
212 
213 #endif // CPC_VDU_H
Z80 * mZ80
Definition: vdu.h:147
tUBYTE * mCpcRamBase
Definition: vdu.h:197
void setScrBase(uint *value)
Definition: vdu.h:133
void draw32bppx2_mode1()
Mode 1, 32 bpp.
Definition: vdu.cpp:824
void draw16bpp_mode1()
Mode 1, 16 bpp.
Definition: vdu.cpp:1162
void draw16bppx2_nullborder()
Border=false, 16 bpp.
Definition: vdu.cpp:503
void setVDelay(uint value)
Definition: vdu.h:121
bool frameCompleted() const
Definition: vdu.h:103
void draw32bppx2_mode2()
Mode 2, 32 bpp.
Definition: vdu.cpp:862
uint mHWidth
Definition: vdu.h:168
void doubling()
Definition: vdu.cpp:468
Bpp mBpp
Definition: vdu.h:149
uint mCharCount
Definition: vdu.h:165
uchar mScale
Definition: vdu.h:195
Crtc * mCrtc
Definition: vdu.h:145
uint charCount() const
Definition: vdu.h:104
uint vStart() const
Definition: vdu.h:109
GLuint GLfloat GLenum cap GLsizei GLuint *textures GLenum GLint *params void GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum GLint GLint GLsizei GLsizei GLint border
Definition: glfunclist.h:21
void draw24bpp_mode0()
Mode 0, 24 bpp.
Definition: vdu.cpp:1032
void draw16bpp_nullborder()
Border=false, 16 bpp.
Definition: vdu.cpp:1134
Vdu(Crtc *crtc=nullptr, GateArray *gatearray=nullptr, Z80 *z80=nullptr)
Definition: vdu.cpp:29
uint mHswActive
Definition: vdu.h:158
Definition: vdu.h:44
void draw16bppx2_mode2()
Mode 2, 16 bpp.
Definition: vdu.cpp:568
void init(bool full=false, Crtc *crtc=0, GateArray *gatearray=0, Z80 *z80=0)
Definition: vdu.cpp:38
GateArray * mGateArray
Definition: vdu.h:146
bool mLineDoubling
Definition: vdu.h:155
Namespace for all CPC components.
Definition: colours.cpp:22
void setScrLine(uint value)
Definition: vdu.h:137
Bpp
Definition: vdu.h:44
uint mVStart
Definition: vdu.h:170
uint mScanline
Definition: vdu.h:163
uint vCount() const
Definition: vdu.h:108
unsigned char uchar
Definition: types.h:127
uint mHDelay
Definition: vdu.h:161
uint mScrHeight
Definition: vdu.h:189
void setVHeight(uint value)
Definition: vdu.h:131
void draw32bpp_mode2()
Mode 2, 32 bpp.
Definition: vdu.cpp:978
void draw32bppx2_nullborder()
Border=false, 32 bpp.
Definition: vdu.cpp:785
Definition: vdu.h:44
uint scanlineMin() const
Definition: vdu.h:102
void setCharCount(uint value)
Definition: vdu.h:125
uint scanline() const
Definition: vdu.h:101
uint hWidth() const
Definition: vdu.h:107
void draw16bpp_mode2()
Mode 2, 16 bpp.
Definition: vdu.cpp:1188
uint mVDelay
Definition: vdu.h:162
void setVswCount(uint value)
Definition: vdu.h:119
BorderHandler mNullBorderHandler[4]
Definition: vdu.h:204
void access_video_memory(int repeat_count)
Definition: vdu.cpp:204
void draw24bppx2_nullborder()
Border=false, 24 bpp.
Definition: vdu.cpp:642
void setLineDoubling(bool doubling=true)
Definition: vdu.cpp:181
uint hCount() const
Definition: vdu.h:105
void setScanlineMin(uint value)
Definition: vdu.h:123
uint vswCount() const
Definition: vdu.h:98
void draw24bpp_mode1()
Mode 1, 24 bpp.
Definition: vdu.cpp:1058
ModeHandler mCurModeHandler
Definition: vdu.h:206
uint vDelay() const
Definition: vdu.h:100
void draw24bpp_nullborder()
Border=false, 24 bpp.
Definition: vdu.cpp:1027
Definition: crtc.h:30
Definition: vdu.h:40
bool mFrameCompleted
Definition: vdu.h:153
void setCpcRamBase(tUBYTE *value)
Definition: vdu.h:138
uint mHStart
Definition: vdu.h:167
uint mScrLine
Definition: vdu.h:193
void draw32bpp_border()
Border=true, 32 bpp.
Definition: vdu.cpp:898
uint mVCount
Definition: vdu.h:169
void setVCount(uint value)
Definition: vdu.h:129
Definition: z80.h:44
~Vdu() ROLAND_DEFAULT typedef void(Vdu typedef void(Vdu::* BorderHandler)()
Definition: vdu.h:52
void setScrEnd(uint *value)
Definition: vdu.h:134
void setBorder(bool border=true)
Definition: vdu.cpp:186
void setHCount(uint value)
Definition: vdu.h:126
uint mScrWidth
Definition: vdu.h:188
uint mHswCount
Definition: vdu.h:159
void setVStart(uint value)
Definition: vdu.h:130
void setHswCount(uint value)
Definition: vdu.h:118
BorderHandler mCurBorderHandler
Definition: vdu.h:207
uint mScrBpp
Definition: vdu.h:190
void setHDelay(uint value)
Definition: vdu.h:120
BorderHandler mBorderHandler[4]
Definition: vdu.h:203
void draw32bpp_mode1()
Mode 1, 32 bpp.
Definition: vdu.cpp:948
Definition: vdu.h:44
void draw24bppx2_mode0()
Mode 0, 24 bpp.
Definition: vdu.cpp:647
void draw24bppx2_border()
Border=true, 24 bpp.
Definition: vdu.cpp:615
void draw16bppx2_mode1()
Mode 1, 16 bpp.
Definition: vdu.cpp:535
uint mVswCount
Definition: vdu.h:160
void draw16bpp_mode0()
Mode 0, 16 bpp.
Definition: vdu.cpp:1139
uint * mScrEnd
Definition: vdu.h:187
void setScrOffset(uint value)
Definition: vdu.h:136
void setScrLineOffset(uint value)
Definition: vdu.h:135
void draw24bppx2_mode1()
Mode 1, 24 bpp.
Definition: vdu.cpp:681
void draw32bppx2_border()
Border=true, 32 bpp.
Definition: vdu.cpp:758
void draw16bpp_border()
Border=true, 16 bpp.
Definition: vdu.cpp:1118
tUBYTE mode0_table[512]
Definition: vdu.h:199
void setScanline(uint value)
Definition: vdu.h:122
void setHStart(uint value)
Definition: vdu.h:127
tREGPAIR addr
Definition: vdu.h:151
uint vHeight() const
Definition: vdu.h:110
#define ROLAND_DEFAULT
Definition: compspec.h:46
uint8_t tUBYTE
Definition: types.h:74
unsigned int uint
Definition: types.h:121
void draw24bpp_border()
Border=true, 24 bpp.
Definition: vdu.cpp:1008
void draw24bppx2_mode2()
Mode 2, 24 bpp.
Definition: vdu.cpp:719
bool mBorder
Definition: vdu.h:154
uint hswCount() const
Definition: vdu.h:97
uint mHCount
Definition: vdu.h:166
void draw32bpp_nullborder()
Border=false, 32 bpp.
Definition: vdu.cpp:917
void draw32bppx2_mode0()
Mode 0, 32 bpp.
Definition: vdu.cpp:790
void draw32bpp_mode0()
Mode 0, 32 bpp.
Definition: vdu.cpp:922
Definition: gatearray.h:31
uint * mScrBase
Definition: vdu.h:186
void draw24bpp_mode2()
Mode 2, 24 bpp.
Definition: vdu.cpp:1088
uint mScrOffset
Definition: vdu.h:192
uint hDelay() const
Definition: vdu.h:99
uint hStart() const
Definition: vdu.h:106
void setScale(uchar scale)
Definition: vdu.cpp:175
ModeHandler mModeHandler[3][4]
Definition: vdu.h:202
void draw16bppx2_mode0()
Mode 0, 16 bpp.
Definition: vdu.cpp:508
void setBpp(Bpp bpp)
Definition: vdu.cpp:169
uint mVHeight
Definition: vdu.h:171
uint hswActive() const
Definition: vdu.h:96
void setHWidth(uint value)
Definition: vdu.h:128
tUBYTE mode1_table[1024]
Definition: vdu.h:200
void draw16bppx2_border()
Border=true, 16 bpp.
Definition: vdu.cpp:483
void setFrameCompleted(bool value)
Definition: vdu.h:124
void setHswActive(uint value)
Definition: vdu.h:117
uint mScanlineMin
Definition: vdu.h:164
uint mScrLineOffset
Definition: vdu.h:191