-
Notifications
You must be signed in to change notification settings - Fork 22
/
vga.hh
72 lines (61 loc) · 1.99 KB
/
vga.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* Ad-hoc programming editor for DOSBox -- (C) 2011-03-08 Joel Yliluoma */
#include "langdefs.hh"
#ifdef __BORLANDC__
extern unsigned short* VidMem;
#define DOSBOX_HICOLOR_OFFSET (-0x8000l)
#elif defined(__DJGPP__)
#include <sys/nearptr.h>
#define VidMem (reinterpret_cast<unsigned short*>(__djgpp_conventional_base + 0xB8000))
#define DOSBOX_HICOLOR_OFFSET (-0x8000l)
#else
#define DOSBOX_HICOLOR_OFFSET (-0x10000l)
extern unsigned short VideoBuffer[];
#define VidMem (VideoBuffer - DOSBOX_HICOLOR_OFFSET/2)
#endif
extern unsigned char VidW, VidH, VidCellHeight;
extern double VidFPS;
extern const unsigned char* VgaFont;
extern bool C64palette, FatMode, DispUcase, DCPUpalette;
extern int columns;
void VgaGetFont();
void VgaEnableFontAccess();
void VgaDisableFontAccess();
void VgaSetFont(unsigned char height, unsigned number, unsigned first, const unsigned char* source);
void VgaGetMode();
void VgaSetMode(unsigned modeno);
void VgaPutCursorAt(unsigned cx, unsigned cy, unsigned shape);
void VgaSetCustomMode(
unsigned width,
unsigned height,
unsigned font_height,
bool is_9pix,
bool is_half/*horizontally doubled*/,
bool is_double/*vertically doubled*/,
int num_columns);
static inline unsigned short* GetVidMem(unsigned x, unsigned y, bool real=false)
{
if(C64palette)
{
// Compensate for margins
register unsigned offs = (x + 2) + (y + 2) * (VidW + 4);
if(FatMode) offs <<= 1;
return VidMem + offs;
}
else
{
register unsigned width = VidW * columns;
if(real || columns == 1 || y == 0)
{
register unsigned offs = x + y * width;
if(FatMode) offs <<= 1;
return VidMem + offs;
}
register unsigned lines_per_real_screen = (VidH-1) / columns;
register unsigned offs =
x
+ ((y-1) % lines_per_real_screen + 1) * width
+ ((y-1) / lines_per_real_screen) * VidW;
if(FatMode) offs <<= 1;
return VidMem + offs;
}
}