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