DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
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 extern uint32_t S3_LFB_BASE;
00023 
00024 #define BIOSMEM_SEG             0x40u
00025 
00026 #define BIOSMEM_INITIAL_MODE  0x10u
00027 #define BIOSMEM_CURRENT_MODE  0x49u
00028 #define BIOSMEM_NB_COLS       0x4Au
00029 #define BIOSMEM_PAGE_SIZE     0x4Cu
00030 #define BIOSMEM_CURRENT_START 0x4Eu
00031 #define BIOSMEM_CURSOR_POS    0x50u
00032 #define BIOSMEM_CURSOR_TYPE   0x60u
00033 #define BIOSMEM_CURRENT_PAGE  0x62u
00034 #define BIOSMEM_CRTC_ADDRESS  0x63u
00035 #define BIOSMEM_CURRENT_MSR   0x65u
00036 #define BIOSMEM_CURRENT_PAL   0x66u
00037 #define BIOSMEM_NB_ROWS       0x84u
00038 #define BIOSMEM_CHAR_HEIGHT   0x85u
00039 #define BIOSMEM_VIDEO_CTL     0x87u
00040 #define BIOSMEM_SWITCHES      0x88u
00041 #define BIOSMEM_MODESET_CTL   0x89u
00042 #define BIOSMEM_DCC_INDEX     0x8Au
00043 #define BIOSMEM_CRTCPU_PAGE   0x8Au
00044 #define BIOSMEM_VS_POINTER    0xA8u
00045 
00046 
00047 /*
00048  *
00049  * VGA registers
00050  *
00051  */
00052 #define VGAREG_ACTL_ADDRESS            0x3c0u
00053 #define VGAREG_ACTL_WRITE_DATA         0x3c0u
00054 #define VGAREG_ACTL_READ_DATA          0x3c1u
00055 
00056 #define VGAREG_INPUT_STATUS            0x3c2u
00057 #define VGAREG_WRITE_MISC_OUTPUT       0x3c2u
00058 #define VGAREG_VIDEO_ENABLE            0x3c3u
00059 #define VGAREG_SEQU_ADDRESS            0x3c4u
00060 #define VGAREG_SEQU_DATA               0x3c5u
00061 
00062 #define VGAREG_PEL_MASK                0x3c6u
00063 #define VGAREG_DAC_STATE               0x3c7u
00064 #define VGAREG_DAC_READ_ADDRESS        0x3c7u
00065 #define VGAREG_DAC_WRITE_ADDRESS       0x3c8u
00066 #define VGAREG_DAC_DATA                0x3c9u
00067 
00068 #define VGAREG_READ_FEATURE_CTL        0x3cau
00069 #define VGAREG_READ_MISC_OUTPUT        0x3ccu
00070 
00071 #define VGAREG_GRDC_ADDRESS            0x3ceu
00072 #define VGAREG_GRDC_DATA               0x3cfu
00073 
00074 #define VGAREG_MDA_CRTC_ADDRESS        0x3b4u
00075 #define VGAREG_MDA_CRTC_DATA           0x3b5u
00076 #define VGAREG_VGA_CRTC_ADDRESS        0x3d4u
00077 #define VGAREG_VGA_CRTC_DATA           0x3d5u
00078 
00079 #define VGAREG_MDA_WRITE_FEATURE_CTL   0x3bau
00080 #define VGAREG_VGA_WRITE_FEATURE_CTL   0x3dau
00081 #define VGAREG_ACTL_RESET              0x3dau
00082 #define VGAREG_TDY_RESET               0x3dau
00083 #define VGAREG_TDY_ADDRESS             0x3dau
00084 #define VGAREG_TDY_DATA                0x3deu
00085 #define VGAREG_PCJR_DATA               0x3dau
00086 
00087 #define VGAREG_MDA_MODECTL             0x3b8u
00088 #define VGAREG_CGA_MODECTL             0x3d8u
00089 #define VGAREG_CGA_PALETTE             0x3d9u
00090 
00091 /* Video memory */
00092 #define VGAMEM_GRAPH 0xA000u
00093 #define VGAMEM_CTEXT 0xB800u
00094 #define VGAMEM_MTEXT 0xB000u
00095 
00096 /* FIXME: Wait, what?? What the hell kind of preprocessor macro is this??? Kill these macros! --J.C. */
00097 #define BIOS_NCOLS Bit16u ncols=IS_PC98_ARCH ? 80 : real_readw(BIOSMEM_SEG,BIOSMEM_NB_COLS);
00098 #define BIOS_NROWS Bit16u nrows=IS_PC98_ARCH ? (Bit16u)(real_readb(0x60,0x112)+1u) : (Bit16u)real_readb(BIOSMEM_SEG,BIOSMEM_NB_ROWS)+1u;
00099 
00100 extern Bit8u int10_font_08[256 * 8];
00101 extern Bit8u int10_font_14[256 * 14];
00102 extern Bit8u int10_font_16[256 * 16];
00103 
00104 struct VideoModeBlock {
00105         Bit16u  mode;
00106         VGAModes        type;
00107         Bitu    swidth, sheight;
00108         Bitu    twidth, theight;
00109         Bitu    cwidth, cheight;
00110         Bitu    ptotal,pstart,plength;
00111 
00112         Bitu    htotal,vtotal;
00113         Bitu    hdispend,vdispend;
00114         Bitu    special;
00115         
00116 };
00117 extern VideoModeBlock ModeList_VGA[];
00118 extern VideoModeBlock * CurMode;
00119 
00120 typedef struct {
00121         struct {
00122                 RealPt font_8_first;
00123                 RealPt font_8_second;
00124                 RealPt font_14;
00125                 RealPt font_16;
00126                 RealPt font_14_alternate;
00127                 RealPt font_16_alternate;
00128                 RealPt static_state;
00129                 RealPt video_save_pointers;
00130                 RealPt video_parameter_table;
00131                 RealPt video_save_pointer_table;
00132                 RealPt video_dcc_table;
00133                 RealPt oemstring;
00134                 RealPt vesa_modes;
00135                 RealPt pmode_interface;
00136                 Bit16u pmode_interface_size;
00137                 Bit16u pmode_interface_start;
00138                 Bit16u pmode_interface_window;
00139                 Bit16u pmode_interface_palette;
00140         Bit16u vesa_alloc_modes;
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 #define _USER_DISABLED          0x4000  /* disabled (cannot set mode) but still listed in modelist */
00155 #define _USER_MODIFIED          0x8000  /* user modified (through VESAMOED) */
00156 
00157 extern Int10Data int10;
00158 
00159 static inline Bit8u CURSOR_POS_COL(Bit8u page) {
00160     if (IS_PC98_ARCH)
00161         return real_readb(0x60,0x11C); /* MS-DOS kernel location */
00162     else
00163         return real_readb(BIOSMEM_SEG,BIOSMEM_CURSOR_POS+page*2u);
00164 }
00165 
00166 static inline Bit8u CURSOR_POS_ROW(Bit8u page) {
00167     if (IS_PC98_ARCH)
00168         return real_readb(0x60,0x110); /* MS-DOS kernel location */
00169     else
00170         return real_readb(BIOSMEM_SEG,BIOSMEM_CURSOR_POS+page*2u+1u);
00171 }
00172 
00174 bool INT10_GetInsertState();
00175 
00176 bool INT10_SetVideoMode(Bit16u mode);
00177 
00178 void INT10_ScrollWindow(Bit8u rul,Bit8u cul,Bit8u rlr,Bit8u clr,Bit8s nlines,Bit8u attr,Bit8u page);
00179 
00180 void INT10_SetActivePage(Bit8u page);
00181 bool INT10_SetCurMode(void);
00182 void INT10_DisplayCombinationCode(Bit16u * dcc,bool set);
00183 void INT10_GetFuncStateInformation(PhysPt save);
00184 
00185 void INT10_SetCursorShape(Bit8u first,Bit8u last);
00186 void INT10_GetScreenColumns(Bit16u* cols);
00187 void INT10_GetCursorPos(Bit8u *row, Bit8u *col, Bit8u page);
00188 void INT10_SetCursorPos(Bit8u row,Bit8u col,Bit8u page);
00189 void INT10_TeletypeOutput(Bit8u chr,Bit8u attr);
00190 void INT10_TeletypeOutputAttr(Bit8u chr,Bit8u attr,bool useattr);
00191 void INT10_ReadCharAttr(Bit16u * result,Bit8u page);
00192 void INT10_WriteChar(Bit16u chr,Bit8u attr,Bit8u page,Bit16u count,bool showattr);
00193 void INT10_WriteString(Bit8u row,Bit8u col,Bit8u flag,Bit8u attr,PhysPt string,Bit16u count,Bit8u page);
00194 
00195 /* Graphics Stuff */
00196 void INT10_PutPixel(Bit16u x,Bit16u y,Bit8u page,Bit8u color);
00197 void INT10_GetPixel(Bit16u x,Bit16u y,Bit8u page,Bit8u * color);
00198 
00199 /* Font Stuff */
00200 void INT10_LoadFont(PhysPt font,bool reload,Bitu count,Bitu offset,Bitu map,Bitu height);
00201 void INT10_ReloadFont(void);
00202 
00203 /* Palette Group */
00204 void INT10_SetBackgroundBorder(Bit8u val);
00205 void INT10_SetColorSelect(Bit8u val);
00206 void INT10_SetSinglePaletteRegister(Bit8u reg,Bit8u val);
00207 void INT10_SetOverscanBorderColor(Bit8u val);
00208 void INT10_SetAllPaletteRegisters(PhysPt data);
00209 void INT10_ToggleBlinkingBit(Bit8u state);
00210 void INT10_GetSinglePaletteRegister(Bit8u reg,Bit8u * val);
00211 void INT10_GetOverscanBorderColor(Bit8u * val);
00212 void INT10_GetAllPaletteRegisters(PhysPt data);
00213 void INT10_SetSingleDACRegister(Bit8u index,Bit8u red,Bit8u green,Bit8u blue);
00214 void INT10_GetSingleDACRegister(Bit8u index,Bit8u * red,Bit8u * green,Bit8u * blue);
00215 void INT10_SetDACBlock(Bit16u index,Bit16u count,PhysPt data);
00216 void INT10_GetDACBlock(Bit16u index,Bit16u count,PhysPt data);
00217 void INT10_SelectDACPage(Bit8u function,Bit8u mode);
00218 void INT10_GetDACPage(Bit8u* mode,Bit8u* page);
00219 void INT10_SetPelMask(Bit8u mask);
00220 void INT10_GetPelMask(Bit8u & mask);
00221 void INT10_PerformGrayScaleSumming(Bit16u start_reg,Bit16u count);
00222 
00223 
00224 /* Vesa Group */
00225 Bit8u VESA_GetSVGAInformation(Bit16u seg,Bit16u off);
00226 Bit8u VESA_GetSVGAModeInformation(Bit16u mode,Bit16u seg,Bit16u off);
00227 Bit8u VESA_SetSVGAMode(Bit16u mode);
00228 Bit8u VESA_GetSVGAMode(Bit16u & mode);
00229 Bit8u VESA_SetCPUWindow(Bit8u window,Bit8u address);
00230 Bit8u VESA_GetCPUWindow(Bit8u window,Bit16u & address);
00231 Bit8u VESA_ScanLineLength(Bit8u subcall, Bit16u val, Bit16u & bytes,Bit16u & pixels,Bit16u & lines);
00232 Bit8u VESA_SetDisplayStart(Bit16u x,Bit16u y);
00233 Bit8u VESA_GetDisplayStart(Bit16u & x,Bit16u & y);
00234 Bit8u VESA_SetPalette(PhysPt data,Bitu index,Bitu count);
00235 Bit8u VESA_GetPalette(PhysPt data,Bitu index,Bitu count);
00236 
00237 /* Sub Groups */
00238 void INT10_SetupRomMemory(void);
00239 void INT10_SetupRomMemoryChecksum(void);
00240 void INT10_SetupVESA(void);
00241 
00242 /* EGA RIL */
00243 RealPt INT10_EGA_RIL_GetVersionPt(void);
00244 void INT10_EGA_RIL_ReadRegister(Bit8u & bl, Bit16u dx);
00245 void INT10_EGA_RIL_WriteRegister(Bit8u & bl, Bit8u bh, Bit16u dx);
00246 void INT10_EGA_RIL_ReadRegisterRange(Bit8u ch, Bit8u cl, Bit16u dx, PhysPt dst);
00247 void INT10_EGA_RIL_WriteRegisterRange(Bit8u ch, Bit8u cl, Bit16u dx, PhysPt dst);
00248 void INT10_EGA_RIL_ReadRegisterSet(Bit16u cx, PhysPt tbl);
00249 void INT10_EGA_RIL_WriteRegisterSet(Bit16u cx, PhysPt tbl);
00250 
00251 /* Video State */
00252 Bitu INT10_VideoState_GetSize(Bitu state);
00253 bool INT10_VideoState_Save(Bitu state,RealPt buffer);
00254 bool INT10_VideoState_Restore(Bitu state,RealPt buffer);
00255 
00256 /* Video Parameter Tables */
00257 Bit16u INT10_SetupVideoParameterTable(PhysPt basepos);
00258 void INT10_SetupBasicVideoParameterTable(void);