Skip to content

Commit 20d12b5

Browse files
committed
Memory Mapped Device Layer
Implemented MemMapDev layer, added User Manual and Programmers Reference.
1 parent 0d47565 commit 20d12b5

17 files changed

+3835
-1120
lines changed

GraphDisp.cpp

+464
Large diffs are not rendered by default.

GraphDisp.h

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#ifndef GRAPHDISP_H
2+
#define GRAPHDISP_H
3+
4+
/*
5+
* Rudimentary emulation of generic raster graphics RGB display device.
6+
*/
7+
8+
#include <thread>
9+
#include <SDL.h>
10+
11+
using namespace std;
12+
13+
namespace MKBasic {
14+
15+
const int GRAPHDISP_MAXW = 640; // "real" display width or maximum virtual width
16+
const int GRAPHDISP_MAXH = 400; // "real" display width or maximum virtual height
17+
18+
class GraphDisp {
19+
20+
public:
21+
22+
bool mContLoop = true;
23+
bool mMainLoopActive = false;
24+
25+
GraphDisp();
26+
GraphDisp(int width, int height);
27+
~GraphDisp();
28+
void Start(GraphDisp *pgd);
29+
void Stop();
30+
void SetPixel(int x, int y);
31+
void ErasePixel(int x, int y);
32+
void DrawLine(int x1, int y1, int x2, int y2);
33+
void EraseLine(int x1, int y1, int x2, int y2);
34+
void SetBgColor(int r, int g, int b);
35+
void SetFgColor(int r, int g, int b);
36+
void Update();
37+
void ReadEvents();
38+
void ClearScreen();
39+
//void MainLoop();
40+
bool IsMainLoopActive();
41+
42+
private:
43+
44+
int mWidth = 320; // virtual display width
45+
int mHeight = 200; // virtual display height
46+
int mPixelSizeX = 2; // virtual pixel width
47+
int mPixelSizeY = 2; // virtual pixel height
48+
int mWinPosX = 0; // SDL window position coordinate X
49+
int mWinPosY = 0; // SDL window position coordinate Y
50+
int mBgRgbR = 0; // bg color, RGB red intensity
51+
int mBgRgbG = 0; // bg color, RGB green intensity
52+
int mBgRgbB = 0; // bg color, RGB blue intensity
53+
int mFgRgbR = 0xFF; // fg color, RGB red intensity
54+
int mFgRgbG = 0xFF; // fg color, RGB green intensity
55+
int mFgRgbB = 0xFF; // fg color, RGB blue intensity
56+
SDL_Window *mpWindow = NULL;
57+
SDL_Surface *mpSurface = NULL;
58+
SDL_Renderer *mpRenderer = NULL;
59+
thread mMainLoopThread;
60+
61+
void Initialize();
62+
void UpdateSurface();
63+
void Clear();
64+
void GetDesktopResolution(int& horizontal, int& vertical);
65+
void DrawLine(int x1, int y1, int x2, int y2, bool draworerase);
66+
void RenderPixel(int x, int y, bool set);
67+
68+
}; // class GraphDisp
69+
70+
} // namespace MKBasic
71+
72+
#endif

0 commit comments

Comments
 (0)