#ifdef _WIN32
#include <windows.h>
#endif

//#include "tinyptc/tinyptc.h"
#include "main.h"

SDL_Surface *screen;
extern int demomain();
int g_bgr;
int g_rgb;

#if 0
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
  int ret = ptc_open("Despair", 640, 480);
  if (!ret) {
	MessageBox(0,"failed to init ptc","error",MB_OK);
	return 0;
  }
#else
int main(int argc, char *argv[]) {
#endif
	SDL_Event event;
	unsigned int sdl_flags = SDL_SWSURFACE;
	const SDL_VideoInfo *videoInfo;

	g_rgb = 0;
	g_bgr = 0;

	if(SDL_Init(SDL_INIT_VIDEO) < 0) {
		fprintf(stderr, "Video initialization failed: %s\n",
			SDL_GetError());
		return 0;
	}

	if (argc>1) {
		sdl_flags |= SDL_FULLSCREEN;
		if (argv[1][0]=='b')
			g_bgr = 1;
		if (argv[1][0]=='r')
			g_rgb = 1;
	} else {
		//printf("options: f - fullscreen, bgr/rgb - color mapping.\n")
	}
	// Attempt to create a 640x480 window with 32bit pixels.
	screen = SDL_SetVideoMode(640, 480, 32, sdl_flags);

	// If we fail, return error.
	if ( screen == NULL ) {
		fprintf(stderr, "Unable to set 640x480 video: %s\n", SDL_GetError());
		return 0;
	}
    demomain();

//  ptc_close();

  return 0;
}