DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
src/ints/int10.h
00001 /*
00002  *  Copyright (C) 2002-2015  The DOSBox Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 
00020 #include "vga.h"
00021 
00022 /* TODO: Make this user-configurable */
00023 #define S3_LFB_BASE             0xE0000000u
00024 
00025 #define BIOSMEM_SEG             0x40u
00026 
00027 #define BIOSMEM_INITIAL_MODE  0x10u
00028 #define BIOSMEM_CURRENT_MODE  0x49u
00029 #define BIOSMEM_NB_COLS       0x4Au
00030 #define BIOSMEM_PAGE_SIZE     0x4Cu
00031 #define BIOSMEM_CURRENT_START 0x4Eu
00032 #define BIOSMEM_CURSOR_POS    0x50u
00033 #define BIOSMEM_CURSOR_TYPE   0x60u
00034 #define BIOSMEM_CURRENT_PAGE  0x62u
00035 #define BIOSMEM_CRTC_ADDRESS  0x63u
00036 #define BIOSMEM_CURRENT_MSR   0x65u
00037 #define BIOSMEM_CURRENT_PAL   0x66u
00038 #define BIOSMEM_NB_ROWS       0x84u
00039 #define BIOSMEM_CHAR_HEIGHT   0x85u
00040 #define BIOSMEM_VIDEO_CTL     0x87u
00041 #define BIOSMEM_SWITCHES      0x88u
00042 #define BIOSMEM_MODESET_CTL   0x89u
00043 #define BIOSMEM_DCC_INDEX     0x8Au
00044 #define BIOSMEM_CRTCPU_PAGE   0x8Au
00045 #define BIOSMEM_VS_POINTER    0xA8u
00046 
00047 
00048 /*
00049  *
00050  * VGA registers
00051  *
00052  */
00053 #define VGAREG_ACTL_ADDRESS            0x3c0u
00054 #define VGAREG_ACTL_WRITE_DATA         0x3c0u
00055 #define VGAREG_ACTL_READ_DATA          0x3c1u
00056 
00057 #define VGAREG_INPUT_STATUS            0x3c2u
00058 #define VGAREG_WRITE_MISC_OUTPUT       0x3c2u
00059 #define VGAREG_VIDEO_ENABLE            0x3c3u
00060 #define VGAREG_SEQU_ADDRESS            0x3c4u
00061 #define VGAREG_SEQU_DATA               0x3c5u
00062 
00063 #define VGAREG_PEL_MASK                0x3c6u
00064 #define VGAREG_DAC_STATE               0x3c7u
00065 #define VGAREG_DAC_READ_ADDRESS        0x3c7u
00066 #define VGAREG_DAC_WRITE_ADDRESS       0x3c8u
00067 #define VGAREG_DAC_DATA                0x3c9u
00068 
00069 #define VGAREG_READ_FEATURE_CTL        0x3cau
00070 #define VGAREG_READ_MISC_OUTPUT        0x3ccu
00071 
00072 #define VGAREG_GRDC_ADDRESS            0x3ceu
00073 #define VGAREG_GRDC_DATA               0x3cfu
00074 
00075 #define VGAREG_MDA_CRTC_ADDRESS        0x3b4u
00076 #define VGAREG_MDA_CRTC_DATA           0x3b5u
00077 #define VGAREG_VGA_CRTC_ADDRESS        0x3d4u
00078 #define VGAREG_VGA_CRTC_DATA           0x3d5u
00079 
00080 #define VGAREG_MDA_WRITE_FEATURE_CTL   0x3bau
00081 #define VGAREG_VGA_WRITE_FEATURE_CTL   0x3dau
00082 #define VGAREG_ACTL_RESET              0x3dau
00083 #define VGAREG_TDY_RESET               0x3dau
00084 #define VGAREG_TDY_ADDRESS             0x3dau
00085 #define VGAREG_TDY_DATA                0x3deu
00086 #define VGAREG_PCJR_DATA               0x3dau
00087 
00088 #define VGAREG_MDA_MODECTL             0x3b8u
00089 #define VGAREG_CGA_MODECTL             0x3d8u
00090 #define VGAREG_CGA_PALETTE             0x3d9u
00091 
00092 /* Video memory */
00093 #define VGAMEM_GRAPH 0xA000u
00094 #define VGAMEM_CTEXT 0xB800u
00095 #define VGAMEM_MTEXT 0xB000u
00096 
00097 /* FIXME: Wait, what?? What the hell kind of preprocessor macro is this??? Kill these macros! --J.C. */
00098 #define BIOS_NCOLS Bit16u ncols=real_readw(BIOSMEM_SEG,BIOSMEM_NB_COLS);
00099 #define BIOS_NROWS Bit16u nrows=(Bit16u)real_readb(BIOSMEM_SEG,BIOSMEM_NB_ROWS)+1u;
00100 
00101 extern Bit8u int10_font_08[256 * 8];
00102 extern Bit8u int10_font_14[256 * 14];
00103 extern Bit8u int10_font_16[256 * 16];
00104 
00105 struct VideoModeBlock {
00106         Bit16u  mode;
00107         VGAModes        type;
00108         Bitu    swidth, sheight;
00109         Bitu    twidth, theight;
00110         Bitu    cwidth, cheight;
00111         Bitu    ptotal,pstart,plength;
00112 
00113         Bitu    htotal,vtotal;
00114         Bitu    hdispend,vdispend;
00115         Bitu    special;
00116         
00117 };
00118 extern VideoModeBlock ModeList_VGA[];
00119 extern VideoModeBlock * CurMode;
00120 
00121 typedef struct {
00122         struct {
00123                 RealPt font_8_first;
00124                 RealPt font_8_second;
00125                 RealPt font_14;
00126                 RealPt font_16;
00127                 RealPt font_14_alternate;
00128                 RealPt font_16_alternate;
00129                 RealPt static_state;
00130                 RealPt video_save_pointers;
00131                 RealPt video_parameter_table;
00132                 RealPt video_save_pointer_table;
00133                 RealPt video_dcc_table;
00134                 RealPt oemstring;
00135                 RealPt vesa_modes;
00136                 RealPt pmode_interface;
00137                 Bit16u pmode_interface_size;
00138                 Bit16u pmode_interface_start;
00139                 Bit16u pmode_interface_window;
00140                 Bit16u pmode_interface_palette;
00141                 Bit16u used;
00142         } rom;
00143         Bit16u vesa_setmode;
00144         bool vesa_nolfb;
00145         bool vesa_oldvbe;
00146 } Int10Data;
00147 
00148 #define _EGA_HALF_CLOCK                 0x0001
00149 #define _DOUBLESCAN                         0x0002  /* CGA/EGA on VGA doublescan (bit 7 of max scanline) */
00150 #define _VGA_PIXEL_DOUBLE               0x0004
00151 #define _S3_PIXEL_DOUBLE                0x0008
00152 #define _REPEAT1                            0x0010  /* VGA doublescan (bit 0 of max scanline) */
00153 #define _CGA_SYNCDOUBLE                 0x0020
00154 
00155 extern Int10Data int10;
00156 
00157 static inline Bit8u CURSOR_POS_COL(Bit8u page) {
00158         return real_readb(BIOSMEM_SEG,BIOSMEM_CURSOR_POS+page*2u);
00159 }
00160 
00161 static inline Bit8u CURSOR_POS_ROW(Bit8u page) {
00162         return real_readb(BIOSMEM_SEG,BIOSMEM_CURSOR_POS+page*2u+1u);
00163 }
00164 
00165 bool INT10_SetVideoMode(Bit16u mode);
00166 
00167 void INT10_ScrollWindow(Bit8u rul,Bit8u cul,Bit8u rlr,Bit8u clr,Bit8s nlines,Bit8u attr,Bit8u page);
00168 
00169 void INT10_SetActivePage(Bit8u page);
00170 bool INT10_SetCurMode(void);
00171 void INT10_DisplayCombinationCode(Bit16u * dcc,bool set);
00172 void INT10_GetFuncStateInformation(PhysPt save);
00173 
00174 void INT10_SetCursorShape(Bit8u first,Bit8u last);
00175 void INT10_SetCursorPos(Bit8u row,Bit8u col,Bit8u page);
00176 void INT10_TeletypeOutput(Bit8u chr,Bit8u attr);
00177 void INT10_TeletypeOutputAttr(Bit8u chr,Bit8u attr,bool useattr);
00178 void INT10_ReadCharAttr(Bit16u * result,Bit8u page);
00179 void INT10_WriteChar(Bit16u chr,Bit8u attr,Bit8u page,Bit16u count,bool showattr);
00180 void INT10_WriteString(Bit8u row,Bit8u col,Bit8u flag,Bit8u attr,PhysPt string,Bit16u count,Bit8u page);
00181 
00182 /* Graphics Stuff */
00183 void INT10_PutPixel(Bit16u x,Bit16u y,Bit8u page,Bit8u color);
00184 void INT10_GetPixel(Bit16u x,Bit16u y,Bit8u page,Bit8u * color);
00185 
00186 /* Font Stuff */
00187 void INT10_LoadFont(PhysPt font,bool reload,Bitu count,Bitu offset,Bitu map,Bitu height);
00188 void INT10_ReloadFont(void);
00189 
00190 /* Palette Group */
00191 void INT10_SetBackgroundBorder(Bit8u val);
00192 void INT10_SetColorSelect(Bit8u val);
00193 void INT10_SetSinglePaletteRegister(Bit8u reg,Bit8u val);
00194 void INT10_SetOverscanBorderColor(Bit8u val);
00195 void INT10_SetAllPaletteRegisters(PhysPt data);
00196 void INT10_ToggleBlinkingBit(Bit8u state);
00197 void INT10_GetSinglePaletteRegister(Bit8u reg,Bit8u * val);
00198 void INT10_GetOverscanBorderColor(Bit8u * val);
00199 void INT10_GetAllPaletteRegisters(PhysPt data);
00200 void INT10_SetSingleDACRegister(Bit8u index,Bit8u red,Bit8u green,Bit8u blue);
00201 void INT10_GetSingleDACRegister(Bit8u index,Bit8u * red,Bit8u * green,Bit8u * blue);
00202 void INT10_SetDACBlock(Bit16u index,Bit16u count,PhysPt data);
00203 void INT10_GetDACBlock(Bit16u index,Bit16u count,PhysPt data);
00204 void INT10_SelectDACPage(Bit8u function,Bit8u mode);
00205 void INT10_GetDACPage(Bit8u* mode,Bit8u* page);
00206 void INT10_SetPelMask(Bit8u mask);
00207 void INT10_GetPelMask(Bit8u & mask);
00208 void INT10_PerformGrayScaleSumming(Bit16u start_reg,Bit16u count);
00209 
00210 
00211 /* Vesa Group */
00212 Bit8u VESA_GetSVGAInformation(Bit16u seg,Bit16u off);
00213 Bit8u VESA_GetSVGAModeInformation(Bit16u mode,Bit16u seg,Bit16u off);
00214 Bit8u VESA_SetSVGAMode(Bit16u mode);
00215 Bit8u VESA_GetSVGAMode(Bit16u & mode);
00216 Bit8u VESA_SetCPUWindow(Bit8u window,Bit8u address);
00217 Bit8u VESA_GetCPUWindow(Bit8u window,Bit16u & address);
00218 Bit8u VESA_ScanLineLength(Bit8u subcall, Bit16u val, Bit16u & bytes,Bit16u & pixels,Bit16u & lines);
00219 Bit8u VESA_SetDisplayStart(Bit16u x,Bit16u y);
00220 Bit8u VESA_GetDisplayStart(Bit16u & x,Bit16u & y);
00221 Bit8u VESA_SetPalette(PhysPt data,Bitu index,Bitu count);
00222 Bit8u VESA_GetPalette(PhysPt data,Bitu index,Bitu count);
00223 
00224 /* Sub Groups */
00225 void INT10_SetupRomMemory(void);
00226 void INT10_SetupRomMemoryChecksum(void);
00227 void INT10_SetupVESA(void);
00228 
00229 /* EGA RIL */
00230 RealPt INT10_EGA_RIL_GetVersionPt(void);
00231 void INT10_EGA_RIL_ReadRegister(Bit8u & bl, Bit16u dx);
00232 void INT10_EGA_RIL_WriteRegister(Bit8u & bl, Bit8u bh, Bit16u dx);
00233 void INT10_EGA_RIL_ReadRegisterRange(Bit8u ch, Bit8u cl, Bit16u dx, PhysPt dst);
00234 void INT10_EGA_RIL_WriteRegisterRange(Bit8u ch, Bit8u cl, Bit16u dx, PhysPt dst);
00235 void INT10_EGA_RIL_ReadRegisterSet(Bit16u cx, PhysPt tbl);
00236 void INT10_EGA_RIL_WriteRegisterSet(Bit16u cx, PhysPt tbl);
00237 
00238 /* Video State */
00239 Bitu INT10_VideoState_GetSize(Bitu state);
00240 bool INT10_VideoState_Save(Bitu state,RealPt buffer);
00241 bool INT10_VideoState_Restore(Bitu state,RealPt buffer);
00242 
00243 /* Video Parameter Tables */
00244 Bit16u INT10_SetupVideoParameterTable(PhysPt basepos);
00245 void INT10_SetupBasicVideoParameterTable(void);