add SDL video mode set code

Thu, 02 Dec 2010 01:03:46 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Thu, 02 Dec 2010 01:03:46 +0000
changeset 28
70665b05cb10
parent 27
ceae676021ca
child 29
d73d07c1d492

add SDL video mode set code

src/main.c file | annotate | diff | revisions
     1.1 --- a/src/main.c	Wed Dec 01 22:43:52 2010 +0000
     1.2 +++ b/src/main.c	Thu Dec 02 01:03:46 2010 +0000
     1.3 @@ -261,23 +261,25 @@
     1.4  	// set up musashi and reset the CPU
     1.5  	m68k_set_cpu_type(M68K_CPU_TYPE_68010);
     1.6  	m68k_pulse_reset();
     1.7 -/*
     1.8 -	size_t i = 0x80001a;
     1.9 -	size_t len;
    1.10 -	do {
    1.11 -		char dasm[512];
    1.12 -		len = m68k_disassemble(dasm, i, M68K_CPU_TYPE_68010);
    1.13 -		printf("%06X: %s\n", i, dasm);
    1.14 -		i += len;
    1.15 -	} while (i < 0x8000ff);
    1.16 -*/
    1.17  
    1.18 -	// set up SDL
    1.19 +	// Set up SDL
    1.20  	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) {
    1.21  		printf("Could not initialise SDL: %s.\n", SDL_GetError());
    1.22 -		return -1;
    1.23 +		exit(EXIT_FAILURE);
    1.24  	}
    1.25  
    1.26 +	// Make sure SDL cleans up after itself
    1.27 +	atexit(SDL_Quit);
    1.28 +
    1.29 +	// Set up the video display
    1.30 +	SDL_Surface *screen = NULL;
    1.31 +	if ((screen = SDL_SetVideoMode(720, 384, 8, SDL_SWSURFACE | SDL_ANYFORMAT)) == NULL) {
    1.32 +		printf("Could not find a suitable video mode: %s.\n", SDL_GetError());
    1.33 +		exit(EXIT_FAILURE);
    1.34 +	}
    1.35 +	printf("Set %dx%d at %d bits-per-pixel mode\n", screen->w, screen->h, screen->format->BitsPerPixel);
    1.36 +	SDL_WM_SetCaption("FreeBee 3B1 emulator", "FreeBee");
    1.37 +
    1.38  	/***
    1.39  	 * The 3B1 CPU runs at 10MHz, with DMA running at 1MHz and video refreshing at
    1.40  	 * around 60Hz (???), with a 60Hz periodic interrupt.