Esempio n. 1
0
void init_screen()
{
	void *host_addr = memalign(1024 * 1024, 1024 * 1024);
	assert(host_addr != NULL);

	context = realityInit(0x10000, 1024 * 1024, host_addr);
	assert(context != NULL);

	assert(videoGetState(0, 0, &state) == 0);
	assert(state.state == 0);

	assert(videoGetResolution(state.displayMode.resolution, &res) == 0);

	memset(&vconfig, 0, sizeof(VideoConfiguration));
	vconfig.resolution = state.displayMode.resolution;
	vconfig.format = VIDEO_BUFFER_FORMAT_XRGB;
	vconfig.pitch = res.width * 4;

	assert(videoConfigure(0, &vconfig, NULL, 0) == 0);
	assert(videoGetState(0, 0, &state) == 0);

	s32 buffer_size = 4 * res.width * res.height;

	gcmSetFlipMode(GCM_FLIP_VSYNC);
	makeBuffer(0, buffer_size);
	makeBuffer(1, buffer_size);

	gcmResetFlipStatus();
	flip(1);
}
Esempio n. 2
0
int
initScreen (void *host_addr, u32 size)
{
  // gcmContextData *context = NULL; /* Context to keep track of the RSX
  // buffer. */
  videoState state;
  videoConfiguration vconfig;
  videoResolution res;		/* Screen Resolution */

  /* Initilise Reality, which sets up the command buffer and shared IO memory */
  context = rsxInit (CB_SIZE, size, host_addr);
  if (context == NULL)
    goto error;

  /* Get the state of the display */
  if (videoGetState (0, 0, &state) != 0)
    goto error;

  /* Make sure display is enabled */
  if (state.state != 0)
    goto error;

  /* Get the current resolution */
  if (videoGetResolution (state.displayMode.resolution, &res) != 0)
    goto error;

  /* Configure the buffer format to xRGB */
  memset (&vconfig, 0, sizeof (videoConfiguration));
  vconfig.resolution = state.displayMode.resolution;
  vconfig.format = VIDEO_BUFFER_FORMAT_XRGB;
  vconfig.pitch = res.width * sizeof (u32);
  vconfig.aspect = state.displayMode.aspect;

  waitRSXIdle (context);

  if (videoConfigure (0, &vconfig, NULL, 0) != 0)
    goto error;

  if (videoGetState (0, 0, &state) != 0)
    goto error;

  gcmSetFlipMode (GCM_FLIP_VSYNC);	// Wait for VSYNC to flip

  depth_pitch = res.width * sizeof (u32);
  depth_buffer = (u32 *) rsxMemalign (64, (res.height * depth_pitch) * 2);
  rsxAddressToOffset (depth_buffer, &depth_offset);

  gcmResetFlipStatus ();

  return 0;

  error:
  if (context)
    rsxFinish (context, 0);

  if (host_addr)
    free (host_addr);

  return 1;
}
Esempio n. 3
0
/* Initilize everything. */
void init_screen(displayData *vdat) {
  int i;

  /* Allocate a 1Mb buffer, alligned to a 1Mb boundary to be our shared IO memory with the RSX. */
  void *host_addr = memalign(1024*1024, 1024*1024);
  assert(host_addr != NULL);

  /* Initilise libRSX, which sets up the command buffer and shared IO memory */
  vdat->context = rsxInit(0x10000, 1024*1024, host_addr);
  assert(vdat->context != NULL);

  videoState state;
  s32 status = videoGetState(0, 0, &state); // Get the state of the display
  assert(status == 0);
  assert(state.state == 0); // Make sure display is enabled

  /* Get the current resolution */
  status = videoGetResolution(state.displayMode.resolution, &vdat->res);
  assert(status == 0);

  /* Configure the buffer format to xRGB */
  videoConfiguration vconfig;
  memset(&vconfig, 0, sizeof(videoConfiguration));
  vconfig.resolution = state.displayMode.resolution;
  vconfig.format = VIDEO_BUFFER_FORMAT_XRGB;
  vconfig.pitch = vdat->res.width * 4;
  vconfig.aspect=state.displayMode.aspect;

  status = videoConfigure(0, &vconfig, NULL, 0);
  assert(status == 0);
  status = videoGetState(0, 0, &state);
  assert(status == 0);

  gcmSetFlipMode(GCM_FLIP_VSYNC); /* Wait for VSYNC to flip */

  /* Allocate and setup two buffers for the RSX to draw to the screen (double buffering) */
  vdat->pitch = vdat->res.width*sizeof(u32);
  for (i=0; i<2; ++i) {
    vdat->buffer[i] = (u32*)rsxMemalign(64,vdat->res.width*vdat->pitch);
    assert(vdat->buffer[i] != NULL);
    status = rsxAddressToOffset(vdat->buffer[i], &vdat->offset[i]);
    assert(status==0);
    status = gcmSetDisplayBuffer(i, vdat->offset[i], vdat->pitch, vdat->res.width, vdat->res.height);
    assert(status==0);
  }

  gcmResetFlipStatus();
  vdat->curr_fb = 0;
  vdat->framecnt = 0;
  flip(vdat);
}
int
PSL1GHT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
    deprintf(1, "+PSL1GHT_SetDisplayMode()\n");
    PSL1GHT_DisplayModeData *dispdata = (PSL1GHT_DisplayModeData *) mode->driverdata;
	videoState state;

    /* Set the new DisplayMode */
    printf("Setting PS3_MODE to %u\n", dispdata->vconfig.resolution);
    if ( videoConfigure(0, &dispdata->vconfig, NULL, 0) != 0)
	{
        deprintf(2, "Could not set PS3FB_MODE\n");
        SDL_SetError("Could not set PS3FB_MODE\n");
        return -1;
    }

	// Wait until RSX is ready
	do{
		SDL_Delay(10);
		assert( videoGetState(0, 0, &state) == 0);
	}while ( state.state == 3);

    deprintf(1, "-PSL1GHT_SetDisplayMode()\n");
    return 0;
}
Esempio n. 5
0
// Initilize everything. You can probally skip over this function.
void init_screen() {
	// Allocate a 1Mb buffer, alligned to a 1Mb boundary to be our shared IO memory with the RSX.
	void *host_addr = memalign(1024*1024, 1024*1024);
	assert(host_addr != NULL);

	// Initilise Reality, which sets up the command buffer and shared IO memory
	context = realityInit(0x10000, 1024*1024, host_addr); 
	assert(context != NULL);

	VideoState state;
	assert(videoGetState(0, 0, &state) == 0); // Get the state of the display
	assert(state.state == 0); // Make sure display is enabled

	// Get the current resolution
	assert(videoGetResolution(state.displayMode.resolution, &res) == 0);
	
	// Configure the buffer format to xRGB
	VideoConfiguration vconfig;
	memset(&vconfig, 0, sizeof(VideoConfiguration));
	vconfig.resolution = state.displayMode.resolution;
	vconfig.format = VIDEO_BUFFER_FORMAT_XRGB;
	vconfig.pitch = res.width * 4;
	vconfig.aspect=state.displayMode.aspect;

	assert(videoConfigure(0, &vconfig, NULL, 0) == 0);
	assert(videoGetState(0, 0, &state) == 0); 

	s32 buffer_size = 4 * res.width * res.height; // each pixel is 4 bytes
	printf("buffers will be 0x%x bytes\n", buffer_size);
	
	gcmSetFlipMode(GCM_FLIP_VSYNC); // Wait for VSYNC to flip

	// Allocate two buffers for the RSX to draw to the screen (double buffering)
	buffer[0] = rsxMemAlign(16, buffer_size);
	buffer[1] = rsxMemAlign(16, buffer_size);
	assert(buffer[0] != NULL && buffer[1] != NULL);

	u32 offset[2];
	assert(realityAddressToOffset(buffer[0], &offset[0]) == 0);
	assert(realityAddressToOffset(buffer[1], &offset[1]) == 0);
	// Setup the display buffers
	assert(gcmSetDisplayBuffer(0, offset[0], res.width * 4, res.width, res.height) == 0);
	assert(gcmSetDisplayBuffer(1, offset[1], res.width * 4, res.width, res.height) == 0);

	gcmResetFlipStatus();
	flip(1);
}
void
PSL1GHT_InitModes(_THIS)
{
    deprintf(1, "+PSL1GHT_InitModes()\n");
    SDL_DisplayMode mode;
    PSL1GHT_DisplayModeData *modedata;
    videoState state;

    modedata = (PSL1GHT_DisplayModeData *) SDL_malloc(sizeof(*modedata));
    if (!modedata) {
        return;
    }

    assert(videoGetState(0, 0, &state) == 0); // Get the state of the display
    assert(state.state == 0); // Make sure display is enabled

    // Get the current resolution
	videoResolution res;
    assert(videoGetResolution(state.displayMode.resolution, &res) == 0);

    /* Setting up the DisplayMode based on current settings */
    mode.format = SDL_PIXELFORMAT_ARGB8888;
    mode.refresh_rate = 0;
    mode.w = res.width;
    mode.h = res.height;

    modedata->vconfig.resolution = state.displayMode.resolution;
    modedata->vconfig.format = VIDEO_BUFFER_FORMAT_XRGB;
    modedata->vconfig.pitch = res.width * 4;
    mode.driverdata = modedata;

    /* Setup the display to it's  default mode */
    assert(videoConfigure(0, &modedata->vconfig, NULL, 1) == 0);

	// Wait until RSX is ready
	do{
		SDL_Delay(10);
		assert( videoGetState(0, 0, &state) == 0);
	}while ( state.state == 3);

    /* Set display's videomode and add it */
    SDL_AddBasicVideoDisplay(&mode);

    deprintf(1, "-PSL1GHT_InitModes()\n");
}
Esempio n. 7
0
void init_screen(void *host_addr,u32 size)
{
	printf("initializing screen....\n");

	context = rsxInit(CB_SIZE,size,host_addr);

	videoState state;
	videoGetState(0,0,&state);

	videoGetResolution(state.displayMode.resolution,&res);

	videoConfiguration vconfig;
	memset(&vconfig,0,sizeof(videoConfiguration));

	vconfig.resolution = state.displayMode.resolution;
	vconfig.format = VIDEO_BUFFER_FORMAT_XRGB;
	vconfig.pitch = res.width*sizeof(u32);

	waitRSXIdle();

	videoConfigure(0,&vconfig,NULL,0);
	videoGetState(0,0,&state);

	gcmSetFlipMode(GCM_FLIP_VSYNC);

	display_width = res.width;
	display_height = res.height;

	color_pitch = display_width*sizeof(u32);
	color_buffer[0] = (u32*)rsxMemalign(64,(display_height*color_pitch));
	color_buffer[1] = (u32*)rsxMemalign(64,(display_height*color_pitch));

	rsxAddressToOffset(color_buffer[0],&color_offset[0]);
	rsxAddressToOffset(color_buffer[1],&color_offset[1]);

	gcmSetDisplayBuffer(0,color_offset[0],color_pitch,display_width,display_height);
	gcmSetDisplayBuffer(1,color_offset[1],color_pitch,display_width,display_height);

	depth_pitch = display_width*sizeof(u32);
	depth_buffer = (u32*)rsxMemalign(64,(display_height*depth_pitch)*2);
	rsxAddressToOffset(depth_buffer,&depth_offset);

	printf("screen initialized....\n");
}
Esempio n. 8
0
int getResolution(u16 *width, u16 *height){
	videoState state;
	videoResolution resolution;

	/* Get the state of the display */
	if(videoGetState(0, 0, &state) == 0 &&
			videoGetResolution(state.displayMode.resolution, &resolution) == 0) {
		if(width)
			*width = resolution.width;
		if(height)
			*height = resolution.height;

		return TRUE;
	}
	return FALSE;
}
Esempio n. 9
0
// Initilize and rsx
void init_screen(int command_buffer, int z_method) {
	// Allocate a 1Mb buffer, alligned to a 1Mb boundary to be our shared IO memory with the RSX.
	void *host_addr = memalign(1024*1024, command_buffer);
	assert(host_addr != NULL);
 
    if(z_method) zformat = REALITY_TARGET_FORMAT_ZETA_Z24S8; else zformat = REALITY_TARGET_FORMAT_ZETA_Z16;

	// Initilise Reality, which sets up the command buffer and shared IO memory
	context = realityInit(0x10000, command_buffer, host_addr); 
	assert(context != NULL);

	VideoState state;
	assert(videoGetState(0, 0, &state) == 0); // Get the state of the display
	assert(state.state == 0); // Make sure display is enabled

	// Get the current resolution
	assert(videoGetResolution(state.displayMode.resolution, &Video_Resolution) == 0);
	
	Video_pitch = 4 * ((Video_Resolution.width + 15)/16) * 16; // each pixel is 4 bytes
    
    if(!z_method)
    // 16 bit float. Note it uses 1920 as minimun because i thinking to use buffer Z with setupRenderTarget2() with one surface > screen 
	    depth_pitch = 2 * ((Video_Resolution.width > 1920) ? (((Video_Resolution.width+31)/32)*32) : 1920); 
    else
    // 32 bit float. Note it uses 1920 as minimun because i thinking to use buffer Z with setupRenderTarget2() with one surface > screen 
        depth_pitch = 4 * ((Video_Resolution.width > 1920) ? (((Video_Resolution.width+15)/16)*16) : 1920);

	// Configure the buffer format to xRGB
	VideoConfiguration vconfig;
	memset(&vconfig, 0, sizeof(VideoConfiguration));
	vconfig.resolution = state.displayMode.resolution;
	vconfig.format = VIDEO_BUFFER_FORMAT_XRGB;
	vconfig.pitch = Video_pitch;
    Video_aspect=vconfig.aspect=state.displayMode.aspect;

	assert(videoConfigure(0, &vconfig, NULL, 0) == 0);
	assert(videoGetState(0, 0, &state) == 0); 

	s32 buffer_size = Video_pitch * Video_Resolution.height; 
	s32 depth_buffer_size;
    
    if(!z_method)
    // 16 bit float. Note it uses 1088 as minimun because i thinking to use buffer Z with setupRenderTarget2() with one surface > screen 
        depth_buffer_size = depth_pitch * ((Video_Resolution.height > 1088) ? (((Video_Resolution.height+31)/32)*32) : 1088);
    else
    // 32 bit float. Note it uses 1920 as minimun because i thinking to use buffer Z with setupRenderTarget2() with one surface > screen
        depth_buffer_size = depth_pitch * ((Video_Resolution.height > 1088) ? (((Video_Resolution.height+15)/16)*16) : 1088);
	printf("buffers will be 0x%x bytes\n", buffer_size);
	
	gcmSetFlipMode(GCM_FLIP_VSYNC); // Wait for VSYNC to flip

	// Allocate two buffers for the RSX to draw to the screen (double buffering)
	Video_buffer[0] = rsxMemAlign(64, buffer_size);
	Video_buffer[1] = rsxMemAlign(64, buffer_size);
	assert(Video_buffer[0] != NULL && Video_buffer[1] != NULL);

	depth_buffer = rsxMemAlign(64, depth_buffer_size);

	assert(realityAddressToOffset(Video_buffer[0], &offset[0]) == 0);
	assert(realityAddressToOffset(Video_buffer[1], &offset[1]) == 0);
	// Setup the display buffers
	assert(gcmSetDisplayBuffer(0, offset[0], Video_pitch, Video_Resolution.width, Video_Resolution.height) == 0);
	assert(gcmSetDisplayBuffer(1, offset[1], Video_pitch, Video_Resolution.width, Video_Resolution.height) == 0);

	assert(realityAddressToOffset(depth_buffer, &depth_offset) == 0);

	gcmResetFlipStatus();
	flip(1);
    waitFlip();
}
Esempio n. 10
0
static void
init_screen(glw_ps3_t *gp)
{

  // Allocate a 1Mb buffer, alligned to a 1Mb boundary to be our shared IO memory with the RSX.
  void *host_addr = memalign(1024*1024, 1024*1024);
  assert(host_addr != NULL);

  // Initilise Reality, which sets up the command buffer and shared IO memory
  gp->gr.gr_be.be_ctx = realityInit(0x10000, 1024*1024, host_addr); 
  assert(gp->gr.gr_be.be_ctx != NULL);
  
  gcmConfiguration config;
  gcmGetConfiguration(&config);

  TRACE(TRACE_INFO, "RSX", "memory @ 0x%x size = %d\n",
	config.localAddress, config.localSize);

  hts_mutex_init(&gp->gr.gr_be.be_mempool_lock);
  gp->gr.gr_be.be_mempool = extent_create(0, config.localSize >> 4);
  gp->gr.gr_be.be_rsx_address = (void *)(uint64_t)config.localAddress;


  VideoState state;
  videoGetState(0, 0, &state);
  
  // Get the current resolution
  videoGetResolution(state.displayMode.resolution, &gp->res);
  
  int num = gp->res.width;
  int den = gp->res.height;
  
  switch(state.displayMode.aspect) {
  case VIDEO_ASPECT_4_3:
    num = 4; den = 3;
    break;
  case VIDEO_ASPECT_16_9:
    num = 16; den = 9;
    break;
  }

  gp->scale = (float)(num * gp->res.height) / (float)(den * gp->res.width);

  TRACE(TRACE_INFO, "RSX",
	"Video resolution %d x %d  aspect=%d, pixel wscale=%f",
	gp->res.width, gp->res.height, state.displayMode.aspect, gp->scale);


  gp->framebuffer_pitch = 4 * gp->res.width; // each pixel is 4 bytes
  gp->depthbuffer_pitch = 4 * gp->res.width; // And each value in the depth buffer is a 16 bit float
  
  // Configure the buffer format to xRGB
  VideoConfiguration vconfig;
  memset(&vconfig, 0, sizeof(VideoConfiguration));
  vconfig.resolution = state.displayMode.resolution;
  vconfig.format = VIDEO_BUFFER_FORMAT_XRGB;
  vconfig.pitch = gp->framebuffer_pitch;

  videoConfigure(0, &vconfig, NULL, 0);
  videoGetState(0, 0, &state);
  
  const s32 buffer_size = gp->framebuffer_pitch * gp->res.height; 
  const s32 depth_buffer_size = gp->depthbuffer_pitch * gp->res.height;
  TRACE(TRACE_INFO, "RSX", "Buffer will be %d bytes", buffer_size);
  
  gcmSetFlipMode(GCM_FLIP_VSYNC); // Wait for VSYNC to flip
  
  // Allocate two buffers for the RSX to draw to the screen (double buffering)
  gp->framebuffer[0] = rsx_alloc(&gp->gr, buffer_size, 16);
  gp->framebuffer[1] = rsx_alloc(&gp->gr, buffer_size, 16);

  TRACE(TRACE_INFO, "RSX", "Buffers at 0x%x 0x%x\n",
	gp->framebuffer[0], gp->framebuffer[1]);

  gp->depthbuffer = rsx_alloc(&gp->gr, depth_buffer_size * 4, 16);
  
  // Setup the display buffers
  gcmSetDisplayBuffer(0, gp->framebuffer[0],
		      gp->framebuffer_pitch, gp->res.width, gp->res.height);
  gcmSetDisplayBuffer(1, gp->framebuffer[1],
		      gp->framebuffer_pitch, gp->res.width, gp->res.height);

  gcmResetFlipStatus();
  flip(gp, 1);
}
Esempio n. 11
0
/* initialize resc */
void
rescInitialize ( videoData *vdata )
{
  dbgprintf ( "initializing" ) ;

  static s32 ret ;

  /* Get the state of the display */
  ret = videoGetState (VIDEO_PRIMARY, 0, &vdata->state) ;
  if (ret != 0)
  {
    errprintf ( "ERROR %x", ret ) ;
    goto error;
  }

  /* Make sure display is enabled */
  if (vdata->state.state != 0 )
  {
    errprintf ( "ERROR %x", vdata->state.state ) ;
    goto error;
  }

  /* initialize resc configuration */
  memset (&vdata->rconfig, 0, (size_t)sizeof( rescInitConfig ));

  vdata->rconfig.size = sizeof( rescInitConfig ) ;
  vdata->rconfig.resourcePolicy = RESC_MINIMUM_GPU_LOAD | RESC_CONSTANT_VRAM ;
  vdata->rconfig.supportModes = RESC_1920x1080 | RESC_1280x720 | RESC_720x576 | RESC_720x480 ;
  vdata->rconfig.ratioMode = (vdata->state.displayMode.aspect == ASPECT_4_3) ? RESC_LETTERBOX : RESC_FULLSCREEN ;
  vdata->rconfig.palTemporalMode = RESC_PAL_50 ;
  vdata->rconfig.interlaceMode = RESC_NORMAL_BILINEAR ;
  vdata->rconfig.flipMode = RESC_DISPLAY_VSYNC ;

  ret = rescInit ( &vdata->rconfig ) ;
  if ( ret != 0 )
  {
    errprintf ( "ERROR %x", ret ) ;
    goto error;
  }

  rescVideoResolution2RescBufferMode ( vdata->state.displayMode.resolution, &vdata->bufMode ) ;

  /* 0 */
  {
    vdata->dsts[0].format = RESC_SURFACE_A8R8G8B8 ;
    vdata->dsts[0].pitch = 0xc00 ;
    vdata->dsts[0].heightAlign = 64 ;

    ret = rescSetDsts ( RESC_720x480, &vdata->dsts[0] ) ;
    if ( ret != 0 )
    {
      errprintf ( "ERROR %x", ret ) ;
      goto error;
    }
  }

  /* 1 */
  {
    vdata->dsts[1].format = RESC_SURFACE_A8R8G8B8 ;
    vdata->dsts[1].pitch = 0xc00 ;
    vdata->dsts[1].heightAlign = 64 ;

    ret = rescSetDsts ( RESC_720x576, &vdata->dsts[1] ) ;
    if ( ret != 0 )
    {
      errprintf ( "ERROR %x", ret ) ;
      goto error;
    }
  }

  /* 2 */
  {
    vdata->dsts[2].format = RESC_SURFACE_A8R8G8B8 ;
    vdata->dsts[2].pitch = 0x1400 ;
    vdata->dsts[2].heightAlign = 64 ;

    ret = rescSetDsts ( RESC_1280x720, &vdata->dsts[2] ) ;
    if ( ret != 0 )
    {
      errprintf ( "ERROR %x", ret ) ;
      goto error;
    }
  }

  /* 3 */
  {
    vdata->dsts[3].format = RESC_SURFACE_A8R8G8B8 ;
    vdata->dsts[3].pitch = 0x2000 ;
    vdata->dsts[3].heightAlign = 32 ;

    ret = rescSetDsts ( RESC_1920x1080, &vdata->dsts[3] ) ;
    if ( ret != 0 )
    {
      errprintf ( "ERROR %x", ret ) ;
      goto error;
    }
  }

  ret = rescSetDisplayMode ( vdata->bufMode ) ;
  if ( ret != 0 )
  {
    errprintf ( "ERROR %d", ret ) ;
    goto error;
  }

  ret = rescGetBufferSize ( &vdata->cbuf.size, &vdata->vertbuf.size, &vdata->fragbuf.size ) ;
  if ( ret != 0 )
  {
    errprintf ( "ERROR %d", ret ) ;
    goto error;
  }

  vdata->cbuf.ptr = (void*) rsxMemalign ( 0x10000, vdata->cbuf.size ) ;
  vdata->vertbuf.ptr = (void*) rsxMemalign ( 0x80, vdata->vertbuf.size ) ;
  vdata->fragbuf.ptr = (void*) rsxMemalign ( 0x80, vdata->fragbuf.size ) ;

  ret = rescSetBufferAddress ( vdata->cbuf.ptr, vdata->vertbuf.ptr, vdata->fragbuf.ptr ) ;
  if ( ret != 0 )
  {
    errprintf ( "ERROR %d", ret ) ;
    goto error;
  }

  argprintf("Required size,  color: 0x%x vertex: 0x%x fragment: 0x%x", vdata->cbuf.size, vdata->vertbuf.size, vdata->fragbuf.size);
  argprintf("Buf addr given, color: %p vertex: %p fragment: %p", vdata->cbuf.ptr, vdata->vertbuf.ptr, vdata->fragbuf.ptr);

  /* */
  /* TILING BULLSHIT GOES HERE */
  /* */

  rescSetFlipHandler ( rescFlipCallback ) ;

  rescSetRenderTarget ( vdata ) ;

  return ;
  
  error:
  {
    return ;
  }
}
Esempio n. 12
0
// Initialise SDL_ttf.
void I_StartupTTF(UINT32 fontpointsize, Uint32 initflags, Uint32 vidmodeflags)
{
	char *fontpath = NULL;
	INT32 fontstatus = -1;
#ifdef _PS3
	videoState state;
	videoGetState(0, 0, &state);
	videoGetResolution(state.displayMode.resolution, &res);
	bitsperpixel = 24;
#else
	res.width = 320;
	res.height = 200;
	bitsperpixel = 8;
#endif

	// what's the point of trying to display an error?
	// SDL_ttf is not started, can't display anything to screen (presumably)...
	if (SDL_InitSubSystem(initflags) < 0)
		I_Error("Couldn't initialize SDL: %s\n", SDL_GetError());

	TTFSurface = SDL_SetVideoMode(res.width, res.height, bitsperpixel, vidmodeflags);
	if (!TTFSurface)
		I_Error("Couldn't set SDL Video resolution: %s\n", SDL_GetError());

	if (TTF_Init() < 0)
		I_Error("Couldn't start SDL_ttf: %s\n", TTF_GetError());

	// look for default font in many directories
#ifdef FONTSEARCHPATH1
	fontpath = searchFont(FONTSEARCHPATH1);
	if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
#endif
#ifdef FONTSEARCHPATH2
	if (fontstatus < 0)
	{
		fontpath = searchFont(FONTSEARCHPATH2);
		if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
	}
#endif
#ifdef FONTSEARCHPATH3
	if (fontstatus < 0)
	{
		fontpath = searchFont(FONTSEARCHPATH3);
		if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
	}
#endif
#ifdef FONTSEARCHPATH4
	if (fontstatus < 0)
	{
		fontpath = searchFont(FONTSEARCHPATH4);
		if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
	}
#endif
#ifdef FONTSEARCHPATH5
	if (fontstatus < 0)
	{
		fontpath = searchFont(FONTSEARCHPATH5);
		if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
	}
#endif
#ifdef FONTSEARCHPATH6
	if (fontstatus < 0)
	{
		fontpath = searchFont(FONTSEARCHPATH6);
		if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
	}
#endif
#ifdef FONTSEARCHPATH7
	if (fontstatus < 0)
	{
		fontpath = searchFont(FONTSEARCHPATH7);
		if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize);
	}
#endif
	// argh! no font file found! disable SDL_ttf code
	if (fontstatus < 0)
	{
		I_ShutdownTTF();
		CONS_Printf("Unable to find default font files! Not loading SDL_ttf\n");
	}
	else
	{
		// Get SDL_ttf compiled and linked version
		SDL_version TTFcompiled;
		const SDL_version *TTFlinked;

		SDL_TTF_VERSION(&TTFcompiled);
		TTFlinked = TTF_Linked_Version();

		// Display it on screen
		CONS_Printf("Compiled for SDL_ttf version: %d.%d.%d\n",
			    TTFcompiled.major, TTFcompiled.minor, TTFcompiled.patch);
		CONS_Printf("Linked with SDL_ttf version: %d.%d.%d\n",
			    TTFlinked->major, TTFlinked->minor, TTFlinked->patch);
	}
}