ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

xboxvideo.c
Go to the documentation of this file.
00001 /* $Id: xboxvideo.c 52526 2011-07-03 23:01:39Z rharabien $
00002  *
00003  *  FreeLoader
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License along
00016  *  with this program; if not, write to the Free Software Foundation, Inc.,
00017  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  *
00019  * Note: much of this code was based on knowledge and/or code developed
00020  * by the Xbox Linux group: http://www.xbox-linux.org
00021  */
00022 
00023 #include <freeldr.h>
00024 
00025 static PVOID FrameBuffer;
00026 static ULONG ScreenWidth;
00027 static ULONG ScreenHeight;
00028 static ULONG BytesPerPixel;
00029 static ULONG Delta;
00030 
00031 #define CHAR_WIDTH  8
00032 #define CHAR_HEIGHT 16
00033 
00034 #define TOP_BOTTOM_LINES 0
00035 
00036 #define FB_SIZE_MB 4
00037 
00038 #define MAKE_COLOR(Red, Green, Blue) (0xff000000 | (((Red) & 0xff) << 16) | (((Green) & 0xff) << 8) | ((Blue) & 0xff))
00039 
00040 BOOLEAN I2CTransmitByteGetReturn(UCHAR bPicAddressI2cFormat, UCHAR bDataToWrite, ULONG *Return);
00041 
00042 static VOID
00043 XboxVideoOutputChar(UCHAR Char, unsigned X, unsigned Y, ULONG FgColor, ULONG BgColor)
00044 {
00045   PUCHAR FontPtr;
00046   PULONG Pixel;
00047   UCHAR Mask;
00048   unsigned Line;
00049   unsigned Col;
00050 
00051   FontPtr = XboxFont8x16 + Char * 16;
00052   Pixel = (PULONG) ((char *) FrameBuffer + (Y * CHAR_HEIGHT + TOP_BOTTOM_LINES) * Delta
00053                   + X * CHAR_WIDTH * BytesPerPixel);
00054   for (Line = 0; Line < CHAR_HEIGHT; Line++)
00055     {
00056       Mask = 0x80;
00057       for (Col = 0; Col < CHAR_WIDTH; Col++)
00058         {
00059           Pixel[Col] = (0 != (FontPtr[Line] & Mask) ? FgColor : BgColor);
00060           Mask = Mask >> 1;
00061         }
00062       Pixel = (PULONG) ((char *) Pixel + Delta);
00063     }
00064 }
00065 
00066 static ULONG
00067 XboxVideoAttrToSingleColor(UCHAR Attr)
00068 {
00069   UCHAR Intensity;
00070 
00071   Intensity = (0 == (Attr & 0x08) ? 127 : 255);
00072 
00073   return 0xff000000 |
00074          (0 == (Attr & 0x04) ? 0 : (Intensity << 16)) |
00075          (0 == (Attr & 0x02) ? 0 : (Intensity << 8)) |
00076          (0 == (Attr & 0x01) ? 0 : Intensity);
00077 }
00078 
00079 static VOID
00080 XboxVideoAttrToColors(UCHAR Attr, ULONG *FgColor, ULONG *BgColor)
00081 {
00082   *FgColor = XboxVideoAttrToSingleColor(Attr & 0xf);
00083   *BgColor = XboxVideoAttrToSingleColor((Attr >> 4) & 0xf);
00084 }
00085 
00086 static VOID
00087 XboxVideoClearScreenColor(ULONG Color, BOOLEAN FullScreen)
00088 {
00089   ULONG Line, Col;
00090   PULONG p;
00091 
00092   for (Line = 0; Line < ScreenHeight - (FullScreen ? 0 : 2 * TOP_BOTTOM_LINES); Line++)
00093     {
00094       p = (PULONG) ((char *) FrameBuffer + (Line + (FullScreen ? 0 : TOP_BOTTOM_LINES)) * Delta);
00095       for (Col = 0; Col < ScreenWidth; Col++)
00096         {
00097           *p++ = Color;
00098         }
00099     }
00100 }
00101 
00102 VOID
00103 XboxVideoClearScreen(UCHAR Attr)
00104 {
00105   ULONG FgColor, BgColor;
00106 
00107   XboxVideoAttrToColors(Attr, &FgColor, &BgColor);
00108 
00109   XboxVideoClearScreenColor(BgColor, FALSE);
00110 }
00111 
00112 VOID
00113 XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
00114 {
00115   ULONG FgColor, BgColor;
00116 
00117   XboxVideoAttrToColors(Attr, &FgColor, &BgColor);
00118 
00119   XboxVideoOutputChar(Ch, X, Y, FgColor, BgColor);
00120 }
00121 
00122 VOID
00123 XboxVideoInit(VOID)
00124 {
00125   ULONG AvMode;
00126 
00127   FrameBuffer = (PVOID)((ULONG) XboxMemReserveMemory(FB_SIZE_MB) | 0xf0000000);
00128 
00129   if (I2CTransmitByteGetReturn(0x10, 0x04, &AvMode))
00130     {
00131       if (1 == AvMode) /* HDTV */
00132         {
00133           ScreenWidth = 720;
00134         }
00135       else
00136         {
00137           /* FIXME Other possible values of AvMode:
00138            * 0 - AV_SCART_RGB
00139            * 2 - AV_VGA_SOG
00140            * 4 - AV_SVIDEO
00141            * 6 - AV_COMPOSITE
00142            * 7 - AV_VGA
00143            * other AV_COMPOSITE
00144            */
00145           ScreenWidth = 640;
00146         }
00147     }
00148   else
00149     {
00150       ScreenWidth = 640;
00151     }
00152 
00153   ScreenHeight = 480;
00154   BytesPerPixel = 4;
00155   Delta = (ScreenWidth * BytesPerPixel + 3) & ~ 0x3;
00156 
00157   XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE);
00158 
00159   /* Tell the nVidia controller about the framebuffer */
00160   *((PULONG) 0xfd600800) = (ULONG) FrameBuffer;
00161 }
00162 
00163 VIDEODISPLAYMODE
00164 XboxVideoSetDisplayMode(char *DisplayMode, BOOLEAN Init)
00165 {
00166   /* We only have one mode, semi-text */
00167   return VideoTextMode;
00168 }
00169 
00170 VOID
00171 XboxVideoGetDisplaySize(PULONG Width, PULONG Height, PULONG Depth)
00172 {
00173   *Width = ScreenWidth / CHAR_WIDTH;
00174   *Height = (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT;
00175   *Depth = 0;
00176 }
00177 
00178 ULONG
00179 XboxVideoGetBufferSize(VOID)
00180 {
00181   return (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT * (ScreenWidth / CHAR_WIDTH) * 2;
00182 }
00183 
00184 VOID
00185 XboxVideoSetTextCursorPosition(UCHAR X, UCHAR Y)
00186 {
00187   /* We don't have a cursor yet */
00188 }
00189 
00190 VOID
00191 XboxVideoHideShowTextCursor(BOOLEAN Show)
00192 {
00193   /* We don't have a cursor yet */
00194 }
00195 
00196 VOID
00197 XboxVideoCopyOffScreenBufferToVRAM(PVOID Buffer)
00198 {
00199   PUCHAR OffScreenBuffer = (PUCHAR) Buffer;
00200   ULONG Col, Line;
00201 
00202   for (Line = 0; Line < (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT; Line++)
00203     {
00204       for (Col = 0; Col < ScreenWidth / CHAR_WIDTH; Col++)
00205         {
00206           XboxVideoPutChar(OffScreenBuffer[0], OffScreenBuffer[1], Col, Line);
00207           OffScreenBuffer += 2;
00208         }
00209     }
00210 }
00211 
00212 BOOLEAN
00213 XboxVideoIsPaletteFixed(VOID)
00214 {
00215   return FALSE;
00216 }
00217 
00218 VOID
00219 XboxVideoSetPaletteColor(UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
00220 {
00221   /* Not supported */
00222 }
00223 
00224 VOID
00225 XboxVideoGetPaletteColor(UCHAR Color, UCHAR* Red, UCHAR* Green, UCHAR* Blue)
00226 {
00227   /* Not supported */
00228 }
00229 
00230 VOID
00231 XboxVideoSync()
00232 {
00233   /* Not supported */
00234 }
00235 
00236 VOID
00237 XboxBeep()
00238 {
00239     /* Call PC version */
00240     PcBeep();
00241 }
00242 
00243 VOID
00244 XboxVideoPrepareForReactOS(IN BOOLEAN Setup)
00245 {
00246   XboxVideoClearScreenColor(MAKE_COLOR(0, 0, 0), TRUE);
00247 }
00248 
00249 /* EOF */

Generated on Sat May 26 2012 04:17:53 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.