Example #1
0
// At some point, we'll have to create more than one texture to handle
// cases like Doom. Or have another go at TV type rendering; it will
// require a 2048x512 texture though. (Note that 512 is the correct height for
// interlaced screens; we won't have to change much here to support it.)
void GLWidget::CreateTextures(void)
{
	// Seems that power of 2 sizes are still mandatory...
	textureWidth  = 1024;
	textureHeight = 512;
	buffer = new uint32_t[textureWidth * textureHeight];
	JaguarSetScreenBuffer(buffer);

	glGenTextures(1, &texture);
	glBindTexture(GL_TEXTURE_2D, texture);
	glPixelStorei(GL_UNPACK_ROW_LENGTH, textureWidth);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, NULL);
}
bool retro_load_game(const struct retro_game_info *info)
{
   enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
   if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
   {
      fprintf(stderr, "Pixel format XRGB8888 not supported by platform, cannot use.\n");
      return false;
   }

   const char *full_path;

   if(failed_init)
      return false;

   full_path = info->path;

   vjs.renderType = 0;
   check_variables();

	jaguarCartInserted = true;

	if (log_enabled)
	{
		bool success = (bool)LogInit("./virtualjaguar.log");	// Init logfile

		if (!success)
			printf("Failed to open virtualjaguar.log for writing!\n");
	}

   //strcpy(vjs.EEPROMPath, "/path/to/eeproms/");   // battery saves
   JaguarInit();                                             // set up hardware
   memcpy(jagMemSpace + 0xE00000, (vjs.biosType == BT_K_SERIES ? jaguarBootROM : jaguarBootROM2), 0x20000); // Use the stock BIOS
//memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000);

   JaguarSetScreenPitch(videoWidth);
   JaguarSetScreenBuffer(videoBuffer);
   //Init video
   for (int i = 0; i < videoWidth * videoHeight; ++i)
      videoBuffer[i] = 0xFF00FFFF;

   SET32(jaguarMainRAM, 0, 0x00200000);                      // set up stack
   JaguarLoadFile((char *)full_path);                // load rom
   JaguarReset();

   return true;
}