| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#include "vga.h" |
| 22 |
|
| 23 |
#define S3_LFB_BASE 0xC0000000 |
| 24 |
|
| 25 |
#define BIOSMEM_SEG 0x40 |
| 26 |
|
| 27 |
#define BIOSMEM_INITIAL_MODE 0x10 |
| 28 |
#define BIOSMEM_CURRENT_MODE 0x49 |
| 29 |
#define BIOSMEM_NB_COLS 0x4A |
| 30 |
#define BIOSMEM_PAGE_SIZE 0x4C |
| 31 |
#define BIOSMEM_CURRENT_START 0x4E |
| 32 |
#define BIOSMEM_CURSOR_POS 0x50 |
| 33 |
#define BIOSMEM_CURSOR_TYPE 0x60 |
| 34 |
#define BIOSMEM_CURRENT_PAGE 0x62 |
| 35 |
#define BIOSMEM_CRTC_ADDRESS 0x63 |
| 36 |
#define BIOSMEM_CURRENT_MSR 0x65 |
| 37 |
#define BIOSMEM_CURRENT_PAL 0x66 |
| 38 |
#define BIOSMEM_NB_ROWS 0x84 |
| 39 |
#define BIOSMEM_CHAR_HEIGHT 0x85 |
| 40 |
#define BIOSMEM_VIDEO_CTL 0x87 |
| 41 |
#define BIOSMEM_SWITCHES 0x88 |
| 42 |
#define BIOSMEM_MODESET_CTL 0x89 |
| 43 |
#define BIOSMEM_DCC_INDEX 0x8A |
| 44 |
#define BIOSMEM_CRTCPU_PAGE 0x8A |
| 45 |
#define BIOSMEM_VS_POINTER 0xA8 |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
#define VGAREG_ACTL_ADDRESS 0x3c0 |
| 54 |
#define VGAREG_ACTL_WRITE_DATA 0x3c0 |
| 55 |
#define VGAREG_ACTL_READ_DATA 0x3c1 |
| 56 |
|
| 57 |
#define VGAREG_INPUT_STATUS 0x3c2 |
| 58 |
#define VGAREG_WRITE_MISC_OUTPUT 0x3c2 |
| 59 |
#define VGAREG_VIDEO_ENABLE 0x3c3 |
| 60 |
#define VGAREG_SEQU_ADDRESS 0x3c4 |
| 61 |
#define VGAREG_SEQU_DATA 0x3c5 |
| 62 |
|
| 63 |
#define VGAREG_PEL_MASK 0x3c6 |
| 64 |
#define VGAREG_DAC_STATE 0x3c7 |
| 65 |
#define VGAREG_DAC_READ_ADDRESS 0x3c7 |
| 66 |
#define VGAREG_DAC_WRITE_ADDRESS 0x3c8 |
| 67 |
#define VGAREG_DAC_DATA 0x3c9 |
| 68 |
|
| 69 |
#define VGAREG_READ_FEATURE_CTL 0x3ca |
| 70 |
#define VGAREG_READ_MISC_OUTPUT 0x3cc |
| 71 |
|
| 72 |
#define VGAREG_GRDC_ADDRESS 0x3ce |
| 73 |
#define VGAREG_GRDC_DATA 0x3cf |
| 74 |
|
| 75 |
#define VGAREG_MDA_CRTC_ADDRESS 0x3b4 |
| 76 |
#define VGAREG_MDA_CRTC_DATA 0x3b5 |
| 77 |
#define VGAREG_VGA_CRTC_ADDRESS 0x3d4 |
| 78 |
#define VGAREG_VGA_CRTC_DATA 0x3d5 |
| 79 |
|
| 80 |
#define VGAREG_MDA_WRITE_FEATURE_CTL 0x3ba |
| 81 |
#define VGAREG_VGA_WRITE_FEATURE_CTL 0x3da |
| 82 |
#define VGAREG_ACTL_RESET 0x3da |
| 83 |
#define VGAREG_TDY_RESET 0x3da |
| 84 |
#define VGAREG_TDY_ADDRESS 0x3da |
| 85 |
#define VGAREG_TDY_DATA 0x3de |
| 86 |
#define VGAREG_PCJR_DATA 0x3da |
| 87 |
|
| 88 |
#define VGAREG_MDA_MODECTL 0x3b8 |
| 89 |
#define VGAREG_CGA_MODECTL 0x3d8 |
| 90 |
#define VGAREG_CGA_PALETTE 0x3d9 |
| 91 |
|
| 92 |
|
| 93 |
#define VGAMEM_GRAPH 0xA000 |
| 94 |
#define VGAMEM_CTEXT 0xB800 |
| 95 |
#define VGAMEM_MTEXT 0xB000 |
| 96 |
|
| 97 |
#define BIOS_NCOLS Bit16u ncols=real_readw(BIOSMEM_SEG,BIOSMEM_NB_COLS); |
| 98 |
#define BIOS_NROWS Bit16u nrows=(Bit16u)real_readb(BIOSMEM_SEG,BIOSMEM_NB_ROWS)+1; |
| 99 |
|
| 100 |
extern Bit8u int10_font_08[256 * 8]; |
| 101 |
extern Bit8u int10_font_14[256 * 14]; |
| 102 |
extern Bit8u int10_font_16[256 * 16]; |
| 103 |
|
| 104 |
struct VideoModeBlock { |
| 105 |
Bit16u mode; |
| 106 |
VGAModes type; |
| 107 |
Bitu swidth, sheight; |
| 108 |
Bitu twidth, theight; |
| 109 |
Bitu cwidth, cheight; |
| 110 |
Bitu ptotal,pstart,plength; |
| 111 |
|
| 112 |
Bitu htotal,vtotal; |
| 113 |
Bitu hdispend,vdispend; |
| 114 |
Bitu special; |
| 115 |
|
| 116 |
}; |
| 117 |
extern VideoModeBlock ModeList_VGA[]; |
| 118 |
extern VideoModeBlock * CurMode; |
| 119 |
|
| 120 |
typedef struct { |
| 121 |
struct { |
| 122 |
RealPt font_8_first; |
| 123 |
RealPt font_8_second; |
| 124 |
RealPt font_14; |
| 125 |
RealPt font_16; |
| 126 |
RealPt font_14_alternate; |
| 127 |
RealPt font_16_alternate; |
| 128 |
RealPt static_state; |
| 129 |
RealPt video_save_pointers; |
| 130 |
RealPt video_parameter_table; |
| 131 |
RealPt video_save_pointer_table; |
| 132 |
RealPt video_dcc_table; |
| 133 |
RealPt oemstring; |
| 134 |
RealPt vesa_modes; |
| 135 |
RealPt pmode_interface; |
| 136 |
Bit16u pmode_interface_size; |
| 137 |
Bit16u pmode_interface_start; |
| 138 |
Bit16u pmode_interface_window; |
| 139 |
Bit16u pmode_interface_palette; |
| 140 |
Bit16u used; |
| 141 |
} rom; |
| 142 |
Bit16u vesa_setmode; |
| 143 |
bool vesa_nolfb; |
| 144 |
bool vesa_oldvbe; |
| 145 |
} Int10Data; |
| 146 |
|
| 147 |
extern Int10Data int10; |
| 148 |
|
| 149 |
static inline Bit8u CURSOR_POS_COL(Bit8u page) { |
| 150 |
return real_readb(BIOSMEM_SEG,BIOSMEM_CURSOR_POS+page*2); |
| 151 |
} |
| 152 |
|
| 153 |
static inline Bit8u CURSOR_POS_ROW(Bit8u page) { |
| 154 |
return real_readb(BIOSMEM_SEG,BIOSMEM_CURSOR_POS+page*2+1); |
| 155 |
} |
| 156 |
|
| 157 |
bool INT10_SetVideoMode(Bit16u mode); |
| 158 |
|
| 159 |
void INT10_ScrollWindow(Bit8u rul,Bit8u cul,Bit8u rlr,Bit8u clr,Bit8s nlines,Bit8u attr,Bit8u page); |
| 160 |
|
| 161 |
void INT10_SetActivePage(Bit8u page); |
| 162 |
void INT10_GetFuncStateInformation(PhysPt save); |
| 163 |
|
| 164 |
void INT10_SetCursorShape(Bit8u first,Bit8u last); |
| 165 |
void INT10_SetCursorPos(Bit8u row,Bit8u col,Bit8u page); |
| 166 |
void INT10_TeletypeOutput(Bit8u chr,Bit8u attr); |
| 167 |
void INT10_TeletypeOutputAttr(Bit8u chr,Bit8u attr,bool useattr); |
| 168 |
void INT10_ReadCharAttr(Bit16u * result,Bit8u page); |
| 169 |
void INT10_WriteChar(Bit8u chr,Bit8u attr,Bit8u page,Bit16u count,bool showattr); |
| 170 |
void INT10_WriteString(Bit8u row,Bit8u col,Bit8u flag,Bit8u attr,PhysPt string,Bit16u count,Bit8u page); |
| 171 |
|
| 172 |
|
| 173 |
void INT10_PutPixel(Bit16u x,Bit16u y,Bit8u page,Bit8u color); |
| 174 |
void INT10_GetPixel(Bit16u x,Bit16u y,Bit8u page,Bit8u * color); |
| 175 |
|
| 176 |
|
| 177 |
void INT10_LoadFont(PhysPt font,bool reload,Bitu count,Bitu offset,Bitu map,Bitu height); |
| 178 |
void INT10_ReloadFont(void); |
| 179 |
|
| 180 |
|
| 181 |
void INT10_SetBackgroundBorder(Bit8u val); |
| 182 |
void INT10_SetColorSelect(Bit8u val); |
| 183 |
void INT10_SetSinglePaletteRegister(Bit8u reg,Bit8u val); |
| 184 |
void INT10_SetOverscanBorderColor(Bit8u val); |
| 185 |
void INT10_SetAllPaletteRegisters(PhysPt data); |
| 186 |
void INT10_ToggleBlinkingBit(Bit8u state); |
| 187 |
void INT10_GetSinglePaletteRegister(Bit8u reg,Bit8u * val); |
| 188 |
void INT10_GetOverscanBorderColor(Bit8u * val); |
| 189 |
void INT10_GetAllPaletteRegisters(PhysPt data); |
| 190 |
void INT10_SetSingleDacRegister(Bit8u index,Bit8u red,Bit8u green,Bit8u blue); |
| 191 |
void INT10_GetSingleDacRegister(Bit8u index,Bit8u * red,Bit8u * green,Bit8u * blue); |
| 192 |
void INT10_SetDACBlock(Bit16u index,Bit16u count,PhysPt data); |
| 193 |
void INT10_GetDACBlock(Bit16u index,Bit16u count,PhysPt data); |
| 194 |
void INT10_SelectDACPage(Bit8u function,Bit8u mode); |
| 195 |
void INT10_GetDACPage(Bit8u* mode,Bit8u* page); |
| 196 |
void INT10_SetPelMask(Bit8u mask); |
| 197 |
void INT10_GetPelMask(Bit8u & mask); |
| 198 |
void INT10_PerformGrayScaleSumming(Bit16u start_reg,Bit16u count); |
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
Bit8u VESA_GetSVGAInformation(Bit16u seg,Bit16u off); |
| 203 |
Bit8u VESA_GetSVGAModeInformation(Bit16u mode,Bit16u seg,Bit16u off); |
| 204 |
Bit8u VESA_SetSVGAMode(Bit16u mode); |
| 205 |
Bit8u VESA_GetSVGAMode(Bit16u & mode); |
| 206 |
Bit8u VESA_SetCPUWindow(Bit8u window,Bit8u address); |
| 207 |
Bit8u VESA_GetCPUWindow(Bit8u window,Bit16u & address); |
| 208 |
Bit8u VESA_ScanLineLength(Bit8u subcall, Bit16u val, Bit16u & bytes,Bit16u & pixels,Bit16u & lines); |
| 209 |
Bit8u VESA_SetDisplayStart(Bit16u x,Bit16u y); |
| 210 |
Bit8u VESA_GetDisplayStart(Bit16u & x,Bit16u & y); |
| 211 |
Bit8u VESA_SetPalette(PhysPt data,Bitu index,Bitu count); |
| 212 |
Bit8u VESA_GetPalette(PhysPt data,Bitu index,Bitu count); |
| 213 |
|
| 214 |
|
| 215 |
void INT10_SetupRomMemory(void); |
| 216 |
void INT10_SetupRomMemoryChecksum(void); |
| 217 |
void INT10_SetupVESA(void); |
| 218 |
|
| 219 |
|
| 220 |
RealPt INT10_EGA_RIL_GetVersionPt(void); |
| 221 |
void INT10_EGA_RIL_ReadRegister(Bit8u & bl, Bit16u dx); |
| 222 |
void INT10_EGA_RIL_WriteRegister(Bit8u & bl, Bit8u bh, Bit16u dx); |
| 223 |
void INT10_EGA_RIL_ReadRegisterRange(Bit8u ch, Bit8u cl, Bit16u dx, PhysPt dst); |
| 224 |
void INT10_EGA_RIL_WriteRegisterRange(Bit8u ch, Bit8u cl, Bit16u dx, PhysPt dst); |
| 225 |
void INT10_EGA_RIL_ReadRegisterSet(Bit16u cx, PhysPt tbl); |
| 226 |
void INT10_EGA_RIL_WriteRegisterSet(Bit16u cx, PhysPt tbl); |
| 227 |
|
| 228 |
|
| 229 |
Bitu INT10_VideoState_GetSize(Bitu state); |
| 230 |
bool INT10_VideoState_Save(Bitu state,RealPt buffer); |
| 231 |
bool INT10_VideoState_Restore(Bitu state,RealPt buffer); |
| 232 |
|
| 233 |
|
| 234 |
Bit16u INT10_SetupVideoParameterTable(PhysPt basepos); |
| 235 |
void INT10_SetupBasicVideoParameterTable(void); |