ReactOS  0.4.14-dev-554-g2f8d847
xboxvideo.c File Reference
#include <freeldr.h>
#include <debug.h>
Include dependency graph for xboxvideo.c:

Go to the source code of this file.

Macros

#define CHAR_WIDTH   8
 
#define CHAR_HEIGHT   16
 
#define TOP_BOTTOM_LINES   0
 
#define FB_SIZE_MB   4
 
#define MAKE_COLOR(Red, Green, Blue)   (0xff000000 | (((Red) & 0xff) << 16) | (((Green) & 0xff) << 8) | ((Blue) & 0xff))
 

Functions

 DBG_DEFAULT_CHANNEL (UI)
 
static VOID XboxVideoOutputChar (UCHAR Char, unsigned X, unsigned Y, ULONG FgColor, ULONG BgColor)
 
static ULONG XboxVideoAttrToSingleColor (UCHAR Attr)
 
static VOID XboxVideoAttrToColors (UCHAR Attr, ULONG *FgColor, ULONG *BgColor)
 
static VOID XboxVideoClearScreenColor (ULONG Color, BOOLEAN FullScreen)
 
VOID XboxVideoClearScreen (UCHAR Attr)
 
VOID XboxVideoPutChar (int Ch, UCHAR Attr, unsigned X, unsigned Y)
 
UCHAR NvGetCrtc (UCHAR Index)
 
VOID XboxVideoInit (VOID)
 
VIDEODISPLAYMODE XboxVideoSetDisplayMode (char *DisplayMode, BOOLEAN Init)
 
VOID XboxVideoGetDisplaySize (PULONG Width, PULONG Height, PULONG Depth)
 
ULONG XboxVideoGetBufferSize (VOID)
 
VOID XboxVideoGetFontsFromFirmware (PULONG RomFontPointers)
 
VOID XboxVideoSetTextCursorPosition (UCHAR X, UCHAR Y)
 
VOID XboxVideoHideShowTextCursor (BOOLEAN Show)
 
VOID XboxVideoCopyOffScreenBufferToVRAM (PVOID Buffer)
 
BOOLEAN XboxVideoIsPaletteFixed (VOID)
 
VOID XboxVideoSetPaletteColor (UCHAR Color, UCHAR Red, UCHAR Green, UCHAR Blue)
 
VOID XboxVideoGetPaletteColor (UCHAR Color, UCHAR *Red, UCHAR *Green, UCHAR *Blue)
 
VOID XboxVideoSync (VOID)
 
VOID XboxBeep (VOID)
 
VOID XboxVideoPrepareForReactOS (VOID)
 

Variables

PVOID FrameBuffer
 
ULONG FrameBufferSize
 
static ULONG ScreenWidth
 
static ULONG ScreenHeight
 
static ULONG BytesPerPixel
 
static ULONG Delta
 

Macro Definition Documentation

◆ CHAR_HEIGHT

#define CHAR_HEIGHT   16

Definition at line 35 of file xboxvideo.c.

◆ CHAR_WIDTH

#define CHAR_WIDTH   8

Definition at line 34 of file xboxvideo.c.

◆ FB_SIZE_MB

#define FB_SIZE_MB   4

Definition at line 39 of file xboxvideo.c.

◆ MAKE_COLOR

#define MAKE_COLOR (   Red,
  Green,
  Blue 
)    (0xff000000 | (((Red) & 0xff) << 16) | (((Green) & 0xff) << 8) | ((Blue) & 0xff))

Definition at line 41 of file xboxvideo.c.

◆ TOP_BOTTOM_LINES

#define TOP_BOTTOM_LINES   0

Definition at line 37 of file xboxvideo.c.

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UI  )

◆ NvGetCrtc()

UCHAR NvGetCrtc ( UCHAR  Index)

Definition at line 124 of file xboxvideo.c.

125 {
127  return *((PUCHAR) NV2A_CRTC_REGISTER_VALUE);
128 }
unsigned char * PUCHAR
Definition: retypes.h:3
#define NV2A_CRTC_REGISTER_VALUE
Definition: machxbox.h:44
#define NV2A_CRTC_REGISTER_INDEX
Definition: machxbox.h:43
static const UCHAR Index[8]
Definition: usbohci.c:18

Referenced by XboxVideoInit().

◆ XboxBeep()

VOID XboxBeep ( VOID  )

Definition at line 245 of file xboxvideo.c.

246 {
247  /* Call PC version */
248  PcBeep();
249 }
VOID PcBeep(VOID)
Definition: i386rtl.c:25

◆ XboxVideoAttrToColors()

static VOID XboxVideoAttrToColors ( UCHAR  Attr,
ULONG FgColor,
ULONG BgColor 
)
static

Definition at line 81 of file xboxvideo.c.

82 {
83  *FgColor = XboxVideoAttrToSingleColor(Attr & 0xf);
84  *BgColor = XboxVideoAttrToSingleColor((Attr >> 4) & 0xf);
85 }
static ULONG XboxVideoAttrToSingleColor(UCHAR Attr)
Definition: xboxvideo.c:68

Referenced by XboxVideoClearScreen(), and XboxVideoPutChar().

◆ XboxVideoAttrToSingleColor()

static ULONG XboxVideoAttrToSingleColor ( UCHAR  Attr)
static

Definition at line 68 of file xboxvideo.c.

69 {
71 
72  Intensity = (0 == (Attr & 0x08) ? 127 : 255);
73 
74  return 0xff000000 |
75  (0 == (Attr & 0x04) ? 0 : (Intensity << 16)) |
76  (0 == (Attr & 0x02) ? 0 : (Intensity << 8)) |
77  (0 == (Attr & 0x01) ? 0 : Intensity);
78 }
unsigned char UCHAR
Definition: xmlstorage.h:181
static WORD Intensity(RGBQUAD clr)
Definition: msrle32.c:44

Referenced by XboxVideoAttrToColors().

◆ XboxVideoClearScreen()

VOID XboxVideoClearScreen ( UCHAR  Attr)

Definition at line 104 of file xboxvideo.c.

105 {
106  ULONG FgColor, BgColor;
107 
108  XboxVideoAttrToColors(Attr, &FgColor, &BgColor);
109 
111 }
static VOID XboxVideoClearScreenColor(ULONG Color, BOOLEAN FullScreen)
Definition: xboxvideo.c:88
static VOID XboxVideoAttrToColors(UCHAR Attr, ULONG *FgColor, ULONG *BgColor)
Definition: xboxvideo.c:81
unsigned int ULONG
Definition: retypes.h:1

Referenced by XboxMachInit().

◆ XboxVideoClearScreenColor()

static VOID XboxVideoClearScreenColor ( ULONG  Color,
BOOLEAN  FullScreen 
)
static

Definition at line 88 of file xboxvideo.c.

89 {
90  ULONG Line, Col;
91  PULONG p;
92 
93  for (Line = 0; Line < ScreenHeight - (FullScreen ? 0 : 2 * TOP_BOTTOM_LINES); Line++)
94  {
95  p = (PULONG) ((char *) FrameBuffer + (Line + (FullScreen ? 0 : TOP_BOTTOM_LINES)) * Delta);
96  for (Col = 0; Col < ScreenWidth; Col++)
97  {
98  *p++ = Color;
99  }
100  }
101 }
#define TOP_BOTTOM_LINES
Definition: xboxvideo.c:37
static ULONG ScreenWidth
Definition: xboxvideo.c:29
struct Color Color
static ULONG ScreenHeight
Definition: xboxvideo.c:30
Definition: ncftp.h:79
PVOID FrameBuffer
Definition: xboxvideo.c:27
static ULONG Delta
Definition: xboxvideo.c:32
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
GLfloat GLfloat p
Definition: glext.h:8902
struct Line Line

Referenced by XboxVideoClearScreen(), XboxVideoInit(), and XboxVideoPrepareForReactOS().

◆ XboxVideoCopyOffScreenBufferToVRAM()

VOID XboxVideoCopyOffScreenBufferToVRAM ( PVOID  Buffer)

Definition at line 205 of file xboxvideo.c.

206 {
207  PUCHAR OffScreenBuffer = (PUCHAR) Buffer;
208  ULONG Col, Line;
209 
210  for (Line = 0; Line < (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT; Line++)
211  {
212  for (Col = 0; Col < ScreenWidth / CHAR_WIDTH; Col++)
213  {
214  XboxVideoPutChar(OffScreenBuffer[0], OffScreenBuffer[1], Col, Line);
215  OffScreenBuffer += 2;
216  }
217  }
218 }
unsigned char * PUCHAR
Definition: retypes.h:3
#define TOP_BOTTOM_LINES
Definition: xboxvideo.c:37
static ULONG ScreenWidth
Definition: xboxvideo.c:29
Definition: bufpool.h:45
static ULONG ScreenHeight
Definition: xboxvideo.c:30
Definition: ncftp.h:79
#define CHAR_WIDTH
Definition: xboxvideo.c:34
VOID XboxVideoPutChar(int Ch, UCHAR Attr, unsigned X, unsigned Y)
Definition: xboxvideo.c:114
#define CHAR_HEIGHT
Definition: xboxvideo.c:35
unsigned int ULONG
Definition: retypes.h:1
struct Line Line

Referenced by XboxMachInit().

◆ XboxVideoGetBufferSize()

ULONG XboxVideoGetBufferSize ( VOID  )

Definition at line 181 of file xboxvideo.c.

182 {
184 }
#define TOP_BOTTOM_LINES
Definition: xboxvideo.c:37
static ULONG ScreenWidth
Definition: xboxvideo.c:29
static ULONG ScreenHeight
Definition: xboxvideo.c:30
#define CHAR_WIDTH
Definition: xboxvideo.c:34
#define CHAR_HEIGHT
Definition: xboxvideo.c:35

Referenced by XboxMachInit().

◆ XboxVideoGetDisplaySize()

VOID XboxVideoGetDisplaySize ( PULONG  Width,
PULONG  Height,
PULONG  Depth 
)

Definition at line 173 of file xboxvideo.c.

174 {
175  *Width = ScreenWidth / CHAR_WIDTH;
176  *Height = (ScreenHeight - 2 * TOP_BOTTOM_LINES) / CHAR_HEIGHT;
177  *Depth = 0;
178 }
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION _In_ ULONG _In_ SIZE_T _In_ ULONG _In_ USHORT Depth
Definition: exfuncs.h:656
#define TOP_BOTTOM_LINES
Definition: xboxvideo.c:37
static ULONG ScreenWidth
Definition: xboxvideo.c:29
static ULONG ScreenHeight
Definition: xboxvideo.c:30
#define CHAR_WIDTH
Definition: xboxvideo.c:34
#define CHAR_HEIGHT
Definition: xboxvideo.c:35

Referenced by XboxConsPutChar(), and XboxMachInit().

◆ XboxVideoGetFontsFromFirmware()

VOID XboxVideoGetFontsFromFirmware ( PULONG  RomFontPointers)

Definition at line 187 of file xboxvideo.c.

188 {
189  TRACE("XboxVideoGetFontsFromFirmware(): UNIMPLEMENTED\n");
190 }
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by XboxMachInit().

◆ XboxVideoGetPaletteColor()

VOID XboxVideoGetPaletteColor ( UCHAR  Color,
UCHAR Red,
UCHAR Green,
UCHAR Blue 
)

Definition at line 233 of file xboxvideo.c.

234 {
235  /* Not supported */
236 }

Referenced by XboxMachInit().

◆ XboxVideoHideShowTextCursor()

VOID XboxVideoHideShowTextCursor ( BOOLEAN  Show)

Definition at line 199 of file xboxvideo.c.

200 {
201  /* We don't have a cursor yet */
202 }

Referenced by XboxMachInit(), and XboxVideoPrepareForReactOS().

◆ XboxVideoInit()

VOID XboxVideoInit ( VOID  )

Definition at line 131 of file xboxvideo.c.

132 {
133  /* Reuse framebuffer that was set up by firmware */
135  /* Verify that framebuffer address is page-aligned */
137 
138  /* FIXME: obtain fb size from firmware somehow (Cromwell reserves high 4 MB of RAM) */
139  FrameBufferSize = 4 * 1024 * 1024;
140 
143  /* Get BPP directly from NV2A CRTC (magic constants are from Cromwell) */
144  BytesPerPixel = 8 * (((NvGetCrtc(0x19) & 0xE0) << 3) | (NvGetCrtc(0x13) & 0xFF)) / ScreenWidth;
145  if (BytesPerPixel == 4)
146  {
147  ASSERT((NvGetCrtc(0x28) & 0xF) == BytesPerPixel - 1);
148  }
149  else
150  {
151  ASSERT((NvGetCrtc(0x28) & 0xF) == BytesPerPixel);
152  }
153  Delta = (ScreenWidth * BytesPerPixel + 3) & ~ 0x3;
154 
155  /* Verify screen resolution */
156  ASSERT(ScreenWidth > 1);
157  ASSERT(ScreenHeight > 1);
158  ASSERT(BytesPerPixel >= 1 && BytesPerPixel <= 4);
159  /* Verify that screen fits framebuffer size */
161 
163 }
#define TRUE
Definition: types.h:120
static VOID XboxVideoClearScreenColor(ULONG Color, BOOLEAN FullScreen)
Definition: xboxvideo.c:88
static ULONG BytesPerPixel
Definition: xboxvideo.c:31
static ULONG ScreenWidth
Definition: xboxvideo.c:29
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define NV2A_RAMDAC_FP_VVALID_END
Definition: machxbox.h:47
ULONG FrameBufferSize
Definition: xboxvideo.c:28
void * PVOID
Definition: retypes.h:9
#define NV2A_CRTC_FRAMEBUFFER_START
Definition: machxbox.h:42
static ULONG ScreenHeight
Definition: xboxvideo.c:30
UCHAR NvGetCrtc(UCHAR Index)
Definition: xboxvideo.c:124
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define PAGE_SIZE
Definition: env_spec_w32.h:49
PVOID FrameBuffer
Definition: xboxvideo.c:27
static ULONG Delta
Definition: xboxvideo.c:32
unsigned int * PULONG
Definition: retypes.h:1
#define MAKE_COLOR(Red, Green, Blue)
Definition: xboxvideo.c:41
#define NV2A_RAMDAC_FP_HVALID_END
Definition: machxbox.h:46

Referenced by XboxMachInit().

◆ XboxVideoIsPaletteFixed()

BOOLEAN XboxVideoIsPaletteFixed ( VOID  )

Definition at line 221 of file xboxvideo.c.

222 {
223  return FALSE;
224 }

Referenced by XboxMachInit().

◆ XboxVideoOutputChar()

static VOID XboxVideoOutputChar ( UCHAR  Char,
unsigned  X,
unsigned  Y,
ULONG  FgColor,
ULONG  BgColor 
)
static

Definition at line 44 of file xboxvideo.c.

45 {
46  PUCHAR FontPtr;
47  PULONG Pixel;
48  UCHAR Mask;
49  unsigned Line;
50  unsigned Col;
51 
52  FontPtr = XboxFont8x16 + Char * 16;
53  Pixel = (PULONG) ((char *) FrameBuffer + (Y * CHAR_HEIGHT + TOP_BOTTOM_LINES) * Delta
54  + X * CHAR_WIDTH * BytesPerPixel);
55  for (Line = 0; Line < CHAR_HEIGHT; Line++)
56  {
57  Mask = 0x80;
58  for (Col = 0; Col < CHAR_WIDTH; Col++)
59  {
60  Pixel[Col] = (0 != (FontPtr[Line] & Mask) ? FgColor : BgColor);
61  Mask = Mask >> 1;
62  }
63  Pixel = (PULONG) ((char *) Pixel + Delta);
64  }
65 }
#define Y(I)
static ULONG BytesPerPixel
Definition: xboxvideo.c:31
unsigned char * PUCHAR
Definition: retypes.h:3
#define TOP_BOTTOM_LINES
Definition: xboxvideo.c:37
UCHAR XboxFont8x16[256 *16]
Definition: xboxfont.c:23
Definition: ncftp.h:79
#define CHAR_WIDTH
Definition: xboxvideo.c:34
unsigned char UCHAR
Definition: xmlstorage.h:181
#define CHAR_HEIGHT
Definition: xboxvideo.c:35
PVOID FrameBuffer
Definition: xboxvideo.c:27
static ULONG Delta
Definition: xboxvideo.c:32
unsigned int * PULONG
Definition: retypes.h:1
struct Line Line

Referenced by XboxVideoPutChar().

◆ XboxVideoPrepareForReactOS()

VOID XboxVideoPrepareForReactOS ( VOID  )

Definition at line 252 of file xboxvideo.c.

253 {
256 }
#define TRUE
Definition: types.h:120
static VOID XboxVideoClearScreenColor(ULONG Color, BOOLEAN FullScreen)
Definition: xboxvideo.c:88
VOID XboxVideoHideShowTextCursor(BOOLEAN Show)
Definition: xboxvideo.c:199
#define MAKE_COLOR(Red, Green, Blue)
Definition: xboxvideo.c:41

Referenced by XboxPrepareForReactOS().

◆ XboxVideoPutChar()

VOID XboxVideoPutChar ( int  Ch,
UCHAR  Attr,
unsigned  X,
unsigned  Y 
)

Definition at line 114 of file xboxvideo.c.

115 {
116  ULONG FgColor, BgColor;
117 
118  XboxVideoAttrToColors(Attr, &FgColor, &BgColor);
119 
120  XboxVideoOutputChar(Ch, X, Y, FgColor, BgColor);
121 }
static VOID XboxVideoOutputChar(UCHAR Char, unsigned X, unsigned Y, ULONG FgColor, ULONG BgColor)
Definition: xboxvideo.c:44
#define Y(I)
#define Ch(x, y, z)
Definition: sha2.c:141
static VOID XboxVideoAttrToColors(UCHAR Attr, ULONG *FgColor, ULONG *BgColor)
Definition: xboxvideo.c:81
unsigned int ULONG
Definition: retypes.h:1

Referenced by XboxConsPutChar(), XboxMachInit(), and XboxVideoCopyOffScreenBufferToVRAM().

◆ XboxVideoSetDisplayMode()

VIDEODISPLAYMODE XboxVideoSetDisplayMode ( char DisplayMode,
BOOLEAN  Init 
)

Definition at line 166 of file xboxvideo.c.

167 {
168  /* We only have one mode, semi-text */
169  return VideoTextMode;
170 }

Referenced by XboxMachInit().

◆ XboxVideoSetPaletteColor()

VOID XboxVideoSetPaletteColor ( UCHAR  Color,
UCHAR  Red,
UCHAR  Green,
UCHAR  Blue 
)

Definition at line 227 of file xboxvideo.c.

228 {
229  /* Not supported */
230 }

Referenced by XboxMachInit().

◆ XboxVideoSetTextCursorPosition()

VOID XboxVideoSetTextCursorPosition ( UCHAR  X,
UCHAR  Y 
)

Definition at line 193 of file xboxvideo.c.

194 {
195  /* We don't have a cursor yet */
196 }

Referenced by XboxMachInit().

◆ XboxVideoSync()

VOID XboxVideoSync ( VOID  )

Definition at line 239 of file xboxvideo.c.

240 {
241  /* Not supported */
242 }

Referenced by XboxMachInit().

Variable Documentation

◆ BytesPerPixel

ULONG BytesPerPixel
static

◆ Delta

◆ FrameBuffer

◆ FrameBufferSize

ULONG FrameBufferSize

◆ ScreenHeight

◆ ScreenWidth